Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:86280 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 3030 invoked from network); 16 May 2015 23:52:32 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 16 May 2015 23:52:32 -0000 Authentication-Results: pb1.pair.com smtp.mail=marcio.web2@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=marcio.web2@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.213.65 as permitted sender) X-PHP-List-Original-Sender: marcio.web2@gmail.com X-Host-Fingerprint: 209.85.213.65 mail-yh0-f65.google.com Received: from [209.85.213.65] ([209.85.213.65:35793] helo=mail-yh0-f65.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 5E/D2-14891-F38D7555 for ; Sat, 16 May 2015 19:52:31 -0400 Received: by yhl29 with SMTP id 29so179151yhl.2 for ; Sat, 16 May 2015 16:52:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=e1HRITv4geb8edR0QXbObrvKcwCeldyV7hdluT++FJI=; b=h3OEAi7wqUpUq5akCBHJYECGuoe1CvyGv8iUfn2/6sXP3cC2qABeUkkH6hBcMSKhAY WOhQh1E2iHMq6Lq4LgaVdVvz3pQ9V2rFcfLlOZe/5AaEDJRgTDbVH0Lg8Y9oOH/pikly gHqvjIW817MPuuoYW1Y2Ooa6hqjl+XNqZywf2h1XG/1/4lP0T96iVUUSKoxBzu6oMPj1 Ze+C+IX1FmHE5bKPeqyt39HgqHPNFfFr6GwgLbn7p/dgJ38KOC5q3RsnDGD2liVyuRrZ SNpTs1zSkcu/5CPY6D1Z/2HRwsbjWuN0GE2syYW3XmccSr5/F5dlcymyqj/oN4p4ANYi ypGA== X-Received: by 10.236.36.8 with SMTP id v8mr16552997yha.83.1431820348562; Sat, 16 May 2015 16:52:28 -0700 (PDT) MIME-Version: 1.0 Received: by 10.13.254.130 with HTTP; Sat, 16 May 2015 16:52:08 -0700 (PDT) In-Reply-To: References: Date: Sat, 16 May 2015 20:52:08 -0300 Message-ID: To: Nikita Popov Cc: PHP internals Content-Type: multipart/alternative; boundary=089e0158bb4a42231005163ba7f1 Subject: Re: [PHP-DEV] Context Sensitive Language RFC - Implementation Candidate From: marcio.web2@gmail.com (Marcio Almada) --089e0158bb4a42231005163ba7f1 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi! > Sorry for late response, forgot about this RFC. I've only glanced over it= , > but the patch looks okay from the technical side. > > No problem :) there are other more important issues being discussed that should be prioritized, specially your engine exception RFC. > The thing that's bothering me is the fact that this patch is basically > saying: "It is no longer possible to correctly tokenize PHP without also > parsing it." > It won't be possible either with your idea "of making the next label after '::' and 'function' unreserved" because it doesn't cover the entire PHP syntax. So I took the approach that fulfills 100% support. > For example, if you're writing a syntax highlighter for PHP and you want > that syntax highlighter to be correct, you'll be writing not only a lexer= , > but also a parser for PHP (which is significantly more complicated). > Actually it's worse than that: The approach of running a parser > concurrently with the token collection does not work for highlighting cod= e > snippets for example, where the snippet may not form syntactically fully > valid code. > If we are talking about syntax highlighters only, then it's pretty easy for an external tool to consider whatever is in front of `::` and `function` a name and highlight it as such, you simply use *token_get_all($code)* without the proposed *TOKEN_PARSE* flag and transform the resulting array accordingly by applying a simple callback to simulate a lookahead. > Syntax highlighting only being an example, this applies to any external > tooling that's not written in PHP and does not have the benefit of using > token_get_all(). > With any approach taken, external tools will need to handle that the same way. The point is, do we want "simpler" rules and pretend a small part of PHP syntax doesn't even exists just because of these external tools? External tools can handle that. Static analyzers inherently have much more complex issues to deal with other than a white list of semi reserved names. > I don't know how important this is to us, but I'm somewhat vary of going > more into the C++ direction (where you essentially need a full > type-analyzer to do a parse). > > Yes, indeed - and this was only possible because we have an AST now (thanks) - but I don't have a problem with it *as long as the parsing is opt in*, and that's the case here. > This is why I still prefer the dead-simple approach of making the next > label after :: and "function" unreserved (what we do for the label after = -> > already), combined with forbidding reserved names for free functions in t= he > compiler (similar to the blacklist we have for classes). This doesn't cov= er > everything (like trait adaptations), but I think it covers the 97% case > (and actually allows us to really allow all names, without exceptions). > The problem with this "dead simple" approach is that it leaves syntax behind like class const list and, like you just said, trait adaptations. So unless a working solution that covers all syntax is given, this simpler idea you suggested is a no go for me as it's not better than the solution already being proposed. > Nikita > I hope we can find enough grounds to agree here ^^ M=C3=A1rcio --089e0158bb4a42231005163ba7f1--