Skip to content

LRParser/MiniCompiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Group #9 Assignment #4
	Jon Boone
	Joshua Datko
	Paul DeMicco
	Joseph Heenan
________________

OVERVIEW: Assignment #4
___________

This project builds upon project #3 which was a compiler developed targeting the RAL instruction set
that runs on the RAM simulator.

This package contains all of the files for Assignment #4.

=======
interpreterext.py		** Contains the grammar for the original mini language. Also contains the main method which
                        ** takes in a file and checks for the correct tokens and syntax.

                        ** p_program will call all of the methods required to translate, optimize and link the RAL
                        ** code to be used in the RAM simulator.

                        ** These text files will be generated as output (both when calling python interpretext.py < myinputfile and via calling make compile < myinputfile)
                        ** 1.) symOut.txt - Contains the symbolic RAL code prior to optimization and linking.
                        ** 2.) program-non-opt.txt - Contains the RAL code after linking is performed (but before optimization)
                        ** 3.) program-opt.txt - Contains the RAL code after optimization and linking has been executed.
                        ** 4.) mem-dump.txt - Outputs the non-optimized memory table. Breaks down the VARS, CONSTS and TEMP variables stored in memory and and displays their name, and memory address.
                        ** 5.) mem-dump-opt.txt - Output the optimized memory table. Used for simulation with RAM simulator

programext.py			** Contains the implementation for the grammar along with all of the implementation for
                        ** generating the RAL code to be used in the RAM simulator.

makefile


                        ** view — display (using the more utility) all of your source code (excluding the modified RAM)
                        ** compile — Does whatever you need to do to produce:
                        *       symbolic RAL code
                        **      linked RAL code
                        ** view-trans — Use cat to display your symbolic RAL program (produced in translate) to stdout.
                        ** view-link — Use cat to display your compiled (not optimised) RAL program (produced in translate to stdout.
                        ** run — invoke ~kschmidt/bin/ram to run your program. Let output go to stdout.
                        ** clean — remove all binaries and intermediate files

    *** Application Notes ***

    The RAL instruction set has been expanded to now include all of the following calls:
        ADD = 'ADD'
        SUB = 'SUB'
        MUL = 'MUL'
        JMP = 'JMP'
        JMI = 'JMI'
        JMN = 'JMN'
        JMZ = 'JMZ'
        CAL = 'CAL'
        HLT = 'HLT'
        LDA = 'LDA'
        STA = 'STA'
        LDI = 'LDI'
        STI = 'STI'

    The call stack has been modified to store ActivationRecords which store parameters, local variables, temporary variables, etc. for
    procedures that are defined.

    A memory map of the following structure has been defined for this project:

    The stack pointer will always be stored at Address #1.
    The frame pointer will always be stored at Address #2.
    Frame pointer buffer will always be stored at Address #3.
    A temporary register will always be stored at Address #4.

    DefineStmt has been modified with a 'translate' method that will not support procedures.
        The DefineStmt will add the function name to the function table along with creating a label
        so that we can jump back to that function.

    Proc has been modified with a 'translate' method so that function calls can be translated.
        Proc will create the ActivationRecord for the function and add the parameters needed for the
        function to the ActivationRecord along with storing all of the instructions needed for the function to be executed.

    FunCall has been modified with a 'translate' method so that function calls can be translated.
        FunCall will access the ActivationRecord created by Proc along with setting the stack and frame pointer.
        The function will be called at this time and the return value will be stored back into
        the AC register.

    The linker is still responsible for resolving actual addresses.
    The final output of the application will be optimized RAL code along with the memory table to be used as input into
    the RAL simulator.

TEST FILES - Will be explained in detail below :
________________
assign1.p       ** Used to test the assignment of constants to variables.
assign2.p       ** Used to test the assignment of constants to variables, and variables to variables.

identTest1.p    ** Used to test the Identity statement.

iftest1.p       ** Used to test the If statement method.

math.p          ** Generic math testing input file.

Plus1.p         ** Used to test the Multiple method using 3 values.
Plus2.p         ** Used to test the Multiple method using 2 values.

Sub1.p          ** Used to test the Subtraction method using 3 values.
Sub2.p          ** Used to test the Subtraction method using 2 values.

Times1.p        ** Used to test the Multiply method using 3 factors.
Times2.p        ** Used to test the Multiply method using 2 factors.

whileTest1.p    ** Used to test the While Statement


README				** This file. Contains details out how to run files, build, test, etc.

RUNNING: Assignment #4, Part #1
___________

Executing make run < myinputfile (where you substitute myinputfile for an appropriate mini language input file) will compile and run myinputfile

Other included targets are view, compile, view-trans, view-link, view-op and clean to supporting viewing all source, compile/link/optimize of input on stdin, viewing symbolic RAL, viewing linked RAL, viewing optimized RAL, and cleaning output file, respectively

TESTING: Assignment #4, Part #1
___________
All test case files (*.p) have been run through the compiler to ensure proper operation. The output of the compiler has
also been ran through the RAM simulator to validate the instructions have been generated properly.