two-level grammars

views updated

two-level grammars (VW-grammars, van Wijngaarden grammars) A generalization of context-free grammars that enables non-context-free aspects of a language to be specified. They were developed by A. van Wijngaarden and used in the formal definition of Algol 68. The productions of a two-level grammar are split into two parts: those in the first part are called hyperrules and act as templates for context-free productions; those in the second part are called metaproductions. The metaproductions are context-free productions and they define the set of nonterminals to be used in the hyperrules. The power of two-level grammars comes from the fact that the hyperrules can be templates for an infinite set of productions. It is in this way that they are used to define non-context-free aspects of a language.