<IF>: "if" <ELSE>: "else" <WHILE>: "while" <REPEAT>: "repeat" <DEFINE>: "def" <RETURN>: "return" <SOURCE>: "source"
<INT>: (<DIGIT>)+ <ID>: <LETTER> (<LETTER>|<DIGIT>|<OTHER_IN_ID>)* <LETTER>: ["A"-"Z", "a"-"z"] <DIGIT>: ["0"-"9"] <OTHER_IN_ID>: "_" <STR>: "\"" (~["\"","\n","\r"])* "\""
<LPAREN>: "("
<RPAREN>: ")"
<LBRACE>: "{"
<RBRACE>: "}"
<LBRACKET>: "["
<RBRACKET>: "]"
<SEMICOLON>: ";"
<COMMA>: ","
<ASSIGN>: "=" <REASSIGN>: ":=" <DEFASSIGN>: "::=" <OR>: "||" <AND>: "&&" <NOT>: "~" <BANG>: "!" <PLUS>: "+" <MINUS>: "-" <TIMES>: "*" <DIV>: "/" <RELEQ>: "==" <RELNE>: "!=" <RELGT>: ">" <RELGE>: ">=" <RELLT>: "<" <RELLE>: "<="
| CommandEOF | ::= | <EOF> |
| | | Command | |
| Commands | ::= | ( Command )* |
| Command | ::= | AssignCommand |
| | | WhileCommand | |
| | | IfCommand | |
| | | RepeatCommand | |
| | | CallCommand | |
| | | ReturnCommand | |
| | | DefunCommand | |
| | | BlockCommand | |
| | | SourceCommand | |
| | | NullCommand | |
| AssignCommand | ::= | Lvalue ( <ASSIGN> Rvalue | <REASSIGN> Rvalue | <DEFASSIGN> Rvalue ) <SEMICOLON> |
| IfCommand | ::= | <IF> <LPAREN> Rvalue <RPAREN> Command ( <ELSE> Command )? |
| WhileCommand | ::= | <WHILE> <LPAREN> Rvalue <RPAREN> Command |
| RepeatCommand | ::= | <REPEAT> Command <WHILE> <LPAREN> Rvalue <RPAREN> |
| CallCommand | ::= | <ID> <LPAREN> ( Rvalue ( <COMMA> Rvalue )* )? <RPAREN> <SEMICOLON> |
| ReturnCommand | ::= | <RETURN> <LPAREN> ( Rvalue )? <RPAREN> <SEMICOLON> |
| DefunCommand | ::= | <DEFINE> <ID> <LPAREN> ( <ID> )? ( <COMMA> <ID> )* <RPAREN> Command |
| BlockCommand | ::= | <LBRACE> ( Command )* <RBRACE> |
| SourceCommand | ::= | <SOURCE> <LPAREN> <STR> <RPAREN> <SEMICOLON> |
| NullCommand | ::= | <SEMICOLON> |
| Lvalue | ::= | <ID> ( <LBRACKET> Rvalue <RBRACKET> )? |
| Rvalue | ::= | AndExpr ( <OR> AndExpr )* |
| AndExpr | ::= | NotExpr ( <AND> NotExpr )* |
| NotExpr | ::= | <NOT> NotExpr |
| | | <BANG> NotExpr | |
| | | RelExpr | |
| RelExpr | ::= | SumExpr ( <RELEQ> SumExpr | <RELNE> SumExpr | <RELGT> SumExpr | <RELGE> SumExpr | <RELLT> SumExpr | <RELLE> SumExpr )? |
| SumExpr | ::= | ProdExpr ( <PLUS> ProdExpr | <MINUS> ProdExpr )* |
| ProdExpr | ::= | FactExpr ( <TIMES> FactExpr | <DIV> FactExpr )* |
| FactExpr | ::= | ( <MINUS> FactExpr | AtomicExpr ) |
| AtomicExpr | ::= | <LPAREN> Rvalue <RPAREN> |
| | | CallExpr | |
| | | ArrayConstructor | |
| | | IntegerConstant | |
| | | StringConstant | |
| | | VariableExpr | |
| VariableExpr | ::= | <ID> ( <LBRACKET> Rvalue <RBRACKET> )? |
| CallExpr | ::= | <ID> <LPAREN> ( Rvalue ( <COMMA> Rvalue )* )? <RPAREN> |
| ArrayConstructor | ::= | <LBRACE> ( Rvalue ( <COMMA> Rvalue )* )? <RBRACE> |
| IntegerConstant | ::= | <INT> |
| StringConstant | ::= | <STR> |