Homework Assignment # 3

Due Friday September 28, 2012 by 12:00 ( Midnight). Use turnin to submit your homework (i.e., turnin -submit [MW use swati, TTh use benself] CS345_HW3 HW3.scm , Parser.jj, and FormatDTraceProfile.jj)

1. [2 Points] Update the Scheme for Chapter 3 Final file to support support * (mul - multiplicaiton) and / (div - division) such that the following example works as shown:

> (parse '{/ {* 3 4} 2})
(div (mul (num 3) (num 4)) (num 2))
> (calc (parse '{/ {* 3 4} 2}))
6

2. [2 Points] Update the Parser.jj file from "javacc demo1" to support support * (mul - multiplicaiton) and / (div - division) such that the following example works as shown:

$ echo "{/ {* 3 4} 2}" | java Parser
(div (mul (num 3) (num 4)) (num 2))

3. [6 Points] Following the "javacc formatter" example given on the website and discussed in class, complete the output() method in FormatDTraceProfile.jj. in the HW3.zip file to format (transform) the HW3 "test" file to the output found in the HW3 "output" file. I highly recommend implementing the output() method a little at a time, i.e., get it to recognize the first line and then the second line, etc. and then get it to output the desired result.

Look at the runTest script, it shows you how to run the parser (i.e., FormatDTraceProfile) or just do ./runTest. The reason its different from before is that now the executable is a java jar file instead of a class file and the executable takes two arguments.

If you're going to use diff to compare results, it might be good to use diff -w