Homework V

 

 

1. [10 points]

Complete the evaluation of all attributes for the derivation tree depicted on page 4 of the on-line notes "Attribute grammar example".

 

 

2. [60 points]

A DCG version of the "attribute grammar example" is provided in the file 'expTrans_ag' in our class directory. This file augments the DCG with code to evaluate the attributes (see comments in the code), and hence provides automation of the translation. Extend this example to the translation of expressions that include an exponentiation operation, written '^', that has higher precedence than '*' and is right-associative. You should fully justify the correctness of your solution through tests that exercise each component of code you add/change, including convincing documentation that this has been accomplished. Please submit a printout of your code and your correctness analysis, and also electronically submit your code only to directory Hwk5 (for class c185).