A simple compiler from the ac (adding calculator) language to the dc (desktop calculator) language. Documentation and interface are entirely in italian.
The program can be easily run from the executable CompilatoreACDC.jar. Just feed it a text file containing a (valid) ac source file and let the program do its magic.
The compiler is made up of a scanner, whose job is to break down the source code into tokens; a parser, that checks if the tokens received from the scanner follow the ac grammar (spedified below) and builds an abstract syntax tree representing the syntax of the source code; a typechecker, that decorates the AST with information regarding data types; and a code generator, that walks the AST and generates dc code.
- Prg → DSs $
- DSs → Dcl DSs
- DSs → Stm DSs
- DSs → ϵ
- Dcl → Ty id DclP
- DclP → ;
- DclP → opAss Exp;
- Stm → id opAss Exp;
- Stm → print id;
- Exp → Tr ExpP
- ExpP → -Tr ExpP
- ExpP → +Tr ExpP
- ExpP → ϵ
- Tr → Val TrP
- TrP → /Val TrP
- TrP → *Val TrP
- TrP → ϵ
- Ty → float
- Ty → int
- Val → intVal
- Val → floatVal
- Val → id
- GUI to make compilation more accessible
- "panic mode" in parser: if the source code is malformed, the parser keeps on parsin' by finding the delimiter ';' and resuming operation