A.1 Lexical Grammar
SourceCharacter ::
any Unicode code unit
InputElementDiv ::
WhiteSpace
LineTerminator
Comment
Token
DivPunctuator
InputElementRegExp ::
WhiteSpace
LineTerminator
Comment
Token
RegularExpressionLiteral
WhiteSpace ::
<TAB>
<VT>
<FF>
<SP>
<NBSP>
<BOM>
<USP>
LineTerminator ::
<LF>
<CR>
<LS>
<PS>
LineTerminatorSequence ::
<LF>
<CR> [lookahead ∉ <LF> ]
<LS>
<PS>
<CR> <LF>
Comment ::
MultiLineComment
SingleLineComment
MultiLineComment ::
/*
MultiLineCommentChars opt */
MultiLineCommentChars ::
MultiLineNotAsteriskChar MultiLineCommentChars opt
*
PostAsteriskCommentChars opt
PostAsteriskCommentChars ::
MultiLineNotForwardSlashOrAsteriskChar MultiLineCommentChars opt
*
PostAsteriskCommentChars opt
MultiLineNotAsteriskChar ::
SourceCharacter but not *
MultiLineNotForwardSlashOrAsteriskChar ::
SourceCharacter but not one of /
or *
SingleLineComment ::
//
SingleLineCommentChars opt
SingleLineCommentChars ::
SingleLineCommentChar SingleLineCommentChars opt
SingleLineCommentChar ::
SourceCharacter but not LineTerminator
Token ::
IdentifierName
Punctuator
NumericLiteral
StringLiteral
Identifier ::
IdentifierName but not ReservedWord
IdentifierName ::
IdentifierStart
IdentifierName IdentifierPart
IdentifierStart ::
UnicodeLetter
$
_
\
UnicodeEscapeSequence
IdentifierPart ::
IdentifierStart
UnicodeCombiningMark
UnicodeDigit
UnicodeConnectorPunctuation
<ZWNJ>
<ZWJ>
UnicodeLetter ::
any character in the Unicode
categories “Uppercase letter (Lu)”, “Lowercase letter (Ll)”, “Titlecase
letter (Lt)”, “Modifier letter (Lm)”, “Other letter (Lo)”, or “Letter
number (Nl)”.
UnicodeCombiningMark ::
any character in the Unicode categories “Non-spacing mark (Mn)” or “Combining spacing mark (Mc)”
UnicodeDigit ::
any character in the Unicode category “Decimal number (Nd)”
UnicodeConnectorPunctuation ::
any character in the Unicode category “Connector punctuation (Pc)”
ReservedWord ::
Keyword
FutureReservedWord
NullLiteral
BooleanLiteral
break
do
instanceof
typeof
case
else
new
var
catch
finally
return
void
continue
for
switch
while
debugger
function
this
with
default
if
throw
delete
in
try
FutureReservedWord :: one of
class
enum
extends
super
const
export
import
The following tokens are also considered to be FutureReservedWords when parsing strict mode code (see 10.1.1) .
implements
let
private
public
interface
package
protected
static
yield
{
}
(
)
[
]
.
;
,
<
>
<=
>=
==
!=
===
!==
+
-
*
%
++
--
<<
>>
>>>
&
|
^
!
~
&&
||
?
:
=
+=
-=
*=
%=
<<=
>>=
>>>=
&=
|=
^=
Literal ::
NullLiteral
BooleanLiteral
NumericLiteral
StringLiteral
RegularExpressionLiteral
BooleanLiteral ::
true
false
NumericLiteral ::
DecimalLiteral
HexIntegerLiteral
DecimalLiteral ::
DecimalIntegerLiteral .
DecimalDigits opt ExponentPart opt
.
DecimalDigits ExponentPart opt
DecimalIntegerLiteral ExponentPart opt
DecimalIntegerLiteral ::
0
NonZeroDigit DecimalDigits opt
DecimalDigits ::
DecimalDigit
DecimalDigits DecimalDigit
DecimalDigit :: one of
0
1
2
3
4
5
6
7
8
9
NonZeroDigit :: one of
1
2
3
4
5
6
7
8
9
ExponentPart ::
ExponentIndicator SignedInteger
ExponentIndicator :: one of
e
E
SignedInteger ::
DecimalDigits
+
DecimalDigits
-
DecimalDigits
HexIntegerLiteral ::
0x
HexDigit
0X
HexDigit
HexIntegerLiteral HexDigit
HexDigit :: one of
0
1
2
3
4
5
6
7
8
9
a
b
c
d
e
f
A
B
C
D
E
F
StringLiteral ::
"
DoubleStringCharacters opt "
'
SingleStringCharacters opt '
DoubleStringCharacters ::
DoubleStringCharacter DoubleStringCharacters opt
SingleStringCharacters ::
SingleStringCharacter SingleStringCharacters opt
DoubleStringCharacter ::
SourceCharacter but not one of "
or \
or LineTerminator
\
EscapeSequence
LineContinuation
SingleStringCharacter ::
SourceCharacter but not one of '
or \
or LineTerminator
\
EscapeSequence
LineContinuation
LineContinuation ::
\
LineTerminatorSequence
EscapeSequence ::
CharacterEscapeSequence
0
[lookahead ∉ DecimalDigit ]
HexEscapeSequence
UnicodeEscapeSequence
CharacterEscapeSequence ::
SingleEscapeCharacter
NonEscapeCharacter
SingleEscapeCharacter :: one of
'
"
\
b
f
n
r
t
v
NonEscapeCharacter ::
SourceCharacter but not one of EscapeCharacter or LineTerminator
EscapeCharacter ::
SingleEscapeCharacter
DecimalDigit
x
u
HexEscapeSequence ::
x
HexDigit HexDigit
UnicodeEscapeSequence ::
u
HexDigit HexDigit HexDigit HexDigit
RegularExpressionLiteral ::
/
RegularExpressionBody /
RegularExpressionFlags
RegularExpressionBody ::
RegularExpressionFirstChar RegularExpressionChars
RegularExpressionChars ::
[empty]
RegularExpressionChars RegularExpressionChar
RegularExpressionFirstChar ::
RegularExpressionNonTerminator but not one of *
or \
or /
or [
RegularExpressionBackslashSequence
RegularExpressionClass
RegularExpressionChar ::
RegularExpressionNonTerminator but not \
or /
or [
RegularExpressionBackslashSequence
RegularExpressionClass
RegularExpressionBackslashSequence ::
\
RegularExpressionNonTerminator
RegularExpressionNonTerminator ::
SourceCharacter but not LineTerminator
RegularExpressionClass ::
[
RegularExpressionClassChars ]
RegularExpressionClassChars ::
[empty]
RegularExpressionClassChars RegularExpressionClassChar
RegularExpressionClassChar ::
RegularExpressionNonTerminator but not ]
or \
RegularExpressionBackslashSequence
RegularExpressionFlags ::
[empty]
RegularExpressionFlags IdentifierPart
A.3 Expressions
PrimaryExpression :
this
Identifier
Literal
ArrayLiteral
ObjectLiteral
(
Expression )
ArrayLiteral :
[
Elision opt ]
[
ElementList ]
[
ElementList ,
Elision opt ]
ElementList :
Elision opt AssignmentExpression
ElementList ,
Elision opt AssignmentExpression
ObjectLiteral :
{
}
{
PropertyNameAndValueList }
{
PropertyNameAndValueList ,
}
PropertyNameAndValueList :
PropertyAssignment
PropertyNameAndValueList ,
PropertyAssignment
PropertyAssignment :
PropertyName :
AssignmentExpression
get
PropertyName (
)
{
FunctionBody }
set
PropertyName (
PropertySetParameterList )
{
FunctionBody }
PropertyName :
IdentifierName
StringLiteral
NumericLiteral
PropertySetParameterList :
Identifier
MemberExpression :
PrimaryExpression
FunctionExpression
MemberExpression [
Expression ]
MemberExpression .
IdentifierName
new
MemberExpression Arguments
NewExpression :
MemberExpression
new
NewExpression
CallExpression :
MemberExpression Arguments
CallExpression Arguments
CallExpression [
Expression ]
CallExpression .
IdentifierName
Arguments :
(
)
(
ArgumentList )
ArgumentList :
AssignmentExpression
ArgumentList ,
AssignmentExpression
LeftHandSideExpression :
NewExpression
CallExpression
PostfixExpression :
LeftHandSideExpression
LeftHandSideExpression [no LineTerminator here] ++
LeftHandSideExpression [no LineTerminator here] --
UnaryExpression :
PostfixExpression
delete
UnaryExpression
void
UnaryExpression
typeof
UnaryExpression
++
UnaryExpression
--
UnaryExpression
+
UnaryExpression
-
UnaryExpression
~
UnaryExpression
!
UnaryExpression
MultiplicativeExpression :
UnaryExpression
MultiplicativeExpression *
UnaryExpression
MultiplicativeExpression /
UnaryExpression
MultiplicativeExpression %
UnaryExpression
AdditiveExpression :
MultiplicativeExpression
AdditiveExpression +
MultiplicativeExpression
AdditiveExpression -
MultiplicativeExpression
ShiftExpression :
AdditiveExpression
ShiftExpression <<
AdditiveExpression
ShiftExpression >>
AdditiveExpression
ShiftExpression >>>
AdditiveExpression
RelationalExpression :
ShiftExpression
RelationalExpression <
ShiftExpression
RelationalExpression >
ShiftExpression
RelationalExpression <=
ShiftExpression
RelationalExpression >=
ShiftExpression
RelationalExpression instanceof
ShiftExpression
RelationalExpression in
ShiftExpression
RelationalExpressionNoIn :
ShiftExpression
RelationalExpressionNoIn <
ShiftExpression
RelationalExpressionNoIn >
ShiftExpression
RelationalExpressionNoIn <=
ShiftExpression
RelationalExpressionNoIn >=
ShiftExpression
RelationalExpressionNoIn instanceof
ShiftExpression
EqualityExpression :
RelationalExpression
EqualityExpression ==
RelationalExpression
EqualityExpression !=
RelationalExpression
EqualityExpression ===
RelationalExpression
EqualityExpression !==
RelationalExpression
EqualityExpressionNoIn :
RelationalExpressionNoIn
EqualityExpressionNoIn ==
RelationalExpressionNoIn
EqualityExpressionNoIn !=
RelationalExpressionNoIn
EqualityExpressionNoIn ===
RelationalExpressionNoIn
EqualityExpressionNoIn !==
RelationalExpressionNoIn
BitwiseANDExpression :
EqualityExpression
BitwiseANDExpression &
EqualityExpression
BitwiseANDExpressionNoIn :
EqualityExpressionNoIn
BitwiseANDExpressionNoIn &
EqualityExpressionNoIn
BitwiseXORExpression :
BitwiseANDExpression
BitwiseXORExpression ^
BitwiseANDExpression
BitwiseXORExpressionNoIn :
BitwiseANDExpressionNoIn
BitwiseXORExpressionNoIn ^
BitwiseANDExpressionNoIn
BitwiseORExpression :
BitwiseXORExpression
BitwiseORExpression |
BitwiseXORExpression
BitwiseORExpressionNoIn :
BitwiseXORExpressionNoIn
BitwiseORExpressionNoIn |
BitwiseXORExpressionNoIn
LogicalANDExpression :
BitwiseORExpression
LogicalANDExpression &&
BitwiseORExpression
LogicalANDExpressionNoIn :
BitwiseORExpressionNoIn
LogicalANDExpressionNoIn &&
BitwiseORExpressionNoIn
LogicalORExpression :
LogicalANDExpression
LogicalORExpression ||
LogicalANDExpression
LogicalORExpressionNoIn :
LogicalANDExpressionNoIn
LogicalORExpressionNoIn ||
LogicalANDExpressionNoIn
ConditionalExpression :
LogicalORExpression
LogicalORExpression ?
AssignmentExpression :
AssignmentExpression
ConditionalExpressionNoIn :
LogicalORExpressionNoIn
LogicalORExpressionNoIn ?
AssignmentExpression :
AssignmentExpressionNoIn
AssignmentExpression :
ConditionalExpression
LeftHandSideExpression =
AssignmentExpression
LeftHandSideExpression AssignmentOperator AssignmentExpression
AssignmentExpressionNoIn :
ConditionalExpressionNoIn
LeftHandSideExpression =
AssignmentExpressionNoIn
LeftHandSideExpression AssignmentOperator AssignmentExpressionNoIn
AssignmentOperator : one of
*=
/=
%=
+=
-=
<<=
>>=
>>>=
&=
^=
|=
Expression :
AssignmentExpression
Expression ,
AssignmentExpression
ExpressionNoIn :
AssignmentExpressionNoIn
ExpressionNoIn ,
AssignmentExpressionNoIn
A.4 Statements
Statement :
Block
VariableStatement
EmptyStatement
ExpressionStatement
IfStatement
IterationStatement
ContinueStatement
BreakStatement
ReturnStatement
WithStatement
LabelledStatement
SwitchStatement
ThrowStatement
TryStatement
DebuggerStatement
Block :
{
StatementList opt }
StatementList :
Statement
StatementList Statement
VariableStatement :
var
VariableDeclarationList ;
VariableDeclarationList :
VariableDeclaration
VariableDeclarationList ,
VariableDeclaration
VariableDeclarationListNoIn :
VariableDeclarationNoIn
VariableDeclarationListNoIn ,
VariableDeclarationNoIn
VariableDeclaration :
Identifier Initialiser opt
VariableDeclarationNoIn :
Identifier InitialiserNoIn opt
Initialiser :
=
AssignmentExpression
InitialiserNoIn :
=
AssignmentExpressionNoIn
ExpressionStatement :
[lookahead ∉ {{
, function
}] Expression ;
IfStatement :
if
(
Expression )
Statement else
Statement
if
(
Expression )
Statement
IterationStatement :
do
Statement while
(
Expression );
while
(
Expression )
Statement
for
(
ExpressionNoIn opt ;
Expression opt ;
Expression opt )
Statement
for
(
var
VariableDeclarationListNoIn ;
Expression opt ;
Expression opt )
Statement
for
(
LeftHandSideExpression in
Expression )
Statement
for
(
var
VariableDeclarationNoIn in
Expression )
Statement
ContinueStatement :
continue
;
continue
[no LineTerminator here] Identifier ;
BreakStatement :
break
;
break
[no LineTerminator here] Identifier ;
ReturnStatement :
return
;
return
[no LineTerminator here] Expression ;
WithStatement :
with
(
Expression )
Statement
SwitchStatement :
switch
(
Expression )
CaseBlock
CaseBlock :
{
CaseClauses opt }
{
CaseClauses opt DefaultClause CaseClauses opt }
CaseClauses :
CaseClause
CaseClauses CaseClause
CaseClause :
case
Expression :
StatementList opt
DefaultClause :
default
:
StatementList opt
LabelledStatement :
Identifier :
Statement
ThrowStatement :
throw
[no LineTerminator here] Expression ;
TryStatement :
try
Block Catch
try
Block Finally
try
Block Catch Finally
Catch :
catch
(
Identifier )
Block
DebuggerStatement :
debugger
;