Class: Antlr4ruby::ArrayPredictionContext

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

Constant Summary

Constants inherited from PredictionContext

PredictionContext::EMPTY_RETURN_STATE

Instance Attribute Summary collapse

Attributes inherited from PredictionContext

#cached_hash_code, #id

Instance Method Summary collapse

Methods inherited from PredictionContext

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

Constructor Details

#initialize(context: nil, parents: [], return_states: []) ⇒ ArrayPredictionContext

Returns a new instance of ArrayPredictionContext.



6
7
8
9
10
11
12
# File 'lib/antlr4ruby/atn/context/array_prediction_context.rb', line 6

def initialize(context: nil, parents:[], return_states: [])
  if context
    parents,  return_states = [context.parent], [context.return_state]
  end
  super(calculate_hash_code(parents, return_states))
  @parents, @return_states = parents, return_states
end

Instance Attribute Details

#parentsObject (readonly)

Returns the value of attribute parents.



4
5
6
# File 'lib/antlr4ruby/atn/context/array_prediction_context.rb', line 4

def parents
  @parents
end

#return_statesObject (readonly)

Returns the value of attribute return_states.



4
5
6
# File 'lib/antlr4ruby/atn/context/array_prediction_context.rb', line 4

def return_states
  @return_states
end

Instance Method Details

#get_parent(index) ⇒ Object



21
22
23
# File 'lib/antlr4ruby/atn/context/array_prediction_context.rb', line 21

def get_parent(index)
  parents[index]
end

#get_return_state(index) ⇒ Object



25
26
27
# File 'lib/antlr4ruby/atn/context/array_prediction_context.rb', line 25

def get_return_state(index)
  return_states[index]
end

#is_empty?Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/antlr4ruby/atn/context/array_prediction_context.rb', line 13

def is_empty?
  return_states[0] == EMPTY_RETURN_STATE
end

#sizeObject



17
18
19
# File 'lib/antlr4ruby/atn/context/array_prediction_context.rb', line 17

def size
  return_states.length
end