Class: Antlr4ruby::SingletonPredictionContext

Inherits:
PredictionContext show all
Defined in:
lib/antlr4ruby/atn/context/singleton_prediction_context.rb

Direct Known Subclasses

EmptyPredictionContext

Constant Summary

Constants inherited from PredictionContext

PredictionContext::EMPTY_RETURN_STATE

Instance Attribute Summary collapse

Attributes inherited from PredictionContext

#cached_hash_code, #id

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from PredictionContext

from_rule_context, get_all_context_nodes, get_all_context_nodes_, get_cached_context, #has_empty_path?, #hash, #is_empty?, merge, merge_arrays, merge_root, merge_singletons, to_dot_string

Constructor Details

#initialize(parent, return_state) ⇒ SingletonPredictionContext

Returns a new instance of SingletonPredictionContext.



5
6
7
8
# File 'lib/antlr4ruby/atn/context/singleton_prediction_context.rb', line 5

def initialize(parent, return_state)
  super(parent ? calculate_hash_code(parent, return_state) : calculate_empty_hash_code)
  @parent, @return_state = parent, return_state
end

Instance Attribute Details

#parentObject (readonly)

Returns the value of attribute parent.



3
4
5
# File 'lib/antlr4ruby/atn/context/singleton_prediction_context.rb', line 3

def parent
  @parent
end

#return_stateObject (readonly)

Returns the value of attribute return_state.



3
4
5
# File 'lib/antlr4ruby/atn/context/singleton_prediction_context.rb', line 3

def return_state
  @return_state
end

Class Method Details

.create(parent, return_state) ⇒ Object



10
11
12
13
# File 'lib/antlr4ruby/atn/context/singleton_prediction_context.rb', line 10

def self.create(parent, return_state)
  return EmptyPredictionContext.INSTANCE if return_state == EMPTY_RETURN_STATE && !parent
  SingletonPredictionContext.new(parent, return_state)
end

Instance Method Details

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/antlr4ruby/atn/context/singleton_prediction_context.rb', line 31

def eql?(other)
  # todo

end

#get_parent(index) ⇒ Object



15
16
17
# File 'lib/antlr4ruby/atn/context/singleton_prediction_context.rb', line 15

def get_parent(index)
  parent
end

#get_return_state(index) ⇒ Object



19
20
21
# File 'lib/antlr4ruby/atn/context/singleton_prediction_context.rb', line 19

def get_return_state(index)
  return_state
end

#sizeObject



23
24
25
# File 'lib/antlr4ruby/atn/context/singleton_prediction_context.rb', line 23

def size
  1
end

#to_sObject



27
28
29
# File 'lib/antlr4ruby/atn/context/singleton_prediction_context.rb', line 27

def to_s
  # todo

end