File tree Expand file tree Collapse file tree 2 files changed +19
-6
lines changed Expand file tree Collapse file tree 2 files changed +19
-6
lines changed Original file line number Diff line number Diff line change @@ -763,12 +763,13 @@ function lex_digit(l::Lexer, kind)
763
763
accept_number (l, isdigit)
764
764
pc,ppc = dpeekchar (l)
765
765
if pc == ' .'
766
- if kind === K " Float"
766
+ if ppc == ' .'
767
+ # Number followed by K".." or K"..."
768
+ return emit (l, kind)
769
+ elseif kind === K " Float"
767
770
# If we enter the function with kind == K"Float" then a '.' has been parsed.
768
771
readchar (l)
769
772
return emit_error (l, K " ErrorInvalidNumericConstant" )
770
- elseif ppc == ' .'
771
- return emit (l, kind)
772
773
elseif is_operator_start_char (ppc) && ppc != = ' :'
773
774
readchar (l)
774
775
return emit_error (l)
@@ -838,7 +839,9 @@ function lex_digit(l::Lexer, kind)
838
839
readchar (l)
839
840
! (ishex (ppc) || ppc == ' .' ) && return emit_error (l, K " ErrorInvalidNumericConstant" )
840
841
accept_number (l, ishex)
841
- if accept (l, ' .' )
842
+ pc,ppc = dpeekchar (l)
843
+ if pc == ' .' && ppc != ' .'
844
+ readchar (l)
842
845
accept_number (l, ishex)
843
846
isfloat = true
844
847
end
Original file line number Diff line number Diff line change @@ -21,6 +21,13 @@ tok(str, i = 1) = collect(tokenize(str))[i]
21
21
22
22
strtok (str) = untokenize .(collect (tokenize (str)), str)
23
23
24
+ function toks (str)
25
+ ts = [untokenize (t, str)=> kind (t) for t in tokenize (str)]
26
+ @test ts[end ] == (" " => K " EndMarker" )
27
+ pop! (ts)
28
+ ts
29
+ end
30
+
24
31
@testset " tokens" begin
25
32
for s in [" a" , IOBuffer (" a" )]
26
33
l = tokenize (s)
553
560
@test kind (tok (" 1234x" , 2 )) == K " Identifier"
554
561
end
555
562
556
- @testset " floats with trailing `.` " begin
563
+ @testset " numbers with trailing `.` " begin
557
564
@test tok (" 1.0" ). kind == K " Float"
558
565
@test tok (" 1.a" ). kind == K " Float"
559
566
@test tok (" 1.(" ). kind == K " Float"
569
576
@test tok (" 1." ). kind == K " Float"
570
577
@test tok (" 1.\" text\" " ). kind == K " Float"
571
578
572
- @test tok (" 1.." ). kind == K " Integer"
579
+ @test toks (" 1.." ) == [" 1" => K " Integer" , " .." => K " .." ]
580
+ @test toks (" .1.." ) == [" .1" => K " Float" , " .." => K " .." ]
581
+ @test toks (" 0x01.." ) == [" 0x01" => K " HexInt" , " .." => K " .." ]
582
+
573
583
@test kind .(collect (tokenize (" 1f0./1" ))) == [K " Float" , K " /" , K " Integer" , K " EndMarker" ]
574
584
end
575
585
You can’t perform that action at this time.
0 commit comments