Questions on the notation used in the spec

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Questions on the notation used in the spec

Joel Reymont
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?

        Thanks, Joel

--
http://wagerlabs.com





_______________________________________________
Es4-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es4-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Questions on the notation used in the spec

Jeff Dyer


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:

   http://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

Jd

_______________________________________________
Es4-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es4-discuss
Reply | Threaded
Open this post in threaded view
|

Re: Questions on the notation used in the spec

John Cowan
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.)

--
John Cowan  [hidden email]  http://ccil.org/~cowan
In the sciences, we are now uniquely privileged to sit side by side
with the giants on whose shoulders we stand.
        --Gerald Holton
_______________________________________________
Es4-discuss mailing list
[hidden email]
https://mail.mozilla.org/listinfo/es4-discuss