improved Parser and added documentation
This commit is contained in:
parent
b0e78033e5
commit
7b54ec9006
@ -135,16 +135,23 @@ readMeshes n = do
|
|||||||
|
|
||||||
infix 5 .-
|
infix 5 .-
|
||||||
|
|
||||||
|
skipToCounter :: Integral a => a -> CParser ()
|
||||||
|
skipToCounter a = do
|
||||||
|
let d = fromIntegral a
|
||||||
|
c <- get
|
||||||
|
when (d < c) $ fail "wanting to skip to counter already passed"
|
||||||
|
_ <- lift $ take $ d .- c
|
||||||
|
put d
|
||||||
|
|
||||||
parseIQM :: CParser IQM
|
parseIQM :: CParser IQM
|
||||||
parseIQM = do
|
parseIQM = do
|
||||||
put 0
|
put 0 --start at offset 0
|
||||||
h <- readHeader
|
h <- readHeader --read header
|
||||||
soFar <- get
|
skipToCounter $ ofs_text h --skip 0-n bytes to get to text
|
||||||
_ <- lift $ take $ ofs_text h .- soFar
|
text <- lift . take . fromIntegral $ num_text h --read texts
|
||||||
text <- lift $ take $ fromIntegral $ num_text h
|
modify . (+) . fromIntegral $ num_text h --put offset forward
|
||||||
soFar <- get
|
skipToCounter $ ofs_meshes h --skip 0-n bytes to get to meshes
|
||||||
_ <- lift $ take $ ofs_meshes h .- soFar
|
meshes' <- readMeshes (fromIntegral (num_meshes h)) --read meshes
|
||||||
meshes' <- readMeshes (fromIntegral (num_meshes h))
|
|
||||||
return IQM
|
return IQM
|
||||||
{ header = h
|
{ header = h
|
||||||
, texts = filter (not.null) (split (unsafeCoerce '\0') text)
|
, texts = filter (not.null) (split (unsafeCoerce '\0') text)
|
||||||
|
Loading…
Reference in New Issue
Block a user