One way of defining the abstract syntax for the expressions of Figure 6.17 is as follows:
xpr → expr + expr | expr * expr | number
number → digit { digit }
digit→ 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9
(a) Why are there no precedences or associativities expressed in this grammar?
(b) Why are there no parentheses in this grammar?
(c) The rule for number is written in EBNF in this grammar, yet we stated in the text that this obscures the structure of the parse tree. Why is the use of EBNF legitimate here? Why did we not use EBNF in the rule for expr?
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here