| xtc.parser.GrammarVisitor xtc.parser.Inliner
Inliner | public class Inliner extends GrammarVisitor (Code) | | Visitor to inline productions. If cost-based inlining is enabled,
this visitor inlines productions with a
CostEstimator costestimate less or equal to the
Inliner.MAX_COST 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.
Note that, to be effective, this visitor requires that
text-only productions have been
TextTester marked as such.
Similarly, token-level productions need to have beeen
Tokenizer marked as such. Further note that, if this visitor
inlines productions, the resulting grammar needs to be
Simplifier simplified before further processing. Also note that
this visitor may create 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.52 $ |
Field Summary | |
final public static boolean | INLINE_PERSISTENT The flag for whether to inline non-transient productions. | final public static int | MAX_COST The maximum cost for inlining productions at arbitrary positions. | protected boolean | attributeState Flag for whether the grammar has the state attribute. | protected boolean | inlined Flag for whether this production inliner has inlined a production. |
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.
Parameters: p - The production. | public Object | visit(Module m) Process the specified grammar.
Parameters: m - The grammar module. | public Element | visit(NonTerminal nt) Visit the specified nonterminal. |
INLINE_PERSISTENT | final public static boolean INLINE_PERSISTENT(Code) | | The flag for whether to inline non-transient productions.
|
MAX_COST | final public static int MAX_COST(Code) | | The maximum cost for inlining productions at arbitrary positions.
|
attributeState | protected boolean attributeState(Code) | | Flag for whether the grammar has the state attribute.
|
inlined | protected boolean inlined(Code) | | Flag for whether this production inliner has inlined a production.
|
Inliner | public Inliner(Runtime runtime, Analyzer analyzer)(Code) | | Create a new production inliner.
Parameters: runtime - The runtime. Parameters: analyzer - The analyzer utility. |
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. |
isBasic | protected boolean isBasic(Production p)(Code) | | Determine whether the specified production is void, text-only, or
token-level.
Parameters: p - The production. true if the production is either text-onlyor void. |
visit | public Object visit(Module m)(Code) | | Process the specified grammar.
Parameters: m - The grammar module. Boolean.TRUE if the grammar has been modified,otherwise Boolean.FALSE . |
|
|