Class: ATNState
Direct Known Subclasses
BasicState, BlockEndState, DecisionState, LoopEndState, RuleStartState, RuleStopState, StarLoopbackState
Constant Summary collapse
- INVALID_TYPE =
constants for serialization
0- BASIC =
1- RULE_START =
2- BLOCK_START =
3- PLUS_BLOCK_START =
4- STAR_BLOCK_START =
5- TOKEN_START =
6- RULE_STOP =
7- BLOCK_END =
8- STAR_LOOP_BACK =
9- STAR_LOOP_ENTRY =
10- PLUS_LOOP_BACK =
11- LOOP_END =
12- INVALID_STATE_NUMBER =
-1
Instance Attribute Summary collapse
-
#atn ⇒ Object
Returns the value of attribute atn.
-
#epsilonOnlyTransitions ⇒ Object
Returns the value of attribute epsilonOnlyTransitions.
-
#nextTokenWithinRule ⇒ Object
Returns the value of attribute nextTokenWithinRule.
-
#ruleIndex ⇒ Object
Returns the value of attribute ruleIndex.
-
#serializationNames ⇒ Object
readonly
Returns the value of attribute serializationNames.
-
#stateNumber ⇒ Object
Returns the value of attribute stateNumber.
-
#stateType ⇒ Object
Returns the value of attribute stateType.
-
#transitions ⇒ Object
Returns the value of attribute transitions.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #addTransition(trans, index = -1)) ⇒ Object
- #hash ⇒ Object
-
#initialize ⇒ ATNState
constructor
A new instance of ATNState.
- #inspect ⇒ Object
- #isNonGreedyExitState ⇒ Object
- #onlyHasEpsilonTransitions ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ ATNState
Returns a new instance of ATNState.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/antlr4/atn/ATNState.rb', line 28 def initialize() # Which ATN are we in? @atn = nil @stateNumber = ATNState::INVALID_STATE_NUMBER @stateType = nil @ruleIndex = 0 # at runtime, we don't have Rule objects @epsilonOnlyTransitions = false # Track the transitions emanating from this ATN state. @transitions = Array.new # Used to cache lookahead during parsing, not used during construction @nextTokenWithinRule = nil @serializationNames = [ "INVALID", "BASIC", "RULE_START", "BLOCK_START", "PLUS_BLOCK_START", "STAR_BLOCK_START", "TOKEN_START", "RULE_STOP", "BLOCK_END", "STAR_LOOP_BACK", "STAR_LOOP_ENTRY", "PLUS_LOOP_BACK", "LOOP_END" ] end |
Instance Attribute Details
#atn ⇒ Object
Returns the value of attribute atn.
25 26 27 |
# File 'lib/antlr4/atn/ATNState.rb', line 25 def atn @atn end |
#epsilonOnlyTransitions ⇒ Object
Returns the value of attribute epsilonOnlyTransitions.
26 27 28 |
# File 'lib/antlr4/atn/ATNState.rb', line 26 def epsilonOnlyTransitions @epsilonOnlyTransitions end |
#nextTokenWithinRule ⇒ Object
Returns the value of attribute nextTokenWithinRule.
26 27 28 |
# File 'lib/antlr4/atn/ATNState.rb', line 26 def nextTokenWithinRule @nextTokenWithinRule end |
#ruleIndex ⇒ Object
Returns the value of attribute ruleIndex.
25 26 27 |
# File 'lib/antlr4/atn/ATNState.rb', line 25 def ruleIndex @ruleIndex end |
#serializationNames ⇒ Object (readonly)
Returns the value of attribute serializationNames.
27 28 29 |
# File 'lib/antlr4/atn/ATNState.rb', line 27 def serializationNames @serializationNames end |
#stateNumber ⇒ Object
Returns the value of attribute stateNumber.
25 26 27 |
# File 'lib/antlr4/atn/ATNState.rb', line 25 def stateNumber @stateNumber end |
#stateType ⇒ Object
Returns the value of attribute stateType.
25 26 27 |
# File 'lib/antlr4/atn/ATNState.rb', line 25 def stateType @stateType end |
#transitions ⇒ Object
Returns the value of attribute transitions.
26 27 28 |
# File 'lib/antlr4/atn/ATNState.rb', line 26 def transitions @transitions end |
Instance Method Details
#==(other) ⇒ Object
59 60 61 62 63 64 65 |
# File 'lib/antlr4/atn/ATNState.rb', line 59 def ==(other) if other.kind_of? ATNState then other and self.stateNumber==other.stateNumber else false end end |
#addTransition(trans, index = -1)) ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/antlr4/atn/ATNState.rb', line 79 def addTransition(trans, index=-1) if self.transitions.length==0 self.epsilonOnlyTransitions = trans.isEpsilon elsif self.epsilonOnlyTransitions != trans.isEpsilon self.epsilonOnlyTransitions = false # TODO System.err.format(Locale.getDefault(), "ATN state %d has both epsilon and non-epsilon transitions.\n", stateNumber); end if index==-1 self.transitions.push(trans) else self.transitions.insert(index, trans) end end |
#hash ⇒ Object
55 56 57 |
# File 'lib/antlr4/atn/ATNState.rb', line 55 def hash return self.stateNumber end |
#inspect ⇒ Object
76 77 78 |
# File 'lib/antlr4/atn/ATNState.rb', line 76 def inspect "<ATNState #{self.stateNumber.to_s} >" end |
#isNonGreedyExitState ⇒ Object
69 70 71 |
# File 'lib/antlr4/atn/ATNState.rb', line 69 def isNonGreedyExitState return false end |
#onlyHasEpsilonTransitions ⇒ Object
66 67 68 |
# File 'lib/antlr4/atn/ATNState.rb', line 66 def onlyHasEpsilonTransitions self.epsilonOnlyTransitions end |
#to_s ⇒ Object
73 74 75 |
# File 'lib/antlr4/atn/ATNState.rb', line 73 def to_s self.stateNumber.to_s end |