SableCC, an Object-Oriented Compiler Framework

  • Authors:
  • Etienne M. Gagnon;Laurie J. Hendren

  • Affiliations:
  • -;-

  • Venue:
  • TOOLS '98 Proceedings of the Technology of Object-Oriented Languages and Systems
  • Year:
  • 1998

Quantified Score

Hi-index 0.00

Visualization

Abstract

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 an 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.