Improve error messages with terminators

This commit is contained in:
José Valim
2012-07-20 13:04:33 +02:00
parent f6d869cb96
commit 49501ef59e
3 changed files with 72 additions and 20 deletions
+6 -3
View File
@@ -43,15 +43,18 @@ parse_error(Line, File, Error, []) ->
end,
raise(Line, File, 'Elixir.TokenMissingError', Message);
parse_error(Line, File, "syntax error before: ", "'end'") ->
raise(Line, File, 'Elixir.SyntaxError', <<"unexpected token: end">>);
parse_error(Line, File, Error, Token) ->
BinError = if
is_atom(Error) -> atom_to_binary(Error, utf8);
true -> iolist_to_binary(Error)
end,
BinToken = case Token of
[] -> <<>>;
_ -> iolist_to_binary(Token)
BinToken = if
Token == [] -> <<>>;
true -> iolist_to_binary(Token)
end,
Message = <<BinError / binary, BinToken / binary >>,