BNF for SPL.jj

NON-TERMINALS

CompilationUnit ::= ( VarDeclaration ";" | Statement )* <EOF>
VarDeclaration ::= ( "boolean" | "int" ) <IDENTIFIER>
Expression ::= Assignment
| ConditionalOrExpression
Assignment ::= PrimaryExpression "=" Expression
ConditionalOrExpression ::= ConditionalAndExpression ( "||" ConditionalAndExpression )*
ConditionalAndExpression ::= InclusiveOrExpression ( "&&" InclusiveOrExpression )*
InclusiveOrExpression ::= ExclusiveOrExpression ( "|" ExclusiveOrExpression )*
ExclusiveOrExpression ::= AndExpression ( "^" AndExpression )*
AndExpression ::= EqualityExpression ( "&" EqualityExpression )*
EqualityExpression ::= RelationalExpression ( "==" RelationalExpression | "!=" RelationalExpression )*
RelationalExpression ::= AdditiveExpression ( "<" AdditiveExpression | ">" AdditiveExpression | "<=" AdditiveExpression | ">=" AdditiveExpression )*
AdditiveExpression ::= MultiplicativeExpression ( "+" MultiplicativeExpression | "-" MultiplicativeExpression )*
MultiplicativeExpression ::= UnaryExpression ( "*" UnaryExpression | "/" UnaryExpression | "%" UnaryExpression )*
UnaryExpression ::= "~" UnaryExpression
| "!" UnaryExpression
| PrimaryExpression
PrimaryExpression ::= Literal
| Id
| "(" Expression ")"
Id ::= <IDENTIFIER>
Literal ::= ( <INTEGER_LITERAL> )
| BooleanLiteral
BooleanLiteral ::= "true"
| "false"
Statement ::= ";"
| LabeledStatement
| Block
| StatementExpression
| IfStatement
| WhileStatement
| IOStatement
LabeledStatement ::= <IDENTIFIER> ":" Statement
Block ::= "{" ( Statement )* "}"
StatementExpression ::= Assignment ";"
IfStatement ::= "if" "(" Expression ")" Statement ( "else" Statement )?
WhileStatement ::= "while" "(" Expression ")" Statement
IOStatement ::= ReadStatement
| WriteStatement
ReadStatement ::= "read" <IDENTIFIER>
WriteStatement ::= "write" <IDENTIFIER>