ComPiler200002:Growing a Compiler
http://www.cs.dartmouth.edu/~mckeeman/cs48/mxcom/gem/html/GrowingCompiler.html
by Bill McKeeman and Lu He
MathWorks and Dartmouth, May 2009
Contents
Abstract
Self-compiling compilers are common. The question is: How far can one go, bootstrapping a (very) small compiler-compiler into more capable compilers?
Context-free grammars are extended to accomodate output. A grammar executing machine (GEM) is introduced which accepts an input text and a grammar, and outputs another text. Both the input text and the output text can also be grammars, permitting the production of ever more powerful grammars. GEM itself can be extended to build-in the capabilities of the previous grammars. The rules of the game require that changing GEM does not add to its original capability -- it merely makes the implementation more robust or faster.
The grammars and the machine have some simple symmetries that lead to actions such as backtracking and decompiling. It is also possible to directly execute bit-strings in the Intel x86 hardware.
Chapters
- Base GEM
- statement of the problem
- executable grammars
- simple examples
- Robust GEM
- pre-entered character classes
- using nowhite, pretty, invert
- GEM with builtin nowhite and chars
- using multi-character input and output symbols
- left-associative arithmetic expressions
- X86 floating point stack
- GEM with builtin multichar symbols
- using Kleene * and + in executable grammars
- Running Intel X86 code
- X86 Assembler
- calculator
- atoi
- Plenty Phrase Names
- BNF
- self
- pretty
Notes
The origin of the idea is a undergraduate thesis (UC Santa Cruz, 1978) written by Doug Michels under the supervsion of Bill McKeeman.
The title is inspired by: Guy Steele's 1998 OOPSLA talk Growing a Language.
Thanks to Steve Johnson for critical advice in the preparation of this presentation.
The default font sizes in Firefox are uncomfortably large for this paper. Try [view][edit][zoom][text only][zoom out][zoom out].
References
- Bill McKeeman Compiler and Compiler Course
- Wikipedia Mealy Machine
- Guy Steele Growing a Language.
- Doug Michels A concise extensible metalanguage for translator implementation
Signatures
- Bill McKeeman , MathWorks Fellow
- Lu He, Computer Science Department, Dartmouth
An earlier version was presented to the Computer Science Colloquium, Stanford, March 4, 2009
【推荐】还在用 ECharts 开发大屏?试试这款永久免费的开源 BI 工具!
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 对象命名为何需要避免'-er'和'-or'后缀
· SQL Server如何跟踪自动统计信息更新?
· AI与.NET技术实操系列:使用Catalyst进行自然语言处理
· 分享一个我遇到过的“量子力学”级别的BUG。
· Linux系列:如何调试 malloc 的底层源码
· JDK 24 发布,新特性解读!
· C# 中比较实用的关键字,基础高频面试题!
· .NET 10 Preview 2 增强了 Blazor 和.NET MAUI
· SQL Server如何跟踪自动统计信息更新?
· windows下测试TCP/UDP端口连通性