Homework 7

This is the archived website of SI 413 from the Fall 2013 semester. Feel free to browse around; you may also find more recent offerings at my teaching page.

1 Draw an AST

Here is a program written in Python. Draw its AST.

x = 10
while x > 0:
    x = x - 3

2 Undraw an AST

Write a program in the language of your choosing that would generate the following AST:

AST for HW 7

AST for HW 7

(Be sure to specify which language you have chosen!)

3 Lexical vs Dynamic Scope

Write a simple program using Java syntax that would behave differently under lexical or dynamic scoping rules. (I know that Java uses lexical scope, but you should be able to imagine the alternative as well.)

Specify what would happen under lexical and under dynamic scoping.

You can work together as always, but everyone should submit a unique example.