sparklemotion/rexical

Meaningful error messages in case of mismatch

Closed this issue · 1 comments

v0dro commented

This my text:

defn
hi
uu

end

This is my lexer code:

class Sample
rule
  . { puts "hello" }

inner

  def tokenize(code)
    scan_setup(code)
    tokens = []
    while token = next_token
      tokens << token
    end
    tokens
  end
end

This is the execution script:

require_relative 'lexer.rex.rb'

e = Sample.new
f = File.read("test.c")
puts f
e.tokenize(f)

...and here's the error message:

in `_next_token': can not match: ' (Sample::ScanError)
hi
uu

end'

Error message conveys no information about the character that could not be matched.

Apologies this never received a response. If you still need help, please reply and I'll reopen and try to help.