SableCC, an object-oriented compiler framework
E.M. Gagnon, Laurie Jane Hendren · Technology of Object-Oriented Languages and Systems · 2002
In this paper, we introduce SableCC, an object-oriented framework that generates compilers (and interpreters) in the Java programming language. This framework is based on two fundamental design decisions. Firstly, the framework uses object-oriented techniques to automatically build a strictly-typed abstract syntax tree that matches the grammar of the compiled language which simplifies debugging. Secondly, the framework generates tree-walker classes using an extended version of the visitor design pattern which enables the implementation of actions on the nodes of the abstract syntax tree using inheritance. These two design decisions lead to a tool that supports a shorter development cycle for constructing compilers. To demonstrate the simplicity of the framework, we present all the steps of building an interpreter for a mini-BASIC language. This example could be easily modified to provide on embedded scripting language in an application. We also provide a brief description of larger systems that have been implemented using the SableCC tool. We conclude that the use of object-oriented techniques significantly reduces the length of the programmer written code, can shorten the development time and finally, makes the code easier to read and maintain.
Cited by 180 works. doi:10.1109/tools.1998.711009
Authors
References
- Design Patterns: Elements of Reusable Object-Oriented Software
- Introduction to automata theory, languages and computation
- Compilers: Principles, Techniques, and Tools
- Yacc : Yet Another Compiler Compiler
- The Java Language Specification
- Java Virtual Machine Specification
- Lex—a lexical analyzer generator
- The FORTRAN automatic coding system
- Points-to analysis in almost linear time
- The TEX Book