dimelab dimelab: shrinking the gap between talk and action.

Parsing to Object-Oriented Dispatch with Gramm

Old-school Unix types will remember the magnificent compiler-generator tools lex and yacc. The modern GNU versions of these tools are flex and bison, and these are some very fine tools despite their advanced age. Our founder has been a long-time user of these tools in their various incarnations and his taste for language design is directly linked to some long-ago exercises in general-purpose data representation that relied heavily on those tools. Still, their age does show (along with that of our founder). Nowadays, the young folks have a prediliction for new-fangled stuff like object-oriented programming. Never fear, with a modest bit of hackery, the pleasures and gratifications of object-oriented programming can be neatly coupled with your custom languages.

Our gramm module provides a meta language for specification of flex, bison, and C++ object-oriented parsers. The gramm language lets you specify a formal grammar, including lexical matches (per flex) and syntax rules (per bison), which deals in your application-specific object-oriented elements. An object-oriented parser is also generated with notifications corresponding grammar productions and lexical events. The interface to these notifications also uses your application-specific objects. In use, the processing of expressions in your custom language is converted to a stream of these parser notifications. A pleasant environment in which to provide your custom languages!

The gramm module is part of our dimekit toolset and is included for use by licensees of the toolset. Because it's not much more than a neat wrap on seriously old-school technology, implementing a sensible idiom for getting from syntax-directed translation to object-oriented notification, we haven't felt any impetus to file for patent protection for gramm.