Use subset directive grammar
# Allen Wirfs-Brock (16 years ago)
Nice catch...it looks like I need to mention the semicolon (which may be supplied by automatic semicolon insertion).
The parentheses form is not intended to be a directive.
Nice catch...it looks like I need to mention the semicolon (which may be supplied by automatic semicolon insertion). The parentheses form is not intended to be a directive. allen >-----Original Message----- >From: es-discuss-bounces at mozilla.org [mailto:es-discuss- >bounces at mozilla.org] On Behalf Of Mike Samuel >Sent: Monday, September 21, 2009 6:33 PM >To: es-discuss at mozilla.org >Subject: Use subset directive grammar > >From section 14.1 of >http://wiki.ecmascript.org/lib/exe/fetch.php?id=es3.1%3Aes3.1_proposal_w >orking_draft&cache=cache&media=es3.1:es5-tc392008-040.pdf > > A Directive Prologue is a sequence of zero or more >ExpressionStatement productions, > each of which having an Expression consists entirely of a >StringLiteral, that occur as the initial > SourceElement productions of a Program or FunctionBody. > >What does "consists entirely" mean? > >From the grammar in the appendix, to get from ExpressionStatement to >StringLiteral, I have to go through the following grammar chain: > ExpressionStatement -> AssignmentExpression -> >ConditionalExpression -> (lots of operator precedence elided) > -> LeftHandSideExpression -> NewExpression -> MemberExpression -> >PrimaryExpression -> Literal -> StringLiteral > >One way to define "consists entirely" might be: an A that consists >entirely of B if it matches A and B and all tokens were consumed by >matching B. >That definition is consistent with > "use strict" >but not > "use strict"; >since the ";" is actually part of the ExpressionStatement production. > >Is there a definition of "consists entirely" that matches > "use strict"; >and > "use strict" >but not > ("use strict"); >? > >Or can the last be part of a directive prologue? >_______________________________________________ >es-discuss mailing list >es-discuss at mozilla.org >https://mail.mozilla.org/listinfo/es-discuss
# Allen Wirfs-Brock (16 years ago)
Here's what I'm current going with:
A Directive Prologue is the longest sequence of ExpressionStatement productions occurring as the initial SourceElement productions of a Program or FunctionBody and where each ExpressionStatement in the sequence consists entirely of a StringLiteral token followed a semicolon. The semicolon may appear explicitly or may be inserted by automatic semicolon insertion. A Directive Prologue may be an empty sequence.
Here's what I'm current going with: A Directive Prologue is the longest sequence of ExpressionStatement productions occurring as the initial SourceElement productions of a Program or FunctionBody and where each ExpressionStatement in the sequence consists entirely of a StringLiteral token followed a semicolon. The semicolon may appear explicitly or may be inserted by automatic semicolon insertion. A Directive Prologue may be an empty sequence. >-----Original Message----- >From: es5-discuss-bounces at mozilla.org [mailto:es5-discuss- >bounces at mozilla.org] On Behalf Of David-Sarah Hopwood >Sent: Monday, September 21, 2009 8:35 PM >To: es5-discuss at mozilla.org >Subject: Re: Use subset directive grammar > >Mike Samuel wrote: >>>From section 14.1 of >> >http://wiki.ecmascript.org/lib/exe/fetch.php?id=es3.1%3Aes3.1_proposal_w >orking_draft&cache=cache&media=es3.1:es5-tc392008-040.pdf >> >> A Directive Prologue is a sequence of zero or more >> ExpressionStatement productions, >> each of which having an Expression consists entirely of a >> StringLiteral, that occur as the initial >> SourceElement productions of a Program or FunctionBody. >> >> What does "consists entirely" mean? >> >>>From the grammar in the appendix, to get from ExpressionStatement to >> StringLiteral, I have to go through the following grammar chain: >> ExpressionStatement -> AssignmentExpression -> >> ConditionalExpression -> (lots of operator precedence elided) >> -> LeftHandSideExpression -> NewExpression -> MemberExpression -> >> PrimaryExpression -> Literal -> StringLiteral >> >> One way to define "consists entirely" might be: an A that consists >> entirely of B if it matches A and B and all tokens were consumed by >> matching B. >> That definition is consistent with >> "use strict" >> but not >> "use strict"; >> since the ";" is actually part of the ExpressionStatement production. > >Hmm. An error in this definition was pointed out before by Jim Blandy: ><https://mail.mozilla.org/pipermail/es5-discuss/2009-August/003195.html> >but the attempted fix seems to have been incorrect. > >As I suggested then, it should say: > > A Directive Prologue is a sequence of zero or more ExpressionStatement > productions, each of which consists, excluding any terminating >semicolon, > entirely of a StringLiteral, that occur as the initial SourceElement > productions of a Program or FunctionBody. > >"having an Expression that consists entirely of a StringLiteral" is >wrong. > >-- >David-Sarah Hopwood ⚥ http://davidsarah.livejournal.com > >_______________________________________________ >es5-discuss mailing list >es5-discuss at mozilla.org >https://mail.mozilla.org/listinfo/es5-discuss