Question: In a previous exercise, you wrote five different programs using the prefix notation of Arithlang and all four arithmetic operators +, , *, and /,

In a previous exercise, you wrote five different programs using the prefix notation of Arithlang and all four arithmetic operators +, −, *, and /, such that each expression produces the value 42. Draw the parse tree and the AST for these programs.


Previous exercise

Draw the parse tree of the following Arithlang programs.1. (+ 515) 2. (* (+43) (+4 0)) 3. (/ (+ 4 3 4 9) (+ 515) 9)

Next, draw ASTs for the same programs. Finally, report on the compression ratio achieved by the AST representation. The compression ratio is defined as (the number of nodes in the parse tree –the number of nodes in the AST) / the number of nodes in the parse tree.

Step by Step Solution

3.23 Rating (147 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Sure lets first draw the parse tree and AST for the provided Arithlang pro... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related An Experiential Introduction To Principles Of Programming Languages Questions!