The compiler is divided in 6 different projects:
- Automata
- Lexer
- ArithmeticParser
- Parser
- ArithmeticEvaluator
- Translator
This project contains a collection of automata, some useful to the Compiler, some not. These are mere exercises.
The lexer is an important part of the compiler, used by the Parsers, Evaluator and Translator to check if the input code respects the CFG of P.
The arithmetic parser controls that the syntax of the input code is an acceptable arithmetic expression.
The parser controls that the syntax of the input code is an acceptable program written in P.
The arithmetic evaluator calculates the actual value of the input code, given it being an acceptable arithmetic expression.
The translator transforms the input code in actual Java ByteCode generating a .j file that JASMIN could easily compile in a .class file.
- 1:
Binary
automaton - 2:
Id
automaton - 3, 4, 5:
Student
automaton - 6:
ModThree
automaton - 7, 8:
AThree
automaton - 9:
Name
automaton - 10, 11:
Comments
automaton
See Projects β Lexer
- 1:
Arithmetic
parser - 2:
Parser
See Projects β ArithmeticEvaluator
See Projects β Translator
To compile a single exercise, use ./es.sh <paragraph> [exercise] [force build]
To compile a project use ./exec.sh build <project> [force build]
To compile a single file (with due dependencies) use ./exec.sh build <file name> [force build]
To test a project use ./exec.sh test <project>
To compile the entire project use make
To clear the executables use make clear
P β SL $
SL β S SL'
SL' β ; S SL'
| Ξ΅
S β id := E
| print ( E )
| read ( id )
| case WL else S
| while ( BO ) S
| { SL }
WL β W WL'
WL' β W WL'
| Ξ΅
W β when ( BO ) S
BO β BA BO'
BO' β or BA BO'
| Ξ΅
BA β B BA'
BA' β and B BA'
| Ξ΅
B β E RELOP E
| ! ( E RELOP E )
E β T E'
E' β + T E'
| - T E'
| Ξ΅
T β F T'
T' β * F T'
| / F T'
| Ξ΅
F β ( E )
| num
| id