I've been wondering what's the meaning of "alternative" in ecma262.
i've seen that the term "alternative" was used many times in the spec.
here are some examples:
quote taken from this section
so, in this example, the nonterminal ForStatement actually has four alternative right-hand sides.
quote taken from this section
A production that has multiple alternative definitions will typically have a distinct algorithm for each alternative
quote taken from this section
a production that has multiple alternative definitions will typically have for each alternative a distinct algorithm for each applicable named static semantic rule.
what does it mean "production that has multiple alternative definitions" ?
i assume that alternative mean the right hand side of a production, here is a simple picture that shows what i mean.
on the picture we can see that the area covered by Pink is the whole Production.
and the area covered by Red is the Nonterminal
finally i'm assuming that the area covered by purple is the Alternative
A production that has multiple alternative definitions will typically have a distinct algorithm for each alternative
however it's still doesn't sounds right, because how can a one individual production have multiple alternatives ?
In formal language theory, a production has a left-hand side and a right-hand side. But in less formal contexts like the EcmaScript spec, it's common to group productions that have the same left-hand side.
So in a formal context, you might see:
A : B
A : C D
and you would say "There are 2 productions, each with a LHS and a RHS."
But in the EcmaScript spec, you might see:
A :
B
C D
and you would say "There is 1 production, with a LHS and 2 alternatives." (This avoids confusion over whether "right-hand side" would refer to everything after the colon, or just a single line.)
So when you ask "how can one individual production have multiple alternatives ?", it sounds like you're thinking of the formal context, where indeed it wouldn't make sense. But it does make sense in the less formal context.
(Note that the EcmaScript spec actually uses both terminology schemes, but it's usually not difficult to know which.)