Skip to content
grammarware edited this page Jan 19, 2013 · 3 revisions

Unchaining is a disciplined form of inlining. The argument production rule must occur in the input grammar, and it must be a chain production rule, i.e., a production rule with a nonterminal as its defining expression. The latter nonterminal is the one whose definition is to be inlined; it must not have any occurrences except in the chain production at hand.

The unchain transformation does not increase the expressivity of the transformational language: technically, it is nothing more than an inline with a precondition. However, this particular precondition seems useful and not uncommon when dealing with layered grammars.

Syntax

unchain:
        production

Semantics

Chain productions are not commonly encountered in grammars of mainstream programming languages. However, when converging grammars that hail from different kinds of sources (i.e., different extraction processes) it can be frequently needed to align grammars that use chain productions with grammars that use labelled ones.

Example

Consider this grammar:

[constant] expr:
        int
[binary] expr:
        binexpr
binexpr:
        expr op expr

After performing this transformation step:

unchain(
 [binary] expr:
        binexpr
);

The auxiliary nonterminal symbol is gone, as is the chain production:

[constant] expr:
        int
[binary] expr:
        expr op expr

Relevant files

See also

  • Unchain is a part of XBGF

Contributors

Clone this wiki locally