Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:51181 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 21197 invoked from network); 1 Jan 2011 14:46:04 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Jan 2011 14:46:04 -0000 Authentication-Results: pb1.pair.com smtp.mail=rumi.kg@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=rumi.kg@gmail.com; sender-id=pass; domainkeys=bad Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.214.170 as permitted sender) DomainKey-Status: bad X-DomainKeys: Ecelerity dk_validate implementing draft-delany-domainkeys-base-01 X-PHP-List-Original-Sender: rumi.kg@gmail.com X-Host-Fingerprint: 209.85.214.170 mail-iw0-f170.google.com Received: from [209.85.214.170] ([209.85.214.170:64796] helo=mail-iw0-f170.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 5C/2A-30618-B2E3F1D4 for ; Sat, 01 Jan 2011 09:46:04 -0500 Received: by iwn6 with SMTP id 6so13372984iwn.29 for ; Sat, 01 Jan 2011 06:46:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:content-type :content-transfer-encoding; bh=37AX+PKbto3yHLShGBKPigI2SKrgetrSgSfvlEtE8K0=; b=rQa1Idlp3+EUHlqEsFGVqF9ks6K4kSrX3nI+OtuHSdFDQAjizdjbKPUbA3irbPHwoD i7m/x1bvaBsDmuBZs8IkKHZaYHbdjlN+FnIEIbhAvLAFdrDXQvOe2VXANJxDjSwDO03+ XUvDK8V+MPCYPwXgA5M0DScOm382EcidWqZpI= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type:content-transfer-encoding; b=toTQKdNO1BArGaIdzqikHWw/fr8XhuIxIgll+hvRnCi5eKh/ZG7g2fzn0nYi9ETzq+ 7olMOF/MV+N5cZkk1Cimb1OmlmuMddTDS3OThEuoK3UQdvRXIse8CROXR/37qw6kfAqL lazWD0UAEpwRODjm9+7DHf9zkr9MRQ6DIOqNo= MIME-Version: 1.0 Received: by 10.231.199.76 with SMTP id er12mr18675728ibb.72.1293893161286; Sat, 01 Jan 2011 06:46:01 -0800 (PST) Received: by 10.231.37.200 with HTTP; Sat, 1 Jan 2011 06:46:01 -0800 (PST) In-Reply-To: <542423FA-1522-4AEC-8CC3-4AFF2DC4B453@darkrainfall.org> References: <20101231115408.GD18520@nibiru.local> <542423FA-1522-4AEC-8CC3-4AFF2DC4B453@darkrainfall.org> Date: Sat, 1 Jan 2011 15:46:01 +0100 Message-ID: To: internals Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Subject: Re: EBNF From: rumi.kg@gmail.com (Rune Kaagaard) > There has never been a language grammar, so there's been nothing to refer= to at all. As for why no one's made one more recently, for fun I snagged t= he .l and .y files from trunk and W3C's version of EBNF from XML. In two ho= urs of hacking away, I managed to come up with this sort-of beginning to a = grammar, which I'm certain contains several errors, and only hints at a syn= tax: I wanted to take your EBNF for a spin so I converted it to a format that the python module "simpleparse" could read. I ironed out a couple of kinks and fixed a bug. You can see it here: http://code.google.com/p/php-snow/source/browse/branches/php-ebnf/gwynne-ra= skind-example/php.ebnf Then I created a prettyprinter to output the parsetree of some very simple PHP code. See it here: http://code.google.com/p/php-snow/source/browse/branches/php-ebnf/gwynne-ra= skind-example/parse_example.py and the output is here: http://code.google.com/p/php-snow/source/browse/branches/php-ebnf/gwynne-ra= skind-example/parse_example.output > Considering what it takes JUST to define namespaces, halt_compiler, basic= blocks, and the idea of a conditional statement... well, suffice to say th= e "expr" production alone would be triple the size of this. It doesn't help= that there's no way I'm immediately aware of to check whether a grammar li= ke this is accurate. Thanks a lot for the example, that does not look so bad :) PHP syntax is not simple so of course the EBNF will not be either. But still any EBNF would be a lot better than none! Testability is a real issue and makes for a nice catch-22. A hypothetical roadmap could _maybe_ look like this: 1) Create the EBNF and reference implementation while comparing it to a stable release. 2) Rewrite the Zend implementation to read from the EBNF. 3) Repeat for all current releases. It's tough to try to guess about things you don't really understand. Looks like major work though! > Nonetheless, it's a significant undertaking to deal with the complexity o= f the language. There are dozens of tiny little edge cases in PHP's parsing= that require bunches of extra parser rules. An example from above is the d= ifference between using "statement" and "inner-statement" for the two diffe= rent forms of "if". Because "statement" includes basic blocks and labels, t= he rule disallows writing "if: { xyz; } endif;", since apparently Zend does= n't support arbitrary basic blocks. All those cases wreak havoc on the gram= mar. In its present form, it will never reduce down to something nearly as = small as Python's. Just to have a solid, complete maintained EBNF would be a _major_ leap forw= ard! Thanks for your cool reply! Cheers Rune