do-while grammar

Brendan Eich brendan at mozilla.com
Tue Feb 8 14:13:01 PST 2011


The do-while one slipped my mind, sorry. I obviously knew about it in 2004, when we changed SpiderMonkey in pre-Firefox-1, also Narcissus.

One was of cross-checking is to look at Narcissus. We've been building it up to have a Harmony mode, adding ES5 support before that (still some missing), and running it on our test-suites. But I wrote Narcissus in 2004 based on ES3 plus only enough reality to self-host. So looking at how it differs from ES3, in all versions from 2004 up to today, could be helpful.

I just reviewed the Narcissus parser, and this do-while case is the only ASI variance noted. The other supported extensions to ES3 (get and set in object initialisers, catch guards) are disabled by an option: --ecma3-only).

/be

On Feb 8, 2011, at 2:01 PM, Mark S. Miller wrote:

> Does anyone know of any other syntax that all major JS engines accept that are not in the official ES5.1 grammar?
> 
> Does anyone know of any places on the web attempting to accumulate such exceptions?
> 
> The other one I know of is nested named function declarations <http://wiki.ecmascript.org/doku.php?id=conventions:no_non_standard_strict_decls>. And there was an ASI mis-description for "break" and "continue" that was corrected between ES5 and ES5.1.
> 
> We really need a complete codification of the consensus ES5.1 grammar. Starting from the official grammar, the Caja <http://caja.appspot.com/trycaja/index.html?input=do%20{%3b}%20while%28false%29%20false> and ES-Lab <http://es-lab.googlecode.com/svn/trunk/site/esparser/index.html> parsers both reject "do {;} while (false) false;" because we didn't know any better. I expect there are many other independent parsers (minimizers, linters, etc) that make the same mistake.
> 
> Even if such "corrections" do not make it into future errata, I would like to see them recorded on the ecmascript wiki.
> 
> 
> On Tue, Feb 8, 2011 at 12:12 PM, André Bargull <andre.bargull at udo.edu> wrote:
> Just for the record, here's a link to the bug report on bugzilla concerning ASI for do-while:
> https://bugzilla.mozilla.org/show_bug.cgi?id=238945
> 
> (Interesting that I came across the very same issue in January while working on the OpenLaszlo parser code :-) 
> 
>> FWIW, JavaScriptCore provides automatic semicolon insertion after all do-while statements in all contexts. We made this change for web compatibility, mimicking a Firefox quirk.
>> 
>> Geoff
>> 
>> On Feb 8, 2011, at 11:53 AM, Dave Fugate wrote:
>> 
>> Just to confirm, do-while iteration statements do in fact require a semi-colon at the end as indicated in 12.6.1 of ES5, correct?  That is, a production of the nature:
>>                 do {;} while (false) false;
>>  
>> would be invalid JavaScript as doesn’t meet any of the three rules set out in 7.9.1,  right?
>>  
>> Thanks,
>>  
>> Dave
> 
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
> 
> 
> 
> 
> -- 
>     Cheers,
>     --MarkM
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20110208/8fe41b12/attachment.html>


More information about the es-discuss mailing list