Title: JavaScript 2 Lexical Grammar
Author: Waldemar Horwat
Company: Netscape

JavaScript 2 Lexical Grammar 7-Feb-2002

The start symbols are: NextInputElement^unit if the previous input element was a number; NextInputElement^re if the previous input element was not a number and a / should be interpreted as a regular expression; and NextInputElement^div if the previous input element was not a number and a / should be interpreted as a division or division-assignment operator.
Unicode Character Classes
UnicodeCharacter  Any Unicode character
UnicodeInitialAlphabetic  Any Unicode initial alphabetic character (includes ASCII A‑Z and a‑z)
UnicodeAlphanumeric  Any Unicode alphabetic or decimal digit character (includes ASCII 0‑9, A‑Z, and a‑z)
WhiteSpaceCharacter 
	«TAB» | «VT» | «FF» | «SP» | «u00A0»
|	«u2000» | «u2001» | «u2002» | «u2003» | «u2004» | «u2005» | «u2006» | «u2007»
|	«u2008» | «u2009» | «u200A» | «u200B»
|	«u3000»
LineTerminator  «LF» | «CR» | «u2028» | «u2029»
ASCIIDigit  0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
Comments
LineComment  / / LineCommentCharacters
LineCommentCharacters 
	«empty»
|	LineCommentCharacters NonTerminator
NonTerminator  UnicodeCharacter except LineTerminator
SingleLineBlockComment  / * BlockCommentCharacters * /
BlockCommentCharacters 
	«empty»
|	BlockCommentCharacters NonTerminatorOrSlash
|	PreSlashCharacters /
PreSlashCharacters 
	«empty»
|	BlockCommentCharacters NonTerminatorOrAsteriskOrSlash
|	PreSlashCharacters /
NonTerminatorOrSlash  NonTerminator except /
NonTerminatorOrAsteriskOrSlash  NonTerminator except * | /
MultiLineBlockComment  / * MultiLineBlockCommentCharacters BlockCommentCharacters * /
MultiLineBlockCommentCharacters 
	BlockCommentCharacters LineTerminator
|	MultiLineBlockCommentCharacters BlockCommentCharacters LineTerminator
White Space
WhiteSpace 
	«empty»
|	WhiteSpace WhiteSpaceCharacter
|	WhiteSpace SingleLineBlockComment
Line Breaks
LineBreak 
	LineTerminator
|	LineComment LineTerminator
|	MultiLineBlockComment
LineBreaks 
	LineBreak
|	LineBreaks WhiteSpace LineBreak
Input Elements
  {re, div, unit}
NextInputElement^re  WhiteSpace InputElement^re
NextInputElement^div  WhiteSpace InputElement^div
NextInputElement^unit 
	[lookahead{ContinuingIdentifierCharacter, \}] WhiteSpace InputElement^div
|	[lookahead{_}] IdentifierName
InputElement^re 
	LineBreaks
|	IdentifierOrKeyword
|	Punctuator
|	NumericLiteral
|	StringLiteral
|	RegExpLiteral
|	EndOfInput
InputElement^div 
	LineBreaks
|	IdentifierOrKeyword
|	Punctuator
|	DivisionPunctuator
|	NumericLiteral
|	StringLiteral
|	EndOfInput
EndOfInput 
	End
|	LineComment End
Keywords and Identifiers
IdentifierName 
	InitialIdentifierCharacterOrEscape
|	NullEscapes InitialIdentifierCharacterOrEscape
|	IdentifierName ContinuingIdentifierCharacterOrEscape
|	IdentifierName NullEscape
NullEscapes 
	NullEscape
|	NullEscapes NullEscape
NullEscape  \ _
InitialIdentifierCharacterOrEscape 
	InitialIdentifierCharacter
|	\ HexEscape
InitialIdentifierCharacter  UnicodeInitialAlphabetic | $ | _
ContinuingIdentifierCharacterOrEscape 
	ContinuingIdentifierCharacter
|	\ HexEscape
ContinuingIdentifierCharacter  UnicodeAlphanumeric | $ | _
IdentifierOrKeyword  IdentifierName
Punctuators
Punctuator 
	!
|	! =
|	! = =
|	%
|	% =
|	&
|	& &
|	& & =
|	& =
|	(
|	)
|	*
|	* =
|	+
|	+ +
|	+ =
|	,
|	-
|	- -
|	- =
|	.
|	. . .
|	:
|	: :
|	;
|	<
|	< <
|	< < =
|	< =
|	=
|	= =
|	= = =
|	>
|	> =
|	> >
|	> > =
|	> > >
|	> > > =
|	?
|	[
|	]
|	^
|	^ =
|	^ ^
|	^ ^ =
|	{
|	|
|	| =
|	| |
|	| | =
|	}
|	~
DivisionPunctuator 
	/ [lookahead{/, *}]
|	/ =
Numeric Literals
NumericLiteral 
	DecimalLiteral
|	HexIntegerLiteral [lookahead{HexDigit}]
DecimalLiteral 
	Mantissa
|	Mantissa LetterE SignedInteger
LetterE  E | e
Mantissa 
	DecimalIntegerLiteral
|	DecimalIntegerLiteral .
|	DecimalIntegerLiteral . Fraction
|	. Fraction
DecimalIntegerLiteral 
	0
|	NonZeroDecimalDigits
NonZeroDecimalDigits 
	NonZeroDigit
|	NonZeroDecimalDigits ASCIIDigit
NonZeroDigit  1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
Fraction  DecimalDigits
SignedInteger 
	DecimalDigits
|	+ DecimalDigits
|	- DecimalDigits
DecimalDigits 
	ASCIIDigit
|	DecimalDigits ASCIIDigit
HexIntegerLiteral 
	0 LetterX HexDigit
|	HexIntegerLiteral HexDigit
LetterX  X | x
HexDigit  0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | A | B | C | D | E | F | a | b | c | d | e | f
String Literals
  {single, double}
StringLiteral 
	' StringChars^single '
|	" StringChars^double "
StringChars 
	«empty»
|	StringChars StringChar
|	StringChars NullEscape
StringChar 
	LiteralStringChar
|	\ StringEscape
LiteralStringChar^single  UnicodeCharacter except ' | \ | LineTerminator
LiteralStringChar^double  UnicodeCharacter except " | \ | LineTerminator
StringEscape 
	ControlEscape
|	ZeroEscape
|	HexEscape
|	IdentityEscape
IdentityEscape  NonTerminator except _ | UnicodeAlphanumeric
ControlEscape 
	b
|	f
|	n
|	r
|	t
|	v
ZeroEscape  0 [lookahead{ASCIIDigit}]
HexEscape 
	x HexDigit HexDigit
|	u HexDigit HexDigit HexDigit HexDigit
Regular Expression Literals
RegExpLiteral  RegExpBody RegExpFlags
RegExpFlags 
	«empty»
|	RegExpFlags ContinuingIdentifierCharacterOrEscape
|	RegExpFlags NullEscape
RegExpBody  / [lookahead{*}] RegExpChars /
RegExpChars 
	RegExpChar
|	RegExpChars RegExpChar
RegExpChar 
	OrdinaryRegExpChar
|	\ NonTerminator
OrdinaryRegExpChar  NonTerminator except \ | /
Index
Nonterminals
Update fields to generate this index