

Public Member Functions | |
| Object | dupNode (Object t) |
| Object | create (Token payload) |
| Token | createToken (int tokenType, String text) |
| Token | createToken (Token fromToken) |
| void | setTokenBoundaries (Object t, Token startToken, Token stopToken) |
| int | getTokenStartIndex (Object t) |
| int | getTokenStopIndex (Object t) |
| String | getText (Object t) |
| int | getType (Object t) |
| Token | getToken (Object t) |
| Object | getChild (Object t, int i) |
| int | getChildCount (Object t) |
| Object | getParent (Object t) |
| void | setParent (Object t, Object parent) |
| int | getChildIndex (Object t) |
| void | setChildIndex (Object t, int index) |
| void | replaceChildren (Object parent, int startChildIndex, int stopChildIndex, Object t) |
To get your parser to build nodes of a different type, override create(Token), errorNode(), and to be safe, YourTreeClass.dupNode(). dupNode is called to duplicate nodes during rewrite operations.
Definition at line 43 of file CommonTreeAdaptor.java.
| Object org.antlr.runtime.tree.CommonTreeAdaptor.dupNode | ( | Object | t | ) |
Duplicate a node. This is part of the factory; override if you want another kind of node to be built.
I could use reflection to prevent having to override this but reflection is slow.
Implements org.antlr.runtime.tree.TreeAdaptor.
Definition at line 50 of file CommonTreeAdaptor.java.
| Object org.antlr.runtime.tree.CommonTreeAdaptor.create | ( | Token | payload | ) |
Create a tree node from Token object; for CommonTree type trees, then the token just becomes the payload. This is the most common create call.
Override if you want another kind of node to be built.
Implements org.antlr.runtime.tree.TreeAdaptor.
Reimplemented in org.antlr.runtime.tree.TreeWizard.TreePatternTreeAdaptor.
Definition at line 57 of file CommonTreeAdaptor.java.
| Token org.antlr.runtime.tree.CommonTreeAdaptor.createToken | ( | int | tokenType, | |
| String | text | |||
| ) | [virtual] |
Tell me how to create a token for use with imaginary token nodes. For example, there is probably no input symbol associated with imaginary token DECL, but you need to create it as a payload or whatever for the DECL node as in ^(DECL type ID).
If you care what the token payload objects' type is, you should override this method and any other createToken variant.
Implements org.antlr.runtime.tree.BaseTreeAdaptor.
Definition at line 69 of file CommonTreeAdaptor.java.
Tell me how to create a token for use with imaginary token nodes. For example, there is probably no input symbol associated with imaginary token DECL, but you need to create it as a payload or whatever for the DECL node as in ^(DECL type ID).
This is a variant of createToken where the new token is derived from an actual real input token. Typically this is for converting '{' tokens to BLOCK etc... You'll see
r : lc='{' ID+ '}' -> ^(BLOCK[$lc] ID+) ;
If you care what the token payload objects' type is, you should override this method and any other createToken variant.
Implements org.antlr.runtime.tree.BaseTreeAdaptor.
Definition at line 87 of file CommonTreeAdaptor.java.
| void org.antlr.runtime.tree.CommonTreeAdaptor.setTokenBoundaries | ( | Object | t, | |
| Token | startToken, | |||
| Token | stopToken | |||
| ) |
Track start/stop token for subtree root created for a rule. Only works with Tree nodes. For rules that match nothing, seems like this will yield start=i and stop=i-1 in a nil node. Might be useful info so I'll not force to be i..i.
Implements org.antlr.runtime.tree.TreeAdaptor.
Definition at line 96 of file CommonTreeAdaptor.java.
| int org.antlr.runtime.tree.CommonTreeAdaptor.getTokenStartIndex | ( | Object | t | ) |
Get the token start index for this subtree; return -1 if no such index
Implements org.antlr.runtime.tree.TreeAdaptor.
Definition at line 112 of file CommonTreeAdaptor.java.
| int org.antlr.runtime.tree.CommonTreeAdaptor.getTokenStopIndex | ( | Object | t | ) |
Get the token stop index for this subtree; return -1 if no such index
Implements org.antlr.runtime.tree.TreeAdaptor.
Definition at line 119 of file CommonTreeAdaptor.java.
| String org.antlr.runtime.tree.CommonTreeAdaptor.getText | ( | Object | t | ) |
Reimplemented from org.antlr.runtime.tree.BaseTreeAdaptor.
Definition at line 126 of file CommonTreeAdaptor.java.
| int org.antlr.runtime.tree.CommonTreeAdaptor.getType | ( | Object | t | ) |
For tree parsing, I need to know the token type of a node
Reimplemented from org.antlr.runtime.tree.BaseTreeAdaptor.
Definition at line 133 of file CommonTreeAdaptor.java.
| Token org.antlr.runtime.tree.CommonTreeAdaptor.getToken | ( | Object | t | ) |
What is the Token associated with this node? If you are not using CommonTree, then you must override this in your own adaptor.
Implements org.antlr.runtime.tree.TreeAdaptor.
Definition at line 144 of file CommonTreeAdaptor.java.
| Object org.antlr.runtime.tree.CommonTreeAdaptor.getChild | ( | Object | t, | |
| int | i | |||
| ) |
Get a child 0..n-1 node
Reimplemented from org.antlr.runtime.tree.BaseTreeAdaptor.
Definition at line 151 of file CommonTreeAdaptor.java.
| int org.antlr.runtime.tree.CommonTreeAdaptor.getChildCount | ( | Object | t | ) |
How many children? If 0, then this is a leaf node
Reimplemented from org.antlr.runtime.tree.BaseTreeAdaptor.
Definition at line 158 of file CommonTreeAdaptor.java.
| Object org.antlr.runtime.tree.CommonTreeAdaptor.getParent | ( | Object | t | ) |
Who is the parent node of this node; if null, implies node is root. If your node type doesn't handle this, it's ok but the tree rewrites in tree parsers need this functionality.
Implements org.antlr.runtime.tree.TreeAdaptor.
Definition at line 165 of file CommonTreeAdaptor.java.
| void org.antlr.runtime.tree.CommonTreeAdaptor.setParent | ( | Object | t, | |
| Object | parent | |||
| ) |
Implements org.antlr.runtime.tree.TreeAdaptor.
Definition at line 169 of file CommonTreeAdaptor.java.
| int org.antlr.runtime.tree.CommonTreeAdaptor.getChildIndex | ( | Object | t | ) |
What index is this node in the child list? Range: 0..n-1 If your node type doesn't handle this, it's ok but the tree rewrites in tree parsers need this functionality.
Implements org.antlr.runtime.tree.TreeAdaptor.
Definition at line 173 of file CommonTreeAdaptor.java.
| void org.antlr.runtime.tree.CommonTreeAdaptor.setChildIndex | ( | Object | t, | |
| int | index | |||
| ) |
Implements org.antlr.runtime.tree.TreeAdaptor.
Definition at line 177 of file CommonTreeAdaptor.java.
| void org.antlr.runtime.tree.CommonTreeAdaptor.replaceChildren | ( | Object | parent, | |
| int | startChildIndex, | |||
| int | stopChildIndex, | |||
| Object | t | |||
| ) |
Replace from start to stop child index of parent with t, which might be a list. Number of children may be different after this call.
If parent is null, don't do anything; must be at root of overall tree. Can't replace whatever points to the parent externally. Do nothing.
Implements org.antlr.runtime.tree.TreeAdaptor.
Definition at line 181 of file CommonTreeAdaptor.java.
1.5.5