on master help sign in
Improve the error message for BadNumberDot
commit5d3f9450c98be6c8fa9f468ccaf12c910bc37043 authorEvan Czaplicki <evancz@users.noreply.github.com> dateTue 19 Dec 2017, 18:40 (9 years ago) parentbc1f2f0
1 file changed+6−6
src/Parse/Primitives/Number.hs+6−6
src/Parse/Primitives/Number.hs+6−6
@@ -114,7 +114,7 @@ chompInt fp !offset terminal !n =
114114 chompInt fp (offset + 1) terminal (10 * n + fromIntegral (word - 0x30 {- 0 -}))
115115
116116 else if word == 0x2E {- . -} then
117− chompFraction fp (offset + 1) terminal
117+ chompFraction fp (offset + 1) terminal n
118118
119119 else if word == 0x65 {- e -} || word == 0x45 {- E -} then
120120 chompExponent fp (offset + 1) terminal
@@ -130,16 +130,16 @@ chompInt fp !offset terminal !n =
130130-- CHOMP FRACTION
131131
132132
133−chompFraction :: ForeignPtr Word8 -> Int -> Int -> Outcome
134−chompFraction fp offset terminal =
133+chompFraction :: ForeignPtr Word8 -> Int -> Int -> Int -> Outcome
134+chompFraction fp offset terminal n =
135135 if offset >= terminal then
136− Err offset E.BadNumberDot
136+ Err offset (E.BadNumberDot n)
137137
138138 else if isDecimalDigit (I.unsafeIndex fp offset) then
139139 chompFractionHelp fp (offset + 1) terminal
140140
141141 else
142− Err offset E.BadNumberDot
142+ Err offset (E.BadNumberDot n)
143143
144144
145145chompFractionHelp :: ForeignPtr Word8 -> Int -> Int -> Outcome
@@ -215,7 +215,7 @@ chompZero fp offset terminal =
215215 chompHexInt fp (offset + 1) terminal
216216
217217 else if word == 0x2E {- . -} then
218− chompFraction fp (offset + 1) terminal
218+ chompFraction fp (offset + 1) terminal 0
219219
220220 else if isDecimalDigit word then
221221 Err offset E.BadNumberZero