on master help sign in
use EF.Float in when parsing numbers
33d1a20Evan Czaplicki
compiler/src/Parse/Number.hs+8−8
@@ -11,11 +11,11 @@ module Parse.Number
11 where
11 where
12
12
13
13
14−import qualified Data.Utf8 as Utf8
15import Data.Word (Word8)
14import Data.Word (Word8)
16import Foreign.Ptr (Ptr, plusPtr, minusPtr)
15import Foreign.Ptr (Ptr, plusPtr, minusPtr)
17
16
18import qualified AST.Utils.Binop as Binop
17import qualified AST.Utils.Binop as Binop
18+import qualified Elm.Float as EF
19import Parse.Primitives (Parser, Row, Col)
19import Parse.Primitives (Parser, Row, Col)
20import qualified Parse.Variable as Var
20import qualified Parse.Variable as Var
21import qualified Parse.Primitives as P
21import qualified Parse.Primitives as P
@@ -43,12 +43,12 @@ isDecimalDigit word =
43
43
44data Number
44data Number
45 = Int Int
45 = Int Int
46− | Float (Utf8.Under256 Float)
46+ | Float EF.Float
47
47
48
48
49number :: (Row -> Col -> x) -> (E.Number -> Row -> Col -> x) -> Parser x Number
49number :: (Row -> Col -> x) -> (E.Number -> Row -> Col -> x) -> Parser x Number
50number toExpectation toError =
50number toExpectation toError =
51− P.Parser $ \(P.State pos end indent row col) cok _ cerr eerr ->
51+ P.Parser $ \(P.State src pos end indent row col) cok _ cerr eerr ->
52 if pos >= end then
52 if pos >= end then
53 eerr row col toExpectation
53 eerr row col toExpectation
54
54
@@ -76,16 +76,16 @@ number toExpectation toError =
76 let
76 let
77 !newCol = col + fromIntegral (minusPtr newPos pos)
77 !newCol = col + fromIntegral (minusPtr newPos pos)
78 !integer = Int n
78 !integer = Int n
79− !newState = P.State newPos end indent row newCol
79+ !newState = P.State src newPos end indent row newCol
80 in
80 in
81 cok integer newState
81 cok integer newState
82
82
83 OkFloat newPos ->
83 OkFloat newPos ->
84 let
84 let
85 !newCol = col + fromIntegral (minusPtr newPos pos)
85 !newCol = col + fromIntegral (minusPtr newPos pos)
86− !copy = Utf8.fromPtr pos newPos
86+ !copy = EF.fromPtr pos newPos
87 !float = Float copy
87 !float = Float copy
88− !newState = P.State newPos end indent row newCol
88+ !newState = P.State src newPos end indent row newCol
89 in
89 in
90 cok float newState
90 cok float newState
91
91
@@ -290,7 +290,7 @@ stepHex pos end word acc
290
290
291precedence :: (Row -> Col -> x) -> Parser x Binop.Precedence
291precedence :: (Row -> Col -> x) -> Parser x Binop.Precedence
292precedence toExpectation =
292precedence toExpectation =
293− P.Parser $ \(P.State pos end indent row col) cok _ _ eerr ->
293+ P.Parser $ \(P.State src pos end indent row col) cok _ _ eerr ->
294 if pos >= end then
294 if pos >= end then
295 eerr row col toExpectation
295 eerr row col toExpectation
296
296
@@ -299,7 +299,7 @@ precedence toExpectation =
299 if isDecimalDigit word then
299 if isDecimalDigit word then
300 cok
300 cok
301 (Binop.Precedence (fromIntegral (word - 0x30 {-0-})))
301 (Binop.Precedence (fromIntegral (word - 0x30 {-0-})))
302− (P.State (plusPtr pos 1) end indent row (col + 1))
302+ (P.State src (plusPtr pos 1) end indent row (col + 1))
303
303
304 else
304 else
305 eerr row col toExpectation
305 eerr row col toExpectation