Trial 5
Due on November 8th 11:59 PM (Not accepted late).
Updates

None yet!

Overview

For this trial, you should create an interpreter called dragoninterp that interactively evaluates a A program. In effect, you should be able to supply valid source code as input to dragoninterp and the output of that source code should be shown on the console.

You may use the code (including the starter code) of ac to build the interpreter. dragoninterp should accept input from stdin. When a declaration is encountered, dragoninterp should keep enough state that the declaration can later be used.

Interactive Scope

dragoninterp should maintain an interactive scope, in which a statement is immediately evaluated. Unless the user is entering a portion of a declaration (i.e. the user is in the midst of creating a function declaration), the result of the statment should take effect immediately. Thus, if the user enters, on stdin, write 1 + 5, dragoninterp should output 6 to the console.

Example session

The behavior of dragoninterp should follow the example. Text in italics describes what the program is doing. Text in bold is output from dragoninterp. Non-bold, non-italic text is user input
		> Welcome to dragoninterp! Enter A code to be interpreted...
		int a;
		(declaration a is added to the global scope)
		int b;
		(declaration b is added to the global scope)
		a = 2;
		(a's value is internally set to 2)
		b = 3;
		(b's value is internally set to 3)
		report a + b;
		> 5
		

Function declarations should suspend evaluation until the declaration is complete. During suspended evaluation, the interpreter should output a . at the beginning of a line. For example:

		> Welcome to dragoninterp! Enter A code to be interpreted...
		v:void(){
		. loc:int;
		. loc = 7;
		. write loc;
		. }
		(Function v is added to the global scope)
		v();
		7
		loc = 2;
		(error/dragoninterp terminates because loc is not in the global scope)
		

Deliverables

Submit a complete source code tarball, including a makefile. It should be possible to run

make all ; dragoninterp

to begin an interactive session.