In ES6, what is the meaning of the parameter [Yield], [In] in a grammar production

Michael Dyck jmdyck at ibiblio.org
Mon Mar 9 14:43:22 UTC 2015


On 15-03-09 04:10 AM, Coolwust wrote:
> I know a production may be parameterized by suffixing the nonterminal
> symbol, my question is what is the meaning of the parameter [Yield], [In]?

To figure out the 'meaning' of a particular parameter, look at all the
places where that parameter is used as a prefix/guard for a whole RHS.

E.g., consider Yield:

12.14 says:
     AssignmentExpression[In,Yield] :
       ...
       [+Yield] YieldExpresion[?In]
So the *presence* of the Yield parameter means that a YieldExpression is
allowed (i.e., 'yield' is treated as a keyword).

Whereas 12.1 says:
     IdentifierReference[Yield] :
       Identifier
       [~Yield] yield
(And similarly for BindingIdentifier and LabelIdentifier.)
So the *absence* of the Yield parameter means that 'yield' is allowed as
an IdentifierReference or BindingIdentifier or LabelIdentifier. (That is,
it's treated the same as an Identifier.)

So, in general, the Yield parameter controls whether 'yield' is treated as
a ReservedWord or not.

-Michael


More information about the es-discuss mailing list