Problem 1)
Write a BNF description of the precedence and associativity rules defined below. Assume the only operands are the names a,b,c,d, and e.
Precedence |
Highest |
*, / |
|
|
+, - |
|
|
- (unary) |
|
Lowest |
=, /= |
Associativity |
Left to right |
|
Problem 2)
Assume the rules of associativity and precedence for expressions described in Problem 1.
Show the order of evaluation of the following expressions by parenthesizing all subexpressions and placing a superscript on the right parenthesis to indicate order. For example, for the expression a + b * c + d the order of evaluation would be represented as ((a + (b * c)1)2 + d)3