Class: SimState
Overview
When we hit an accept state in either the DFA or the ATN, we
have to notify the character stream to start buffering characters
via {@link IntStream#mark} and record the current state. The current sim state
includes the current index into the input, the current line,
and current character position in that line. Note that the Lexer is
tracking the starting line and characterization of the token. These
variables track the "state" of the simulator when it hits an accept state.
<p>We track these variables separately for the DFA and ATN simulation
because the DFA simulation often has to fail over to the ATN
simulation. If the ATN simulation fails, we need the DFA to fall
back to its previously accepted state, if any. If the ATN succeeds,
then the ATN does the accept and the DFA simulator that invoked it
can simply return the predicted token type.</p>
Instance Attribute Summary collapse
-
#column ⇒ Object
Returns the value of attribute column.
-
#dfaState ⇒ Object
Returns the value of attribute dfaState.
-
#index ⇒ Object
Returns the value of attribute index.
-
#line ⇒ Object
Returns the value of attribute line.
Instance Method Summary collapse
-
#initialize ⇒ SimState
constructor
A new instance of SimState.
- #reset ⇒ Object
Constructor Details
#initialize ⇒ SimState
Returns a new instance of SimState.
19 20 21 |
# File 'lib/antlr4/atn/LexerATNSimulator.rb', line 19 def initialize self.reset() end |
Instance Attribute Details
#column ⇒ Object
Returns the value of attribute column.
18 19 20 |
# File 'lib/antlr4/atn/LexerATNSimulator.rb', line 18 def column @column end |
#dfaState ⇒ Object
Returns the value of attribute dfaState.
18 19 20 |
# File 'lib/antlr4/atn/LexerATNSimulator.rb', line 18 def dfaState @dfaState end |
#index ⇒ Object
Returns the value of attribute index.
18 19 20 |
# File 'lib/antlr4/atn/LexerATNSimulator.rb', line 18 def index @index end |
#line ⇒ Object
Returns the value of attribute line.
18 19 20 |
# File 'lib/antlr4/atn/LexerATNSimulator.rb', line 18 def line @line end |
Instance Method Details
#reset ⇒ Object
23 24 25 26 27 28 |
# File 'lib/antlr4/atn/LexerATNSimulator.rb', line 23 def reset @index = -1 @line = 0 @column = -1 @dfaState = nil end |