1.1 语言处理器
- 如何实现语言?
- Interpreter 解释器(用“is”的方法解释程序,几乎没有预处理)
source code + input —interpreter—> output - compilers 编译器(特点是有预处理)
source code —compiler—> machine code(target code)
input —target code—> output - hybrid compilers(如java)
source code —translator—> intermediate program(bytecode)
intermediate program(bytecode) + input —virtual machine—> output
1.2 编译器结构
词法分析(lexical analysis):单词拼写是否正确?
语法分析(syntax analysis):句子语法结构是否正确
语义分析(semantic analysis)+ 中间代码生成(intermediate code generate):分析句子语义,初步翻译生成中间代码
优化(optimizer):对翻译进行修饰