|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectxtc.tree.Visitor
xtc.parser.Generifier
public class Generifier
Visitor to add generic nodes as semantic values.
For any production with pseudotype "generic" that
does not contain any direct left-recursions (which is also called a
generic node production), this visitor adds the appropriate generic node value elements, which create a
generic node as the productions' semantic
value. The children of such a generic node are the matched
component values of the production, though voided elements, void
nonterminals, and character terminals are not included. If an
alternative assigns CodeGenerator.VALUE either through a
binding or a semantic action, that alternative's semantic value is
the specified semantic value and not a newly generated generic
node. This visitor requires that all nested choices that do not
appear as the last element in a sequence have been lifted. It also
assumes that the entire grammar is contained in a single module.
Note that this visitor does not process generic productions
that contain direct left-recursions; they are processed by DirectLeftRecurser.
| Field Summary | |
|---|---|
protected Analyzer |
analyzer
The analyzer utility. |
protected java.util.List<Binding> |
children
The list of variables representing the children of the generic node to be created. |
static java.lang.String |
MARKER
The marker for synthetic variables. |
protected java.util.List<NodeMarker> |
markers
The list of node markers. |
protected Runtime |
runtime
The runtime. |
| Constructor Summary | |
|---|---|
Generifier(Runtime runtime,
Analyzer analyzer)
Create a new generifier. |
|
| Method Summary | |
|---|---|
protected Binding |
bind(Element e)
Create a binding for the specified element. |
static boolean |
isGeneric(FullProduction p)
Determine whether the specified production is a generic node or a generic recursion production. |
static boolean |
isGenericNode(FullProduction p)
Determine whether the specified production is a generic node production. |
static boolean |
isGenericRecursion(FullProduction p)
Determine whether the specified production is a generic recursion production. |
static void |
markGenericNode(FullProduction p,
boolean verbose)
Mark the specified production as a generic node production. |
static void |
markGenericRecursion(FullProduction p,
boolean verbose)
Mark the specified production as a generic recursion production. |
Element |
visit(Binding b)
Visit the specified binding. |
Element |
visit(Element e)
Visit the specified element. |
void |
visit(FullProduction p)
Visit the specified production. |
void |
visit(Module m)
Visit the specified grammar. |
Element |
visit(NodeMarker m)
Visit the specified node marker. |
Element |
visit(NonTerminal nt)
Visit the specified nonterminal. |
Element |
visit(NullLiteral l)
Visit the specified null literal. |
Element |
visit(Option o)
Visit the specified option. |
Element |
visit(OrderedChoice c)
Visit the specified ordered choice. |
Element |
visit(ParseTreeNode n)
Visit the specified parse tree node. |
Element |
visit(Repetition r)
Visit the specified repetition. |
Element |
visit(Sequence s)
Visit the specified sequence. |
Element |
visit(StringLiteral l)
Visit the specified string literal. |
Element |
visit(StringMatch m)
Visit the specified string match. |
| 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 java.lang.String MARKER
protected final Runtime runtime
protected final Analyzer analyzer
protected java.util.List<Binding> children
protected java.util.List<NodeMarker> markers
| Constructor Detail |
|---|
public Generifier(Runtime runtime,
Analyzer analyzer)
runtime - The runtime.analyzer - The analyzer utility.| Method Detail |
|---|
protected Binding bind(Element e)
e - The element to bind.
public void visit(Module m)
public void visit(FullProduction p)
public Element visit(OrderedChoice c)
public Element visit(Repetition r)
public Element visit(Option o)
public Element visit(Sequence s)
public Element visit(Binding b)
public Element visit(StringMatch m)
public Element visit(NonTerminal nt)
public Element visit(StringLiteral l)
public Element visit(ParseTreeNode n)
public Element visit(NullLiteral l)
public Element visit(NodeMarker m)
public Element visit(Element e)
public static void markGenericNode(FullProduction p,
boolean verbose)
p - The production.verbose - The flag for whether to be verbose.
public static void markGenericRecursion(FullProduction p,
boolean verbose)
p - The production.verbose - The flag for whether to be verbose.public static boolean isGeneric(FullProduction p)
p - The production.
true if the specified production is a generic
node or generic recursion production.public static boolean isGenericNode(FullProduction p)
p - The production.
true if the specified production is
a generic node production.public static boolean isGenericRecursion(FullProduction p)
p - The production.
true if the specified production is
a generic recursion production.DirectLeftRecurser
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||