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
-
#backtracking ⇒ Object
Returns the value of attribute backtracking.
-
#channel ⇒ Object
Returns the value of attribute channel.
-
#error_recovery ⇒ Object
Returns the value of attribute error_recovery.
-
#following ⇒ Object
Returns the value of attribute following.
-
#last_error_index ⇒ Object
Returns the value of attribute last_error_index.
-
#rule_memory ⇒ Object
Returns the value of attribute rule_memory.
-
#syntax_errors ⇒ Object
Returns the value of attribute syntax_errors.
-
#text ⇒ Object
Returns the value of attribute text.
-
#token ⇒ Object
Returns the value of attribute token.
-
#token_start_column ⇒ Object
Returns the value of attribute token_start_column.
-
#token_start_line ⇒ Object
Returns the value of attribute token_start_line.
-
#token_start_position ⇒ Object
Returns the value of attribute token_start_position.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize ⇒ RecognizerSharedState
constructor
A new instance of RecognizerSharedState.
-
#reset! ⇒ Object
restores all of the state variables to their respective initial default values.
Constructor Details
#initialize ⇒ RecognizerSharedState
Returns 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
#backtracking ⇒ Object
Returns the value of attribute backtracking
38 39 40 |
# File 'lib/antlr3/recognizers.rb', line 38 def backtracking @backtracking end |
#channel ⇒ Object
Returns the value of attribute channel
38 39 40 |
# File 'lib/antlr3/recognizers.rb', line 38 def channel @channel end |
#error_recovery ⇒ Object
Returns the value of attribute error_recovery
38 39 40 |
# File 'lib/antlr3/recognizers.rb', line 38 def error_recovery @error_recovery end |
#following ⇒ Object
Returns the value of attribute following
38 39 40 |
# File 'lib/antlr3/recognizers.rb', line 38 def following @following end |
#last_error_index ⇒ Object
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 |
#rule_memory ⇒ Object
Returns the value of attribute rule_memory
38 39 40 |
# File 'lib/antlr3/recognizers.rb', line 38 def rule_memory @rule_memory end |
#syntax_errors ⇒ Object
Returns the value of attribute syntax_errors
38 39 40 |
# File 'lib/antlr3/recognizers.rb', line 38 def syntax_errors @syntax_errors end |
#text ⇒ Object
Returns the value of attribute text
38 39 40 |
# File 'lib/antlr3/recognizers.rb', line 38 def text @text end |
#token ⇒ Object
Returns the value of attribute token
38 39 40 |
# File 'lib/antlr3/recognizers.rb', line 38 def token @token end |
#token_start_column ⇒ Object
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 |
#token_start_line ⇒ Object
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 |
#token_start_position ⇒ Object
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 |
#type ⇒ Object
Returns the value of attribute type
38 39 40 |
# File 'lib/antlr3/recognizers.rb', line 38 def type @type end |
Instance Method Details
#reset! ⇒ Object
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 |