class ActionDispatch::Journey::Scanner

:nodoc:
:nodoc:

def initialize

def initialize
  @scanner = nil
  @length = nil
end

def last_literal

def last_literal
  last_str = @scanner.string.byteslice(@scanner.pos - @length, @length)
  last_str.tr! "\\", ""
  -last_str
end

def last_string

def last_string
  -@scanner.string.byteslice(@scanner.pos - @length, @length)
end

def next_byte_is_not_a_token?

def next_byte_is_not_a_token?
  !STATIC_TOKENS[@scanner.string.getbyte(@scanner.pos + 1)]
end

def next_token

def next_token
  return if @scanner.eos?
  until token = scan || @scanner.eos?; end
  token
end

def scan

def scan
  next_byte = @scanner.peek_byte
  case
  when (token = STATIC_TOKENS[next_byte]) && (token != :SYMBOL || next_byte_is_not_a_token?)
    @scanner.pos += 1
    @length = @scanner.skip(/\w+/).to_i + 1 if token == :SYMBOL || token == :STAR
    token
  when @length = @scanner.skip(/(?:[\w%\-~!$&'*+,;=@]|\\[:()])+/)
    :LITERAL
  when @length = @scanner.skip(/./)
    :LITERAL
  end
end

def scan_setup(str)

def scan_setup(str)
  @scanner = Scanner.new(str)
end