Class: ANTLR3::RecognizerSharedState
- Inherits:
-
Struct
- Object
- Struct
- ANTLR3::RecognizerSharedState
- Defined in:
- lib/antlr3/recognizers.rb,
lib/antlr3/recognizers.rb
Overview
A big Struct-based class containing most of the data that makes up a recognizer's state. These attributes are externalized from the recognizer itself so that recognizer delegation (which occurs when you import other grammars into your grammar) can function; multiple recognizers can share a common state.
Structure Attributes
following |
a stack that tracks follow sets for error recovery |
error_recovery |
a flag indicating whether or not the recognizer is in error recovery mode |
last_error_index |
the index in the input stream of the last error |
backtracking |
tracks the backtracking depth |
rule_memory |
if a grammar is compiled with the memoization option, this will be set to a hash mapping previously parsed rules to cached indices |
syntax_errors |
tracks the number of syntax errors seen so far |
token |
holds newly constructed tokens for lexer rules |
token_start_position |
the input stream index at which the token starts |
token_start_line |
the input stream line number at which the token starts |
token_start_column |
the input stream column at which the token starts |
channel |
the channel value of the target token |
type |
the type value of the target token |
text |
the text of the target token |
Instance Attribute Summary (collapse)
-
- (Object) backtracking
Returns the value of attribute backtracking.
-
- (Object) channel
Returns the value of attribute channel.
-
- (Object) error_recovery
Returns the value of attribute error_recovery.
-
- (Object) following
Returns the value of attribute following.
-
- (Object) last_error_index
Returns the value of attribute last_error_index.
-
- (Object) rule_memory
Returns the value of attribute rule_memory.
-
- (Object) syntax_errors
Returns the value of attribute syntax_errors.
-
- (Object) text
Returns the value of attribute text.
-
- (Object) token
Returns the value of attribute token.
-
- (Object) token_start_column
Returns the value of attribute token_start_column.
-
- (Object) token_start_line
Returns the value of attribute token_start_line.
-
- (Object) token_start_position
Returns the value of attribute token_start_position.
-
- (Object) type
Returns the value of attribute type.
Instance Method Summary (collapse)
-
- (RecognizerSharedState) initialize
constructor
A new instance of RecognizerSharedState.
-
- (Object) reset!
restores all of the state variables to their respective initial default values.
Constructor Details
- (RecognizerSharedState) initialize
A new instance of RecognizerSharedState
94 95 96 97 98 99 100 101 102 103 |
# File 'lib/antlr3/recognizers.rb', line 94 def initialize super( [], false, -1, 0, nil, 0, nil, -1 ) # ^-- same as this --v # self.following = [] # self.error_recovery = false # self.last_error_index = -1 # self.backtracking = 0 # self.syntax_errors = 0 # self.token_start_position = -1 end |
Instance Attribute Details
- (Object) backtracking
Returns the value of attribute backtracking
38 39 40 |
# File 'lib/antlr3/recognizers.rb', line 38 def backtracking @backtracking end |
- (Object) channel
Returns the value of attribute channel
38 39 40 |
# File 'lib/antlr3/recognizers.rb', line 38 def channel @channel end |
- (Object) error_recovery
Returns the value of attribute error_recovery
38 39 40 |
# File 'lib/antlr3/recognizers.rb', line 38 def error_recovery @error_recovery end |
- (Object) following
Returns the value of attribute following
38 39 40 |
# File 'lib/antlr3/recognizers.rb', line 38 def following @following end |
- (Object) last_error_index
Returns the value of attribute last_error_index
38 39 40 |
# File 'lib/antlr3/recognizers.rb', line 38 def last_error_index @last_error_index end |
- (Object) rule_memory
Returns the value of attribute rule_memory
38 39 40 |
# File 'lib/antlr3/recognizers.rb', line 38 def rule_memory @rule_memory end |
- (Object) syntax_errors
Returns the value of attribute syntax_errors
38 39 40 |
# File 'lib/antlr3/recognizers.rb', line 38 def syntax_errors @syntax_errors end |
- (Object) text
Returns the value of attribute text
38 39 40 |
# File 'lib/antlr3/recognizers.rb', line 38 def text @text end |
- (Object) token
Returns the value of attribute token
38 39 40 |
# File 'lib/antlr3/recognizers.rb', line 38 def token @token end |
- (Object) token_start_column
Returns the value of attribute token_start_column
38 39 40 |
# File 'lib/antlr3/recognizers.rb', line 38 def token_start_column @token_start_column end |
- (Object) token_start_line
Returns the value of attribute token_start_line
38 39 40 |
# File 'lib/antlr3/recognizers.rb', line 38 def token_start_line @token_start_line end |
- (Object) token_start_position
Returns the value of attribute token_start_position
38 39 40 |
# File 'lib/antlr3/recognizers.rb', line 38 def token_start_position @token_start_position end |
- (Object) type
Returns the value of attribute type
38 39 40 |
# File 'lib/antlr3/recognizers.rb', line 38 def type @type end |
Instance Method Details
- (Object) reset!
restores all of the state variables to their respective initial default values
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/antlr3/recognizers.rb', line 108 def reset! self.following.clear self.error_recovery = false self.last_error_index = -1 self.backtracking = 0 self.rule_memory and rule_memory.clear self.syntax_errors = 0 self.token = nil self.token_start_position = -1 self.token_start_line = nil self.token_start_column = nil self.channel = nil self.type = nil self.text = nil end |