ZJU standard C Compiler
- Lex and Yas related codes are in the folder yyparse.
- Symbol table and Type check related codes are in the folder symbol.
- Generating machine code related codes are in the folder generation.
- Treating Special variables related codes are in the folder public.
- Optimization codes are stored separately in each folder.
declaration
declaration_specifiers
storage_class_specifier
typedef
declaration_specifiers
type_specifier
struct_or_union_specifier
struct_or_union
struct
{
struct_declaration_list
struct_declaration_list
struct_declaration
specifier_qualifier_list
type_specifier
int
struct_declarator_list
struct_declarator
declarator
direct_declarator
a
;
struct_declaration
specifier_qualifier_list
type_specifier
double
struct_declarator_list
struct_declarator
declarator
direct_declarator
c
;
}
init_declarator_list
init_declarator
declarator
direct_declarator
mytype
;
Call functions in self.tools to translate.
Detailed comments and examples can be found in generation.generate.
- Calculation: add, sub, mul, div.
- Logic: and, or, not.
- Jump: jmp, je, jg, jl.
- Shift: sal, sar.
- Function: call, ret.
- Stack: push, pop.
- Float number operation: fld, fstp, fadd, fsub, fmul, fdiv.
- Global/Static variables, Constant float number, String
http://www.compileroptimizations.com/index.html
http://people.eecs.berkeley.edu/~bodik/cs264/lectures/4-chaotic-notes.pdf