===
This is a repo for my homework in Compiler Design, NCTU. It contains four directories.
The lab is seperated into 4 parts, only hw4
is a complete work.
- HW1 contains only the lex scanner
- HW2 has the lex scanner and the parser by yacc
- HW3 is extended from HW2, a symbol table and the ability to find semantic error is added.
- HW4 is the complete work, compiles the code and generates java bytecode
The compiler is for the pascal-like P language.
- varible: integer, real. Supports global, local and constant varible
- loop: for, while
- I/O: print, read
- function: supports function define and invocation.
- expression: arithmetic, boolean expressions
- branch: if...else
lex
orflex
yacc
orbison
java
runtimegcc
orclang
to compile the compiler
Goto HW4
Patterns
is for full functionality testtest
is for small conponent test
Use bash ./compile_and_run [filename]
to compile and run the code
for example: bash ./compile_and_run Patterns/general.p
This is a game of guessing a number
The code of the program
result