Martin & Oleg(?), Thank you for the links. Unfortunately, they just confirm my point I think unless, I've got myself completely confused. For example, taking Martin's first link (http://www.antlr.org/grammar/1153976512034/ecmascriptA3.g), the grammar is full of things like:
continueStatement: 'continue' /* [ no line terminator here ] */ (identifier)? SEMI ; In other words, the grammar is saying one thing (that continue, followed by a new line, then a semicolon is valid and that continue without the semicolon is not valid) whereas the true language rules are different (as partially expressed by the /* [ no line terminator here ] */ comment.) Likewise, Martin found a grammar that tried to deal with it by just marking semicolons as optional (http://tomcopeland.blogs.com/EcmaScript.html) The problem with this grammar is that it effectively makes var x:int y = 9 return 1 + 1; a legal line of code. Not only is it unpleasant to read, but it would cause a parser conflict as the parser would not know (and so would have to guess) whether return 1 + 1 meant "return 1 + 1"; or "return; 1 + 1;". The EcmaScript specs seem bad enough, without us adding to the WTF? count :) Everything I've read points to the same thing: EcmaScript-style languages cannot be expressed as BNF. I suspect that the reason why Adobe are talking about the changes to language in the Falcon compiler breaking some existing AS3 projects is because they have had to modify the language to make it definable in something like BNF. David. -----Original Message----- From: Martin Heidegger [mailto:m...@leichtgewicht.at] Sent: 21 February 2012 17:39 To: flex-dev@incubator.apache.org Subject: Re: [gosh] On the sad tale of BNF and optional semicolons Hello David, I don't have the time to read into it, but afaik JavaScript has the same "problem", maybe [1] can help you find a solution for your problem. I am finding it hard to believe this is a unsolved problem in BNF. yours Martin [1] http://www.antlr.org/grammar/1153976512034/ecmascriptA3.g