Final project for the Compilers course at National Central University, Fall 2023.
❗
|
Features 1-4 must be finished before other features. |
Feature | Description | Points | Public1 | Public2 | Hidden1 | Hidden2 |
---|---|---|---|---|---|---|
Syntax Validation |
Print “syntax error” when parsing invalid syntax |
10 |
✅ |
✅ |
✅ |
✅ |
Implement print-num statement |
10 |
✅ |
✅ |
✅ |
✅ |
|
Numerical Operations |
Implement all numerical operations |
25 |
✅ |
✅ |
✅ |
✅ |
Logical Operations |
Implement all logical operations |
25 |
✅ |
✅ |
✅ |
✅ |
if Expression |
Implement if expression |
8 |
✅ |
✅ |
✅ |
✅ |
Variable Definition |
Able to define a variable |
8 |
✅ |
✅ |
✅ |
✅ |
Function |
Able to declare and call an anonymous function |
8 |
✅ |
✅ |
✅ |
✅ |
Named Function |
Able to declare and call a named function |
6 |
✅ |
✅ |
✅ |
✅ |
Public test case points : Hidden test case points = 80% : 20% (pass partial get partial)
Feature | Description | Points | Public1 | Public2 | Hidden1 | Hidden2 |
---|---|---|---|---|---|---|
Recursion |
Support recursive function call |
5 |
✅ |
✅ |
✅ |
✅ |
Type Checking |
Print error messages for type errors |
5 |
✅ |
✅ |
✅ |
✅ |
Nested Function |
Nested function |
5 |
✅ |
✅ |
✅ |
✅ |
First-class Function |
Able to pass functions, support closure |
5 |
❌ |
❌ |
❌ |
❌ |
bison -d -o src/minilisp.tab.c src/minilisp.y
gcc -c -g -I. -o src/minilisp.tab.o src/minilisp.tab.c
flex -o src/lex.yy.c src/minilisp.l
gcc -c -g -I. -o src/lex.yy.o src/lex.yy.c
gcc -o bin/minilisp src/minilisp.tab.o src/lex.yy.o
bison -d -o src/minilisp.tab.c src/minilisp.y
gcc -c -g -I. -o src/minilisp.tab.o src/minilisp.tab.c
lex -o src/lex.yy.c src/minilisp.l
gcc -c -g -I. -o src/lex.yy.o src/lex.yy.c
gcc -o bin/minilisp src/minilisp.tab.o src/lex.yy.o
Script Features
-
Compile, execute tests, and clear output files
-
Count the number of test cases passed and failed
-
Display expected and actual outputs for failed test cases
Excution Method
./run_test.sh
Sample Project Structure
.
|
| run_tests.sh
|
+---bin
| minilisp.exe
|
+---src
| minilisp.l
| minilisp.y
|
\---tests
| public_test_data_ans.txt
\---public_test_data
If encountering issues like permission error, try modifying script permissions
chmod +x run_tests.sh
Books
Documents and Other Resources
-
NCU CE3006 Course Video and Slides
Articles and Others
-
How can I traverse the parse tree generated by YACC? (Stack Overflow) - yacc does not build a parse tree. It does build (and destroy) a parse stack as it works
Tools
-
Excalidraw - Virtual whiteboard for sketching hand-drawn like diagrams, good for drawing AST