conferences | speakers | series

Migrating code with SmaCC

home

Migrating code with SmaCC
FOSDEM 2018

SmaCC is a LALR/GLR parser generation framework written in Smalltalk. It has support for creating abstract syntax trees (ASTs) and source code transformations. Several software projects have been migrated to other languages using SmaCC.

Many companies have large software projects that have been developed over decades. Many times these projects use older technologies that may not support newer features that are wanted, and it may be difficult to hire resources that want to work with the older technologies. To solve these issues, sometimes companies decide to use a rules-based migration to convert their code base to a new language. Over the past 20 years, I have worked on several such migration projects and have developed SmaCC for such projects.

Creating a rules-based migrator is similar to normal software development. Instead of creating classes and methods, you create transformation rules. A typical migration project may need hundreds if not thousands of transformation rules. SmaCC supports both imperative, code-based, transformations as well as declarative, pattern-based, transformations. While an individual rule may be simple and easy to implement, there can be interactions between the rules that cause problems when running in a group. SmaCC provides support for debugging the rules. It has a custom debugger that knows about AST nodes and transformation rules, as well as a previewer that shows what rule changed a particular piece of code. Together all of these SmaCC features, from the AST generation to the custom debug support, allow me to more quickly migrate projects.

Speakers: John Brant