|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectxtc.tree.Visitor
xtc.parser.GrammarVisitor
xtc.parser.Inliner
public class Inliner
Visitor to inline productions. If cost-based inlining is enabled,
this visitor inlines productions with a cost
estimate less or equal to the maximum cost.
However, to avoid changing a production's semantic value,
cost-based inlining is limited to void, text-only, and token-level
productions. Independent of whether cost-based inlining is enabled
or not, this visitor inlines productions that are referenced from a
production consisting solely of a nonterminal (which, optionally,
may be bound to CodeGenerator.VALUE). Note that generic
productions are never inlined; neither are productions with the
state attribute.
marked as such.
Similarly, token-level productions need to have beeen marked as such. Further note that, if this visitor
inlines productions, the resulting grammar needs to be simplified before further processing. Also note that
this visitor may create new opportunities for the elimination of dead productions. This
visitor assumes that the entire grammar is contained in a single
module.
| Field Summary | |
|---|---|
protected boolean |
attributeState
Flag for whether the grammar has the state attribute. |
static boolean |
INLINE_PERSISTENT
The flag for whether to inline non-transient productions. |
protected boolean |
inlined
Flag for whether this production inliner has inlined a production. |
static int |
MAX_COST
The maximum cost for inlining productions at arbitrary positions. |
| Fields inherited from class xtc.parser.GrammarVisitor |
|---|
analyzer, isBound, isLastElement, isPredicate, isRepeatedOnce, isTopLevel, isVoided, needsSequence, runtime, transformInPlace |
| Constructor Summary | |
|---|---|
Inliner(Runtime runtime,
Analyzer analyzer)
Create a new production inliner. |
|
| Method Summary | |
|---|---|
protected void |
inlined(Production p)
Record that the specified production has been inlined and, if necessary, print a message to the console. |
protected boolean |
isBasic(Production p)
Determine whether the specified production is void, text-only, or token-level. |
java.lang.Object |
visit(Module m)
Process the specified grammar. |
Element |
visit(NonTerminal nt)
Visit the specified nonterminal. |
| Methods inherited from class xtc.parser.GrammarVisitor |
|---|
visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit |
| Methods inherited from class xtc.tree.Visitor |
|---|
dispatch, equals, hashCode, iterate, map, mapInPlace, unableToVisit, visit |
| Methods inherited from class java.lang.Object |
|---|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int MAX_COST
public static final boolean INLINE_PERSISTENT
protected boolean attributeState
protected boolean inlined
| Constructor Detail |
|---|
public Inliner(Runtime runtime,
Analyzer analyzer)
runtime - The runtime.analyzer - The analyzer utility.| Method Detail |
|---|
protected boolean isBasic(Production p)
p - The production.
true if the production is either text-only
or void.protected void inlined(Production p)
p - The production.public java.lang.Object visit(Module m)
visit in class GrammarVisitorm - The grammar module.
Boolean.TRUE if the grammar has been modified,
otherwise Boolean.FALSE.public Element visit(NonTerminal nt)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||