(a) One simple grammar for describing expressions is:
Goal = Expression . Expression = Term | Expression "-" Term . Term = Factor | Term "*" Factor . Factor = "a" | "b" | "c" | "d" .
Show the parse tree corresponding to the string a - b - c
(b) Another grammar is
Goal = Expression . Expression = Term | Term "-" Expression . Term = Factor | Factor "*" Term . Factor = "a" | "b" | "c" | "d" .
Show the parse tree corresponding to the string a - b - c and discuss the differences between this grammar and the last.
(c) Yet another grammar for describing expressions might be:
Goal = Expression . Expression = Term | Expression "*" Term . Term = Factor | Term "-" Factor . Factor = "a" | "b" | "c" | "d" .
Show the parse tree corresponding to the string a - b * c
(d) How does one find a grammar that will allow all four operators (+ - * and /) with the familiar precedence and associativity conventions, and will also allow for parentheses within expressions - so that one can derive strings like
(a - b) * (c + d)