Re: Re: Approaching the First Draft [of a language spec]

From: Date: Tue, 21 Nov 2000 00:46:19 +0000
Subject: Re: Re: Approaching the First Draft [of a language spec]
References: 1  Groups: php.dev php.lang 
Request: Send a blank email to php-dev+get-38740@lists.php.net to get a copy of this message
[..] > I mean, in my little example, there is additional information in the > explanation that I don't know how to describe using BNF. I mean, how > would you describe this: > > while(bool) expr1; expr2; > > vs. > > while(bool): expr1; expr2; endwhile; > > In the first case expr2 is not executed within the loop and in the second > case it is. There probably is some way to indicate in the BNF that the : > syntax implies statement grouping, but chances are it would be easy for > someone to misinterpret that and having a little note that goes along with > the BNF that clarifies this with an example is not just catering to the > end user, it is also for the compiler weenie. We are all end users when > it comes down to it and something can never be made too clear. Well, that is something which can be expressed in a syntactic rule. I'm not familiar with writing BNF (only reading), so here is the relevant part of the spec in the php-lang module (note the difference between statement and statement-list): iteration-statement: 'while' '(' expression ')' while-statement while-statement: statement ':' statement-list 'endwhile' ';' statement-list: statement statement-list statement There are examples of what you cannot express in those rules. For example, our syntax has to allow constructs like $var(); The validness of such a construct depends on the contents of $var, only to be determined at run-time. In all cases, semantics definitions have to describe the conditions of an action, the action itself and all possible results of that action. - Sascha

« previous php.dev (#38740) next »