Skip to content

Simple front-end compiler based on a simple grammar producing gforth code from Compilers Course

Notifications You must be signed in to change notification settings

kp646576/Simple-Compiler

Repository files navigation

--------------------------------------------------------------------------------
Running Code:
--------------------------------------------------------------------------------
main.py is structured so that it takes in one argument which is the name of a
file containing a string.  To run using the makefile:


Manually running a file:

    python main.py <file_name>


Running proftest.out files:

    make proftest.out


* make searches the current directory for proftest* files and runs each one in
succession

--------------------------------------------------------------------------------
Notes:
--------------------------------------------------------------------------------
Boolean values true and false are case sensitive to only be considered boolean
if they are in lowercase, otherwise they are treated as variable names.

--------------------------------------------------------------------------------
Tests:
--------------------------------------------------------------------------------
Tests can be run one at a time through:

    python main.py ./tests/<test_name>.txt


Outputs of all tests can be generated through:

    make stutest.out


All tests can be run using the unittest framework through:

    make unittests


*test.py uses python's unittest framework to compare the parser's output with the
correctly tested output

--------------------------------------------------------------------------------
Extra Credit:
--------------------------------------------------------------------------------
Integration:
The parser should be able to successfully parse the rectangle integration method
 and produce the correct result.  Code can be generated by either running

    make integral

        or

    python main.py tests/integral.txt


Blocked Scoping:
I did not however do the blocked scoping.  Scoping was implemented such that all
variables are visible up until the top most level.  So for example:

1: ( (let ((x int)))  x)
2: (x)

x would be defined on the first line, but undefined on the second line

About

Simple front-end compiler based on a simple grammar producing gforth code from Compilers Course

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published