ECMAScript Language Specification
Standard ECMA-262 3rd Edition -December 1999
Standard ECMA-262
>
Annex A. Grammar Summary
Standard ECMA-262
Part 1. Scope
Part 2. Conformance
Part 3. References
Part 4. OverView
Part 5. Notational Conventions
Part 6. Source Text
Part 7. Lexical Conventions
Part 8. Types
Part 9. Type Conversion
Part 10. Execution Contexts
Part 11. Primary Expressions
Part 12. Statements
Part 13. Function Definition
Part 14. Program
Part 15. Native ECMAScript Objects
Part 16. Errors
Annex A. Grammar Summary
Annex B. Compatibility
Annex
A
(informative)
Grammar Summary
A.1 Lexical Grammar
SourceCharacter
::
See clause
6
any Unicode character
InputElementDiv
::
See clause
7
WhiteSpace
LineTerminator
Comment
Token DivPunctuator
InputElementRegExp
::
See clause
7
WhiteSpace
LineTerminator
Comment
Token
RegularExpressionLiteral
WhiteSpace
::
See
7.2
<TAB>
<VT>
<FF>
<SP>
<NBSP>
<USP>
LineTerminator
::
See
7.3
<LF>
<CR>
<LS>
<PS>
Comment
::
See
7.4
MultiLineComment
SingleLineComment
MultiLineComment
::
See
7.4
/*
MultiLineCommentChars
opt
*/
MultiLineCommentChars
::
See
7.4
MultiLineNotAsteriskChar MultiLineCommentChars
opt
*
PostAsteriskCommentChars
opt
PostAsteriskCommentChars
::
See
7.4
MultiLineNotForwardSlashOrAsteriskChar MultiLineCommentChars
opt
*
PostAsteriskCommentChars
opt
MultiLineNotAsteriskChar
::
See
7.4
SourceCharacter
but not
asterisk
*
MultiLineNotForwardSlashOrAsteriskChar
::
See
7.4
SourceCharacter
but not
forward-slash
/
or
asterisk
*
SingleLineComment
::
See
7.4
//
SingleLineCommentChars
opt
SingleLineCommentChars
::
See
7.4
SingleLineCommentChar SingleLineCommentChars
opt
SingleLineCommentChar
::
See
7.4
SourceCharacter
but not
LineTerminator
Token
::
See
7.5
ReservedWord
Identifier
Punctuator
NumericLiteral
StringLiteral
ReservedWord
::
See
7.5.1
Keyword
FutureReservedWord
NullLiteral
BooleanLiteral
Keyword
:: one of
See
7.5.2
break else new var case finally return void catch for switch while continue function this with default if throw delete in try do instanceof typeof
FutureReservedWord
:: one of
See
7.5.3
abstract enum int short boolean export interface static byte extends long super char final native synchronized class float package throws const goto private transient debugger implements protected volatile double import public
Identifier
::
See
7.6
IdentifierName
but not
ReservedWord
IdentifierName
::
See
7.6
IdentifierStart
IdentifierName IdentifierPart
IdentifierStart
::
See
7.6
UnicodeLetter
$
_
\ UnicodeEscapeSequence
IdentifierPart
::
See
7.6
IdentifierStart
UnicodeCombiningMark
UnicodeDigit
UnicodeConnectorPunctuation
\ UnicodeEscapeSequence
UnicodeLetter
See
7.6
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
See
7.6
any character in the Unicode categories "Non-spacing mark (Mn)" or "Combining spacing mark (Mc)"
UnicodeDigit
See
7.6
any character in the Unicode category "Decimal number (Nd)"
UnicodeConnectorPunctuation
See
7.6
any character in the Unicode category "Connector punctuation (Pc)"
HexDigit
:: one of
See
7.6
0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F
Punctuator
:: one of
See
7.7
{ } ( ) [ ]
. ; , < > <=
>= == != === !==
+ - * % ++ --
<< >> >>> & | ^
! ~ && || ? :
= += -= *= %= <<=
>>= >>>= &= |= ^=
DivPunctuator
:: one of
See
7.7
/
/=
Literal
::
See
7.8
NullLiteral
BooleanLiteral
NumericLiteral
StringLiteral
NullLiteral
::
See
7.8.1
null
BooleanLiteral
::
See
7.8.2
true
false
NumericLiteral
::
See
7.8.3
DecimalLiteral
HexIntegerLiteral
DecimalLiteral
::
See
7.8.3
DecimalIntegerLiteral
.
DecimalDigits
opt
ExponentPart
opt
.
DecimalDigits ExponentPart
opt
DecimalIntegerLiteral ExponentPart
opt
DecimalIntegerLiteral
::
See
7.8.3
0
NonZeroDigit DecimalDigits
opt
DecimalDigits
::
See
7.8.3
DecimalDigit
DecimalDigits DecimalDigit
DecimalDigit
:: one of
See
7.8.3
0 1 2 3 4 5 6 7 8 9
ExponentIndicator
:: one of
See
7.8.3
e E
SignedInteger
::
See
7.8.3
DecimalDigits
+
DecimalDigits
-
DecimalDigits
HexIntegerLiteral
::
See
7.8.3
0x
HexDigit
0X
HexDigit
HexIntegerLiteral HexDigit
StringLiteral
::
See
7.8.4
"
DoubleStringCharacters
opt
"
'
SingleStringCharacters
opt
'
DoubleStringCharacters
::
See
7.8.4
DoubleStringCharacter DoubleStringCharacters
opt
SingleStringCharacters
::
See
7.8.4
SingleStringCharacter SingleStringCharacters
opt
DoubleStringCharacter
::
See
7.8.4
SourceCharacter
but not
double-quote
"
or
backslash
\
or
LineTerminator
\
EscapeSequence
SingleStringCharacter
::
See
7.8.4
SourceCharacter
but not
single-quote
'
or
backslash
\
or
LineTerminator
\
EscapeSequence
EscapeSequence
::
See
7.8.4
CharacterEscapeSequence
0
[lookahead ∉
DecimalDigit]
HexEscapeSequence
UnicodeEscapeSequence
CharacterEscapeSequence
::
See
7.8.4
SingleEscapeCharacter
NonEscapeCharacter
SingleEscapeCharacter
:: one of
See
7.8.4
' " \ b f n r t v
EscapeCharacter
::
See
7.8.4
SingleEscapeCharacter
DecimalDigit
x
u
HexEscapeSequence
::
See
7.8.4
x
HexDigit HexDigit
UnicodeEscapeSequence
::
See
7.8.4
u
HexDigit HexDigit HexDigit HexDigit
RegularExpressionLiteral
::
See
7.8.5
/
RegularExpressionBody
/
RegularExpressionFlags
RegularExpressionBody
::
See
7.8.5
RegularExpressionFirstChar RegularExpressionChars
RegularExpressionChars
::
See
7.8.5
[empty]
RegularExpressionChars RegularExpressionChar
RegularExpressionFirstChar
::
See
7.8.5
NonTerminator
but not
*
or
\
or
/
BackslashSequence
RegularExpressionChar
::
See
7.8.5
NonTerminator
but not
\
or
/
BackslashSequence
BackslashSequence
::
See
7.8.5
\
NonTerminator
NonTerminator
::
See
7.8.5
SourceCharacter
but not
LineTerminator
RegularExpressionFlags
::
See
7.8.5
[empty]
RegularExpressionFlags IdentifierPart
A.2 Number Conversions
StringNumericLiteral
:::
See
9.3.1
StrWhiteSpace
opt
StrWhiteSpace
opt
StrNumericLiteral StrWhiteSpace
opt
StrWhiteSpace
:::
See
9.3.1
StrWhiteSpaceChar StrWhiteSpace
opt
StrWhiteSpaceChar
:::
See
9.3.1
<TAB>
<SP>
<NBSP>
<FF>
<VT>
<CR>
<LF>
<LS>
<PS>
<USP>
StrNumericLiteral
:::
See
9.3.1
StrDecimalLiteral
HexIntegerLiteral
StrDecimalLiteral
:::
See
9.3.1
StrUnsignedDecimalLiteral
+
StrUnsignedDecimalLiteral
-
StrUnsignedDecimalLiteral
StrUnsignedDecimalLiteral
:::
See
9.3.1
Infinity
DecimalDigits
.
DecimalDigits
opt
ExponentPart
opt
.
DecimalDigits ExponentPart
opt
DecimalDigits ExponentPart
opt
DecimalDigits
:::
See
9.3.1
DecimalDigit
DecimalDigits DecimalDigit
DecimalDigit
::: one of
See
9.3.1
0 1 2 3 4 5 6 7 8 9
ExponentPart
:::
See
9.3.1
ExponentIndicator SignedInteger
ExponentIndicator
::: one of
See
9.3.1
e E
SignedInteger
:::
See
9.3.1
DecimalDigits
+
DecimalDigits
-
DecimalDigits
HexIntegerLiteral
:::
See
9.3.1
0x
HexDigit
0X
HexDigit
HexIntegerLiteral HexDigit
HexDigit
::: one of
See
9.3.1
0 1 2 3 4 5 6 7 8 9 a b c d e f A B C D E F
A.3 Expressions
PrimaryExpression
:
See
11.1
this
Identifier
Literal
ArrayLiteral
ObjectLiteral
(
Expression
)
ArrayLiteral
:
See
11.1.4
[
Elision
opt
]
[
ElementList
]
[
ElementList
,
Elision
opt
]
ElementList
:
See
11.1.4
Elision
opt
AssignmentExpression
ElementList
,
Elision
opt
AssignmentExpression
Elision
:
See
11.1.4
,
Elision
,
ObjectLiteral
:
See
11.1.5
{}
{
PropertyNameAndValueList
}
PropertyNameAndValueList
:
See
11.1.5
PropertyName
:
AssignmentExpression
PropertyNameAndValueList
,
PropertyName
:
AssignmentExpression
PropertyName
:
See
11.1.5
Identifier
StringLiteral
NumericLiteral
MemberExpression
:
See
11.2
PrimaryExpression
FunctionExpression
MemberExpression
[
Expression
]
MemberExpression
.
Identifier
new
MemberExpression Arguments
NewExpression
:
See
11.2
MemberExpression
new
NewExpression
CallExpression
:
See
11.2
MemberExpression Arguments
CallExpression Arguments
CallExpression
[
Expression
]
CallExpression
.
Identifier
Arguments
:
See
11.2
()
(
ArgumentList
)
ArgumentList
:
See
11.2
AssignmentExpression
ArgumentList
,
AssignmentExpression
LeftHandSideExpression
:
See
11.2
NewExpression
CallExpression
PostfixExpression
:
See
11.3
LeftHandSideExpression
LeftHandSideExpression
[no
LineTerminator
here]
++
LeftHandSideExpression
[no
LineTerminator
here]
--
UnaryExpression
:
See
11.4
PostfixExpression
delete
UnaryExpression
void
UnaryExpression
typeof
UnaryExpression
++
UnaryExpression
--
UnaryExpression
+
UnaryExpression
-
UnaryExpression
~
UnaryExpression
!
UnaryExpression
MultiplicativeExpression
:
See
11.5
UnaryExpression
MultiplicativeExpression
*
UnaryExpression
MultiplicativeExpression
/
UnaryExpression
MultiplicativeExpression
%
UnaryExpression
AdditiveExpression
:
See
11.6
MultiplicativeExpression
AdditiveExpression
+
MultiplicativeExpression
AdditiveExpression
-
MultiplicativeExpression
ShiftExpression
:
See
11.7
AdditiveExpression
ShiftExpression
<<
AdditiveExpression
ShiftExpression
>>
AdditiveExpression
ShiftExpression
>>>
AdditiveExpression
RelationalExpression
:
See
11.8
ShiftExpression
RelationalExpression
<
ShiftExpression
RelationalExpression
>
ShiftExpression
RelationalExpression
<=
ShiftExpression
RelationalExpression
>=
ShiftExpression
RelationalExpression
instanceof
ShiftExpression
RelationalExpression
in
ShiftExpression
RelationalExpressionNoIn
:
See
11.8
ShiftExpression
RelationalExpressionNoIn
<
ShiftExpression
RelationalExpressionNoIn
>
ShiftExpression
RelationalExpressionNoIn
<=
ShiftExpression
RelationalExpressionNoIn
>=
ShiftExpression
RelationalExpressionNoIn
instanceof
ShiftExpression
EqualityExpression
:
See
11.9
RelationalExpression
EqualityExpression
==
RelationalExpression
EqualityExpression
!=
RelationalExpression
EqualityExpression
===
RelationalExpression
EqualityExpression
!==
RelationalExpression
EqualityExpressionNoIn
:
See
11.9
RelationalExpressionNoIn
EqualityExpressionNoIn
==
RelationalExpressionNoIn
EqualityExpressionNoIn
!=
RelationalExpressionNoIn
EqualityExpressionNoIn
===
RelationalExpressionNoIn
EqualityExpressionNoIn
!==
RelationalExpressionNoIn
BitwiseANDExpression
:
See
11.10
EqualityExpression
BitwiseANDExpression
&
EqualityExpression
BitwiseANDExpressionNoIn
:
See
11.10
EqualityExpressionNoIn
BitwiseANDExpressionNoIn
&
EqualityExpressionNoIn
BitwiseXORExpression
:
See
11.10
BitwiseANDExpression
BitwiseXORExpression
^
BitwiseANDExpression
BitwiseXORExpressionNoIn
:
See
11.10
BitwiseANDExpressionNoIn
BitwiseXORExpressionNoIn
^
BitwiseANDExpressionNoIn
BitwiseORExpression
:
See
11.10
BitwiseXORExpression
BitwiseORExpression
|
BitwiseXORExpression
BitwiseORExpressionNoIn
:
See
11.10
BitwiseXORExpressionNoIn
BitwiseORExpressionNoIn
|
BitwiseXORExpressionNoIn
LogicalANDExpression
:
See
11.11
BitwiseORExpression
LogicalANDExpression
&&
BitwiseORExpression
LogicalANDExpressionNoIn
:
See
11.11
BitwiseORExpressionNoIn
LogicalANDExpressionNoIn
&&
BitwiseORExpressionNoIn
LogicalORExpression
:
See
11.11
LogicalANDExpression
LogicalORExpression
||
LogicalANDExpression
LogicalORExpressionNoIn
:
See
11.11
LogicalANDExpressionNoIn
LogicalORExpressionNoIn
||
LogicalANDExpressionNoIn
ConditionalExpression
:
See
11.12
LogicalORExpression
LogicalORExpression
?
AssignmentExpression
:
AssignmentExpression
ConditionalExpressionNoIn
:
See
11.12
LogicalORExpressionNoIn
LogicalORExpressionNoIn
?
AssignmentExpressionNoIn
:
AssignmentExpressionNoIn
AssignmentExpression
:
See
11.13
ConditionalExpression
LeftHandSideExpression AssignmentOperator AssignmentExpression
AssignmentExpressionNoIn
:
See
11.13
ConditionalExpressionNoIn
LeftHandSideExpression AssignmentOperator AssignmentExpressionNoIn
AssignmentOperator
:one of
See
11.13
= *= /= %= += -= <<= >>= >>>= &= ^= |=
Expression
:
See
11.14
AssignmentExpression
Expression
,
AssignmentExpression
ExpressionNoIn
:
See
11.14
AssignmentExpressionNoIn
ExpressionNoIn
,
AssignmentExpressionNoIn
A.4 Statements
Statement
:
See clause 12
Block
VariableStatement
EmptyStatement
ExpressionStatement
IfStatement
IterationStatement
ContinueStatement
BreakStatement
ReturnStatement
WithStatement
LabelledStatement
SwitchStatement
ThrowStatement
TryStatement
Block
:
See
12.1
{
StatementList
opt
}
StatementList
:
See
12.1
Statement
StatementList Statement
VariableStatement
:
See
12.2
var
VariableDeclarationList
;
VariableDeclarationList
:
See
12.2
VariableDeclaration
VariableDeclarationList
,
VariableDeclaration
VariableDeclarationListNoIn
:
See
12.2
VariableDeclarationNoIn
VariableDeclarationListNoIn
,
VariableDeclarationNoIn
VariableDeclaration
:
See
12.2
Identifier Initialiser
opt
VariableDeclarationNoIn
:
See
12.2
Identifier InitialiserNoIn
opt
Initialiser
:
See
12.2
=
AssignmentExpression
InitialiserNoIn
:
See
12.2
=
AssignmentExpressionNoIn
EmptyStatement
:
See
12.3
;
ExpressionStatement
:
See
12.4
[lookahead ∉ {
{, function
}]
Expression
;
IfStatement
:
See
12.5
if (
Expression
)
Statement
else
Statement
if (
Expression
)
Statement
IterationStatement
:
See
12.6
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
:
See
12.7
continue
[no
LineTerminator
here]
Identifier
opt
;
BreakStatement
:
See
12.8
break
[no
LineTerminator
here]
Identifier
opt
;
ReturnStatement
:
See
12.9
return
[no
LineTerminator
here]
Expression
opt
;
WithStatement
:
See
12.10
with (
Expression
)
Statement
SwitchStatement
:
See
12.11
switch (
Expression
)
CaseBlock
CaseBlock
:
See
12.11
{
CaseClauses
opt
}
{
CaseClauses
opt
DefaultClause CaseClauses
opt
}
CaseClauses
:
See
12.11
CaseClause
CaseClauses CaseClause
CaseClause
:
See
12.11
case
Expression
:
StatementList
opt
DefaultClause
:
See
12.11
default :
StatementList
opt
LabelledStatement
:
See
12.12
Identifier
:
Statement
ThrowStatement
:
See
12.13
throw
[no
LineTerminator
here]
Expression ;
TryStatement
:
See
12.14
try
Block Catch
try
Block Finally
try
Block Catch Finally
Catch
:
See
12.14
catch (
Identifier
)
Block
Finally
:
See
12.14
finally
Block
A.5 Functions and Programs
FunctionDeclaration
:
See clause 13
function
Identifier
(
FormalParameterList
opt
){
FunctionBody
}
FunctionExpression
:
See clause 13
function
Identifier
opt
(
FormalParameterList
opt
){
FunctionBody
}
FormalParameterList
:
See clause 13
Identifier
FormalParameterList
,
Identifier
FunctionBody
:
See clause 13
SourceElements
Program
:
See clause 14
SourceElements
SourceElements
:
See clause 14
SourceElement
SourceElements SourceElement
SourceElement
:
See clause 14
Statement FunctionDeclaration
A.6 Universal Resource Identifier Character Classes
uri
:::
See
15.1.3
uriCharacters
opt
uriCharacters
:::
See
15.1.3
uriCharacter uriCharacters
opt
uriCharacter
:::
See
15.1.3
uriReserved
uriUnescaped
uriEscaped
uriReserved
::: one of
See
15.1.3
; / ? : @ & = + $ ,
uriUnescaped
:::
See
15.1.3
uriAlpha
DecimalDigit
uriMark
uriEscaped
:::
See
15.1.3
%
HexDigit HexDigit
uriAlpha
::: one of
See
15.1.3
a b c d e f g h i j k l m n o p q r s t u v w x y z
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
uriMark
::: one of
See
15.1.3
- _ . ! ~ * ' ( )
A.7 Regular Expressions
Pattern
::
See
15.10.1
Disjunction
Disjunction
::
See
15.10.1
Alternative
Alternative
|
Disjunction
Alternative
::
See
15.10.1
[empty]
Alternative Term
Term
::
See
15.10.1
Assertion
Atom
Atom Quantifier
Assertion
::
See
15.10.1
^
$
\ b
\ B
Quantifier
::
See
15.10.1
QuantifierPrefix
QuantifierPrefix
?
QuantifierPrefix
::
See
15.10.1
*
+
?
{
DecimalDigits
}
{
DecimalDigits
,}
{
DecimalDigits
,
DecimalDigits
}
Atom
::
See
15.10.1
PatternCharacter
.
\
AtomEscape
CharacterClass
(
Disjunction
)
(?:
Disjunction
)
(?=
Disjunction
)
(?!
Disjunction
)
PatternCharacter
::
SourceCharacter
but not any of:
See
15.10.1
^ $ \ . * + ? ( ) [ ] { } |
AtomEscape
::
See
15.10.1
DecimalEscape CharacterEscape CharacterClassEscape
CharacterEscape
::
See
15.10.1
ControlEscape
c
ControlLetter
HexEscapeSequence
UnicodeEscapeSequence
IdentityEscape
ControlEscape
:: one of
See
15.10.1
f n r t v
ControlLetter
:: one of
See
15.10.1
a b c d e f g h i j k l m n o p q r s t u v w x y z
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
IdentityEscape
::
See
15.10.1
SourceCharacter
but not
IdentifierPart
DecimalEscape
::
See
15.10.1
DecimalIntegerLiteral
[lookahead ∉
DecimalDigit]
CharacterClass
::
See
15.10.1
[
[lookahead ∉ {^}]
ClassRanges
]
[^
ClassRanges
]
ClassRanges
::
See
15.10.1
[empty]
NonemptyClassRanges
NonemptyClassRanges
::
See
15.10.1
ClassAtom
ClassAtom NonemptyClassRangesNoDash
ClassAtom
-
ClassAtom ClassRanges
NonemptyClassRangesNoDash
::
See
15.10.1
ClassAtom>
ClassAtomNoDash NonemptyClassRangesNoDash
ClassAtomNoDash
-
ClassAtom ClassRanges
ClassAtom
::
See
15.10.1
-
ClassAtomNoDash
ClassAtomNoDash
::
See
15.10.1
SourceCharacter
but not one of
\ ] -
\
ClassEscape
ClassEscape
::
See
15.10.1
DecimalEscape
b
CharacterEscape
CharacterClassEscape