class Kleene::BatchMatchTracker
def add_empty_match(nfa_with_dead_end, token_index)
def add_empty_match(nfa_with_dead_end, token_index) positions = empty_match_positions(nfa_with_dead_end) positions << token_index end
def add_end_of_match(nfa_with_dead_end, token_index)
def add_end_of_match(nfa_with_dead_end, token_index) # puts "add_end_of_match(#{nfa.object_id}, #{token_index})" positions = end_positions(nfa_with_dead_end) positions << token_index end
def add_match(nfa, match)
def add_match(nfa, match) matches = matches_for(nfa) matches << match end
def add_start_of_candidate_match(nfa_with_dead_end, token_index)
def add_start_of_candidate_match(nfa_with_dead_end, token_index) # puts "add_start_of_candidate_match(#{nfa.object_id}, #{token_index})" positions = start_positions(nfa_with_dead_end) positions << token_index end
def empty_match_positions(nfa)
def empty_match_positions(nfa) empty_matches[nfa] ||= Array.new end
def end_positions(nfa)
def end_positions(nfa) match_end_positions[nfa] ||= Array.new end
def initialize
def initialize reset end
def invert_candidate_match_start_positions # : Hash(Int32, Array(NFA))
def invert_candidate_match_start_positions # : Hash(Int32, Array(NFA)) index_to_nfas = Hash.new candidate_match_start_positions.each do |nfa_with_dead_end, indices| indices.each do |index| nfas = index_to_nfas[index] ||= Array.new nfas << nfa_with_dead_end end end index_to_nfas end
def matches_for(nfa)
def matches_for(nfa) matches[nfa] ||= Array.new end
def reset
def reset @candidate_match_start_positions = Hash.new @match_end_positions = Hash.new @empty_matches = Hash.new @matches = Hash.new end
def start_positions(nfa)
def start_positions(nfa) candidate_match_start_positions[nfa] ||= Array.new end