Grammar fragments fly first-class

  • Authors:
  • Marcos Viera;Doaitse Swierstra;Atze Dijkstra

  • Affiliations:
  • Universidad de la República, Montevideo, Uruguay;Utrecht University, Utrecht, The Netherlands;Utrecht University, Utrecht, The Netherlands

  • Venue:
  • Proceedings of the Twelfth Workshop on Language Descriptions, Tools, and Applications
  • Year:
  • 2012

Quantified Score

Hi-index 0.00

Visualization

Abstract

We present a Embedded Domain Specific language in the form of a Haskell library (EDSL) for expressing grammar (fragments), using typed abstract syntax with observable references. Thus grammar fragments have become fully typed, first-class Haskell values. We can analyze and transform such representations and generate parsers from them. What makes our approach special is that we can combine embedded grammar fragments on the fly, i.e. after they have been compiled and that the Haskell type system is used to check the consistency of a collection of combined fragments. We show how we can extend an initial, limited grammar embedded in a compiler with new syntactic constructs, either by introducing new non-terminals or by adding new productions for existing non-terminals. We do not impose any restrictions on the individual grammar fragments, nor on the structure as a whole.