Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update Parsers support #327

Merged
merged 3 commits into from
Aug 1, 2021
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
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[compat]
julia = "0.7, 1.0"
Parsers = "0.1, 0.2, 0.3, 1"
Parsers = "1, 2"

[targets]
test = ["DataStructures", "Distributed", "FixedPointNumbers", "OffsetArrays", "Sockets", "Test"]
12 changes: 1 addition & 11 deletions src/Parser.jl
Original file line number Diff line number Diff line change
Expand Up @@ -319,17 +319,7 @@ byte before `to`. Bytes enclosed should all be ASCII characters.
float_from_bytes(bytes::MemoryParserState, from::Int, to::Int) = float_from_bytes(bytes.utf8, from, to)

function float_from_bytes(bytes::Union{String, Vector{UInt8}}, from::Int, to::Int)::Union{Float64,Nothing}
# Would like to use tryparse, but we want it to consume the full input,
# and the version in Parsers does not do this.

# return Parsers.tryparse(Float64, @view bytes.utf8[from:to])

len = to - from + 1
x, code, vpos, vlen, tlen = Parsers.xparse(Float64, bytes, from, to, Parsers.OPTIONS)
if !Parsers.ok(code) || vlen < len
return nothing
end
return x::Float64
return Parsers.tryparse(Float64, bytes isa String ? SubString(bytes, from:to) : view(bytes, from:to))
end

"""
Expand Down
2 changes: 1 addition & 1 deletion test/json-checker.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Run modified JSON checker tests

const JSON_DATA_DIR = joinpath(dirname(@__DIR__), "data")
const JSON_DATA_DIR = joinpath(dirname(pathof(JSON)), "../data")

for i in 1:38
file = "fail$(lpad(string(i), 2, "0")).json"
Expand Down