Use subset directive grammar
Allen.Wirfs-Brock at microsoft.com
Tue Sep 22 10:06:12 PDT 2009
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.
>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
>> 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:
>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
> 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
>David-Sarah Hopwood ⚥ http://davidsarah.livejournal.com
>es5-discuss mailing list
>es5-discuss at mozilla.org
More information about the es-discuss