The objective of this assignment is the construction of your compiler for level
B compliance.
To Do
The first thing to do is mark up with action symbols the section of the mPascal grammar that you identify as necessary for level
B compliance. The action symbols you insert should also show which semantic records
are needed to accomplish the action.
Bring your compiler up to level B compliance. This means that you are to
generate IR that can be run through the mMachine emulator for
any mPascal program consisting of just a main program with
Read, Write, assignment, and all control statements. Your compiler is to follow the
standard approach of using semantic records and semantic actions (methods in the Analyzer
object) for symbol table management and IR code generation. In summary, your
compiler should now be capable of:
Compiling programs that consist of just a main program.
Full symbol table functionality for a main program only
Compiling read statements
Compiling write statements
Compiling assignment statements
Compiling the control structures.
In other words, your compiler should compile any valid mPascal
program that consists of just a main program.
Special Note
Note the
following:
Level C compliance does not require handling Boolean expressions, but level B does,
because level B entails the compilation of the various control statements, such as ifs and loops..
You have to decide how you are going to represent Boolean values internally.
For example, a standard approach is to use the integer 1 to represent TRUE and the
integer 0 to represent FALSE.
Booleans are not treated the same in Pascal as in, for example, C. You cannot
allow an integer result where a Boolean value is expected, and vice versa. For
instance, the statement
If A + B then write(A) else Write(B);
is not valid regardless of the result of A + B. Also, you cannot perform
arithmetic operations on Boolean values.
To Turn In
There is nothing to turn in this week. Your project will be due at the due
date for level A compliance, at which point it will be tested for all levels of
compliance.