CSCI 5220
Homework Set 1

Due: Jan 23 in class.

  1. Text, exercise 2.8. Just write a grammar and give a translation rule for each rule of the grammar. You can choose whether you are using a functional approach (based on computing synthesized attributes for nodes in the parse tree) or an imperative approach (based on performing actions at nodes in the parser tree). Make it clear what your semantic rules are intended to do. Assume that the allowed operators are +, -, * and /.

    Translating to infix with a minimum number of parentheses is a little tricky, since you need to pay close attention to precedence. For this exercise, you can use extra parentheses. Just put parentheses around every expression.

  2. Text, exercise 2.11, but only grammars (a) and (b). The parser must only determine whether the input is in the language described by the grammar. It should print yes or no.