JavaScript 1.4 Grammar
|
Monday, May 3, 1999
This is an LR(1) grammar written by waldemar that describes the state of ECMAScript
as of February 1999. The grammar is complete except for semicolon insertion (the OptionalSemicolon
grammar state can sometimes reduce to «empty») and distinguishing RegularExpression
from /
and /=
. Also, there is some controversy about elision in array literals, so this feature has been
omitted for now.
Grammar productions may expand nonterminals into empty right sides. Such right sides are indicated as «empty».
A number of rules in the grammar occur in groups of analogous rules. Rather than list them individually, these groups have been summarized using the shorthand illustrated by the example below:
Statements such as
introduce grammar arguments and . If these arguments later parametrize the nonterminal on the left side of a rule, that rule is implicitly replicated into a set of rules in each of which a grammar argument is consistently substituted by one of its variants. For example,
=
AssignmentExpressionnormal,expands into the following four rules:
=
AssignmentExpressionnormal,allowIn=
AssignmentExpressionnormal,noIn=
AssignmentExpressionnormal,allowIn=
AssignmentExpressionnormal,noInAssignmentExpressionnormal,allowIn is now an unparametrized nonterminal and processed normally by the grammar.
Some of the expanded rules (such as the fourth one in the example above) may be unreachable from the starting nonterminal Program; these are ignored.
this
null
true
false
delete
LeftSideExpressionnormalvoid
UnaryExpressionnormaltypeof
UnaryExpressionnormal++
LeftSideExpressionnormal--
LeftSideExpressionnormal+
UnaryExpressionnormal-
UnaryExpressionnormal~
UnaryExpressionnormal!
UnaryExpressionnormal
Waldemar Horwat Last modified Monday, May 3, 1999 |