CS4212 Compiler Design, AY 2016-17 Semester 1 @ National University of Singapore
- Liu Siyuan (A0153030B)
- Francesco Picciotti (A0153447A)
- Yohanes Yudhi (A0152954Y)
This is a compiler for the mini GO language. For the language specification, please visit here.
- Stage 1: Lexical and syntax analysis
- Stage 2: Type checking
- Stage 3: Code generation
To compile the compiler, just run
$ make clean && make
To compile and run a mini-go source program, type the following command
$ ./calc /path/to/your/program
Example programs are available in the examples
folder. Every example program in that folder tests one or more language features.
- arithmetic.go: tests arithmetic operations
- eqgt.go: tests the
==
and>
operator - ite.go: tests
if exp {} else {}
structure and variable declaration in inner scope - while.go: tests while loop (it's a infinite loop, will cause stack overflow)
- func.go: tests calling function as statement (
FuncCall
) - return.go: tests calling function as expression (
FuncExp
) and recursive function call
Our compiler doesn't support negative numbers. However, negative number doesn't seems to be part of the language specification.
Although variable declaration/redeclaration in inner scope is supported, returning a variable in the inner scope is not supported. This is because the return statement must be the last statement. Therefore, variables in inner scope cannot be accessed by the return statement.