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)
763763 accept_number (l, isdigit)
764764 pc,ppc = dpeekchar (l)
765765 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"
767770 # If we enter the function with kind == K"Float" then a '.' has been parsed.
768771 readchar (l)
769772 return emit_error (l, K " ErrorInvalidNumericConstant" )
770- elseif ppc == ' .'
771- return emit (l, kind)
772773 elseif is_operator_start_char (ppc) && ppc != = ' :'
773774 readchar (l)
774775 return emit_error (l)
@@ -838,7 +839,9 @@ function lex_digit(l::Lexer, kind)
838839 readchar (l)
839840 ! (ishex (ppc) || ppc == ' .' ) && return emit_error (l, K " ErrorInvalidNumericConstant" )
840841 accept_number (l, ishex)
841- if accept (l, ' .' )
842+ pc,ppc = dpeekchar (l)
843+ if pc == ' .' && ppc != ' .'
844+ readchar (l)
842845 accept_number (l, ishex)
843846 isfloat = true
844847 end
Original file line number Diff line number Diff line change @@ -21,6 +21,13 @@ tok(str, i = 1) = collect(tokenize(str))[i]
2121
2222strtok (str) = untokenize .(collect (tokenize (str)), str)
2323
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+
2431@testset " tokens" begin
2532 for s in [" a" , IOBuffer (" a" )]
2633 l = tokenize (s)
553560 @test kind (tok (" 1234x" , 2 )) == K " Identifier"
554561end
555562
556- @testset " floats with trailing `.` " begin
563+ @testset " numbers with trailing `.` " begin
557564 @test tok (" 1.0" ). kind == K " Float"
558565 @test tok (" 1.a" ). kind == K " Float"
559566 @test tok (" 1.(" ). kind == K " Float"
569576 @test tok (" 1." ). kind == K " Float"
570577 @test tok (" 1.\" text\" " ). kind == K " Float"
571578
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+
573583 @test kind .(collect (tokenize (" 1f0./1" ))) == [K " Float" , K " /" , K " Integer" , K " EndMarker" ]
574584end
575585
You can’t perform that action at this time.
0 commit comments