|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectantlr.BaseAST
org.antlr.tool.GrammarAST
public class GrammarAST
Grammars are first converted to ASTs using this class and then are converted to NFAs via a tree walker. The reader may notice that I have made a very non-OO decision in this class to track variables for many different kinds of nodes. It wastes space for nodes that don't need the values and OO principles cry out for a new class type for each kind of node in my tree. I am doing this on purpose for a variety of reasons. I don't like using the type system for different node types; it yields too many damn class files which I hate. Perhaps if I put them all in one file. Most importantly though I hate all the type casting that would have to go on. I would have all sorts of extra work to do. Ick. Anyway, I'm doing all this on purpose, not out of ignorance. ;)
Field Summary | |
---|---|
StringTemplate |
code
if this is a TOKEN_REF or RULE_REF node, this is the code StringTemplate generated for this node. |
static java.util.Map |
defaultBlockOptions
What are the default options for a subrule? |
protected java.lang.String |
enclosingRule
|
NFAState |
followingNFAState
Rule ref nodes, token refs, set, and NOT set refs need to track their location in the generated NFA so that local FOLLOW sets can be computed during code gen for automatic error recovery. |
int |
ID
|
static java.util.Set |
legalBlockOptions
|
DFA |
lookaheadDFA
If this is a decision node, what is the lookahead DFA? |
NFAState |
NFAStartState
What NFA start state was built from this node? |
NFAState |
NFATreeDownState
This is used for TREE_BEGIN nodes to point into the NFA. |
protected java.util.Map |
options
If this is a BLOCK node, track options here |
int |
outerAltNum
if this is an ACTION node, this is the outermost enclosing alt num in rule. |
java.util.Set<GrammarAST> |
rewriteRefsDeep
|
java.util.Set<GrammarAST> |
rewriteRefsShallow
If this is a BLOCK node for a rewrite rule, track referenced elements here. |
int |
ruleStartTokenIndex
If this is a RULE node then track rule's start, stop tokens' index. |
int |
ruleStopTokenIndex
|
protected IntSet |
setValue
If this is a SET node, what are the elements? |
antlr.Token |
token
This AST node was created from what token? |
Fields inherited from class antlr.BaseAST |
---|
down, right |
Constructor Summary | |
---|---|
GrammarAST()
|
|
GrammarAST(int t,
java.lang.String txt)
|
Method Summary | |
---|---|
static GrammarAST |
dup(antlr.collections.AST t)
|
static GrammarAST |
dupListNoActions(GrammarAST t,
GrammarAST parent)
Duplicate tree including siblings of root. |
static GrammarAST |
dupTreeNoActions(GrammarAST t,
GrammarAST parent)
Duplicate a tree, assuming this is a root node of a tree-- duplicate that node and what's below; ignore siblings of root node. |
boolean |
equals(antlr.collections.AST ast)
Make nodes unique based upon Token so we can add them to a Set; if not a GrammarAST, check type. |
GrammarAST |
findFirstType(int ttype)
Return a reference to the first node (depth-first) that has token type ttype. |
GrammarAST |
getChild(int i)
Get the ith child from 0 |
GrammarAST[] |
getChildrenAsArray()
|
int |
getColumn()
|
java.lang.String |
getEnclosingRule()
|
GrammarAST |
getFirstChildWithType(int ttype)
|
GrammarAST |
getLastChild()
|
GrammarAST |
getLastSibling()
|
int |
getLine()
|
DFA |
getLookaheadDFA()
|
NFAState |
getNFAStartState()
|
java.lang.Object |
getOption(java.lang.String key)
|
java.util.Map |
getOptions()
|
IntSet |
getSetValue()
|
java.lang.String |
getText()
|
antlr.Token |
getToken()
|
int |
getType()
|
boolean |
hasSameListStructure(antlr.collections.AST t)
|
boolean |
hasSameTreeStructure(antlr.collections.AST t)
See if tree has exact token types and structure; no text |
void |
initialize(antlr.collections.AST ast)
|
void |
initialize(int i,
java.lang.String s)
|
void |
initialize(antlr.Token token)
|
static void |
main(java.lang.String[] args)
|
void |
setColumn(int col)
|
void |
setEnclosingRule(java.lang.String rule)
|
void |
setLine(int line)
|
void |
setLookaheadDFA(DFA lookaheadDFA)
|
void |
setNFAStartState(NFAState nfaStartState)
|
java.lang.String |
setOption(Grammar grammar,
java.lang.String key,
java.lang.Object value)
Save the option key/value pair and process it; return the key or null if invalid option. |
void |
setOptions(Grammar grammar,
java.util.Map options)
|
void |
setSetValue(IntSet setValue)
|
void |
setText(java.lang.String text)
|
void |
setType(int type)
|
Methods inherited from class antlr.BaseAST |
---|
addChild, decode, encode, equalsList, equalsListPartial, equalsTree, equalsTreePartial, findAll, findAllPartial, getFirstChild, getNextSibling, getNumberOfChildren, getTokenNames, removeChildren, setFirstChild, setNextSibling, setVerboseStringConversion, toString, toStringList, toStringTree, xmlSerialize, xmlSerializeNode, xmlSerializeRootClose, xmlSerializeRootOpen |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public int ID
public antlr.Token token
protected java.lang.String enclosingRule
public int ruleStartTokenIndex
public int ruleStopTokenIndex
public DFA lookaheadDFA
public NFAState NFAStartState
public NFAState NFATreeDownState
public NFAState followingNFAState
protected IntSet setValue
protected java.util.Map options
public java.util.Set<GrammarAST> rewriteRefsShallow
public java.util.Set<GrammarAST> rewriteRefsDeep
public static final java.util.Set legalBlockOptions
public static final java.util.Map defaultBlockOptions
public int outerAltNum
public StringTemplate code
Constructor Detail |
---|
public GrammarAST()
public GrammarAST(int t, java.lang.String txt)
Method Detail |
---|
public void initialize(int i, java.lang.String s)
initialize
in interface antlr.collections.AST
initialize
in class antlr.BaseAST
public void initialize(antlr.collections.AST ast)
initialize
in interface antlr.collections.AST
initialize
in class antlr.BaseAST
public void initialize(antlr.Token token)
initialize
in interface antlr.collections.AST
initialize
in class antlr.BaseAST
public DFA getLookaheadDFA()
public void setLookaheadDFA(DFA lookaheadDFA)
public antlr.Token getToken()
public NFAState getNFAStartState()
public void setNFAStartState(NFAState nfaStartState)
public java.lang.String setOption(Grammar grammar, java.lang.String key, java.lang.Object value)
public java.lang.Object getOption(java.lang.String key)
public void setOptions(Grammar grammar, java.util.Map options)
public java.util.Map getOptions()
public java.lang.String getText()
getText
in interface antlr.collections.AST
getText
in class antlr.BaseAST
public void setType(int type)
setType
in interface antlr.collections.AST
setType
in class antlr.BaseAST
public void setText(java.lang.String text)
setText
in interface antlr.collections.AST
setText
in class antlr.BaseAST
public int getType()
getType
in interface antlr.collections.AST
getType
in class antlr.BaseAST
public int getLine()
getLine
in interface antlr.collections.AST
getLine
in class antlr.BaseAST
public int getColumn()
getColumn
in interface antlr.collections.AST
getColumn
in class antlr.BaseAST
public void setLine(int line)
public void setColumn(int col)
public void setEnclosingRule(java.lang.String rule)
public java.lang.String getEnclosingRule()
public IntSet getSetValue()
public void setSetValue(IntSet setValue)
public GrammarAST getLastChild()
public GrammarAST getLastSibling()
public GrammarAST getChild(int i)
public GrammarAST getFirstChildWithType(int ttype)
public GrammarAST[] getChildrenAsArray()
public GrammarAST findFirstType(int ttype)
public boolean equals(antlr.collections.AST ast)
equals
in interface antlr.collections.AST
equals
in class antlr.BaseAST
public boolean hasSameTreeStructure(antlr.collections.AST t)
public boolean hasSameListStructure(antlr.collections.AST t)
public static GrammarAST dup(antlr.collections.AST t)
public static void main(java.lang.String[] args)
public static GrammarAST dupListNoActions(GrammarAST t, GrammarAST parent)
public static GrammarAST dupTreeNoActions(GrammarAST t, GrammarAST parent)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |