@@ -12,19 +12,6 @@ include("tokenize_utils.jl")
1212# -------------------------------------------------------------------------------
1313# Tokens
1414
15- # Error kind => description
16- TOKEN_ERROR_DESCRIPTION = Dict {Kind, String} (
17- K " ErrorEofMultiComment" => " unterminated multi-line comment #= ... =#" ,
18- K " ErrorInvalidNumericConstant" => " invalid numeric constant" ,
19- K " ErrorInvalidInterpolationTerminator" => " interpolated variable ends with invalid character; use `\$ (...)` instead" ,
20- K " ErrorNumericOverflow" => " overflow in numeric literal" ,
21- K " ErrorInvalidEscapeSequence" => " invalid string escape sequence" ,
22- K " ErrorOverLongCharacter" => " character literal contains multiple characters" ,
23- K " ErrorInvalidOperator" => " invalid operator" ,
24- K " Error**" => " use `x^y` instead of `x**y` for exponentiation, and `x...` instead of `**x` for splatting" ,
25- K " error" => " unknown error token" ,
26- )
27-
2815struct Token
2916 kind:: Kind
3017 # Offsets into a string or buffer
@@ -283,11 +270,11 @@ function emit(l::Lexer, kind::Kind, maybe_op=true)
283270end
284271
285272"""
286- emit_error(l::Lexer, err::Kind=K"error" )
273+ emit_error(l::Lexer, err::Kind)
287274
288275Returns an `K"error"` token with error `err` and starts a new `Token`.
289276"""
290- function emit_error (l:: Lexer , err:: Kind = K " error " )
277+ function emit_error (l:: Lexer , err:: Kind )
291278 @assert is_error (err)
292279 return emit (l, err)
293280end
@@ -387,7 +374,7 @@ function _next_token(l::Lexer, c)
387374 elseif (k = get (UNICODE_OPS, c, K " error" )) != K " error"
388375 return emit (l, k)
389376 else
390- emit_error (l)
377+ emit_error (l, K " ErrorUnknownCharacter " )
391378 end
392379end
393380
@@ -785,7 +772,7 @@ function lex_digit(l::Lexer, kind)
785772 return emit_error (l, K " ErrorInvalidNumericConstant" )
786773 elseif is_operator_start_char (ppc) && ppc != = ' :'
787774 readchar (l)
788- return emit_error (l)
775+ return emit_error (l, K " ErrorAmbiguousNumericConstant " )
789776 elseif (! (isdigit (ppc) ||
790777 iswhitespace (ppc) ||
791778 is_identifier_start_char (ppc)
@@ -824,7 +811,7 @@ function lex_digit(l::Lexer, kind)
824811 return emit_error (l, K " ErrorInvalidNumericConstant" )
825812 end
826813 else
827- return emit_error (l)
814+ return emit_error (l, K " ErrorInvalidNumericConstant " )
828815 end
829816 elseif pc == ' .' && (is_identifier_start_char (ppc) || ppc == EOF_CHAR)
830817 readchar (l)
@@ -842,7 +829,7 @@ function lex_digit(l::Lexer, kind)
842829 return emit_error (l, K " ErrorInvalidNumericConstant" )
843830 end
844831 else
845- return emit_error (l)
832+ return emit_error (l, K " ErrorInvalidNumericConstant " )
846833 end
847834 elseif position (l) - startpos (l) == 1 && l. chars[1 ] == ' 0'
848835 kind == K " Integer"
0 commit comments