|
||||||||||
| 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 Map<String,GrammarAST> |
actions
Map a name to an action for this rule. |
protected Map<String,List<GrammarAST>>[] |
altToRuleRefMap
Each alt has a Map |
protected Map<String,List<GrammarAST>>[] |
altToTokenRefMap
Each alt has a Map |
GrammarAST |
argActionAST
For convenience, track the argument def AST action node if any |
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? |
boolean |
imported
|
int |
index
|
protected List<GrammarAST> |
inlineActions
Track all executable actions other than named actions like @init. |
boolean |
isSynPred
|
protected Map<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 Set |
legalOptions
|
String |
modifier
|
String |
name
|
int |
numberOfAlts
|
protected 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 |
LinkedHashMap |
ruleLabels
A list of all LabelElementPair attached to rule references like f=field |
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
|
Set<String> |
throwsSpec
Exceptions that this rule can throw |
LinkedHashMap |
tokenLabels
A list of all LabelElementPair attached to tokens like id=ID |
LinkedHashMap |
tokenListLabels
A list of all Token list LabelElementPair like ids+=ID |
GrammarAST |
tree
The AST representing the whole rule |
List |
useScopes
A list of scope names (String) used by this rule |
LinkedHashMap |
wildcardTreeLabels
A list of all LabelElementPair attached to tokens like x=. |
LinkedHashMap |
wildcardTreeListLabels
A list of all LabelElementPair attached to tokens like x+=. |
| Constructor Summary | |
|---|---|
Rule(Grammar grammar,
String ruleName,
int ruleIndex,
int numberOfAlts)
|
|
| Method Summary | |
|---|---|
void |
defineLabel(Token label,
GrammarAST elementRef,
int type)
|
void |
defineNamedAction(GrammarAST ampersandAST,
GrammarAST nameAST,
GrammarAST actionAST)
Given @scope::name {action} define it for this grammar. |
Map<String,GrammarAST> |
getActions()
|
Set |
getAllRuleRefsInAltsWithRewrites()
For use with rewrite rules, we must track all rule AST results on the left-hand-side; so we need Lists. |
Set |
getAllTokenRefsInAltsWithRewrites()
For use with rewrite rules, we must track all tokens matched on the left-hand-side; so we need Lists. |
AttributeScope |
getAttributeScope(String name)
Return the scope containing name |
String |
getElementLabel(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()
|
List<GrammarAST> |
getInlineActions()
|
Grammar.LabelElementPair |
getLabel(String name)
|
AttributeScope |
getLocalAttributeScope(String name)
Get the arg, return value, or predefined property for this rule |
Grammar.LabelElementPair |
getRuleLabel(String name)
|
Map |
getRuleLabels()
|
Grammar.LabelElementPair |
getRuleListLabel(String name)
|
Map |
getRuleListLabels()
|
Set |
getRuleRefsInAlt(int outerAltNum)
|
List |
getRuleRefsInAlt(String ref,
int outerAltNum)
|
static int |
getRuleType(String ruleName)
|
String |
getSingleValueReturnName()
|
String |
getSingleValueReturnType()
|
Grammar.LabelElementPair |
getTokenLabel(String name)
|
Grammar.LabelElementPair |
getTokenListLabel(String name)
|
Set |
getTokenRefsInAlt(int altNum)
|
List |
getTokenRefsInAlt(String ref,
int outerAltNum)
|
boolean |
hasRewrite(int i)
|
void |
setActions(Map<String,GrammarAST> actions)
|
String |
setOption(String key,
Object value,
Token optionsStartToken)
Save the option key/value pair and process it; return the key or null if invalid option. |
void |
setOptions(Map options,
Token optionsStartToken)
|
String |
toString()
Used during grammar imports to see if sets of rules intersect... |
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 String name
public int index
public String modifier
public NFAState startState
public NFAState stopState
protected Map options
public static final Set legalOptions
public GrammarAST tree
public Grammar grammar
public GrammarAST argActionAST
public GrammarAST EORNode
public AttributeScope returnScope
public AttributeScope parameterScope
public AttributeScope ruleScope
public List useScopes
public Set<String> throwsSpec
public LinkedHashMap tokenLabels
public LinkedHashMap wildcardTreeLabels
public LinkedHashMap wildcardTreeListLabels
public LinkedHashMap charLabels
public LinkedHashMap ruleLabels
public LinkedHashMap tokenListLabels
public LinkedHashMap ruleListLabels
protected Map<String,Grammar.LabelElementPair> labelNameSpace
protected Map<String,GrammarAST> actions
protected List<GrammarAST> inlineActions
public int numberOfAlts
protected Map<String,List<GrammarAST>>[] altToTokenRefMap
protected Map<String,List<GrammarAST>>[] altToRuleRefMap
public boolean referencedPredefinedRuleAttributes
public boolean isSynPred
public boolean imported
| Constructor Detail |
|---|
public Rule(Grammar grammar,
String ruleName,
int ruleIndex,
int numberOfAlts)
| Method Detail |
|---|
public static int getRuleType(String ruleName)
public void defineLabel(Token label,
GrammarAST elementRef,
int type)
public Grammar.LabelElementPair getLabel(String name)
public Grammar.LabelElementPair getTokenLabel(String name)
public Map getRuleLabels()
public Map getRuleListLabels()
public Grammar.LabelElementPair getRuleLabel(String name)
public Grammar.LabelElementPair getTokenListLabel(String name)
public Grammar.LabelElementPair getRuleListLabel(String name)
public void trackTokenReferenceInAlt(GrammarAST refAST,
int outerAltNum)
public List getTokenRefsInAlt(String ref,
int outerAltNum)
public void trackRuleReferenceInAlt(GrammarAST refAST,
int outerAltNum)
public List getRuleRefsInAlt(String ref,
int outerAltNum)
public Set getTokenRefsInAlt(int altNum)
public Set getAllTokenRefsInAltsWithRewrites()
public Set getRuleRefsInAlt(int outerAltNum)
public Set getAllRuleRefsInAltsWithRewrites()
public List<GrammarAST> getInlineActions()
public boolean hasRewrite(int i)
public AttributeScope getAttributeScope(String name)
public AttributeScope getLocalAttributeScope(String name)
public String getElementLabel(String refdSymbol,
int outerAltNum,
CodeGenerator generator)
public boolean getHasMultipleReturnValues()
public boolean getHasSingleReturnValue()
public boolean getHasReturnValue()
public String getSingleValueReturnType()
public String getSingleValueReturnName()
public void defineNamedAction(GrammarAST ampersandAST,
GrammarAST nameAST,
GrammarAST actionAST)
public void trackInlineAction(GrammarAST actionAST)
public Map<String,GrammarAST> getActions()
public void setActions(Map<String,GrammarAST> actions)
public String setOption(String key,
Object value,
Token optionsStartToken)
public void setOptions(Map options,
Token optionsStartToken)
public String toString()
toString in class Object
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||