| xtc.parser.GrammarVisitor xtc.parser.ChoiceExpander
ChoiceExpander | public class ChoiceExpander extends GrammarVisitor (Code) | | 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 all
ValueElement valueelements have been added to the grammar (notably, for generic
productions), and that the grammar's productions have been
ReferenceCounter reference counted . Also note that this visitor
may result in new opportunities for the
DeadProductionEliminator elimination of dead productions .
This visitor assumes that the entire grammar is contained in a
single module.
author: Robert Grimm version: $Revision: 1.34 $ |
Inner Class :public static enum Mode | |
Field Summary | |
protected boolean | hasState The flag for whether the grammar has the state attribute. | protected Mode | mode The current processing mode. |
hasState | protected boolean hasState(Code) | | The flag for whether the grammar has the state attribute.
|
mode | protected Mode mode(Code) | | The current processing mode.
|
ChoiceExpander | public ChoiceExpander(Runtime runtime, Analyzer analyzer)(Code) | | Create a new choice expander.
Parameters: runtime - The runtime. Parameters: analyzer - The analyzer utility. |
candidate | protected NonTerminal candidate(Sequence alternative, boolean top)(Code) | | Determine whether the specified alternative is a candidate for
replacement. If the alternative is a candidate, this method
returns the nonterminal for inlining. Otherwise, it returns
null .
Parameters: alternative - The alternative. Parameters: top - The flag for whether the alternative appears in atop-level choice. The candidate nonterminal. |
inlined | protected void inlined(Production p)(Code) | | Record that the specified production has been inlined and, if
necessary, print a message to the console.
Parameters: p - The production. |
|
|