Our SIT triplet is (Go, Python, MIPS).
- Native Data types (
integer,float,bool,string). - Variables and Expressions
- Control structures
- Conditionals (
if,if-else,switch) - Loops (
for).
- Conditionals (
- Input/Output statements (
scanf,printf) - Arrays (
multidimensional arraysupported) - Functions (Recursion is supported)
- User defined types (
struct)- Nested
structs are also supported
- Nested
- Pointers/References
- Short declarations using
:= - Automatic type inference
- Short-circuit evaluation
- String concatenation with "+" (memory allocated to string from heap)
- Evaluation of compile-time constant expressions
- Multi level Pointers
- Multi level Break
- Milestone 1 : Specs
- Due on: 24.01.2022
- In this milestone, we had to provide the details of our Compiler.
- Deliverables
docs/specs.pdf
- Milestone 2 : Scanner
- Due on: 01.02.2022
- In this milestone, we had to construct a scanner for the source language to output the tokens in a tabular form.
- Deliverables
src/lexer.pytests/scanner/docs/lexer.mdMakefile
- Milestone 3 : Parser
- Due on: 18.02.2022
- In this milestone, you have to develop a parser for the source language that outputs the Parser Automaton in a graphical form.
- Deliverables
src/parser.pysrc/dot.pytests/parser/docs/parser.mdMakefile
- Milestone 4 : Semantic Analysis
- Due on: 28.03.2022
- In this milestone, you extend the project to perform semantic analysis. The goal is to convert your program into an AST Representation to be used by later stages (Intermediate and Final code generation, optimization, etc.).
- Deliverables
src/parser.pysrc/utils.pysrc/ast_plot.pngsrc/ast.dotMakefile
- Milestone 5: Activation Record and Intermediate Code Generation
- Due on: 10.04.2022
- Now that you can create AST and Symbol Table for a semantically meaningful program, it is time to generate Intermediate code (3-address code, 3AC) with support for run-time activations.
- Deliverables
src/parser.pysrc/utils.pysrc/classes.pyMakefile
- Milestone 6: The Destination
- Due on: 25.04.2022
- In this last part of the project, you will generate code for the target assembly.
- Deliverables
src/compiler.pysrc/constants.pysrc/classes.pysrc/tests.pyMakefile
Clone the repository, navigate into the directory and install the dependencies
git clone [email protected]:gurbaaz27/CS335-Course-Project.git
cd CS335-Course-Project/
pip install -r requirements.txt ## or pip3, according to your systemThere are 5 test-cases present in tests/scanner/ directory.
To run the test cases, simply run
make scanner test=<test_num>
## For example,
make scanner test=2In case no test variable is mentioned,make defaults to test=1, i.e.
make scanner ## is equivalent to
make scanner test=1In case you want to run all test-cases at once, run
make scanner-allIf you do not have make installed, you can simply run the python script using
python src/lexer.py tests/scanner/<test_num>.go ## or python3, according to your system
## For example,
python src/lexer.py tests/scanner/2.goNOTE 1 : We do not print COMMENT and NEWLINE in our output, since they have no role in parser.
NOTE 2 : We have purposely added an illegal character in 5th test-case, which should result our lexer throw an error message on encountering that character(s).
There are 5 test-cases present in tests/parser/ directory.
To run the test cases, simply run
make parser test=<test_num>
## For example,
make parser test=2In case no test variable is mentioned,make defaults to test=1, i.e.
make parser ## is equivalent to
make parser test=1If you do not have make installed, you can simply run the python script using
python src/parser.py tests/parser/<test_num>.go ## or python3, according to your system
## For example,
python src/parser.py tests/parser/2.goThis will generate src/parser.out and src/parsetab.py files and generate dot file named <test_num>.dot
Before moving to next test case, make sure to clean the src/ folder using
make clean ## or
rm -rf src/parser.out
rm -rf src/parsetab.pyTo generate graph from dot file, install graphviz. For Ubuntu, you can use
sudo apt install graphvizand make graph using
make graph test=<test_num> ## or
dot -Tpdf <test_num>.dot -o <test_num>.pdfNOTE : We have purposely added an illegal syntx in 5th test-case, which should result our parser throw an error message.
There are 5 test-cases present in tests/semantic/ directory.
To run the test cases, simply run
make semantic test=<test_num>
## For example,
make semantic test=2In case no test variable is mentioned,make defaults to test=1, i.e.
make semantic ## is equivalent to
make semantic test=1If you do not have make installed, you can simply run the python script using
python src/parser.py tests/semantic/<test_num>.go ## or python3, according to your system
## For example,
python src/parser.py tests/semantic/2.goNOTE : We have purposely added wrong semantic in 3rd testcase, which should result our semantic analyser throw an error message.
There are 5 test-cases present in tests/3ac/ directory.
To run the test cases, simply run
make ir test=<test_num>
## For example,
make ir test=2In case no test variable is mentioned,make defaults to test=1, i.e.
make ir ## is equivalent to
make ir test=1If you do not have make installed, you can simply run the python script using
python src/parser.py tests/3ac/<test_num>.go ## or python3, according to your system
## For example,
python src/parser.py tests/3ac/2.goThe test-cases are present in tests/final/ directory.
To run the test cases, simply run
make final test=<test_name>
## For example,
make final test=print_literalIn case no test variable is mentioned,make defaults to test=print_literal, i.e.
make final ## is equivalent to
make final test=print_literalIf you do not have make installed, you can simply run the python script using
python src/compiler.py tests/final/<test_name>.go ## or python3, according to your system
## For example,
python src/compiler.py tests/final/print_literal.goGroup Number: 26
- Anshumann (190162)
- Antreev Singh Brar (190163)
- Dipanshu Garg (190306)
- Gurbaaz Singh Nandra (190349)