class Antlr4::Runtime::SingletonPredictionContext

Attributes

parent[RW]
return_state[RW]

Public Class Methods

new(parent, return_state) click to toggle source
Calls superclass method Antlr4::Runtime::PredictionContext::new
# File lib/antlr4/runtime/singleton_prediction_context.rb, line 7
def initialize(parent, return_state)
  super(!parent.nil? ? PredictionContextUtils.calculate_hash_code1(parent, return_state) : PredictionContextUtils.calculate_empty_hash_code)
  @parent = parent
  @return_state = return_state
end

Public Instance Methods

empty?() click to toggle source
# File lib/antlr4/runtime/singleton_prediction_context.rb, line 21
def empty?
  @return_state == EMPTY_RETURN_STATE
end
equals(other) click to toggle source
# File lib/antlr4/runtime/singleton_prediction_context.rb, line 29
def equals(other)
  if self == other
    return true
  elsif !(other.is_a? SingletonPredictionContext)
    return false
  end

  if hash != other.hash
    return false # can't be same if hash is different
  end

  @return_state == other.return_state && (!@parent.nil? && @parent.eql?(other.parent))
end
get_parent(_i) click to toggle source
# File lib/antlr4/runtime/singleton_prediction_context.rb, line 13
def get_parent(_i)
  @parent
end
get_return_state(_index) click to toggle source
# File lib/antlr4/runtime/singleton_prediction_context.rb, line 25
def get_return_state(_index)
  @return_state
end
size() click to toggle source
# File lib/antlr4/runtime/singleton_prediction_context.rb, line 17
def size
  1
end
to_s() click to toggle source
# File lib/antlr4/runtime/singleton_prediction_context.rb, line 43
def to_s
  up = !@parent.nil? ? @parent.to_s : ''
  if up.empty?
    return '$' if @return_state == EMPTY_RETURN_STATE

    return @return_state.to_s
  end
  @return_state.to_s + ' ' + up
end