Questions on the notation used in the spec
On 10/22/07 10:40 AM, Joel Reymont wrote:
Folks,
I'm trying to create a Yacc grammar for ES4 and I have trouble understanding the notation used in the spec.
For example, there's
alpha = { allowColon, noColon } beta = { allowIn, noIn } gamma = { allowExpr, noExpr }
and then
ParenExpression ( AssignmentExpression /allowColon, allowIn/ )
as well as
FunctionExpression /alpha, beta/ function Identifier FunctionSignature FunctionExpressionBody / alpha, beta/ function FunctionSignature FunctionExpressionBody /alpha, beta/
How should I interpret these?
Alpha, beta, etc are a short-hand for describing similar productions. They can be expanded by replicating the parameterised production for each value in the corresponding set. E.g.
A(alpha) := B(alpha)
can be rewritten as:
A_allowColon := B_allowColon A_noColon := B_noColon
The original description of this notation can be found here:
www.mozilla.org/js/language/grammar14.html
I also see other notation such as omega, tau, local, global, etc. Are these documented somewhere?
Yes, in the grammar
Jeff Dyer scripsit:
Alpha, beta, etc are a short-hand for describing similar productions. They can be expanded by replicating the parameterised production for each value in the corresponding set. E.g.
A(alpha) := B(alpha)
can be rewritten as:
A_allowColon := B_allowColon A_noColon := B_noColon
Yet another partial reinvention of Ad van Wijngaarden's two-level grammars, I see. Like most reinventions, it generates only a finite number of rules, although in principle there is nothing to prevent recursion in the metarules (those named with Greek letters here).
(The below .sig was chosen entirely at random.)
Folks,
I'm trying to create a Yacc grammar for ES4 and I have trouble
understanding the notation used in the spec.
For example, there's
alpha = { allowColon, noColon } beta = { allowIn, noIn } gamma = { allowExpr, noExpr }
and then
ParenExpression ( AssignmentExpression /allowColon, allowIn/ )
as well as
FunctionExpression /alpha, beta/ function Identifier FunctionSignature FunctionExpressionBody / alpha, beta/ function FunctionSignature FunctionExpressionBody /alpha, beta/
How should I interpret these?
I also see other notation such as omega, tau, local, global, etc. Are
these documented somewhere?
-- wagerlabs.com