-
Notifications
You must be signed in to change notification settings - Fork 15
Unchain
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.
unchain:
production
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.
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
shared/prolog/xbgf1.pro
shared/prolog/xbgf2.pro
shared/rascal/src/transform/library/Chaining.rsc
shared/xsd/xbgf.xsd
- Unchain is a part of XBGF