Question: For this assignment, we will enhance the A compiler by implementing name analysis, which collects each semantic symbol ( e . g . variable or

For this assignment, we will enhance the A compiler by implementing name analysis, which collects each semantic symbol (e.g. variable or function) of the input program and builds a correspondance between identifiers and their symbol. From a black-box view of ac, the changes needed are fairly straightforward: Implement a new command-line option for ac that augments unparsing so that every use or definition of an identifier has its type, in curly brackets, after its name. We will also write error checking code which reports name analysis issues. Make any changes in the code necessary to support the above tasks.
Requirements
Edit the makefile such that the following invocations build and execute your code:
make
./ac -n2>
Where
is a lexically- and syntactically-valid A file, which may contain binding errors (i.e. the kinds of errors name analysis would catch).
is the file to which the augmented unparse file will be written in the required output format.
is the file to which the required error messages will be written in the required error message format.
Unparse Output Format
For names of functions, the information should be of the form
(param1Type,param2Type,...,paramNType)-> returnType
For names of global variables, parameters, and local variables output the type.
Error Reporting
Your name analysis should find all of the errors described in the table given below; it should report the specified position of the error, and it should give exactly the specified error message (each message should appear on a single line, even if your browser adds a line break in the following table). Error messages should have the same format as in the scanner and parser.
Type of ErrorError Message \t Description
More than one declaration of an identifier in a given scope \t
For this assignment, we will enhance the A

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Programming Questions!