Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/tokenize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -766,15 +766,17 @@ function lex_xor(l::Lexer)
end

function accept_number(l::Lexer, f::F) where {F}
lexed_number = false
while true
pc, ppc = dpeekchar(l)
if pc == '_' && !f(ppc)
return
return lexed_number
elseif f(pc) || pc == '_'
readchar(l)
else
return
return lexed_number
end
lexed_number = true
end
end

Expand Down Expand Up @@ -864,7 +866,9 @@ function lex_digit(l::Lexer, kind)
if accept(l, "pP")
kind = K"Float"
accept(l, "+-−")
accept_number(l, isdigit)
if !accept_number(l, isdigit)
return emit_error(l, K"ErrorInvalidNumericConstant")
end
elseif isfloat
return emit_error(l, K"ErrorInvalidNumericConstant")
end
Expand Down
1 change: 1 addition & 0 deletions test/tokenize.jl
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,7 @@ end
@test kind.(collect(tokenize("3.2e2.2"))) == [K"ErrorInvalidNumericConstant", K"Integer", K"EndMarker"]
@test kind.(collect(tokenize("3e2.2"))) == [K"ErrorInvalidNumericConstant", K"Integer", K"EndMarker"]
@test kind.(collect(tokenize("0b101__101"))) == [K"BinInt", K"Identifier", K"EndMarker"]
@test tok("0x1p").kind == K"ErrorInvalidNumericConstant"
end

@testset "floating points" begin
Expand Down