|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--net.percederberg.grammatica.parser.Analyzer
A parse tree analyzer. This class provides callback methods that may be used either during parsing, or for a parse tree traversal. This class should be subclassed to provide adequate handling of the parse tree nodes. The general contract for the analyzer class does not guarantee a strict call order for the callback methods. Depending on the type of parser, the enter() and exit() methods for production nodes can be called either in a top-down or a bottom-up fashion. The only guarantee provided by this API, is that the calls for any given node will always be in the order enter(), child(), and exit(). If various child() calls are made, they will be made from left to right as child nodes are added (to the right).
Constructor Summary | |
Analyzer()
Creates a new parse tree analyzer. |
Method Summary | |
Node |
analyze(Node node)
Analyzes a parse tree node by traversing all it's child nodes. |
protected void |
child(Production node,
Node child)
Called when adding a child to a parse tree node. |
protected void |
enter(Node node)
Called when entering a parse tree node. |
protected Node |
exit(Node node)
Called when exiting a parse tree node. |
protected Node |
getChildAt(Node node,
int pos)
Returns a child at the specified position. |
protected Node |
getChildWithId(Node node,
int id)
Returns the first child with the specified id. |
protected int |
getIntValue(Node node,
int pos)
Returns the node integer value at the specified position. |
protected java.lang.String |
getStringValue(Node node,
int pos)
Returns the node string value at the specified position. |
protected java.lang.Object |
getValue(Node node,
int pos)
Returns the node value at the specified position. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public Analyzer()
Method Detail |
public Node analyze(Node node) throws ParserLogException
node
- the parse tree node to process
ParserLogException
- if the node analysis discovered
errorsprotected void enter(Node node) throws ParseException
node
- the node being entered
ParseException
- if the node analysis discovered errorsprotected Node exit(Node node) throws ParseException
node
- the node being exited
ParseException
- if the node analysis discovered errorsprotected void child(Production node, Node child) throws ParseException
node
- the parent nodechild
- the child node, or null
ParseException
- if the node analysis discovered errorsprotected Node getChildAt(Node node, int pos) throws ParseException
node
- the parent nodepos
- the child position
ParseException
- if either the node or the child node
was nullprotected Node getChildWithId(Node node, int id) throws ParseException
node
- the parent nodeid
- the child node id
ParseException
- if the node was null, or a child node
couldn't be foundprotected java.lang.Object getValue(Node node, int pos) throws ParseException
node
- the parse tree nodepos
- the child position
ParseException
- if either the node or the value was nullprotected int getIntValue(Node node, int pos) throws ParseException
node
- the parse tree nodepos
- the child position
ParseException
- if either the node was null, or the
value wasn't an integerprotected java.lang.String getStringValue(Node node, int pos) throws ParseException
node
- the parse tree nodepos
- the child position
ParseException
- if either the node was null, or the
value wasn't a string
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |