概论
字数: 0

语言处理器

How are Languages Implemented?There are two major strategies.
Interpreters (解释器) run your program
  • Python, Ruby
notion image
 
Some language provide both
  • Java, Javascript, WebAssembly
  • Interpreter + Just in Time compiler
 
🤖
这门课主要关于编译器
Compilers (编译器) translate your program
  • C, C++, Go, Rust
notion image
notion image
更多参考内容:
🕳️
Lab 知识点补充
notion image
notion image

编译器结构

notion image
词法分析器将源代码从字符流转换为令牌(tokens)流 →
语法分析器使用文法规则将令牌流组织成一个抽象语法树(AST)
编译器检查源代码的语义(类型兼容性、变量是否已声明、函数调用是否正确等)→
编译器将 AST 转换为中间代码(与特定机器无关的代码表示),便于优化和转换 →
编译器对中间代码进行优化,以提高执行效率,减少资源消耗 →
编译器将优化后的中间代码转换为目标机器能理解和执行的代码,如机器代码或字节码
📋
符号表是编译过程中用来跟踪源代码中各种符号(如变量名、函数名、类名等)的数据结构。它通常包含关于每个符号的信息,如其类型、作用域、内存地址等。
notion image
2023 - 2026