Question: Write a grammar for Booleanexpressions , assuming that we already have rules in our grammar for arithmetic expressions . Arithmetic expressions might be simple literals
Write a grammar for Booleanexpressions
Boolean expressions include the literals TRUE and FALSE; they can be combined with the unary operator ! (meaning NOT) and binary operators && and || (meaning AND and OR). Also, arithmetic expressions can be combined with the following binary operators to form new Boolean expressions: <, >, <=, >=, !=.When your grammar is complete, you should be able to derive parse trees for expressions like the following:
TRUE || FALSE
FALSE && !TRUE
27<32 || x != 15
To get you started, heres a preliminary rule:
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
