inline - grammarware/slps GitHub Wiki
When this transformation is performed, an existing definition is eliminated by inlining. This means that the argument nonterminal identifies the (horizontal) definition that is to be unfolded and stripped away from the grammar.
The semantics of inline is that of a sequential composition of unfold and eliminate.
inline:
nonterminal
The inline transformation is by far the most used in Java Language Specification case study. One of the reasons is what we call layering: in particular expressions and statements are introduced in the “readable” grammar with a set of related nonterminals: LabeledStatement
, IfThenElseStatement
, WhileStatement
, ForStatement
, etc, and CastExpression
, PreIncrementExpression
, PreDecrementExpression
, PostfixExpression
, etc. The “implementable” grammar takes another approach, just listing all the alternatives in the productions for Statement and Expression. In order to converge these two variants, a lot of inlining transformations are needed. This can also be apparent from the statistics table, that demonstrates that targets that converge only “readable” or only “implementable” grammars, require less than ten inline transformations each, while each target that takes both readable and implementable grammars in, contains 67–100 inline transformations in convergence path.
An example follows. When we have:
foo:
wez
bar:
wez ".." wez
wez:
qux*
After using this transformation:
inline(wez);
It will look like this:
foo:
qux*
bar:
qux* ".." qux*
shared/prolog/xbgf1.pro
shared/prolog/xbgf2.pro
shared/rascal/src/transform/library/Folding.rsc
shared/xsd/xbgf.xsd
- Inline is a part of XBGF