unfold - grammarware/slps GitHub Wiki

The most basic unfolding transformation searches the scope for all the instances of the given nonterminal usage and replaces such occurrences with the defining expression of that nonterminal. By default the scope of the transformation is the full grammar, but it can be limited to all the definitions of one nonterminal or to one labelled production. Regardless of the specified scope, unfolding is not applied to the definition of the argument nonterminal.

Almost all the unfold transformations used in Java Language Specification case study are restricted in scope by a nonterminal. The reason for such statistics is that when language engineers want to give up the nonterminal, they use the inline transformations. However, unfold usually happens as a part of sequences with fold, downgrade, disappear, deyaccify, distribute, etc. — in which case it is only natural to limit the impact of every step.

The definition that is being unfolded is assumed to be horizontal, i.e. to consist of one single production. See the section on refactorings for more information about horizontal and vertical definitions.

Syntax

unfold:
        nonterminal in::scope?

Example

Given the input:

[l1] foo:
        bar
[l2] qux:
        bar
bar:
        wez*

After using this transformation:

unfold(bar);

Will look like this:

[l1] foo:
        wez*
[l2] qux:
        wez*
bar:
        wez*

Relevant files

See also

  • Unfold is a part of XBGF

Contributors

⚠️ **GitHub.com Fallback** ⚠️