Skip to content

Instantly share code, notes, and snippets.

@SMotaal
Forked from avdg/es6.ebnf
Created May 2, 2020 13:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SMotaal/80e3cbb45fc44e13805a9b43c86405fd to your computer and use it in GitHub Desktop.
Save SMotaal/80e3cbb45fc44e13805a9b43c86405fd to your computer and use it in GitHub Desktop.
ES6 bnf grammer - See https://avdg.github.io/es6.xhtml
/* ebnf file for es 6 - MAY CONTAIN ERRORS / DISAMBIGUITY */
Grammer::= Statement
/* Lexical grammer */
SourceCharacter ::= #x0000-#x10FFFF
InputElementDiv ::= WhiteSpace | LineTerminator | Comment | CommonToken | DivPunctuator | RightBracePunctuator
InputElementRegExp ::= WhiteSpace | LineTerminator | Comment | CommonToken | RightBracePunctuator | RegularExpressionLiteral
InputElementRegExpOrTemplateTail ::= WhiteSpace | LineTerminator | Comment | CommonToken | RegularExpressionLiteral | TemplateSubstitutionTail
InputElementTemplateTail ::= WhiteSpace | LineTerminator | Comment | CommonToken | DivPunctuator | TemplateSubstitutionTail
WhiteSpace ::= "<TAB>" | "<VT>" | "<FF>" | "<SP>" | "<NBSP>" | "<ZWNBSP>" | "<USP>"
LineTerminator ::= "<LF>" | "<CR>" | "<LS>" | "<PS>" /* #x0012 #x0015 #x2028 #x2029 */
LineTerminatorSequence ::= "<LF>" | "<CR>" "<LF>"? | "<LS>" | "<PS>"
Comment ::= MultiLineComment | SingleLineComment
MultiLineComment ::= "/*" MultiLineCommentChars? "*/"
MultiLineCommentChars ::= MultiLineNotAsteriskChar MultiLineCommentChars?
PostAsteriskCommentChars ::= MultiLineNotForwardSlashOrAsteriskChar MultiLineCommentChars? | "*" PostAsteriskCommentChars?
MultiLineNotAsteriskChar ::= /* SourceCharacter but not */ [^*]
MultiLineNotForwardSlashOrAsteriskChar ::= /* SourceCharacter but not one of */ [^/*]
SingleLineComment ::= "/" "/" SingleLineCommentChars?
SingleLineCommentChars ::= SingleLineCommentChar SingleLineCommentChars?
SingleLineCommentChar ::= /* SourceCharacter but not LineTerminator*/ [^ #x0012 #x0015 #x2028 #x2029 ]
CommonToken ::= IdentifierName | Punctuator | NumericLiteral | StringLiteral | Template
IdentifierName ::= IdentifierStart | IdentifierName IdentifierPart
IdentifierStart ::= UnicodeIDStart | "$" | "_" | "\" UnicodeEscapeSequence
IdentifierPart ::= UnicodeIDContinue | "$" | "_" | "\" UnicodeEscapeSequence | "<ZWNJ>" | "<ZWJ>"
UnicodeIDStart ::= [https://github.com/mathiasbynens/unicode-data/blob/master/5.1.0/properties/ID_Start-regex.js] /* Unicode 5.1 or later */
UnicodeIDContinue ::= [https://github.com/mathiasbynens/unicode-data/blob/master/5.1.0/properties/Other_ID_Continue-regex.js] /* Unicode 5.1 or later */
ReservedWord ::= Keyword | FutureReservedWord | NullLIteral | BooleanLiteral
Keyword ::= "break" | "case" | "catch" | "class" | "const" | "continue" | "debugger" | "default" | "delete" |
"do" | "else" | "export" | "extends" | "finally" | "for" | "function" | "if" | "import" |
"in" | "instanceof" | "new" | "return" | "super" | "switch" | "this" | "throw" | "try" |
"typeof" | "var" | "void" | "while" | "with" | "yield"
FutureReservedWord ::= "enum" | "await" /* await is only treated as a FutureReservedWord when Module is the goal symbol of the syntactic grammar. */
/* The following tokens are also considered to be FutureReservedWords when parsing strict mode code: */
| "implements" | "interface" | "package" | "private" | "protected" | "public"
Punctuator ::= "{" | "}" | "(" | ")" | "[" | "]" | "." | ";" | "," | "<" | ">" | "<=" | ">=" | "==" | "!=" | "===" | "!==" |
"+" | "-" | "*" | "%" | "++" | "--" | "<<" | ">>" | ">>>" | "&" | "|" | "^" |
"!" | "~" | "&&" | "?" | ":" | "=" | "+=" | "-=" | "*=" | "%=" | "<<=" | ">>=" | ">>>=" | "&=" | "|=" | "^=" | "=>"
DivPunctuator ::= "/" | "/="
RightBracePunctuator ::= "}"
NullLiteral ::= "null"
BooleanLiteral ::= "true" | "false"
NumbericLiteral ::= DecimalLiteral | BinaryLiteral | OctalIntegerLiteral | HexIntegerLiteral
DecimalLiteral ::= DecimalIntegerLiteral "." DecimalDigits? ExponentPart? | "." DecimalDigits ExponentPart? | DecimalIntegerLiteral ExponentPart?
DecimalIntegerLiteral ::= "0" | NonZeroDigit DecimalDigits?
DecimalDigits ::= DecimalDigit | DecimalDigits DecimalDigit
DecimalDigit ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
NonZeroDigit ::= "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9"
ExponentPart ::= ExponentIndicator SignedInteger
ExponentIndicator ::= "e" | "E"
SignedInteger ::= DecimalDigits | "+" DecimalDigits | "-" DecimalDigits
BinaryIntegerLiteral ::= "0b" BinaryDigits | "0B" BinaryDigits
BinaryDigits ::= BinaryDigit | BinaryDigits BinaryDigit
BinaryDigit ::= "0" | "1"
OctalIntegerLiteral ::= "0o" OctalDigits | "0O" OctalDigits
OctalDigits ::= OctalDigit | OctalDigits OctalDigit
OctalDigit ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7"
HexIntegerLiteral ::= "0x" HexDigits | "0X" HexDigits
HexDigits ::= HexDigit | HexDigits HexDigit
HexDigit ::= "0" | "1" | "2" | "3" | "4" | "5" | "6" | "7" | "8" | "9" | "a" | "b" | "c" | "d" | "e" | "f" | "A" | "B" | "C" | "D" | "E" | "F"
StringLiteral ::= '"' DoubleStringCharacters? '"' | '"' SingleStringCharacters? '"'
DoubleStringCharacters ::= DoubleStringCharacter DoubleStringCharacters?
SingleStringCharacters ::= SingleStringCharacter SingleStringCharacters?
DoubleStringCharacter ::= /* chars are lineTerminators */ [^" \ #x0012 #x0015 #x2028 #x2029] | "\" EscapeSequence | LineContinuation
SingleStringCharacter ::= /* chars are lineTerminators */ [^' \ #x0012 #x0015 #x2028 #x2029] | "\" EscapeSequence | LineContinuation
LineContinuation ::= "\" LineTerminatorSequence
EscapeSequence ::= CharacterEscapeSequence | "0" /* lookahead not DecimalDigit */ [^ 0 1 2 3 4 5 6 7 8 9] | HexEscapeSequence | UnicodeEscapeSequence
CharacterEscapeSequence ::= SingleEscapeCharacter | NonEscapeCharacter
SingleEscapeCharacter ::= "'" | '"' | "\" | "b" | "f" | "n" | "r" | "t" | "v"
NonEscapeCharacter ::= /* SourceCharacter but not one of EscapeCharacter or LineTerminator */ [^ ' " \ b f n r t v #x0012 #x0015 #x2028 #x2029]
EscapeCharacter ::= SingleEscapeCharacter | DecimalDigit | "x" | "u"
HexEscapeSequence ::= "x" HexDigit HexDigit
UnicodeEscapeSequence ::= "u" Hex4Digits | "u{" HexDigits "}"
Hex4Digits ::= HexDigit HexDigit HexDigit HexDigit
RegularExpressionLiteral ::= "/" RegularExpressionBody "/" RegularExpressionFlags
RegularExpressionBody ::= RegularExpressionFirstChar RegularExpressionChars
RegularExpressionChars ::= | RegularExpressionChars RegularExpressionChar
RegularExpressionFirstChar ::= /* RegularExpressionNonTerminator but not one of * or \ or / or [ */ [^ #x0012 #x0015 #x2028 #x2029 * \ / []| RegularExpressionBackslashSequence | RegularExpressionClass
RegularExpressionChar ::= /* RegularExpressionNonTerminator but not one of \ or / or [ */ [^ #x0012 #x0015 #x2028 #x2029 \ / []| RegularExpressionBackslashSequence | RegularExpressionClass
RegularExpressionBackslashSequence ::= "\" RegularExpressionNonTerminator
RegularExpressionNonTerminator ::= /* SourceCharacter but not LineTerminator */ [^#x0012 #x0015 #x2028 #x2029]
RegularExpressionClass ::= "[" RegularExpressionClassChars "]"
RegularExpressionClassChars ::= | RegularExpressionClassChars RegularExpressionClassChar
RegularExpressionClassChar ::= /* RegularExpressionNonTerminator but not one of ] or \ */ [^ \ #x0012 #x0015 #x2028 #x2029 #x005D] | RegularExpressionBackslashSequence
RegularExpressionFlags ::= | RegularExpressionFlags IdentifierPart
Template ::= NoSubstitutionTemplate | TemplateHead
NoSubstitutionTemplate ::= "`" TemplateCharacters? "`"
TemplateHead ::= "`" TemplateCharacters? "${"
TemplateSubstitutionTail ::= TemplateMiddle | TemplateTail
TemplateMiddle ::= "}" TemplateCharacters? "${"
TemplateTail ::= "}" TemplateCharacters? "`"
TemplateCharacters ::= TemplateCharacter TemplateCharacters?
TemplateCharacter ::= "$" [^{] | "\" EscapeSequence | LineContinuation | LineTerminatorSequence | /* SourceCharacter but not one of ` or \ or $ or LineTerminator */ [^ ` \ $ #x0012 #x0015 #x2028 #x2029]
/* Expressions */
IdentifierReference ::= Identifier | /* [~Yield] */ "yield"
BindingIdentifier ::= Identifier | /* [~Yield] */ "yield"
LabelIdentifier ::= Identifier | /* [~Yield] */ "yield"
Identifier ::= /* IdentifierName but not ReservedWord */ IdentifierName
PrimaryExpression ::= "this" | IdentifierReference | Literal | ArrayLiteral | ObjectLiteral | FunctionExpression | ClassExpression | GeneratorExpression | RegularExpressionLiteral |
TemplateLIteral | CoverParenthesizedExpressionAndArrowParameterList
CoverParenthesizedExpressionAndArrowParameterList ::= "(" Expression ")" | "(" ")" | "(" "..." BindingIdentifier ")" | "(" Expression "," "..." BindingIdentifier ")"
ParenthesizedExpression ::= "(" Expression ")"
Literal ::= NullLiteral | BooleanLiteral | NumbericLiteral | StringLiteral
ArrayLiteral ::= "[" Elision? "]" | "[" ElementList "]" | "[" ElementList "," Elision? "]"
ElementList ::= Elision? AssignmentExpression | Elision? SpreadElement | ElementList "," Elision? AssignmentExpression | ElementLIst "," | Elision? SpreadElement
Elision ::= "," | Elision ","
SpreadElement ::= "..." AssignmentExpression
ObjectLiteral ::= "{" "}" | "{" PropertyDefinitionList "}" | "{" PropertyDefinitionList "," "}"
PropertyDefinitionList ::= PropertyDefinition | PropertyDefinitionList "," PropertyDefinition
PropertyDefinition ::= IdentifierReference | CoverInitializedName | PropertyName ":" AssignmentExpression | MethodDefinition
PropertyName ::= LiteralPropertyName | ComputedPropertyName
LiteralPropertyName ::= IdentifierName | StringLiteral | NumericLiteral
ComputedPropertyName ::= "[" AssignmentExpression "]"
CoverInitializedName ::= IdentifierReference Initializer
Initializer ::= "=" AssignmentExpression
TemplateLiteral ::= NoSubstitutionTemplate | TemplateHead Expression TemplateSpans
TemplateSpans ::= TemplateTail | TemplateMiddleList TemplateTail
TemplateMiddleList ::= TemplateMiddle Expression | TemplateMiddleList TemplateMiddle Expression
MemberExpression ::= PrimaryExpression | MemberExpression "[" Expression "]" | MemberExpression "." IdentifierName | MemberExpression TemplateLiteral
| SuperProperty | MetaProperty | "new" MemberExpression Arguments
SuperProperty ::= "super" "[" Expression "]" | "super" "." IdentifierName
MetaProperty ::= NewTarget
NewTarget ::= "new" "." "target"
NewExpression ::= MemberExpression | "new" NewExpression
CallExpression ::= MemberExpression Arguments | SuperCall | CallExpression Arguments | CallExpression "[" Expression "]" | CallExpression "." IdentifierName | CallExpression TemplateLiteral
SuperCall ::= "super" Arguments
Arguments ::= "(" ")" | "(" ArgumentList ")"
ArgumentList ::= AssignmentExpression | "..." AssignmentExpression | ArgumentList "," AssignmentExpression | ArugmentList "," "..." 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 MultiplicativeOperator UnaryExpression
MultiplicativeOperator ::= [* / %]
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
EqualityExpression ::= RelationalExpression
| EqualityExpression "==" RelationalExpression
| EqualityExpression "!=" RelationalExpression
| EqualityExpression "===" RelationalExpression
| EqualityExpression "!==" RelationalExpression
BitwiseANDExpression ::= RelationalExpression
| BitwiseANDExpression "&" RelationalExpression
BitwiseXORExpression ::= BitwiseANDExpression
| BitwiseXORExpression "^" BitwiseANDExpression
BitwiseORExpression ::= BitwiseXORExpression
| BitwiseORExpression "|" BitwiseXORExpression
ConditionalExpression ::= LogicalORExpression
| LogicalORExpression "?" AssignmentExpression ":" AssignmentExpression
AssignmentExpression ::= ConditionalExpression
| YieldExpression
| ArrowFunction
| LeftHandSideExpression "=" AssignmentExpression
| LeftHandSideExpression AssignmentOperator AssignmentExpression
AssignmentOperator ::= "*=" | "/=" | "%=" | "+=" | "-=" | "<<=" | ">>=" | ">>>=" | "&=" | "^=" | "|="
Expression ::= AssignmentExpression | Expression AssignmentExpression
/* Statements */
Statement ::= BlockStatement | VariableStatement | EmptyStatement | ExpressionStatement | IfStatement
| BreakableStatement | ContinueStatement | BreakStatement | ReturnStatement | WithStatement
| LabelledStatement | ThrowStatement | TryStatement | DebuggerStatement
Declaration ::= HoistableDeclaration | ClassDeclaration | LexicalDeclaration
HoistableDeclaration ::= FunctionDeclaration | GeneratorDeclaration
BreakableStatement ::= IterationStatement | SwitchStatement
BlockStatement ::= Block
Block ::= "{" StatementList? "}"
StatementList ::= StatementListItem | StatementList StatementListItem
StatementListItem ::= Statement | Declaration
LexicalDeclaration ::= LetOrConst BindingList
LetOrConst ::= "let" | "const"
BindingList ::= LexicalBinding | BindingList "," LexicalBinding
LexicalBinding ::= BindingIdentifier Initializer? | BindingPattern Initializer
VariableStatement ::= "var" VariableDeclarationList
VariableDeclarationList ::= VariableDeclaration | VariableDeclarationList "," VariableDeclaration
VariableDeclaration ::= BindingIdentifier Initializer? | BindingPattern Initializer
BindingPattern ::= ObjectBindingPattern | ArrayBindingPattern
ObjectBindingPattern ::= "{" "}" | "{" BindingPropertyList "}" | "{" BindingPropertyList "," "}"
ArrayBindingPattern ::= "[" Elision? BindingRestElement? "]" | "[" BindingElementList "]" | "[" BindingElementList "," Elision? BindingRestElement? "]"
BindingPropertyList ::= BindingProperty | BindingPropertyList BindingProperty
BindingElementList ::= BindingElisionElement | BindingElementList "," BindingElisionElement
BindingElisionElement ::= Elision? BindingElement
BindingProperty ::= SingleNameBinding | PropertyName ":" BindingElement
BindingElement ::= SingleNameBinding | BindingPattern Initializer?
SingleNameBinding ::= BindingIdentifier Initializer?
BindingRestElement ::= "..." BindingIdentifier
EmptyStatement ::= ";"
ExpressionStatement ::= /* [lookahead ∉ {{, function, class, let [}] */ Expression ";"
IfStatement ::= "if" "(" Expression ")" Statement "else" statement
| "if" "(" Expression ")" Statement
IterationStatement ::= "do" Statement "while" "(" Expression ")" ";"
| "while" "(" Expression ")" Statement
| "for" "(" /* [lookahead ∉ {let [}] */ Expression? ";" Expression? ";" Expression? ")" Statement
| "for" "(" "var" VariableDeclarationList ";" Expression? ";" Expression? ")" Statement
| "for" "(" LexicalDeclaration Expression? ";" Expression? ";" Expression? ")" Statement
| "for" "(" /* [lookahead ∉ {let [}] */ LeftHandSideExpression "in" Expression ")" Statement
| "for" "(" "var" ForBinding "in" Expression ")" Statement
| "for" "(" ForDeclaration "in" Expression ")" Statement
| "for" "(" /* [lookahead ∉ {let [}] */ LeftHandSideExpression "of" AssignmentExpression ")" Statement
| "for" "(" "var" ForBinding "of" AssignmentExpression ")" Statement
| "for" "(" LexicalDeclaration Expression "of" AssignmentExpression ")" Statement
ForDeclaration ::= LetOrConst ForBinding
ForBinding ::= BindingIdentifier | BindingPattern
ContinueStatement ::= "continue" ";" | "continue" /* no LineTerminator here */ LabelIdentifier ";"
BreakStatement ::= "break" ";" | "break" /* no LineTerminator here */ LabelIdentifier ";"
ReturnStatement ::= "return" ";" | "return" /* no LineTerminator here */ Expression ";"
WithStatement ::= "with" "(" Expression ")" Statement
SwitchStatement ::= "switch" "(" Expression ")" CaseBlock
CaseBlock ::= "{" CaseClauses? "}" | "{" CaseClauses? DefaultClause CaseClauses? "}"
CaseClauses ::= CaseClause | CaseClauses CaseClause
CaseClause ::= "case" Expression ":" StatementList?
DefaultClause ::= "default" ":" StatementList?
LabelledStatement ::= LabelIdentifier ":" LabelledItem
LabelledItem ::= Statement | FunctionDeclaration
ThrowStatement ::= "throw" /* no LineTerminator here */ Expression ";"
TryStatement ::= "try" Block Catch | "try" Block Finally | "try" Block Catch finally
Catch ::= "catch" "(" CatchParameter ")" Block
Finally ::= "finally" Block
CatchParameter ::= BindingIdentifier | BindingPattern
DebuggerStatement ::= "debugger" ";"
/* Functions and classes */
FunctionDeclaration ::= "function" BindingIdentifier "(" FormalParameters ")" "{" FunctionBody "}"
| /* [+Default] */ "function" "(" FormalParameters ")" "{" FunctionBody "}"
FunctionExpression ::= "function" BindingIdentifier? "(" FormalParameters ")" "{" FunctionBody "}"
StrictFormalParameters ::= FormalParameters
FormalParameters ::= | FormalParameterList
FormalParameterList ::= FunctionRestParameter | FormalsList | FormalsList "," FormalParameter
FormalsList ::= FormalParameter | FormalsList "," FormalParameter
FunctionRestParameter ::= BindingRestElement
FormalParameter ::= BindingElement
FunctionBody ::= FunctionStatementList
FunctionStatementList ::= StatementList?
ArrowFunction ::= ArrowParameters /* no LineTerminator here */ "=>" ConciseBody
ArrowParameters ::= BindingIdentifier | CoverParenthesizedExpressionAndArrowParameterList
ConciseBody ::= /* [lookahead ≠ { ] */ AssignmentExpression | "{" FunctionBody "}"
ArrowFormalParameters ::= "(" StrictFormalParameters ")"
MethodDefinition ::= PropertyName "(" StrictFormalParameters ")" "{" FunctionBody "}"
| GeneratorMethod
| "get" PropertyName "(" ")" "{" FunctionBody "}"
| "set" PropertyName "(" PropertySetParameterList ")" "{" FunctionBody "}"
PropertySetParameterList ::= FormalParameter
GeneratorMethod ::= "*" PropertyName "(" StrictFormalParameters ")" "{" GeneratorBody "}"
GeneratorDeclaration ::= "function" "*" BindingIdentifier "(" FormalParameters ")" "{" GeneratorBody "}"
| /* [+Default] */ "function" "*" "(" FormalParameters ")" "{" GeneratorBody "}"
GeneratorExpression ::= "function" "*" BindingIdentifier? "(" FormalParameters ")" "{" GeneratorBody "}"
GeneratorBody ::= FunctionBody
YieldExpression ::= "yield"
| "yield" /* no LineTerminator here */ AssignmentExpression
| "yield" /* no LineTerminator here */ "*" AssignmentExpression
ClassDeclaration ::= "class" BindingIdentifier? ClassTail
| /* [+Default] */ class ClassTail
ClassExpression ::= "class" BindingIdentifier? ClassTail
ClassTail ::= ClassHeritage? "{" ClassBody? "}"
ClassHeritage ::= "extends" LeftHandSideExpression
ClassBody ::= ClassElementList
ClassElementList ::= ClassElement
| classElementLIst ClassElement
ClassElement ::= MethodDefinition
| "static" MethodDefinition
| ";"
/* Scripts and Modules */
script ::= ScriptBody?
ScriptBody ::= StatementList
Module ::= ModuleBody?
ModuleBody ::= ModuleItemList
ModuleItemList ::= ModuleItem
| ModuleItemList ModuleItem
ModuleItem ::= ImportDeclaration
| ExportDeclaration
| StatementListItem
ImportDeclaration ::= "import" ImportClause FromClause ";"
| "import" ModuleSpecifier ";"
ImportClause ::= ImportedDefaultBinding
| NameSpaceImport
| NamedImports
| ImportedDefaultBinding "," NameSpaceImport
| ImportedDefaultBinding "," NamedImports
ImportedDefaultBinding ::= ImportedBinding
NameSpaceImport ::= "*" "as" ImportedBinding
NamedImports ::= "{" "}"
FromClause ::= "from" ModuleSpecifier
ImportsList ::= ImportSpecifier
| ImportsList "," ImportSpecifier
ImportSpecifier ::= ImportedBinding
| IdentifierName "as" ImportedBinding
ModuleSpecifier ::= StringLiteral
ImportedBinding ::= BindingIdentifier
ExportDeclaration ::= "export" "*" FromClause ";"
| "export" ExportClause FromClause ";"
| "export" ExportClause ";"
| "export" VariableStatement
| "export" Declaration
| "export" "default" HoistableDeclaration
| "export" "default" ClassDeclaration
| "export" "default" /* [lookahead ∉ {function, class}] */ AssignmentExpression ";"
ExportClause ::= "{" "}"
| "{" ExportList "}"
| "{" ExportList "," "}"
ExportList ::= ExportSpecifier
| ExportsList "," ExportSpecifier
ExportSpecifier ::= IdentifierName
| IdentifierName "as" IdentifierName
/* Number Conversions */
StringNumericLiteral ::= StrWhiteSpace?
| StrWhiteSpace? StrNumericLiteral StrWhiteSpace?
StrWhiteSpace ::= StrWhiteSpaceChar StrWhiteSpace?
StrWhiteSpaceChar ::= WhiteSpace
| LineTerminator
StrNumericLiteral ::= StrDecimalLiteral
| BinaryIntegerLiteral
| OctalIntegerLiteral
| HexIntegerLiteral
StrDecimalLiteral ::= StrUnsignedDecimalLiteral
| "+" StrUnsignedDecimalLiteral
| "-" StrUnsignedDecimalLiteral
StrUnsignedDecimalLiteral ::= "Infinity"
| DecimalDigits "." DecimalDigits? ExponentPart?
| "." DecimalDigits ExponentPart?
| DecimalDigits ExponentPart?
/* Also using, but already declared: DecimalDigits DecimalDigit ExponentPart ExponentIndicator SignedInteger HexIntegerLiteral HexDigit */
/* Universal Resource Identifier Character Classes */
uri ::= uriCharacters?
uriCharacters ::= uriCharacter uriCharacters?
uriCharacter ::= uriReserved
| uriUnescaped
| uriEscaped
uriReserved ::= [ ; / ? : @ & = + $ , ]
uriUnescaped ::= uriAlpha
| DecimalDigit
| uriMark
uriEscaped ::= "%" HexDigit HexDigit
uriAlpha ::= [abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ]
uriMark ::= [-_.!~*'()]
/* Regular Expressions */
Pattern ::= Disjunction
Disjunction ::= Alternative
| Alternative "|" Disjunction
Alternative ::= /* empty */
| Alternative Term
Term ::= Assertion
| Atom
| Atom Quantifier
Assertion ::= "^"
| "$"
| "\" "b"
| "\" "B"
| "(" "?" "=" Disjunction ")"
| "(" "?" "!" Disjunction ")"
Quantifier ::= QuantifierPrefix
| QuantifierPrefix "?"
QuantifierPrefix ::= "*"
| "+"
| "?"
| "{" DecimalDigits "}"
| "{" DecimalDigits "," "}"
| "{" DecimalDigits "," DecimalDigits "}"
Atom ::= PatternCharacter
| "."
| "\" AtomEscape
| CharacterClass
| "(" Disjunction ")"
| "(" "?" ":" Disjunction ")"
SyntaxCharacter ::= [$^\.*+?()[#x005D{}|] /* #x005D is ] */
PatternCharacter ::= /* SourceCharacter but not SyntaxCharacter */ [^$^\.*+?()[#x005D{}|] /* #x005D is ] */
AtomEscape ::= DecimalEscape
| CharacterEscape
| CharacterClassEscape
CharacterEscape ::= ControlEscape
| "c" ControlLetter
| HexEscapeSequence
| RegExpUnicodeEscapeSequence
| IdentityEscape
ControlLetter ::= [fnrtv]
ControlEscape ::= uriAlpha /* being lazy */
RegExpUnicodeEscapeSequence ::= "u" LeadSurrogate "\u" TrailSurrogate
| "u" LeadSurrogate
| "u" TrailSurrogate
| "u" NonSurrogate
| Hex4Digits
| "u{" HexDigits "}"
LeadSurrogate ::= Hex4Digits /* [match only if the SV of Hex4Digits is in the inclusive range 0xD800 to 0xDBFF] */
TrailSurrogate ::= Hex4Digits /* [match only if the SV of Hex4Digits is in the inclusive range 0xDC00 to 0xDFFF] */
NonSurrogate ::= Hex4Digits /* [match only if the SV of Hex4Digits is not in the inclusive range 0xD800 to 0xDFFF] */
IdentityEscape ::= SyntaxCharacter
| "/"
| [^UnicodeContinue] /* SourceCharacter but not UnicodeIDContinue */
DecimalEscape ::= DecimalIntegerLiteral /* [lookahead ∉ DecimalDigit] */
CharacterClassEscape ::= [dDsSwW]
CharacterClass ::= "[" /* [lookahead ∉ {^}] */ ClassRanges "]"
| "[" "^" ClassRanges "]"
ClassRanges ::= /* empty */
| NonemptyClassRanges
NonemptyClassRanges ::= ClassAtom
| ClassAtom NonemptyClassRangesNoDash
| ClassAtom "-" ClassAtom ClassRanges
NonemptyClassRangesNoDash ::= ClassAtom
| ClassAtomNoDash NonemptyClassRangesNoDash
| ClassAtomNoDash "-" ClassAtom ClassRanges
ClassAtom ::= "-"
| ClassAtomNoDash
ClassAtomNoDash ::= /* SourceCharacter but not one of \ or ] or - */ [^\#x005D-]
| "\" ClassEscape
ClassEscape ::= DecimalEscape
| "b"
| "-"
| CharacterEscape
| CharacterClassEscape
/* Additional syntax: (non strict) Numeric Literals */
NumericLiteral ::= DecimalLiteral
| BinaryIntegerLiteral
| OctalIntegerLiteral
| HexIntegerLiteral
| LegacyOctalIntegerLiteral
LegacyOctalIntegerLiteral ::= "0" OctalDigit
| NonZeroDigit DecimalDigits?
| NonOctalDecimalIntegerLiteral
DecimalIntegerLiteral ::= "0" OctalDigit
| LegacyOctalIntegerLiteral OctalDigit
NonOctalDecimalIntegerLiteral ::= "0" NonOctalDigit
| LegacyOctalLikeDecimalIntegerLiteral NonOctalDigit
| NonOctalDecimalIntegerLiteral DecimalDigit
LegacyOctalLikeDecimalIntegerLiteral ::= "0" OctalDigit
| LegacyOctalLikeDecimalIntegerLiteral OctalDigit
NonOctalDigit ::= "8"
| "9"
/* Additional syntax: (non strict) String Literals */
EscapeSequence ::= CharacterEscapeSequence
| LegacyOctalEscapeSequence
| HexEscapeSequence
| UnicodeEscapeSequence
LegacyOctalEscapeSequence ::= OctalDigit /* [lookahead ∉ OctalDigit] */
| ZeroToThree OctalDigit /* [lookahead ∉ OctalDigit] */
| FourToSeven OctalDigit
| ZeroToThree OctalDigit OctalDigit
ZeroToThree ::= [0123]
FourToSeven ::= [4567]
/* Additional syntax: HTML-like Comments */
Comment ::= MultiLineComment
| SingleLineComment
| SingleLineHTMLOpenComment
| SingleLineHTMLCloseComment
| SingleLineDelimitedComment
MultiLineComment ::= "/*" FirstCommentLine? LineTerminator MultiLineCommentChart? "*/" HTMLCloseComment?
FirstCommentLine ::= SingleLineDelimitedCommentChars
SingleLineHTMLOpenComment ::= "<!--" SingleLineCommentChars?
SingleLineHTMLCloseComment ::= LineTerminatorSequence HTMLCloseComment
SingleLineDelimiterComment ::= "/*" SingleLineDelimitedCommentChars? "*/"
HTMLCloseComment ::= WhiteSpaceSequence? SingleLineDelimitedCommentSequence? "-->" SingleLineCommentChars?
SingleLineDelimitedCommentChars ::= SingleLineNotAsteriskChar SingleLineDelimitedCommentChars?
| "*" SingleLinePstAsteriskCommentChars?
SingleLineNotAsteriskChar ::= /* SourceCharacter but not one of * or LineTerminator */ [^*#x0012#x0015#x2028#x2029]
SingleLinePostAsteriskCommentChars ::= SingleLineNotForwardSlashOrAsteriskChar SingleLineDelimitedCommentChars?
| "*" SingleLinePostAsteriskCommentChars?
SingleLineNotForwardSlashOrAsteriskChar ::= /* SourceCharacter but not one of / or * or LineTerminator */ [^*/#x0012#x0015#x2028#x2029]
WhiteSpaceSequence ::= WhiteSpace WhiteSpaceSequence?
SingleLineDelimitedCommentSequence ::= SingleLineDelimitedComment WhiteSpaceSequence? SingleLineDelimitedCommentSequence?
/* Additional syntax: Regular Expressions Patterns */
Term ::= ExtendedTerm
| Assertion
| Atom
| Atom Quantifier
ExtendedTerm ::= Assertion
| AtomNoBrace Quantifier
| Atom
| QuantifiableAssertion Quantifier
AtomNoBrace ::= PatternCharacterNoBrace
| "."
| "\" AtomEscape
| CharacterClass
| "(" Disjunction ")"
| "(" "?" ":" Disjunction ")"
Atom ::= PatternCharacter
| "."
| "\" AtomEscape
| CharacterClass
| "(" Disjunction ")"
| "(" "?" ":" Disjunction ")"
PatternCharacterNoBrace ::= /* SourceCharacter but not one of ^ $ \ . * + ? ( ) [ ] { } | */ [^^$\.*+?()[#x005D{}|]
PatternCharacter ::= /* SourceCharacter but not one of ^ $ \ . * + ? ( ) [ ] | */ [^^$\.*+?()[#x005D|]
QuantifiableAssertion ::= "(" "?" "=" Disjunction ")"
| "(" "?" "!" Disjunction ")"
Assertion ::= "^"
| "$"
| "\" "b"
| "\" "B"
| "(" "?" "=" Disjunction ")"
| "(" "?" "!" Disjunction ")"
| QuantifiableAssertion
AtomEscape ::= DecimalEscape
| CharacterEscape
| CharacterClassEscape
| DecimalEscape /* but only if the integer value of DecimalEscape is <= NCapturingParens */
| CharacterClassEscape
| CharacterEscape
CharacterEscape ::= ControlEscape
| "c" ControlLetter
| HexEscapeSequence
| RegExpUnicodeEscapeSequence
| LegacyOctalEscapeSequence
| IdentityEscape
IdentityEscape ::= SyntaxCharacter
| "/"
| SourceCharacter /* but not c */
NonemptyClassRanges ::= ClassAtom
| ClassAtom NonemptyClassRangesNoDash
| ClassAtom "-" ClassAtom ClassRanges
| ClassAtomInRange "-" ClassAtomInRange ClassRanges
NonemptyClassRangesNoDash ::= ClassAtom
| ClassAtomNoDash NonemptyClassRangesNoDash
| ClassAtomNoDash "-" ClassAtom ClassRanges
| ClassAtomNoDashInRange "-" ClassAtomInRange ClassRanges
ClassAtom ::= "-"
| ClassAtomNoDashInRange
ClassAtomNoDash ::= /* SourceCharacter but not one of \ or ] or - */ [^\#x005D-]
| "\" ClassEscape
ClassAtomInRange ::= "-"
| ClassAtomNoDashInRange
ClassAtomNoDashInRange ::= /* SourceCharacter but not one of \ or ] or - */ [^\#x005D-]
| "\" ClassEscape /* but only if ClassEscape evaluates to a CharSet with exactly one character */
| "\" IdentityEscape
ClassEscape ::= DecimalEscape
| CharacterEscape
| CharacterClassEscape
| DecimalEscape
| "b"
| CharacterClassEscape
| CharacterEscape
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment