I am assuming a non-terminal ArithmeticExpression,
and defining BooleanExpression.
Literal -> TRUE |
FALSE
Relation -> ArithmeticExpression == ArithmeticExpression |
ArithmeticExpression < ArithmeticExpression |
ArithmeticExpression > ArithmeticExpression |
ArithmeticExpression <= ArithmeticExpression |
ArithmeticExpression >= ArithmeticExpression |
ArithmeticExpression != ArithmeticExpression
Primary -> Literal |
Relation |
!Primary |
(BooleanExpression)
Term -> Primary |
Term && Primary
BooleanExpression -> Term |
BooleanExpression || Term
Note:
This grammar provides the usual precedence of Boolean operators.
This grammar is unusual in that it does not allow Boolean variables; the teacher did not mention them.