Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <program> ::= <declaration>*;
- <declaration> ::= <classDeclaration> | <funDeclaration> | <varDeclaration> | <statement>;
- <classDeclaration> ::= "class" <identifier> ( ":" <identifier> )? "{" <function>* "}" ;
- <funDeclaration> ::= "fun" <function>;
- <varDeclaration> ::= "let" <identifier> ("=" <expression>)? ("," <identifier> \1?)* ";";
- <function> ::= <identifier> "(" <parameters>? ")" <block>;
- <statement> ::= <expressionStmt> | <block>| <ifThenStatement> | <whileStatement> | <forStatement>;
- <ifThenStatement> ::= "if" "(" <expression> ")" <statement> ("else" <statement>)?;
- <whileStatement> ::= "while" "(" <expression> ")" <statement>;
- <forStatement> ::= "for" "(" (<varDeclaration> | <expressionStmt> | ";") <expression>? ";" <expression>? ")" <statement>;
- <block> ::= "{" <declaration>* "}";
- <expressionStmt> ::= <arguments> ";";
- <arguments> ::= <expression> ("," <expression>)* ;
- <expression> ::= <assignment>;
- <assignment> ::= <identifier> ("=" | "+=" | "-=" | "*=" | "/=") <expression> | <trinary> | <logicalOr>;
- <logicalOr> ::= <logicalAnd> ("or" <logicalAnd>)?;
- <logicalAnd> ::= <trinary> ("and" <trinary>)?;
- <trinary> ::= <equality> ("?" <trinary> ":" <trinary>)?;
- <equality> ::= <comparision> (("==" | "!=") <comparision>)*;
- <comparison> ::= <addition> ((">" | ">=" | "<" | "<=") <addition>)*;
- <addition> ::= <multiplication> (("+" | "-") <multiplication>)*;
- <multiplication> ::= <unary> (("+" | "-") <unary>)*;
- <unary> ::= ("!" | "-" | "+" | "typeof" | "++" | "--") <unary> | <postfix>;
- <postfix> ::= <call> ("++" | "--")?;
- <call> ::= <literal> ("(" arguments? ")" | "." <identifier>)*;
- <literal> ::= "(" <expression> ")" | <string> | <number> | "true" | "false" | "null" | <parameters>;
- <parameters> ::= <identifier> ("," <identifier>)* ;
- <identifier> ::= "@" \[A-z]\w\;
- <number> ::= \\d\*;
- <string> ::= (\[“’`]\) (\[^\1]\)* \1;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement