
      The Language of Binary Arithmetic and Boolean Expressions


A binary arithmetic or boolean expression is defined by the following grammar.

        Exp ::= AExp | BExp

       AExp ::= '(' BinOp AExp AExp ')'
              | INTEGER

      BinOp ::= '+' | '-' | '*' | '/' | '%'

       BExp ::= '(' BoolOp BExp BExp ')'
              | '(' '!' BExp '()' ')'      // notice how ugly this unary ! operator is
              | '(' RelOp AExp AExp ')'
              | '(' EqOp  Exp  Exp  ')'
              | BOOLEAN

     BoolOp ::= '&&' | '||'
      RelOp ::= '<' | '>' | '<=' | '>='
       EqOp ::= '==' | '!='

    INTEGER ::= [0-9]+
    BOOLEAN ::= 'true' | 'false'


Notice that the result of evaluating an Exp is either an integer value or a boolean value.


Notice that the language of binary arithmetic and boolean expressions is a subset of the language of binary trees (i.e., cs50200-Language-1) and a superset of the language of binary arithmetic expressions (i.e. cs50200-Language-2).