[back]
# simple expression grammar

# start rule
start -> expr

# expr
expr -> assign-expr

# assign expr
[AssignExprNode]
assign-expr -> or-expr assign-op assign-expr
assign-expr -> or-expr

# logical or expr
[OrExprNode]
or-expr -> or-expr or-op and-expr
or-expr -> and-expr

# logical and expr
[AndExprNode]
and-expr -> and-expr and-op eq-expr
and-expr -> eq-expr

# equality expr
[EqExprNode]
eq-expr -> eq-expr eq-op rel-expr
eq-expr -> rel-expr

# relational expr
[RelExprNode]
rel-expr -> rel-expr rel-op shift-expr
rel-expr -> shift-expr

# shift expr
[ShiftExprNode]
 shift-expr -> shift-expr shift-op add-expr
shift-expr -> add-expr

# additive expr
[AddExprNode]
add-expr -> add-expr add-op mul-expr
add-expr -> mul-expr

# multiplicative expr
[MulExprNode]
mul-expr -> mul-expr mul-op unary-expr
mul-expr -> unary-expr

# unary expr
[UnaryExprNode]
unary-expr -> unary-op unary-expr
unary-expr -> primary-expr

# primary expr
[PrimaryExpr1Node]
primary-expr -> NUMBER
[PrimaryExpr2Node]
primary-expr -> IDENT
[PrimaryExpr3Node]
primary-expr -> LPAREN expr RPAREN

# asignment operator
assign-op -> ASSIGN

# logical or operator
or-op -> OR

# logical and operator
and-op -> AND

# equality operators
eq-op -> EQ
eq-op -> NE

# relational operators
rel-op -> LT
rel-op -> GT
rel-op -> LE
rel-op -> GE

# shift operators
shift-op -> LSHIFT
shift-op -> RSHIFT

# additive operators
add-op -> PLUS
add-op -> MINUS

# multiplicative operators
mul-op -> TIMES
mul-op -> DIVIDE

# unary operators
unary-op -> PLUS
unary-op -> MINUS

[back]