Class: SingletonPredictionContext
Constant Summary
PredictionContext::EMPTY_RETURN_STATE
Instance Attribute Summary collapse
#cachedHashCode
Class Method Summary
collapse
Instance Method Summary
collapse
EMPTY, EMPTY_RETURN_STATE, calculateEmptyHashCode, calculateHashCode, #hasEmptyPath, #isEmpty
Constructor Details
Returns a new instance of SingletonPredictionContext.
109
110
111
112
113
114
115
116
117
118
119
|
# File 'lib/antlr4/PredictionContext.rb', line 109
def initialize( parent, returnState)
if parent.nil? then
hashCode = PredictionContext.calculateEmptyHashCode
else
hashCode = PredictionContext.calculateHashCode(parent, returnState)
end
super(hashCode)
@parentCtx = parent
@returnState = returnState
end
|
Instance Attribute Details
#cache_string ⇒ Object
Returns the value of attribute cache_string.
108
109
110
|
# File 'lib/antlr4/PredictionContext.rb', line 108
def cache_string
@cache_string
end
|
#parentCtx ⇒ Object
Returns the value of attribute parentCtx.
107
108
109
|
# File 'lib/antlr4/PredictionContext.rb', line 107
def parentCtx
@parentCtx
end
|
#returnState ⇒ Object
Returns the value of attribute returnState.
107
108
109
|
# File 'lib/antlr4/PredictionContext.rb', line 107
def returnState
@returnState
end
|
Class Method Details
.create(parent, returnState) ⇒ Object
98
99
100
101
102
103
104
105
|
# File 'lib/antlr4/PredictionContext.rb', line 98
def self.create(parent, returnState)
if returnState == PredictionContext::EMPTY_RETURN_STATE and parent.nil? then
return PredictionContext.EMPTY
else
return SingletonPredictionContext.new(parent, returnState)
end
end
|
Instance Method Details
#==(other) ⇒ Object
138
139
140
141
142
143
144
145
146
147
148
|
# File 'lib/antlr4/PredictionContext.rb', line 138
def ==(other)
return true if self.equal?(other)
return false unless self.class == other.class
if self.hash != other.hash
false
else
self.returnState == other.returnState and \
(self.parentCtx.equal?(other.parentCtx) \
or self.parentCtx==other.parentCtx )
end
end
|
#eql?(other) ⇒ Boolean
135
136
137
|
# File 'lib/antlr4/PredictionContext.rb', line 135
def eql?(other)
self == other
end
|
#getParent(index) ⇒ Object
125
126
127
128
|
# File 'lib/antlr4/PredictionContext.rb', line 125
def getParent(index)
return self.parentCtx
end
|
#getReturnState(index) ⇒ Object
130
131
132
133
|
# File 'lib/antlr4/PredictionContext.rb', line 130
def getReturnState(index)
return self.returnState
end
|
149
150
151
|
# File 'lib/antlr4/PredictionContext.rb', line 149
def hash
return self.cachedHashCode
end
|
121
122
123
|
# File 'lib/antlr4/PredictionContext.rb', line 121
def length
return 1
end
|
#mk_string ⇒ Object
157
158
159
160
161
162
163
164
165
166
167
|
# File 'lib/antlr4/PredictionContext.rb', line 157
def mk_string
if @parentCtx.nil? then
if @returnState == PredictionContext::EMPTY_RETURN_STATE
return "$"
else
return @returnState.to_s
end
else
return "#{@returnState} #{@parentCtx}"
end
end
|
153
154
155
156
|
# File 'lib/antlr4/PredictionContext.rb', line 153
def to_s
@cache_string = mk_string if @cache_string.nil?
return @cache_string
end
|