Distribute - grammarware/slps GitHub Wiki
Distribute sequential composition over choices so that choices are pulled out of sequences. The transformation is either attempted for all productions of a nonterminal or for a specific one appointed by its label.
Syntax
distribute:
scope
Semantics
In fact, distribute is nothing more than an automated version of factor that aggressively pushes all the choices that can be found in a production outwards.
This transformation is apparently non-injective, hence, it is impossible to have a complete inverse of it. A more general factor transformation, however, is as capable of emulating distribute's effect as it is capable of doing the reverse thing.
Example
For instance,
foo:
bar (qux | wez)
After using this transformation:
distribute( in foo );
Will look like this:
foo:
bar qux
bar wez
Relevant files
shared/prolog/xbgf1.pro
shared/prolog/xbgf2.pro
shared/rascal/src/transform/library/Factoring.rsc
shared/xsd/xbgf.xsd
See also
- Distribute is a part of XBGF