class Antlr4::Runtime::PredictionContext
Constants
- EMPTY_RETURN_STATE
- INITIAL_HASH
Attributes
cached_hash_code[RW]
Public Class Methods
new(cached_hash_code)
click to toggle source
# File lib/antlr4/runtime/prediction_context.rb, line 13 def initialize(cached_hash_code) @id = @@global_node_count @@global_node_count += 1 @cached_hash_code = cached_hash_code end
Public Instance Methods
empty_path?()
click to toggle source
# File lib/antlr4/runtime/prediction_context.rb, line 19 def empty_path? # since EMPTY_RETURN_STATE can only appear in the last position, we check last one get_return_state(size - 1) == EMPTY_RETURN_STATE end
hash()
click to toggle source
# File lib/antlr4/runtime/prediction_context.rb, line 23 def hash @cached_hash_code end
to_s_recog(_recog)
click to toggle source
# File lib/antlr4/runtime/prediction_context.rb, line 27 def to_s_recog(_recog) to_s end
to_strings(recognizer, current_state)
click to toggle source
# File lib/antlr4/runtime/prediction_context.rb, line 31 def to_strings(recognizer, current_state) to_strings3(recognizer, EMPTY, current_state) end
to_strings3(_recognizer, _stop, _current_state)
click to toggle source
# File lib/antlr4/runtime/prediction_context.rb, line 35 def to_strings3(_recognizer, _stop, _current_state) result = [] while to_strings3_inner result end result end
to_strings3_inner(result)
click to toggle source
# File lib/antlr4/runtime/prediction_context.rb, line 45 def to_strings3_inner(result) perm = 0 while perm offset = 0 last = true p = self state_number = current_state local_buffer = '' local_buffer << '[' while !p.empty? && p != stop index = 0 unless p.empty? bits = 1 bits += 1 while (1 << bits) < p.size mask = (1 << bits) - 1 index = (perm >> offset) & mask last &= index >= p.size - 1 return true if index >= p.size offset += bits end if !recognizer.nil? if local_buffer.length > 1 # first char is '[', if more than that this isn't the first rule local_buffer << ' ' end atn = recognizer.getATN s = atn.states.get(state_number) ruleName = recognizer.rule_names[s.rule_index] local_buffer << ruleName elsif p.get_return_state(index) != EMPTY_RETURN_STATE unless p.empty? if local_buffer.length > 1 # first char is '[', if more than that this isn't the first rule local_buffer << ' ' end local_buffer << p.get_return_state(index) end end state_number = p.get_return_state(index) p = p.getParent(index) end local_buffer << ']' result.push(local_buffer.to_s) break if last perm += 1 end false end