Parent

Dhaka::LexerSupport::DFARun

Public Class Methods

new(dfa, input) click to toggle source
# File lib/dhaka/lexer/dfa.rb, line 89
def initialize(dfa, input)
  @dfa, @input = dfa, input
  @matched = ""
  @not_yet_accepted = ""
  @curr_state = @dfa.start_state
end

Public Instance Methods

accept(pattern) click to toggle source
# File lib/dhaka/lexer/dfa.rb, line 110
def accept(pattern)
  @matched.concat @not_yet_accepted
  @not_yet_accepted = ""
end
accept_last_saved_checkpoint(pattern) click to toggle source
# File lib/dhaka/lexer/dfa.rb, line 115
def accept_last_saved_checkpoint(pattern)
  @matched = @last_saved_checkpoint
  @not_yet_accepted = ""
end
match() click to toggle source
# File lib/dhaka/lexer/dfa.rb, line 96
def match
  @input.unpack("C*").each do |i|
    break unless dest_state = @curr_state.transitions[i.chr]
    @not_yet_accepted << i.chr
    @curr_state = dest_state
    @curr_state.process(self)
  end
  @matched
end
save_checkpoint(pattern) click to toggle source
# File lib/dhaka/lexer/dfa.rb, line 106
def save_checkpoint(pattern)
  @last_saved_checkpoint = @matched + @not_yet_accepted
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.