- Goal: Implementing a C_Minus_Minus compiler
- Environment: Ubuntu 12.04.4 LTS
- Language: C++
- Main program: compiler.cpp
- Input file: main.c grammar.txt
- Output file: token.txt set.txt LLtable.txt tree.txt symbol.txt quadruples.txt code.tm
"./compile.sh" or "make" "./compiler input/main.c input/grammar.txt"
- Kerwords: int char return if else while break
- Operators: = ! + - * / == != < > <= >= && ||
- Special Symbols: [ ] ( ) { } ; ,
- Identifier: [a-zA-Z_][a-zA-Z0-9_]*
- Number: [0-9]+
- Char: ‘[.|\n|\t| ]’ Ex. ‘a’、’\n’、’ ’
- Comment (no need to print): //
- Lexical Analysis
- Syntax Analysis
- Semantic Analysis
- IR Generation
- Code Generation
- lib: all custom class file
- input: include main.c & grammar.txt
- ouput: all output file could found in this directoy
- compile.sh: shell program for quick compile and run program
- Tiny_Machine.c: machine source code for run result code.tm
compiler support char to int implicit conversion (no need to type checking)