Modular grammar specification

Adrian Johnstone, Elizabeth Scott, Mark van den Brand

Research output: Contribution to journalArticlepeer-review

363 Downloads (Pure)


We establish a semantics for building grammars from a modularised speci-
cation in which modules are able to delete productions from imported nonterminals.
Our goal is to allow a precise answer to the question: `what character
level language does this grammar generate' in the face of dicult issues such
as the mutual embedding of languages that have dierent whitespace and
commenting conventions. Our technique is to automatically generate a character
level grammar from grammars written at token level in the conventional
way; the grammar is constructed from modules each of which may have its
own whitespace convention. Modules have import lists of nonterminals; some
or all of an imported nonterminal's productions may be suppressed at import
time. There are two basic import mechanisms which (a) reference or
(b) clone an imported nonterminal's productions. We conclude with a set
of examples using the concrete syntax from our ART GLL parser generator
Original languageEnglish
Pages (from-to)23-43
Number of pages21
JournalScience of Computer Programming
Early online date1 Oct 2013
Publication statusPublished - 1 Jul 2014


  • Context Free Grammar, Modularity, Whitespace processing

Cite this