Class: Antlr4ruby::ArrayPredictionContext
- Inherits:
-
PredictionContext
- Object
- PredictionContext
- Antlr4ruby::ArrayPredictionContext
- Defined in:
- lib/antlr4ruby/atn/context/array_prediction_context.rb
Constant Summary
Constants inherited from PredictionContext
PredictionContext::EMPTY_RETURN_STATE
Instance Attribute Summary collapse
-
#parents ⇒ Object
readonly
Returns the value of attribute parents.
-
#return_states ⇒ Object
readonly
Returns the value of attribute return_states.
Attributes inherited from PredictionContext
Instance Method Summary collapse
- #get_parent(index) ⇒ Object
- #get_return_state(index) ⇒ Object
-
#initialize(context: nil, parents: [], return_states: []) ⇒ ArrayPredictionContext
constructor
A new instance of ArrayPredictionContext.
- #is_empty? ⇒ Boolean
- #size ⇒ Object
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
#parents ⇒ Object (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_states ⇒ Object (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
13 14 15 |
# File 'lib/antlr4ruby/atn/context/array_prediction_context.rb', line 13 def is_empty? return_states[0] == EMPTY_RETURN_STATE end |
#size ⇒ Object
17 18 19 |
# File 'lib/antlr4ruby/atn/context/array_prediction_context.rb', line 17 def size return_states.length end |