|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.antlr.tool.Rule
public class Rule
Combine the info associated with a rule
Field Summary | |
---|---|
protected java.util.Map<java.lang.String,GrammarAST> |
actions
Map a name to an action for this rule. |
protected boolean[] |
altsWithRewrites
Track which alts have rewrite rules associated with them. |
protected java.util.Map<java.lang.String,java.util.List<GrammarAST>>[] |
altToRuleRefMap
Each alt has a Map |
protected java.util.Map<java.lang.String,java.util.List<GrammarAST>>[] |
altToTokenRefMap
Each alt has a Map |
GrammarAST |
argActionAST
For convenience, track the argument def AST action node if any |
java.util.LinkedHashMap |
charLabels
A list of all LabelElementPair attached to single char literals like x='a' |
GrammarAST |
EORNode
|
Grammar |
grammar
To which grammar does this belong? |
int |
index
|
protected java.util.List<GrammarAST> |
inlineActions
Track all executable actions other than named actions like @init. |
boolean |
isSynPred
|
protected java.util.Map<java.lang.String,Grammar.LabelElementPair> |
labelNameSpace
All labels go in here (plus being split per the above lists) to catch dup label and label type mismatches. |
static java.util.Set |
legalOptions
|
java.lang.String |
modifier
|
java.lang.String |
name
|
int |
numberOfAlts
|
protected java.util.Map |
options
This rule's options |
AttributeScope |
parameterScope
|
boolean |
referencedPredefinedRuleAttributes
Do not generate start, stop etc... |
AttributeScope |
returnScope
The return values of a rule and predefined rule attributes |
java.util.LinkedHashMap |
ruleLabels
A list of all LabelElementPair attached to rule references like f=field |
java.util.LinkedHashMap |
ruleListLabels
A list of all rule ref list LabelElementPair like ids+=expr |
AttributeScope |
ruleScope
the attributes defined with "scope {...}" inside a rule |
NFAState |
startState
|
NFAState |
stopState
|
java.util.LinkedHashMap |
tokenLabels
A list of all LabelElementPair attached to tokens like id=ID |
java.util.LinkedHashMap |
tokenListLabels
A list of all Token list LabelElementPair like ids+=ID |
GrammarAST |
tree
The AST representing the whole rule |
java.util.List |
useScopes
A list of scope names (String) used by this rule |
Constructor Summary | |
---|---|
Rule(Grammar grammar,
java.lang.String ruleName,
int ruleIndex,
int numberOfAlts)
|
Method Summary | |
---|---|
void |
defineLabel(antlr.Token label,
GrammarAST elementRef,
int type)
|
void |
defineNamedAction(GrammarAST ampersandAST,
GrammarAST nameAST,
GrammarAST actionAST)
Given @scope::name {action} define it for this grammar. |
java.util.Map<java.lang.String,GrammarAST> |
getActions()
|
java.util.Set |
getAllRuleRefsInAltsWithRewrites()
For use with rewrite rules, we must track all rule AST results on the left-hand-side; so we need Lists. |
java.util.Set |
getAllTokenRefsInAltsWithRewrites()
For use with rewrite rules, we must track all tokens matched on the left-hand-side; so we need Lists. |
AttributeScope |
getAttributeScope(java.lang.String name)
Return the scope containing name |
java.lang.String |
getElementLabel(java.lang.String refdSymbol,
int outerAltNum,
CodeGenerator generator)
For references to tokens rather than by label such as $ID, we need to get the existing label for the ID ref or create a new one. |
boolean |
getHasMultipleReturnValues()
If a rule has no user-defined return values and nobody references it's start/stop (predefined attributes), then there is no need to define a struct; otherwise for now we assume a struct. |
boolean |
getHasReturnValue()
|
boolean |
getHasSingleReturnValue()
|
java.util.List<GrammarAST> |
getInlineActions()
|
Grammar.LabelElementPair |
getLabel(java.lang.String name)
|
AttributeScope |
getLocalAttributeScope(java.lang.String name)
Get the arg, return value, or predefined property for this rule |
Grammar.LabelElementPair |
getRuleLabel(java.lang.String name)
|
java.util.Map |
getRuleLabels()
|
Grammar.LabelElementPair |
getRuleListLabel(java.lang.String name)
|
java.util.Map |
getRuleListLabels()
|
java.util.Set |
getRuleRefsInAlt(int outerAltNum)
|
java.util.List |
getRuleRefsInAlt(java.lang.String ref,
int outerAltNum)
|
java.lang.String |
getSingleValueReturnName()
|
java.lang.String |
getSingleValueReturnType()
|
Grammar.LabelElementPair |
getTokenLabel(java.lang.String name)
|
Grammar.LabelElementPair |
getTokenListLabel(java.lang.String name)
|
java.util.Set |
getTokenRefsInAlt(int altNum)
|
java.util.List |
getTokenRefsInAlt(java.lang.String ref,
int outerAltNum)
|
boolean |
hasRewrite(int i)
|
void |
setActions(java.util.Map<java.lang.String,GrammarAST> actions)
|
java.lang.String |
setOption(java.lang.String key,
java.lang.Object value,
antlr.Token optionsStartToken)
Save the option key/value pair and process it; return the key or null if invalid option. |
void |
setOptions(java.util.Map options,
antlr.Token optionsStartToken)
|
java.lang.String |
toString()
|
void |
trackAltsWithRewrites(GrammarAST altAST,
int outerAltNum)
Track which rules have rewrite rules. |
void |
trackInlineAction(GrammarAST actionAST)
|
void |
trackRuleReferenceInAlt(GrammarAST refAST,
int outerAltNum)
|
void |
trackTokenReferenceInAlt(GrammarAST refAST,
int outerAltNum)
Track a token ID or literal like '+' and "void" as having been referenced somewhere within the alts (not rewrite sections) of a rule. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
---|
public java.lang.String name
public int index
public java.lang.String modifier
public NFAState startState
public NFAState stopState
protected java.util.Map options
public static final java.util.Set legalOptions
public GrammarAST tree
public Grammar grammar
public GrammarAST argActionAST
public GrammarAST EORNode
public AttributeScope returnScope
public AttributeScope parameterScope
public AttributeScope ruleScope
public java.util.List useScopes
public java.util.LinkedHashMap tokenLabels
public java.util.LinkedHashMap charLabels
public java.util.LinkedHashMap ruleLabels
public java.util.LinkedHashMap tokenListLabels
public java.util.LinkedHashMap ruleListLabels
protected java.util.Map<java.lang.String,Grammar.LabelElementPair> labelNameSpace
protected java.util.Map<java.lang.String,GrammarAST> actions
protected java.util.List<GrammarAST> inlineActions
public int numberOfAlts
protected java.util.Map<java.lang.String,java.util.List<GrammarAST>>[] altToTokenRefMap
protected java.util.Map<java.lang.String,java.util.List<GrammarAST>>[] altToRuleRefMap
protected boolean[] altsWithRewrites
public boolean referencedPredefinedRuleAttributes
public boolean isSynPred
Constructor Detail |
---|
public Rule(Grammar grammar, java.lang.String ruleName, int ruleIndex, int numberOfAlts)
Method Detail |
---|
public void defineLabel(antlr.Token label, GrammarAST elementRef, int type)
public Grammar.LabelElementPair getLabel(java.lang.String name)
public Grammar.LabelElementPair getTokenLabel(java.lang.String name)
public java.util.Map getRuleLabels()
public java.util.Map getRuleListLabels()
public Grammar.LabelElementPair getRuleLabel(java.lang.String name)
public Grammar.LabelElementPair getTokenListLabel(java.lang.String name)
public Grammar.LabelElementPair getRuleListLabel(java.lang.String name)
public void trackTokenReferenceInAlt(GrammarAST refAST, int outerAltNum)
public java.util.List getTokenRefsInAlt(java.lang.String ref, int outerAltNum)
public void trackRuleReferenceInAlt(GrammarAST refAST, int outerAltNum)
public java.util.List getRuleRefsInAlt(java.lang.String ref, int outerAltNum)
public java.util.Set getTokenRefsInAlt(int altNum)
public java.util.Set getAllTokenRefsInAltsWithRewrites()
public java.util.Set getRuleRefsInAlt(int outerAltNum)
public java.util.Set getAllRuleRefsInAltsWithRewrites()
public java.util.List<GrammarAST> getInlineActions()
public boolean hasRewrite(int i)
public void trackAltsWithRewrites(GrammarAST altAST, int outerAltNum)
public AttributeScope getAttributeScope(java.lang.String name)
public AttributeScope getLocalAttributeScope(java.lang.String name)
public java.lang.String getElementLabel(java.lang.String refdSymbol, int outerAltNum, CodeGenerator generator)
public boolean getHasMultipleReturnValues()
public boolean getHasSingleReturnValue()
public boolean getHasReturnValue()
public java.lang.String getSingleValueReturnType()
public java.lang.String getSingleValueReturnName()
public void defineNamedAction(GrammarAST ampersandAST, GrammarAST nameAST, GrammarAST actionAST)
public void trackInlineAction(GrammarAST actionAST)
public java.util.Map<java.lang.String,GrammarAST> getActions()
public void setActions(java.util.Map<java.lang.String,GrammarAST> actions)
public java.lang.String setOption(java.lang.String key, java.lang.Object value, antlr.Token optionsStartToken)
public void setOptions(java.util.Map options, antlr.Token optionsStartToken)
public java.lang.String toString()
toString
in class java.lang.Object
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |