Repository navigation
Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Repository files navigation
# Brenton Hauth (1229237) - CIS*4650 - Checkpoint 3 ## Problem The problem was to enhance my Parser/Scanner and Syntactical Analysis with a CodeGenerator. I was mostly able to accomplish this. ## Files * docs/C3.pdf - the report for this checkpoint * cminus.flex - the code used to generate the lexer * cminus.cup - the code used to generate the parser * CM.java - the entry point for the code * cm - a quick file used to wrap CM.java * tests/* - the location of the test files I created * examples/* - the examples from the sample code * absyn/* - all the code used for the AST * symbol/* - The code for the Scope, NodeType and Variables * CodeGenerator.java - the code for generating code. ## Limitations * I was unable to fully implement the arrays * My code is kind of buggy; it generates machine code but sometimes the registers/memory will get messed up * If Statements may execute the else (I spent hours and hours trying to fix this) ## Notes & Improvements * I abstracted a lot the logging into a single "Log" class which can be called from anywhere (makes things more neat). * I need to tweek it so that I can replace function prototypes with their actual function definitions (v.minor). * For greater detail on my design choices please see docs/C3.pdf * I want to make it so that I can describe types with different bit settings (so "ARRAY | INT" could describe "int[]") ## How to Run * call `make` to build the project * Use `java -cp ./lib/java-cup-11b.jar:. CM [-a] [-s] [-c] <filename>.cm` to parse a file or use `./cm [-a] [-s] [-c] <filename.cm>` for simplicity. * To test the code, you can use `./tm <filename.tm>` to specifically test a compiled file. * Use can use the files located in tests/ for the tests I created (please see the file for the errors) * Using [-a] will print the AST to a file of the same name ending in ".ast" * Using [-s] will print the Scope declarations to a file of the same name ending in ".sym" * Using [-c] will compile the project to a ".tm" file. If there are any errors, no compilation will take place.