Handle lexer errors in --dump-lexer.
@@ -66,7 +66,12 @@ local inspect_opts = {
local function print_tokens(lexer)
while true do
- local token = lexer:next()
+ local token, err = lexer:next()
+ if not token then
+ local loc = lexer:loc()
+ print(string.format("%02d:%02d ERROR %s", loc.line, loc.col, err))
+ break
+ end
if token.name == "EOF" then
break
end
