-
Notifications
You must be signed in to change notification settings - Fork 15
Fold
Folding replaces every expression that matches with the right hand side of the given nonterminal's definition with the nonterminal itself. As with unfold, fold works on the scope of the grammar, and its impact can be limited to one labelled production rule or to all the productions belonging to one nonterminal. Regardless of the specified scope, folding is not applied to the definition of the argument nonterminal.
Since this transformation strives to preserve the language, it needs a horizontal definition to work. When only one of several existing definitions is used for folding, it would actually increase the semantics of the language after transformation: the corresponding XBGF command is called upgrade.
fold:
nonterminal in::scope?
Very much like unfolding, folding can take place locally. For instance,
[l1] foo:
wez*
[l2] qux:
wez*
bar:
wez*
After using this transformation:
fold(bar in foo);
Will look like this:
[l1] foo:
bar
[l2] qux:
wez*
bar:
wez*
shared/prolog/xbgf1.pro
shared/rascal/src/transform/library/Chaining.rsc
shared/rascal/src/transform/library/Folding.rsc
shared/xsd/xbgf.xsd
- Fold is a part of XBGF