class ANTLR3::RecognizerSharedState

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

Public Class Methods

new() click to toggle source
Calls superclass method
# 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

Public Instance Methods

reset!() click to toggle source

restores all of the state variables to their respective initial default values

# 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