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):對翻譯進行修飾