Course project for Compiler Principle at ZJU. Co-Authored with @Tinghao(Vitus) Xie.Visit Github repo.
1 | int main(){ |
Features
- Advanced self-defined types (nested struct and arrays)
- MACRO support (#define/#define f(X),#ifdef/ifndef and nested)
- Error detection and recovery (primary)
Language definitions
This language is a miniature of C. We highlight our differences as follows:
- type system: char, int, double and n-dimensional array type; Pointer type is not supported in this version.
- no controled jumps, gotos and labels , i.e. break, continue and switch statements are not supported.
scanf
andprintf
are automaticly embedded in runtime. Do not override it.- calling convention of scanf is modified. e.g. you shall use
scanf("%d",i);
to read the value into variable i and drop the & symbol. for
loop switched to pascal-like, i.e.for(i: 0 to n){}
andfor(i: n downto 0){}
snippet.i
is only seen within the scope of this loop.- unary operators are not supported in this version.
You are encouraged to peruse the test examples in order to get a better understanding of the gramma. Here is a quicksort implementation in our language:
1 |
|