Skip to content

Commit

Permalink
Capture errors in parser
Browse files Browse the repository at this point in the history
  • Loading branch information
thofma committed Nov 21, 2023
1 parent 7a7abf4 commit 2a5ca9f
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions examples/NFDB.jl
Original file line number Diff line number Diff line change
Expand Up @@ -523,6 +523,11 @@ function _parse(::Type{Int}, io, start = Base.read(io, UInt8))
end
lo = UInt8('0')
up = UInt8('9')

if !(lo <= b <= up)
error("Not a number")
end

while !eof(io) && lo <= b <= up
res = res * exp + (b - lo)
b = Base.read(io, UInt8)
Expand Down Expand Up @@ -596,6 +601,10 @@ function _parse(::Type{ZZRingElem}, io, start = Base.read(io, UInt8))
up = UInt8('9')
mi = UInt8('-')

if !((lo <= b <= up) || b == mi)
error("Not a number")
end

while (lo <= b <= up) || b == mi
Base.write(n, b)
if eof(io)
Expand Down

0 comments on commit 2a5ca9f

Please sign in to comment.