Size: 1399
Comment:
|
Size: 1748
Comment:
|
Deletions are marked like this. | Additions are marked like this. |
Line 28: | Line 28: |
* 所有的Identifier用single character来代替,不考虑空格(即词法规定不允许用户写空格) | * 所有的Identifier用single character来代替,不考虑空格(即词法规定不允许用户写空格)。作者认为如果他能正确处理I-T-L,那么他也能让IF-THEN-ELSE工作 * 只处理实时I/O,不处理File I/O。 * 忽略error correction/recovery。遇到第一个error即停机,但这不是崩溃。 |
Line 31: | Line 33: |
1. 从源代码直接生成汇编代码。不需要中间码 1. 延迟对module的构建,直至真的需要它的时候 |
申明不会采用典型教科书上关于编译器的教学顺序,比如:
- o An introductory chapter describing what a compiler is. o A chapter or two on syntax equations, using Backus-Naur Form
- (BNF).
- deterministic and non-deterministic finite automata.
- recursive descent, and ending with LALR parsers.
- and similar reverse polish representations.
- parameter passing, type declarations, and such.
- imaginary CPU with a simple instruction set. Most readers (and in fact, most college classes) never make it this far.
- goes unread, too.
作者不会遵照这些,而是带着你直接上手写一个能工作的编译器,采用他的方式:
- KISS原则
- 所有的Identifier用single character来代替,不考虑空格(即词法规定不允许用户写空格)。作者认为如果他能正确处理I-T-L,那么他也能让IF-THEN-ELSE工作
- 只处理实时I/O,不处理File I/O。
- 忽略error correction/recovery。遇到第一个error即停机,但这不是崩溃。
- 只讨论一种情形的解析:top-down、recursive descent parsing
- 自顶向下、递归下降的情形,作者认为这是唯一一种支持手写编译器的技术选型
- 从源代码直接生成汇编代码。不需要中间码
- 延迟对module的构建,直至真的需要它的时候