(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)
(e) Develop a Cocol grammar to describe a list of names of staff who have titles, first names and/or initials, surnames, and (usually) qualifications, for example
Professor Shaun Bangay, PhD . Professor P. D. Terry, MSc, PhD . George Clifford Wells, BSc(Hons), MSc, PhD . Greg G. Foster, PhD . Dave A. Sewry, PhD . Dr Karen Lee Bradshaw, MSc, PhD . Mrs Madeleine Wright, MA, MSc . B. Cleo C. Biko, BCom, BEd . Dr Dameon Wagner, PhD . Ms Cheryl Fischer .