Skip to content

Instantly share code, notes, and snippets.

@rbuckton
Created June 16, 2015 00:06
Show Gist options
  • Save rbuckton/0d8c1f1c607f52f5ae37 to your computer and use it in GitHub Desktop.
Save rbuckton/0d8c1f1c607f52f5ae37 to your computer and use it in GitHub Desktop.

ES6 Grammar

Generated using http://github.com/rbuckton/grammarkdown

  SourceCharacter ::
   any Unicode code point

  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>

  LineTerminatorSequence ::
   <LF>
   <CR> [lookahead ≠ <LF>]
   <LS>
   <PS>
   <CR> <LF>

  Comment ::
   MultiLineComment
   SingleLineComment

  MultiLineComment ::
   /*MultiLineCommentCharsopt*/

  MultiLineCommentChars ::
   MultiLineNotAsteriskCharMultiLineCommentCharsopt
   *PostAsteriskCommentCharsopt

  PostAsteriskCommentChars ::
   MultiLineNotForwardSlashOrAsteriskCharMultiLineCommentCharsopt
   *PostAsteriskCommentCharsopt

  MultiLineNotAsteriskChar ::
   SourceCharacter but not *

  MultiLineNotForwardSlashOrAsteriskChar ::
   SourceCharacter but not one of / or *

  SingleLineComment ::
   //SingleLineCommentCharsopt

  SingleLineCommentChars ::
   SingleLineCommentCharSingleLineCommentCharsopt

  SingleLineCommentChar ::
   SourceCharacter but not LineTerminator

  CommonToken ::
   IdentifierName
   Punctuator
   NumericLiteral
   StringLiteral
   Template

  IdentifierName ::
   IdentifierStart
   IdentifierNameIdentifierPart

  IdentifierStart ::
   UnicodeIDStart
   $
   _
   \UnicodeEscapeSequence

  IdentifierPart ::
   UnicodeIDContinue
   $
   _
   \UnicodeEscapeSequence
   <ZWNJ>
   <ZWJ>

  UnicodeIDStart ::
   any Unicode code point with the Unicode property "ID_Start" or "Other_ID_Start"

  UnicodeIDContinue ::
   any Unicode code point with the Unicode property "ID_Continue" or "Other_ID_Continue", or "Other_ID_Start"

  ReservedWord ::
   Keyword
   FutureReservedWord
   NullLiteral
   BooleanLiteral

  Keyword :: one of

   break      do         in         typeof     case  
   else       instanceof var        catch      export  
   new        void       class      extends    return  
   while      const      finally    super      with  
   continue   for        switch     yield      debugger  
   function   this       default    if         throw  
   delete     import     try

  FutureReservedWord :: one of

   enum       await      implements package    protected  
   interface  private    public

  Punctuator :: one of

   {     }     (     )     [     ]     .     ;     ,     <  
   >     <=    >=    ==    !=    ===   !==   +     -     *  
   %     ++    --    <<    >>    >>>   &     |     ^     !  
   ~     &&    ||    ?      ::   =     +=    -=    *=    %=  
   <<=   >>=   >>>=  &=    |=    ^=    =>

  DivPunctuator :: one of

   /     /=

  RightBracePunctuator :: one of

   )

  NullLiteral ::
   null

  BooleanLiteral ::
   true
   false

  NumericLiteral ::
   DecimalLiteral
   BinaryIntegerLiteral
   OctalIntegerLiteral
   HexIntegerLiteral

  DecimalLiteral ::
   DecimalIntegerLiteral.DecimalDigitsoptExponentPartopt
   .DecimalDigitsExponentPartopt
   DecimalIntegerLiteralExponentPartopt

  DecimalIntegerLiteral ::
   0
   NonZeroDigitDecimalDigitsopt

  DecimalDigits ::
   DecimalDigit
   DecimalDigitsDecimalDigit

  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 ::
   ExponentIndicatorSignedInteger

  ExponentIndicator :: one of

   e     E

  SignedInteger ::
   DecimalDigits
   +DecimalDigits
   -DecimalDigits

  BinaryIntegerLiteral ::
   0bBinaryDigits
   0BBinaryDigits

  BinaryDigits ::
   BinaryDigit
   BinaryDigitsBinaryDigit

  BinaryDigit :: one of

   0     1

  OctalIntegerLiteral ::
   0oOctalDigits
   0OOctalDigits

  OctalDigits ::
   OctalDigit
   OctalDigitsOctalDigit

  OctalDigit :: one of

   0     1     2     3     4     5     6     7

  HexIntegerLiteral ::
   0xHexDigits
   0XHexDigits

  HexDigits ::
   HexDigit
   HexDigitsHexDigit

  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 ::
   "DoubleStringCharactersopt"
   'SingleStringCharactersopt'

  DoubleStringCharacters ::
   DoubleStringCharacterDoubleStringCharactersopt

  SingleStringCharacters ::
   SingleStringCharacterSingleStringCharactersopt

  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 ::
   xHexDigitHexDigit

  UnicodeEscapeSequence ::
   uHex4Digits
   u{HexDigits}

  Hex4Digits ::
   HexDigitHexDigitHexDigitHexDigit

  RegularExpressionLiteral ::
   /RegularExpressionBody/RegularExpressionFlags

  RegularExpressionBody ::
   RegularExpressionFirstCharRegularExpressionChars

  RegularExpressionChars ::
   [empty]
   RegularExpressionCharsRegularExpressionChar

  RegularExpressionFirstChar ::
   RegularExpressionNonTerminator but not one of * or \ or / or [
   RegularExpressionBackslashSequence
   RegularExpressionClass

  RegularExpressionChar ::
   RegularExpressionNonTerminator but not one of \ or / or [
   RegularExpressionBackslashSequence
   RegularExpressionClass

  RegularExpressionBackslashSequence ::
   \RegularExpressionNonTerminator

  RegularExpressionNonTerminator ::
   SourceCharacter but not LineTerminator

  RegularExpressionClass ::
   [RegularExpressionClassChars]

  RegularExpressionClassChars ::
   [empty]
   RegularExpressionClassCharsRegularExpressionClassChar

  RegularExpressionClassChar ::
   RegularExpressionNonTerminator but not one of ] or \
   RegularExpressionBackslashSequence

  RegularExpressionFlags ::
   [empty]
   RegularExpressionFlagsIdentifierPart

  Template ::
   NoSubstitutionTemplate
   TemplateHead

  NoSubstitutionTemplate ::
   `TemplateCharactersopt`

  TemplateHead ::
   `TemplateCharactersopt${

  TemplateSubstitutionTail ::
   TemplateMiddle
   TemplateTail

  TemplateMiddle ::
   }TemplateCharactersopt${

  TemplateTail ::
   }TemplateCharactersopt`

  TemplateCharacters ::
   TemplateCharacterTemplateCharactersopt

  TemplateCharacter ::
   $ [lookahead ≠ {]
   \EscapeSequence
   LineContinuation
   LineTerminatorSequence
   SourceCharacter but not one of ` or \ or $ or LineTerminator

  IdentifierReference[Yield] :
   Identifier
   [~Yield] yield

  BindingIdentifier[Yield] :
   Identifier
   [~Yield] yield

  LabelIdentifier[Yield] :
   Identifier
   [~Yield] yield

  Identifier :
   IdentifierName but not ReservedWord

  PrimaryExpression[Yield] :
   this
   IdentifierReference[?Yield]
   Literal
   ArrayLiteral[?Yield]
   ObjectLiteral[?Yield]
   FunctionExpression
   ClassExpression[?Yield]
   GeneratorExpression
   RegularExpressionLiteral
   TemplateLiteral[?Yield]
   CoverParenthesizedExpressionAndArrowParameterList[?Yield]

  CoverParenthesizedExpressionAndArrowParameterList[Yield] :
   (Expression[In, ?Yield])
   ()
   (...BindingIdentifier[?Yield])
   (Expression[In, ?Yield],...BindingIdentifier[?Yield])

  Literal :
   NullLiteral
   BooleanLiteral
   NumericLiteral
   StringLiteral

  ArrayLiteral[Yield] :
   [Elisionopt]
   [ElementList[?Yield]]
   [ElementList[?Yield],Elisionopt]

  ElementList[Yield] :
   ElisionoptAssignmentExpression[In, ?Yield]
   ElisionoptSpreadElement[?Yield]
   ElementList[?Yield],ElisionoptAssignmentExpression[In, ?Yield]
   ElementList[?Yield],ElisionoptSpreadElement[?Yield]

  Elision :
   ,
   Elision,

  SpreadElement[Yield] :
   ...AssignmentExpression[In, ?Yield]

  ObjectLiteral[Yield] :
   {}
   {PropertyDefinitionList[?Yield]}
   {PropertyDefinitionList[?Yield],}

  PropertyDefinitionList[Yield] :
   PropertyDefinition[?Yield]
   PropertyDefinitionList[?Yield],PropertyDefinition[?Yield]

  PropertyDefinition[Yield] :
   IdentifierReference[?Yield]
   CoverInitializedName[?Yield]
   PropertyName[?Yield]:AssignmentExpression[In, ?Yield]
   MethodDefinition[?Yield]

  PropertyName[Yield] :
   LiteralPropertyName
   ComputedPropertyName[?Yield]

  LiteralPropertyName :
   IdentifierName
   StringLiteral
   NumericLiteral

  ComputedPropertyName[Yield] :
   [AssignmentExpression[In, ?Yield]]

  CoverInitializedName[Yield] :
   IdentifierReference[?Yield]Initializer[In, ?Yield]

  Initializer[In, Yield] :
   =AssignmentExpression[?In, ?Yield]

  TemplateLiteral[Yield] :
   NoSubstitutionTemplate
   TemplateHeadExpression[In, ?Yield]TemplateSpans[?Yield]

  TemplateSpans[Yield] :
   TemplateTail
   TemplateMiddleList[?Yield]TemplateTail

  TemplateMiddleList[Yield] :
   TemplateMiddleExpression[In, ?Yield]
   TemplateMiddleList[?Yield]TemplateMiddleExpression[In, ?Yield]

  MemberExpression[Yield] :
   PrimaryExpression[?Yield]
   MemberExpression[?Yield][Expression[In, ?Yield]]
   MemberExpression[?Yield].IdentifierName
   MemberExpression[?Yield]TemplateLiteral[?Yield]
   SuperProperty[?Yield]
   MetaProperty
   newMemberExpression[?Yield]Arguments[?Yield]

  SuperProperty[Yield] :
   super[Expression[In, ?Yield]]
   super.IdentifierName

  MetaProperty :
   NewTarget

  NewTarget :
   new.target

  NewExpression[Yield] :
   MemberExpression[?Yield]
   newNewExpression[?Yield]

  CallExpression[Yield] :
   MemberExpression[?Yield]Arguments[?Yield]
   SuperCall[?Yield]
   CallExpression[?Yield]Arguments[?Yield]
   CallExpression[?Yield][Expression[In, ?Yield]]
   CallExpression[?Yield].IdentifierName
   CallExpression[?Yield]TemplateLiteral[?Yield]

  SuperCall[Yield] :
   superArguments[?Yield]

  Arguments[Yield] :
   ()
   (ArgumentList[?Yield])

  ArgumentList[Yield] :
   AssignmentExpression[In, ?Yield]
   ...AssignmentExpression[In, ?Yield]
   ArgumentList[?Yield],AssignmentExpression[In, ?Yield]
   ArgumentList[?Yield],...AssignmentExpression[In, ?Yield]

  LeftHandSideExpression[Yield] :
   NewExpression[?Yield]
   CallExpression[?Yield]

  PostfixExpression[Yield] :
   LeftHandSideExpression[?Yield]
   LeftHandSideExpression[?Yield] [no LineTerminator here] ++
   LeftHandSideExpression[?Yield] [no LineTerminator here] --

  UnaryExpression[Yield] :
   PostfixExpression[?Yield]
   deleteUnaryExpression[?Yield]
   voidUnaryExpression[?Yield]
   typeofUnaryExpression[?Yield]
   ++UnaryExpression[?Yield]
   --UnaryExpression[?Yield]
   +UnaryExpression[?Yield]
   -UnaryExpression[?Yield]
   ~UnaryExpression[?Yield]
   !UnaryExpression[?Yield]

  MultiplicativeExpression[Yield] :
   UnaryExpression[?Yield]
   MultiplicativeExpression[?Yield]MultiplicativeOperatorUnaryExpression[?Yield]

  MultiplicativeOperator : one of

   *     /     %

  AdditiveExpression[Yield] :
   MultiplicativeExpression[?Yield]
   AdditiveExpression[?Yield]+MultiplicativeExpression[?Yield]
   AdditiveExpression[?Yield]-MultiplicativeExpression[?Yield]

  ShiftExpression[Yield] :
   AdditiveExpression[?Yield]
   ShiftExpression[?Yield]<<AdditiveExpression[?Yield]
   ShiftExpression[?Yield]>>AdditiveExpression[?Yield]
   ShiftExpression[?Yield]>>>AdditiveExpression[?Yield]

  RelationalExpression[In, Yield] :
   ShiftExpression[?Yield]
   RelationalExpression[?In, ?Yield]<ShiftExpression[?Yield]
   RelationalExpression[?In, ?Yield]>ShiftExpression[?Yield]
   RelationalExpression[?In, ?Yield]<=ShiftExpression[?Yield]
   RelationalExpression[?In, ?Yield]>=ShiftExpression[?Yield]
   RelationalExpression[?In, ?Yield]instanceofShiftExpression[?Yield]
   [+In] RelationalExpression[In, ?Yield]inShiftExpression[?Yield]

  EqualityExpression[In, Yield] :
   RelationalExpression[?In, ?Yield]
   EqualityExpression[?In, ?Yield]==RelationalExpression[?In, ?Yield]
   EqualityExpression[?In, ?Yield]!=RelationalExpression[?In, ?Yield]
   EqualityExpression[?In, ?Yield]===RelationalExpression[?In, ?Yield]
   EqualityExpression[?In, ?Yield]!==RelationalExpression[?In, ?Yield]

  BitwiseANDExpression[In, Yield] :
   EqualityExpression[?In, ?Yield]
   BitwiseANDExpression[?In, ?Yield]&EqualityExpression[?In, ?Yield]

  BitwiseXORExpression[In, Yield] :
   BitwiseANDExpression[?In, ?Yield]
   BitwiseXORExpression[?In, ?Yield]^BitwiseANDExpression[?In, ?Yield]

  BitwiseORExpression[In, Yield] :
   BitwiseXORExpression[?In, ?Yield]
   BitwiseORExpression[?In, ?Yield]|BitwiseXORExpression[?In, ?Yield]

  LogicalANDExpression[In, Yield] :
   BitwiseORExpression[?In, ?Yield]
   LogicalANDExpression[?In, ?Yield]&&BitwiseORExpression[?In, ?Yield]

  LogicalORExpression[In, Yield] :
   LogicalANDExpression[?In, ?Yield]
   LogicalORExpression[?In, ?Yield]||LogicalANDExpression[?In, ?Yield]

  ConditionalExpression[In, Yield] :
   LogicalORExpression[?In, ?Yield]
   LogicalORExpression[?In, ?Yield]?AssignmentExpression[In, ?Yield]:AssignmentExpression[?In, ?Yield]

  AssignmentExpression[In, Yield] :
   ConditionalExpression[?In, ?Yield]
   [+Yield] YieldExpression[?In]
   ArrowFunction[?In, ?Yield]
   LeftHandSideExpression[?Yield]=AssignmentExpression[?In, ?Yield]
   LeftHandSideExpression[?Yield]AssignmentOperatorAssignmentExpression[?In, ?Yield]

  AssignmentOperator : one of

   *=    /=    %=    +=    -=    <<=   >>=   >>>=  &=    ^=  
   |=

  Expression[In, Yield] :
   AssignmentExpression[?In, ?Yield]
   Expression[?In, ?Yield],AssignmentExpression[?In, ?Yield]

  Statement[Yield, Return] :
   BlockStatement[?Yield, ?Return]
   VariableStatement[?Yield]
   EmptyStatement
   ExpressionStatement[?Yield]
   IfStatement[?Yield, ?Return]
   BreakableStatement[?Yield, ?Return]
   ContinueStatement[?Yield]
   BreakStatement[?Yield]
   [+Return] ReturnStatement[?Yield]
   WithStatement[?Yield, ?Return]
   LabelledStatement[?Yield, ?Return]
   ThrowStatement[?Yield]
   TryStatement[?Yield, ?Return]
   DebuggerStatement

  Declaration[Yield] :
   HoistableDeclaration[?Yield]
   ClassDeclaration[?Yield]
   LexicalDeclaration[In, ?Yield]

  HoistableDeclaration[Yield, Default] :
   FunctionDeclaration[?Yield, ?Default]
   GeneratorDeclaration[?Yield, ?Default]

  BreakableStatement[Yield, Return] :
   IterationStatement[?Yield, ?Return]
   SwitchStatement[?Yield, ?Return]

  BlockStatement[Yield, Return] :
   Block[?Yield, ?Return]

  Block[Yield, Return] :
   {StatementList[?Yield, ?Return]opt}

  StatementList[Yield, Return] :
   StatementListItem[?Yield, ?Return]
   StatementList[?Yield, ?Return]StatementListItem[?Yield, ?Return]

  StatementListItem[Yield, Return] :
   Statement[?Yield, ?Return]
   Declaration[?Yield]

  LexicalDeclaration[In, Yield] :
   LetOrConstBindingList[?In, ?Yield];

  LetOrConst :
   let
   const

  BindingList[In, Yield] :
   LexicalBinding[?In, ?Yield]
   BindingList[?In, ?Yield],LexicalBinding[?In, ?Yield]

  LexicalBinding[In, Yield] :
   BindingIdentifier[?Yield]Initializer[?In, ?Yield]opt
   BindingPattern[?Yield]Initializer[?In, ?Yield]

  VariableStatement[Yield] :
   varVariableDeclarationList[In, ?Yield];

  VariableDeclarationList[In, Yield] :
   VariableDeclaration[?In, ?Yield]
   VariableDeclarationList[?In, ?Yield],VariableDeclaration[?In, ?Yield]

  VariableDeclaration[In, Yield] :
   BindingIdentifier[?Yield]Initializer[?In, ?Yield]opt
   BindingPattern[?Yield]Initializer[?In, ?Yield]

  BindingPattern[Yield] :
   ObjectBindingPattern[?Yield]
   ArrayBindingPattern[?Yield]

  ObjectBindingPattern[Yield] :
   {}
   {BindingPropertyList[?Yield]}
   {BindingPropertyList[?Yield],}

  ArrayBindingPattern[Yield] :
   [ElisionoptBindingRestElement[?Yield]opt]
   [BindingElementList[?Yield]]
   [BindingElementList[?Yield],ElisionoptBindingRestElement[?Yield]opt]

  BindingPropertyList[Yield] :
   BindingProperty[?Yield]
   BindingPropertyList[?Yield],BindingProperty[?Yield]

  BindingElementList[Yield] :
   BindingElisionElement[?Yield]
   BindingElementList[?Yield],BindingElisionElement[?Yield]

  BindingElisionElement[Yield] :
   ElisionoptBindingElement[?Yield]

  BindingProperty[Yield] :
   SingleNameBinding[?Yield]
   PropertyName[?Yield]:BindingElement[?Yield]

  BindingElement[Yield] :
   SingleNameBinding[?Yield]
   BindingPattern[?Yield]Initializer[In, ?Yield]opt

  SingleNameBinding[Yield] :
   BindingIdentifier[?Yield]Initializer[In, ?Yield]opt

  BindingRestElement[Yield] :
   ...BindingIdentifier[?Yield]

  EmptyStatement :
   ;

  ExpressionStatement[Yield] :
   [lookahead ∉ { {, function, class, let[ }] Expression[In, ?Yield];

  IfStatement[Yield, Return] :
   if(Expression[In, ?Yield])Statement[?Yield, ?Return]elseStatement[?Yield, ?Return]
   if(Expression[In, ?Yield])Statement[?Yield, ?Return]

  IterationStatement[Yield, Return] :
   doStatement[?Yield, ?Return]while(Expression[In, ?Yield]);
   while(Expression[In, ?Yield])Statement[?Yield, ?Return]
   for( [lookahead ∉ { let[ }] Expression[?Yield]opt;Expression[In, ?Yield]opt;Expression[In, ?Yield]opt)Statement[?Yield, ?Return]
   for(varVariableDeclarationList[?Yield];Expression[In, ?Yield]opt;Expression[In, ?Yield]opt)Statement[?Yield, ?Return]
   for(LexicalDeclaration[?Yield]Expression[In, ?Yield]opt;Expression[In, ?Yield]opt)Statement[?Yield, ?Return]
   for( [lookahead ∉ { let[ }] LeftHandSideExpression[?Yield]inExpression[In, ?Yield])Statement[?Yield, ?Return]
   for(varForBinding[?Yield]inExpression[In, ?Yield])Statement[?Yield, ?Return]
   for(ForDeclaration[?Yield]inExpression[In, ?Yield])Statement[?Yield, ?Return]
   for( [lookahead ≠ let] LeftHandSideExpression[?Yield]ofAssignmentExpression[In, ?Yield])Statement[?Yield, ?Return]
   for(varForBinding[?Yield]ofAssignmentExpression[In, ?Yield])Statement[?Yield, ?Return]
   for(ForDeclaration[?Yield]ofAssignmentExpression[In, ?Yield])Statement[?Yield, ?Return]

  ForDeclaration[Yield] :
   LetOrConstForBinding[?Yield]

  ForBinding[Yield] :
   BindingIdentifier[?Yield]
   BindingPattern[?Yield]

  ContinueStatement[Yield] :
   continue;
   continue [no LineTerminator here] LabelIdentifier[?Yield];

  BreakStatement[Yield] :
   break;
   break [no LineTerminator here] LabelIdentifier[?Yield];

  ReturnStatement[Yield] :
   return;
   return [no LineTerminator here] Expression[In, ?Yield];

  WithStatement[Yield, Return] :
   with(Expression[In, ?Yield])Statement[?Yield, ?Return]

  SwitchStatement[Yield, Return] :
   switch(Expression[In, ?Yield])CaseBlock[?Yield, ?Return]

  CaseBlock[Yield, Return] :
   {CaseClauses[?Yield, ?Return]opt}
   {CaseClauses[?Yield, ?Return]optDefaultClause[?Yield, ?Return]CaseClauses[?Yield, ?Return]opt}

  CaseClauses[Yield, Return] :
   CaseClause[?Yield, ?Return]
   CaseClauses[?Yield, ?Return]CaseClause[?Yield, ?Return]

  CaseClause[Yield, Return] :
   caseExpression[In, ?Yield]:StatementList[?Yield, ?Return]opt

  DefaultClause[Yield, Return] :
   default:StatementList[?Yield, ?Return]opt

  LabelledStatement[Yield, Return] :
   LabelIdentifier[?Yield]:LabelledItem[?Yield, ?Return]

  LabelledItem[Yield, Return] :
   Statement[?Yield, ?Return]
   FunctionDeclaration[?Yield]

  ThrowStatement[Yield] :
   throw [no LineTerminator here] Expression[In, ?Yield];

  TryStatement[Yield, Return] :
   tryBlock[?Yield, ?Return]Catch[?Yield, ?Return]
   tryBlock[?Yield, ?Return]Finally[?Yield, ?Return]
   tryBlock[?Yield, ?Return]Catch[?Yield, ?Return]Finally[?Yield, ?Return]

  Catch[Yield, Return] :
   catch(CatchParameter[?Yield])Block[?Yield, ?Return]

  Finally[Yield, Return] :
   finallyBlock[?Yield, ?Return]

  CatchParameter[Yield] :
   BindingIdentifier[?Yield]
   BindingPattern[?Yield]

  DebuggerStatement :
   debugger;

  FunctionDeclaration[Yield, Default] :
   functionBindingIdentifier[?Yield](FormalParameters){FunctionBody}
   [+Default] function(FormalParameters){FunctionBody}

  FunctionExpression :
   functionBindingIdentifieropt(FormalParameters){FunctionBody}

  StrictFormalParameters[Yield] :
   FormalParameters[?Yield]

  FormalParameters[Yield] :
   [empty]
   FormalParameterList[?Yield]

  FormalParameterList[Yield] :
   FunctionRestParameter[?Yield]
   FormalsList[?Yield]
   FormalsList[?Yield],FunctionRestParameter[?Yield]

  FormalsList[Yield] :
   FormalParameter[?Yield]
   FormalsList[?Yield],FormalParameter[?Yield]

  FunctionRestParameter[Yield] :
   BindingRestElement[?Yield]

  FormalParameter[Yield] :
   BindingElement[?Yield]

  FunctionBody[Yield] :
   FunctionStatementList[?Yield]

  FunctionStatementList[Yield] :
   StatementList[?Yield, Return]opt

  ArrowFunction[In, Yield] :
   ArrowParameters[?Yield] [no LineTerminator here] =>ConciseBody[?In]

  ArrowParameters[Yield] :
   BindingIdentifier[?Yield]
   CoverParenthesizedExpressionAndArrowParameterList[?Yield]

  ConciseBody[In] :
   [lookahead ≠ {] AssignmentExpression[?In]
   {FunctionBody}

  MethodDefinition[Yield] :
   PropertyName[?Yield](StrictFormalParameters){FunctionBody}
   GeneratorMethod[?Yield]
   getPropertyName[?Yield](){FunctionBody}
   setPropertyName[?Yield](PropertySetParameterList){FunctionBody}

  PropertySetParameterList :
   FormalParameter

  GeneratorMethod[Yield] :
   *PropertyName[?Yield](StrictFormalParameters[Yield]){GeneratorBody}

  GeneratorDeclaration[Yield, Default] :
   function*BindingIdentifier[?Yield](FormalParameters[Yield]){GeneratorBody}
   [+Default] function*(FormalParameters[Yield]){GeneratorBody}

  GeneratorExpression :
   function*BindingIdentifier[Yield]opt(FormalParameters[Yield]){GeneratorBody}

  GeneratorBody :
   FunctionBody[Yield]

  YieldExpression[In] :
   yield
   yield [no LineTerminator here] AssignmentExpression[?In, Yield]
   yield [no LineTerminator here] *AssignmentExpression[?In, Yield]

  ClassDeclaration[Yield, Default] :
   classBindingIdentifier[?Yield]ClassTail[?Yield]
   [+Default] classClassTail[?Yield]

  ClassExpression[Yield] :
   classBindingIdentifier[?Yield]optClassTail[?Yield]

  ClassTail[Yield] :
   ClassHeritage[?Yield]opt{ClassBody[?Yield]opt}

  ClassHeritage[Yield] :
   extendsLeftHandSideExpression[?Yield]

  ClassBody[Yield] :
   ClassElementList[?Yield]

  ClassElementList[Yield] :
   ClassElement[?Yield]
   ClassElementList[?Yield]ClassElement[?Yield]

  ClassElement[Yield] :
   MethodDefinition[?Yield]
   staticMethodDefinition[?Yield]
   ;

  Script :
   ScriptBodyopt

  ScriptBody :
   StatementList

  Module :
   ModuleBodyopt

  ModuleBody :
   ModuleItemList

  ModuleItemList :
   ModuleItem
   ModuleItemListModuleItem

  ModuleItem :
   ImportDeclaration
   ExportDeclaration
   StatementListItem

  ImportDeclaration :
   importImportClauseFromClause;
   importModuleSpecifier;

  ImportClause :
   ImportedDefaultBinding
   NameSpaceImport
   NamedImports
   ImportedDefaultBinding,NameSpaceImport
   ImportedDefaultBinding,NamedImports

  ImportedDefaultBinding :
   ImportedBinding

  NameSpaceImport :
   *asImportedBinding

  NamedImports :
   {}
   {ImportsList}
   {ImportsList,}

  FromClause :
   fromModuleSpecifier

  ImportsList :
   ImportSpecifier
   ImportsList,ImportSpecifier

  ImportSpecifier :
   ImportedBinding
   IdentifierNameasImportedBinding

  ModuleSpecifier :
   StringLiteral

  ImportedBinding :
   BindingIdentifier

  ExportDeclaration :
   export*FromClause;
   exportExportClauseFromClause;
   exportExportClause;
   exportVariableStatement
   exportDeclaration
   exportdefaultHoistableDeclaration[Default]
   exportdefaultClassDeclaration[Default]
   exportdefault [lookahead ∉ { function, class }] AssignmentExpression[In];

  ExportClause :
   {}
   {ExportsList}
   {ExportsList,}

  ExportsList :
   ExportSpecifier
   ExportsList,ExportSpecifier

  ExportSpecifier :
   IdentifierName
   IdentifierNameasIdentifierName

@jneuendorf
Copy link

jneuendorf commented Jan 14, 2018

Hey, that's pretty neat. But what (grammar) source did you use to generate that markdown? Is it https://tc39.github.io/ecma262/#sec-ecmascript-language-lexical-grammar ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment