I've been confused lately about productions in ecma262 spec.
There are productions based on my assumption that can be other productions.
for example, Statement
Statement can be a Block it can also be an IfStatement.
my confusion begins with algorithms that looks like that
a. Let stmtCompletion be the result of evaluating the first Statement.
evaluating Statement? What does it mean?
if a Statement, for example, is an IfStatement will it go to the 14.6 The if Statement 14.6.2 Runtime Semantics: Evaluation ?
I'm mostly confused because there are productions that have their RS: Evaluation like IfStatement and some don't have the RS: Evaluation like Statement,Declaration, etc...
If a Statement, for example, is an IfStatement will it go to the 14.6 The if Statement 14.6.2 Runtime Semantics: Evaluation ?
Yes.
I'm mostly confused because there are productions that have their RS: Evaluation like IfStatement and some don't have the RS: Evaluation like Statement,Declaration, etc...
What does it mean?
This is (in recent revisions of the spec) even explained in §5.2.2 Syntax-Directed Operations. In particular,
Unless explicitly specified otherwise, all chain productions have an implicit definition for every operation that might be applied to that production's left-hand side nonterminal. The implicit definition simply reapplies the same operation with the same parameters, if any, to the chain production's sole right-hand side nonterminal and then returns the result. For example, assume that some algorithm has a step of the form: “Return the result of evaluating Block
” and that there is a production:
Block : { StatementList }
but the Evaluation operation does not associate an algorithm with that production. In that case, the Evaluation operation implicitly includes an association of the form:
Runtime Semantics: Evaluation
Block : { StatementList }
StatementList
.So since there are no "Runtime Semantics: Evaluation" for the Statement
production, it gets implicit semantics that will simply evaluate the respective statement kind.