| Modifier and Type | Field and Description |
|---|---|
| protected Map | actions
Map a name to an action for this rule. |
| protected Map | altToRuleRefMap
Each alt has a Map<ruleRefName,List<ruleRefAST>>; range 1..numberOfAlts So, if there are 3 expr refs in a rule's alt number 2, you'll have altToRuleRef[2].get("expr").size()==3. |
| protected Map | altToTokenRefMap
Each alt has a Map<tokenRefName,List<tokenRefAST>>; range 1..numberOfAlts. |
| public GrammarAST | argActionAST
For convenience, track the argument def AST action node if any |
| public LinkedHashMap | charLabels
A list of all LabelElementPair attached to single char literals like x='a' |
| public GrammarAST | |
| public Grammar | grammar
To which grammar does this belong? |
| public boolean | |
| public int | |
| protected List | inlineActions
Track all executable actions other than named actions like @init. |
| public boolean | |
| protected Map | labelNameSpace
All labels go in here (plus being split per the above lists) to catch dup label and label type mismatches. |
| public static final Set | |
| public String | |
| public String | |
| public int | |
| protected Map | options
This rule's options |
| public AttributeScope | |
| public boolean | referencedPredefinedRuleAttributes
Do not generate start, stop etc... |
| public AttributeScope | returnScope
The return values of a rule and predefined rule attributes |
| public LinkedHashMap | ruleLabels
A list of all LabelElementPair attached to rule references like f=field |
| public LinkedHashMap | ruleListLabels
A list of all rule ref list LabelElementPair like ids+=expr |
| public AttributeScope | ruleScope
the attributes defined with "scope {...}" inside a rule |
| public NFAState | |
| public NFAState | |
| public static final boolean | |
| public Set | throwsSpec
Exceptions that this rule can throw |
| public LinkedHashMap | tokenLabels
A list of all LabelElementPair attached to tokens like id=ID |
| public LinkedHashMap | tokenListLabels
A list of all Token list LabelElementPair like ids+=ID |
| public GrammarAST | tree
The AST representing the whole rule |
| public List | useScopes
A list of scope names (String) used by this rule |
| public LinkedHashMap | wildcardTreeLabels
A list of all LabelElementPair attached to tokens like x=. |
| public LinkedHashMap | wildcardTreeListLabels
A list of all LabelElementPair attached to tokens like x+=. |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | |
| public void | defineNamedAction(GrammarAST ampersandAST, GrammarAST nameAST, GrammarAST actionAST)
Given @scope::name {action} define it for this grammar. |
| public Map | |
| public Set | getAllRuleRefsInAltsWithRewrites()
For use with rewrite rules, we must track all rule AST results on the left-hand-side; so we need Lists. |
| public Set | getAllTokenRefsInAltsWithRewrites()
For use with rewrite rules, we must track all tokens matched on the left-hand-side; so we need Lists. |
| public AttributeScope | |
| public 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. |
| public 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. |
| public boolean | |
| public boolean | |
| public List | |
| public Grammar. | |
| public AttributeScope | |
| public Grammar. | |
| public Map | |
| public Grammar. | |
| public Map | |
| public List | |
| public Set | |
| public static int | |
| public String | |
| public String | |
| public Grammar. | |
| public Grammar. | |
| public List | |
| public Set | |
| public boolean | |
| public void | |
| public String | |
| public void | |
| public String | toString()
Overrides java. |
| public void | |
| public void | |
| public 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. |
| actions | back to summary |
|---|---|
| protected Map<String, Object> actions Map a name to an action for this rule. Currently init is only one we use, but we can add more in future. The code generator will use this to fill holes in the rule template. I track the AST node for the action in case I need the line number for errors. A better name is probably namedActions, but I don't want everyone to have to change their code gen templates now. | |
| altToRuleRefMap | back to summary |
|---|---|
| protected Map<String, List<GrammarAST>>[] altToRuleRefMap Each alt has a Map<ruleRefName,List<ruleRefAST>>; range 1..numberOfAlts So, if there are 3 expr refs in a rule's alt number 2, you'll have altToRuleRef[2].get("expr").size()==3. This is used to see if $expr is ok. There must be only one expr reference in the alt for $expr to be ok in an action--must be unique. Rewrite rules force tracking of all rule result ASTs. 1..n | |
| altToTokenRefMap | back to summary |
|---|---|
| protected Map<String, List<GrammarAST>>[] altToTokenRefMap Each alt has a Map<tokenRefName,List<tokenRefAST>>; range 1..numberOfAlts. So, if there are 3 ID refs in a rule's alt number 2, you'll have altToTokenRef[2].get("ID").size()==3. This is used to see if $ID is ok. There must be only one ID reference in the alt for $ID to be ok in an action--must be unique. This also tracks '+' and "int" literal token references (if not in LEXER). Rewrite rules force tracking of all tokens. | |
| argActionAST | back to summary |
|---|---|
| public GrammarAST argActionAST For convenience, track the argument def AST action node if any | |
| charLabels | back to summary |
|---|---|
| public LinkedHashMap<String, Grammar. A list of all LabelElementPair attached to single char literals like x='a' | |
| EORNode | back to summary |
|---|---|
| public GrammarAST EORNode | |
| grammar | back to summary |
|---|---|
| public Grammar grammar To which grammar does this belong? | |
| imported | back to summary |
|---|---|
| public boolean imported | |
| index | back to summary |
|---|---|
| public int index | |
| inlineActions | back to summary |
|---|---|
| protected List<GrammarAST> inlineActions Track all executable actions other than named actions like @init. Also tracks exception handlers, predicates, and rewrite rewrites. We need to examine these actions before code generation so that we can detect refs to $rule.attr etc... | |
| isSynPred | back to summary |
|---|---|
| public boolean isSynPred | |
| labelNameSpace | back to summary |
|---|---|
| protected Map<String, Grammar. All labels go in here (plus being split per the above lists) to catch dup label and label type mismatches. | |
| legalOptions | back to summary |
|---|---|
| public static final Set<String> legalOptions | |
| modifier | back to summary |
|---|---|
| public String modifier | |
| name | back to summary |
|---|---|
| public String name | |
| numberOfAlts | back to summary |
|---|---|
| public int numberOfAlts | |
| options | back to summary |
|---|---|
| protected Map<String, Object> options This rule's options | |
| parameterScope | back to summary |
|---|---|
| public AttributeScope parameterScope | |
| referencedPredefinedRuleAttributes | back to summary |
|---|---|
| public boolean referencedPredefinedRuleAttributes Do not generate start, stop etc... in a return value struct unless somebody references $r.start somewhere. | |
| returnScope | back to summary |
|---|---|
| public AttributeScope returnScope The return values of a rule and predefined rule attributes | |
| ruleLabels | back to summary |
|---|---|
| public LinkedHashMap<String, Grammar. A list of all LabelElementPair attached to rule references like f=field | |
| ruleListLabels | back to summary |
|---|---|
| public LinkedHashMap<String, Grammar. A list of all rule ref list LabelElementPair like ids+=expr | |
| ruleScope | back to summary |
|---|---|
| public AttributeScope ruleScope the attributes defined with "scope {...}" inside a rule | |
| startState | back to summary |
|---|---|
| public NFAState startState | |
| stopState | back to summary |
|---|---|
| public NFAState stopState | |
| supportsLabelOptimization | back to summary |
|---|---|
| public static final boolean supportsLabelOptimization | |
| throwsSpec | back to summary |
|---|---|
| public Set<String> throwsSpec Exceptions that this rule can throw | |
| tokenLabels | back to summary |
|---|---|
| public LinkedHashMap<String, Grammar. A list of all LabelElementPair attached to tokens like id=ID | |
| tokenListLabels | back to summary |
|---|---|
| public LinkedHashMap<String, Grammar. A list of all Token list LabelElementPair like ids+=ID | |
| tree | back to summary |
|---|---|
| public GrammarAST tree The AST representing the whole rule | |
| useScopes | back to summary |
|---|---|
| public List<String> useScopes A list of scope names (String) used by this rule | |
| wildcardTreeLabels | back to summary |
|---|---|
| public LinkedHashMap<String, Grammar. A list of all LabelElementPair attached to tokens like x=. in tree grammar | |
| wildcardTreeListLabels | back to summary |
|---|---|
| public LinkedHashMap<String, Grammar. A list of all LabelElementPair attached to tokens like x+=. in tree grammar | |
| Rule | back to summary |
|---|---|
public Rule(Grammar grammar, String ruleName, int ruleIndex, int numberOfAlts)
| |
| defineLabel | back to summary |
|---|---|
| public void defineLabel(Token label, GrammarAST elementRef, int type) | |
| defineNamedAction | back to summary |
|---|---|
| public void defineNamedAction(GrammarAST ampersandAST, GrammarAST nameAST, GrammarAST actionAST) Given @scope::name {action} define it for this grammar. Later, the code generator will ask for the actions table. | |
| getActions | back to summary |
|---|---|
| public Map | |
| getAllRuleRefsInAltsWithRewrites | back to summary |
|---|---|
| public Set For use with rewrite rules, we must track all rule AST results on the left-hand-side; so we need Lists. This is a unique list of all rule results for which the rule needs a list of results. | |
| getAllTokenRefsInAltsWithRewrites | back to summary |
|---|---|
| public Set For use with rewrite rules, we must track all tokens matched on the left-hand-side; so we need Lists. This is a unique list of all token types for which the rule needs a list of tokens. This is called from the rule template not directly by the code generator. | |
| getAttributeScope | back to summary |
|---|---|
| public AttributeScope getAttributeScope(String name) Return the scope containing name | |
| getElementLabel | back to summary |
|---|---|
| public 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. | |
| getHasMultipleReturnValues | back to summary |
|---|---|
| public 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. A rule also has multiple return values if you are building trees or templates. | |
| getHasReturnValue | back to summary |
|---|---|
| public boolean getHasReturnValue() | |
| getHasSingleReturnValue | back to summary |
|---|---|
| public boolean getHasSingleReturnValue() | |
| getInlineActions | back to summary |
|---|---|
| public List | |
| getLabel | back to summary |
|---|---|
| public Grammar. | |
| getLocalAttributeScope | back to summary |
|---|---|
| public AttributeScope getLocalAttributeScope(String name) Get the arg, return value, or predefined property for this rule | |
| getRuleLabel | back to summary |
|---|---|
| public Grammar. | |
| getRuleLabels | back to summary |
|---|---|
| public Map | |
| getRuleListLabel | back to summary |
|---|---|
| public Grammar. | |
| getRuleListLabels | back to summary |
|---|---|
| public Map | |
| getRuleRefsInAlt | back to summary |
|---|---|
| public List | |
| getRuleRefsInAlt | back to summary |
|---|---|
| public Set | |
| getRuleType | back to summary |
|---|---|
| public static int getRuleType(String ruleName) | |
| getSingleValueReturnName | back to summary |
|---|---|
| public String getSingleValueReturnName() | |
| getSingleValueReturnType | back to summary |
|---|---|
| public String getSingleValueReturnType() | |
| getTokenLabel | back to summary |
|---|---|
| public Grammar. | |
| getTokenListLabel | back to summary |
|---|---|
| public Grammar. | |
| getTokenRefsInAlt | back to summary |
|---|---|
| public List | |
| getTokenRefsInAlt | back to summary |
|---|---|
| public Set | |
| hasRewrite | back to summary |
|---|---|
| public boolean hasRewrite(int i) | |
| setActions | back to summary |
|---|---|
| public void setActions(Map<String, Object> actions) | |
| setOption | back to summary |
|---|---|
| public 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. | |
| setOptions | back to summary |
|---|---|
| public void setOptions(Map<String, Object> options, Token optionsStartToken) | |
| toString | back to summary |
|---|---|
| public String toString() Overrides java. Used during grammar imports to see if sets of rules intersect... public int hashCode() { return name.hashCode(); }
| |
| trackInlineAction | back to summary |
|---|---|
| public void trackInlineAction(GrammarAST actionAST) | |
| trackRuleReferenceInAlt | back to summary |
|---|---|
| public void trackRuleReferenceInAlt(GrammarAST refAST, int outerAltNum) | |
| trackTokenReferenceInAlt | back to summary |
|---|---|
| public 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. This differs from Grammar.altReferencesTokenID(), which tracks all token IDs to check for token IDs without corresponding lexer rules. | |