TENTATIVE VERSION of Assignment 2 CS 152 due October 14, 1996 Write and test a run-time implementation of the language defined by the grammar of Assignment 1 by (1) constructing a representation of an input "program" in terms of a target language and (2) executing the "program" given by the representation. Your input, which may be a command-line argument or an input to a special parsing function, should be a file name containing the input "program". Assume that static scoping is used. The only instructions in the target language are function calls. Each function call should be represented as a list of offset pairs as described in class. Note that the function itself, as well as each of its arguments, may be represented by an offset pair. Since there are no constants in the language, a mechanism is needed to represent the actual arguments of the top-level function in each "program". This issue is to be handled by assuming that the kth top-level actual argument is represented as the pair (DUMMY, k), where DUMMY is an integer that cannot be the first component of an offset pair. In a simulated run, trace execution by printing the values of the list of actual arguments for each simulated function call. This is easy to do if you have an explicit binding function that binds formal parameters to actual arguments. Error checking: You should detect and report as fatal errors 1) any call to undeclared or inaccessible functions, 2) any use of undeclared or inaccessible actual arguments 3) mismatches in number of parameters and number of arguments 4) program files that cannot be opened You needn't 1) check for duplicate formal parameters 2) recover gracefully from out-of-memory errors (the use of the "assert" facility is appropriate here) 3) recover storage You should recover gracefully from errors discovered by the "compiler". Since there is no notion of type in the source language, you needn't worry about type checking. Use the same grammar as Assignment 1. A collection of 6 test files is in the A2 directory on both my web page for this class, and on the K: drive subdirectory for this class. Test with these files, and also with a nonexistent file. In this assignment (and also in Assignments 3-5), you will need ADTs for function objects, activation records, environments, offset pairs, and various types of lists. Ideally you will have typedefs for each of these, although it's debatable whether you should have one list type, or different list types for each member type. In Assignment 5 (in C++), I will expect you to use different list types (i.e., classes) for each member type (or use templates).