File tree 2 files changed +12
-6
lines changed
2 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -629,12 +629,13 @@ function lex_digit(l::Lexer, kind)
629
629
accept_number (l, isdigit)
630
630
pc,ppc = dpeekchar (l)
631
631
if pc == ' .'
632
- if kind === Tokens. FLOAT
632
+ if ppc == ' .'
633
+ # Number followed by .. or ...
634
+ return emit (l, kind)
635
+ elseif kind === Tokens. FLOAT
633
636
# If we enter the function with kind == FLOAT then a '.' has been parsed.
634
637
readchar (l)
635
638
return emit_error (l, Tokens. INVALID_NUMERIC_CONSTANT)
636
- elseif ppc == ' .'
637
- return emit (l, kind)
638
639
elseif is_operator_start_char (ppc) && ppc != = ' :'
639
640
readchar (l)
640
641
return emit_error (l)
@@ -703,7 +704,9 @@ function lex_digit(l::Lexer, kind)
703
704
readchar (l)
704
705
! (ishex (ppc) || ppc == ' .' ) && return emit_error (l, Tokens. INVALID_NUMERIC_CONSTANT)
705
706
accept_number (l, ishex)
706
- if accept (l, ' .' )
707
+ pc,ppc = dpeekchar (l)
708
+ if pc == ' .' && ppc != ' .'
709
+ readchar (l)
707
710
accept_number (l, ishex)
708
711
isfloat = true
709
712
end
Original file line number Diff line number Diff line change 358
358
@test tok (" 1234x" , 2 ). kind == T. IDENTIFIER
359
359
end
360
360
361
- @testset " floats with trailing `.` " begin
361
+ @testset " numbers with trailing `.` " begin
362
362
@test tok (" 1.0" ). kind == Tokens. FLOAT
363
363
@test tok (" 1.a" ). kind == Tokens. FLOAT
364
364
@test tok (" 1.(" ). kind == Tokens. FLOAT
373
373
@test tok (" 1." ). kind == Tokens. FLOAT
374
374
@test tok (" 1.\" text\" " ). kind == Tokens. FLOAT
375
375
376
- @test tok (" 1.." ). kind == Tokens. INTEGER
376
+ @test toks (" 1.." ) == [" 1" => Tokens. INTEGER, " .." => Tokens. DDOT]
377
+ @test toks (" .1.." ) == [" .1" => Tokens. FLOAT, " .." => Tokens. DDOT]
378
+ @test toks (" 0x01.." ) == [" 0x01" => Tokens. HEX_INT, " .." => Tokens. DDOT]
379
+
377
380
@test T. kind .(collect (tokenize (" 1f0./1" ))) == [T. FLOAT, T. OP, T. INTEGER, T. ENDMARKER]
378
381
end
379
382
You can’t perform that action at this time.
0 commit comments