Growing Languages with Metamorphic Syntax Macros
DOI:
https://doi.org/10.7146/brics.v7i24.20151Resumé
"From now on, a main goal in designing a language should be to plan for growth."Guy Steele: Growing a Language, OOPSLA'98 invited talk.
We present our experiences with a syntax macro language augmented with a concept of metamorphisms. We claim this forms a general abstraction mechanism for
growing (domain-specific) extensions of programming languages.
Our syntax macros are similar to previous work in that the compiler accepts collections of grammatical rules that extend the syntax in which a subsequent program may be written. We exhibit how almost arbitrary extensions can be defined in a purely declarative manner without resorting to compile-time programming. The macros are
thus terminating in that parsing is guaranteed to terminate, hygienic since full-conversion eliminates the risk of name clashes, and transparent such that subsequent phases in the compiler are unaware of them. Error messages from later phases in the compiler are tracked through all macro invocations to pinpoint their sources in the extended syntax. A concept of metamorphic rules allows the arguments of a macro to be defined
in an almost arbitrary meta level grammar and then to be morphed into the host language. We show through examples how creative use of metamorphic syntax macros may be used not only to create convenient shorthand notation but also to introduce new
language concepts and mechanisms. In fact, whole new languages can be created at surprisingly low cost. The resulting programs are significantly easier to understand and maintain.
This work is fully implemented as part of the system for defining
interactive Web services, but could find use in many other languages.
Downloads
Publiceret
2000-01-24
Citation/Eksport
Brabrand, C., & Schwartzbach, M. I. (2000). Growing Languages with Metamorphic Syntax Macros. BRICS Report Series, 7(24). https://doi.org/10.7146/brics.v7i24.20151
Nummer
Sektion
Artikler
Licens
Authors who publish with this journal agree to the following terms:- Authors retain copyright and grant the journal right of first publication with the work simultaneously licensed under a Creative Commons Attribution License that allows others to share the work with an acknowledgement of the work's authorship and initial publication in this journal.
- Authors are able to enter into separate, additional contractual arrangements for the non-exclusive distribution of the journal's published version of the work (e.g., post it to an institutional repository or publish it in a book), with an acknowledgement of its initial publication in this journal.
- Authors are permitted and encouraged to post their work online (e.g., in institutional repositories or on their website) prior to and during the submission process, as it can lead to productive exchanges, as well as earlier and greater citation of published work (See The Effect of Open Access).