Understanding static semantics

Michael Dyck jmdyck at ibiblio.org
Fri Mar 6 15:50:00 UTC 2015


On 15-03-06 06:46 AM, raul mihaila wrote:
> Do sentences like "it's a syntax error if the LexicallyDeclaredNames of
> StatementList contains any duplicate entries" (section 15.1.1) refer to the
> result of applying the LexicallyDeclaredNames rule for a production
> alternative in which StatementList is the left-hand side nonterminal?

Yes, pretty much. Though I would word it:
     ... the result of applying the LexicallyDeclaredNames rule to the
     'StatementList' child of the 'ScriptBody' node [that this early error
     rule is being applied to]

> If this is correct, then looking at LexicallyDeclaredNames for
> StatementList at some point we get to apply LexicallyDeclaredNames for
> Statement: "1. If Statement is Statement : LabelledStatement , return
> LexicallyDeclaredNames of Statement." (section 13.1.5). But I couldn't
> find a definition for LexicallyDeclaredNames where Statement is the lhs
> nonterminal.

The production 'Statement : LabelledStatement' is what the spec calls a
'chain production' (5.1.1), so (according to 5.2), there's an implicit rule:

     Static Semantics: LexicallyDeclaredNames
     Statement : LabelledStatement
         1. Return LexicallyDeclaredNames of LabelledStatement

> So in section 13.1.5 shouldn't it say "If Statement is
> Statement : LabelledStatement , return LexicallyDeclaredNames of
> LabelledStatement"?

Changing 'Statement' to 'LabelledStatement' there is not necessary, given
the implicit rule. However, it seems simpler/clearer to me to avoid going
through the implicit rule, so you could submit this as an 'enhancement' bug.

-Michael


More information about the es-discuss mailing list