Class: ArrayPredictionContext
Constant Summary
PredictionContext::EMPTY_RETURN_STATE
Instance Attribute Summary
#cachedHashCode
Instance Method Summary
collapse
EMPTY, EMPTY_RETURN_STATE, calculateEmptyHashCode, calculateHashCode, #hasEmptyPath, #hash, #initialize
Instance Method Details
#==(other) ⇒ Object
229
230
231
232
233
234
235
236
237
|
# File 'lib/antlr4/PredictionContext.rb', line 229
def ==(other)
return false if self.class != other.class
return true if self.equal?(other)
if self.hash != other.hash
false
else
self.returnStates==other.returnStates and self.parents==other.parents
end
end
|
#eql?(other) ⇒ Boolean
226
227
228
|
# File 'lib/antlr4/PredictionContext.rb', line 226
def eql?(other)
self == other
end
|
#getParent(index) ⇒ Object
220
221
222
|
# File 'lib/antlr4/PredictionContext.rb', line 220
def getParent(index)
return self.parents[index]
end
|
#getReturnState(index) ⇒ Object
223
224
225
|
# File 'lib/antlr4/PredictionContext.rb', line 223
def getReturnState(index)
return self.returnStates[index]
end
|
#initialzie(parents, returnStates) ⇒ Object
Parent can be null only if full ctx mode and we make an array
from {@link
returnState == {@link
202
203
204
205
206
207
208
|
# File 'lib/antlr4/PredictionContext.rb', line 202
def initialzie(parents, returnStates)
super(PredictionContext.calculateHashCode(parents, returnStates))
self.parents = parents
self.returnStates = returnStates
end
|
210
211
212
213
214
|
# File 'lib/antlr4/PredictionContext.rb', line 210
def isEmpty
return self.returnStates[0]==PredictionContext::EMPTY_RETURN_STATE
end
|
216
217
218
|
# File 'lib/antlr4/PredictionContext.rb', line 216
def length
return self.returnStates.length()
end
|
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
|
# File 'lib/antlr4/PredictionContext.rb', line 239
def to_s
if self.isEmpty()
return "[]"
end
StringIO.open do |buf|
buf.write("[")
for i in 0..self.returnStates.length-1 do
buf.write(", ") if i>0
if self.returnStates[i]==PredictionContext::EMPTY_RETURN_STATE
buf.write("$")
next
end
buf.write(self.returnStates[i].to_s)
if not self.parents[i].nil?
buf.write(' ')
buf.write(self.parents[i].to_s())
end
end
buf.write("]")
return buf.string()
end
end
|