summaryrefslogtreecommitdiff
path: root/src/Wavefront.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Wavefront.hs')
-rw-r--r--src/Wavefront.hs11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/Wavefront.hs b/src/Wavefront.hs
index 9e42779..d53c786 100644
--- a/src/Wavefront.hs
+++ b/src/Wavefront.hs
@@ -189,15 +189,15 @@ nextToken :: (L.ByteString -> L.ByteString) -> L.ByteString -> L.ByteString
189nextToken tok bs = tok $ L.dropWhile (not . isSpace) bs 189nextToken tok bs = tok $ L.dropWhile (not . isSpace) bs
190 190
191parseFloats tok bs cont = case L.splitAt 10 (tok bs) of 191parseFloats tok bs cont = case L.splitAt 10 (tok bs) of
192 (ds,bs') -> case F.readSigned F.readExponential (L.toStrict ds) of 192 (ds,bs') -> case F.readSigned F.readDecimal (L.toStrict ds) of
193 Just (x,b) -> parseFloats tok (reconsChunk b bs') (cont . (x :)) 193 Just (x,b) -> parseFloats tok (reconsChunk b bs') (cont . (x :))
194 Nothing -> cont [] (ds <> bs') 194 Nothing -> cont [] bs
195 195
196parseFloatsN 0 _ bs cont = cont [] bs 196parseFloatsN 0 _ bs cont = cont [] bs
197parseFloatsN n tok bs cont = case L.splitAt 10 (tok bs) of 197parseFloatsN n tok bs cont = case L.splitAt 10 (tok bs) of
198 (ds,bs') -> case F.readSigned F.readExponential (L.toStrict ds) of 198 (ds,bs') -> case F.readSigned F.readDecimal (L.toStrict ds) of
199 Just (x,b) -> parseFloatsN (n-1) tok (reconsChunk b bs') (cont . (x :)) 199 Just (x,b) -> parseFloatsN (n-1) tok (reconsChunk b bs') (cont . (x :))
200 Nothing -> cont [] (ds <> bs') 200 Nothing -> cont [] bs
201 201
202parseInts tok bs cont = case L.splitAt 5 (tok bs) of 202parseInts tok bs cont = case L.splitAt 5 (tok bs) of
203 (ds,bs') -> case I.readSigned I.readDecimal (L.toStrict ds) of 203 (ds,bs') -> case I.readSigned I.readDecimal (L.toStrict ds) of
@@ -210,6 +210,7 @@ parseIntsN n tok bs cont = case L.splitAt 5 (tok bs) of
210 Just (x,b) -> parseIntsN (n-1) tok (reconsChunk b bs') (cont . (x :)) 210 Just (x,b) -> parseIntsN (n-1) tok (reconsChunk b bs') (cont . (x :))
211 Nothing -> cont [] (ds <> bs') 211 Nothing -> cont [] (ds <> bs')
212 212
213-- Optimize me
213parseTriples :: (L.ByteString -> L.ByteString) -> L.ByteString -> ([RefTriple] -> L.ByteString -> b) -> b 214parseTriples :: (L.ByteString -> L.ByteString) -> L.ByteString -> ([RefTriple] -> L.ByteString -> b) -> b
214parseTriples tok bs cont = case L.splitAt 17 (tok bs) of 215parseTriples tok bs cont = case L.splitAt 17 (tok bs) of
215 (ds,bs') -> case I.readSigned I.readDecimal (L.toStrict ds) of 216 (ds,bs') -> case I.readSigned I.readDecimal (L.toStrict ds) of
@@ -235,7 +236,7 @@ parseTriples tok bs cont = case L.splitAt 17 (tok bs) of
235 236
236 _ -> parseTriples tok (reconsChunk b bs') $ cont . (RefTriple v Nothing Nothing :) 237 _ -> parseTriples tok (reconsChunk b bs') $ cont . (RefTriple v Nothing Nothing :)
237 238
238 Nothing -> cont [] (ds <> bs') 239 Nothing -> cont [] bs
239 240
240parseCurveSpecs :: (L.ByteString -> L.ByteString) -> L.ByteString -> ([CurveSpec] -> L.ByteString -> b) -> b 241parseCurveSpecs :: (L.ByteString -> L.ByteString) -> L.ByteString -> ([CurveSpec] -> L.ByteString -> b) -> b
241parseCurveSpecs tok bs cont = parseFloatsN 2 tok bs $ \fs bs' -> case fs of 242parseCurveSpecs tok bs cont = parseFloatsN 2 tok bs $ \fs bs' -> case fs of