-
体系总览
-
1、reader:从输入流中读取数据结构
- 配置文件读取
- 类文件载入
- 程序分析工具(方法交叉引用工具)
- ...
-
2、generator:遍历内部数据结构并输出
- 对象至关系数据库映射工具
- 对象序列化
- 源码生成器
- web页面生成器
- ...
-
3、translator and rewriter:读取输入,输出为同一或不同语言
- 过时语言到现代语言的翻译器
- Wiki至html页面的翻译器
- refacters、profilers
- 日志文件报表生成
- 宏语言预处理器
- 汇编器、编译器
- ...
-
4、interpreter:读取、解码、执行
- 简单的计算器
- POP协议服务器
- ...
-
实现模式
-
1、Mapping Grammars to Recursive-Descent Recognizers
- 目的:将语法翻译为递归向下识别器;为recursive-descent lexer,parser,tree parser提供控制流框架
- 实现:public class G extends Parser {
<<token-type-definitions>>
<<suitable-constructor>>
<<rule-methods>>
}
转换规则,转换tokens,转换子规则
-
2、LL(1) Recursive-Descent Lexer
- 目的:通过识别lexical patterns来从字符流中提取token流
又叫scanner,lexical analyzer,tokenizer
- 3、LL(1) Recursive-Descent parser
- 4、LL(k) Recursive-Descent Parser
- 5、Backtracking Parser
- 6、Memoizing Parser
- 7、Predicated Parse
- 8、Parse Tree
- 9、Homogeneous AST
- 10、Normalized Heterogeneous AST
- 11、Irregular Heterogeneous AST
- 12、Embedded Heterogeneous Tree Walker
- 13、External Tree Visitor
- 14、Tree Grammar
- 15、Tree Pattern Matcher
- 16、Symbol Table for Monolithic Scope
- 17、Symbol Table for Nested Scopes
- 18、Symbol Table for Data Aggregates
- 19、Symbol Table for Classes
- 20、Computing Static Expression Types
- 21、Automatic Type Promotion
- 22、Enforcing Static Type Safety
- 23、Enforcing Polymorphic Type Safety
- 24、Syntax-Directed Interpreter
- 25、Tree-Based Interpreter
- 27、Stack-Based Bytecode Interpreter
- 28、Register-Based Bytecode Interpreter
- 29、Syntax-Directed Translator
- Parsing input sentences
- Constructing Trees
- Walking Trees
- Figuring Out What the Input Means
- Interpreting Input Sentences
- Translating One Language to Another
- 概要