|
||||||||||
| 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.ChoiceExpander
public class ChoiceExpander
Visitor to expand choices by inlining productions. This visitor inlines transient productions if they are essentially the only element appearing in ordered choices' alternatives.
Note that this visitor requires that text-only productions have been marked as such, that allvalue
elements have been added to the grammar (notably, for generic
productions), and that the grammar's productions have been reference counted. Also note that this visitor
may result in new opportunities for the elimination of dead productions.
This visitor assumes that the entire grammar is contained in a
single module.
| Nested Class Summary | |
|---|---|
static class |
ChoiceExpander.Mode
The processing mode. |
| Field Summary | |
|---|---|
protected boolean |
hasState
The flag for whether the grammar has the state attribute. |
protected ChoiceExpander.Mode |
mode
The current processing mode. |
| Fields inherited from class xtc.parser.GrammarVisitor |
|---|
analyzer, isBound, isLastElement, isPredicate, isRepeatedOnce, isTopLevel, isVoided, needsSequence, runtime, transformInPlace |
| Constructor Summary | |
|---|---|
ChoiceExpander(Runtime runtime,
Analyzer analyzer)
Create a new choice expander. |
|
| Method Summary | |
|---|---|
protected NonTerminal |
candidate(Sequence alternative,
boolean top)
Determine whether the specified alternative is a candidate for replacement. |
protected void |
inlined(Production p)
Record that the specified production has been inlined and, if necessary, print a message to the console. |
java.lang.Object |
visit(Module m)
Visit the specified grammar. |
Element |
visit(OrderedChoice c)
Visit the specified ordered choice. |
Element |
visit(Sequence s)
Visit the specified sequence. |
Element |
visit(ValueElement v)
Visit the specified value element. |
| Methods inherited from class xtc.parser.GrammarVisitor |
|---|
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 |
|---|
protected boolean hasState
protected ChoiceExpander.Mode mode
| Constructor Detail |
|---|
public ChoiceExpander(Runtime runtime,
Analyzer analyzer)
runtime - The runtime.analyzer - The analyzer utility.| Method Detail |
|---|
protected NonTerminal candidate(Sequence alternative,
boolean top)
null.
alternative - The alternative.top - The flag for whether the alternative appears in a
top-level choice.
protected void inlined(Production p)
p - The production.public java.lang.Object visit(Module m)
visit in class GrammarVisitorpublic Element visit(OrderedChoice c)
visit in class GrammarVisitorpublic Element visit(Sequence s)
visit in class GrammarVisitorpublic Element visit(ValueElement v)
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||