Package org.antlr.tool
Class AttributeScope
java.lang.Object
org.antlr.tool.AttributeScope
- Direct Known Subclasses:
RuleLabelScope
Track the attributes within a scope. A named scoped has just its list
of attributes. Each rule has potentially 3 scopes: return values,
parameters, and an implicitly-named scope (i.e., a scope defined in a rule).
Implicitly-defined scopes are named after the rule; rules and scopes then
must live in the same name space--no collisions allowed.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected LinkedHashMap
<String, Attribute> The list of Attribute objectsThis scope is associated with which input token (for error handling)?boolean
Not a rule scope, but visible to all rules "scope symbols { ...}"boolean
Visible to all rules, but defined in rule "scope { int i; }"boolean
boolean
boolean
boolean
private String
The scope namestatic final AttributeScope
All token scopes (token labels) share the same fixed scope of of predefined attributes. -
Constructor Summary
ConstructorsConstructorDescriptionAttributeScope
(String name, Token derivedFromToken) AttributeScope
(Grammar grammar, String name, Token derivedFromToken) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addAttribute
(String name, String decl) void
addAttributes
(String definitions, int separator) From a chunk of text holding the definitions of the attributes, pull them apart and create an Attribute for each one.final void
defineNamedAction
(GrammarAST nameAST, GrammarAST actionAST) Given @scope::name {action} define it for this attribute scope.getAttribute
(String name) Used by templates to get all attributesgetName()
intersection
(AttributeScope other) Return the set of keys that collide from this and other.int
size()
toString()
-
Field Details
-
tokenScope
All token scopes (token labels) share the same fixed scope of of predefined attributes. I keep this out of the runtime.Token object to avoid a runtime space burden. -
derivedFromToken
This scope is associated with which input token (for error handling)? -
grammar
-
name
The scope name -
isDynamicGlobalScope
public boolean isDynamicGlobalScopeNot a rule scope, but visible to all rules "scope symbols { ...}" -
isDynamicRuleScope
public boolean isDynamicRuleScopeVisible to all rules, but defined in rule "scope { int i; }" -
isParameterScope
public boolean isParameterScope -
isReturnScope
public boolean isReturnScope -
isPredefinedRuleScope
public boolean isPredefinedRuleScope -
isPredefinedLexerRuleScope
public boolean isPredefinedLexerRuleScope -
attributes
The list of Attribute objects -
actions
-
-
Constructor Details
-
AttributeScope
-
AttributeScope
-
-
Method Details
-
getName
-
addAttributes
From a chunk of text holding the definitions of the attributes, pull them apart and create an Attribute for each one. Add to the list of attributes for this scope. Pass in the character that terminates a definition such as ',' or ';'. For example, scope symbols { int n; List names; } would pass in definitions equal to the text in between {...} and separator=';'. It results in two Attribute objects. -
addAttribute
-
defineNamedAction
Given @scope::name {action} define it for this attribute scope. Later, the code generator will ask for the actions table. -
getAttribute
-
getAttributes
Used by templates to get all attributes -
intersection
Return the set of keys that collide from this and other. -
size
public int size() -
toString
-