InputElement ::= WhiteSpace|LineTerminator|Comment|Token

WhiteSpace ::= " "|"　"

LineTerminator ::= "\n"|"\r"

Comment ::=SingleLineComment|MultilineComment
SingleLineComment ::= "/" "/" <any>*
MultilineComment ::= "/" "*" ([^*] | "*" [^/])* "*" "/"

Token ::= Literal|Keywords|Identifier|Punctuator
Literal ::= NumbericLiteral|BooleanLiteral|StringLiteral|NullLiteral
Keywords ::= "if"|"else"|"for"|"function"|.....
Punctuator ::= "+"|"-"|"*"|"/"|"{"|"}"|.....

Program ::= Statement+

Statement ::= ExpressionStatement | IfStatement
    | ForStatement | WhileStatement
    | VariableDeclaration | FunctionDeclaration |ClassDeclaration
    | BreakStatement | ContinueStatement | ReturnStatement | ThrowStatement
    | TryStatement | Block

IfStatement ::= "if" "(" Expression ")" Statement

Block = "{" Statement "}"

TryStatement ::= "try" "{" Statement "}" "catch" "(" Expression ")" "{" Statement+ "}"

ExpressionStatement ::= Expression ";"

Expression ::= AdditiveExpression

AdditiveExpression ::= MultiplicativeExpression
    | AdditiveExpression ("+" | "-") MultiplicativeExpression

MultiplicativeExpression ::= UnaryExpression
    | MultiplicativeExpression ("*" | "/") UnaryExpression

UnaryExpression ::= PrimaryExpression
    | ("+" | "-" | "typeof") PrimaryExpression

PrimaryExpression ::= "(" Expression ")" | Literal | Identifier

InputElement: "<Whitespace>|<LineTerminator>|<Comments>|<Token>",
  Whitespace: / /,
  LineTerminator: /\n/,
  Comments: /\/\*(?:[^*]|\*[^\/])*\*\/|\/\/[^\n]*/,
  Token: "<Literal>|<Keywords>|<Identifer>|<Punctuator>",
  Literal:"<NumbericLiteral>|<BooleanLiteral>|<StringLiteral>|<NullLiteral>",
  NumericLiteral: /(?:[1-9][0-9]*|0)(?:\.[0-9]*)?|\.[0-9]+/,
  BooleanLiteral: /true|false/,
  StringLiteral: /\"(?:[^"\n]|\\[\s\S])*\"|\'(?:[^'\n]|\\[\s\S])*\'/,
  NullLiteral: /null/,
  Identifer: /[a-zA-Z_$][a-zA-Z0-9_$]*/,
  Keywords:/if|else|for|function/,
  Punctuator: /\+|\,|\?|\:|\{|\}|\.|\(|\=|\<|\+\+|\=\=|\=\>|\*|\)|\[|\]|;/

},"g","InputElement")