started getRead

This commit is contained in:
Johannes Winklehner 2016-08-29 11:55:15 +02:00
parent 55d002a4e7
commit 28fb6ccc86

View file

@ -198,7 +198,7 @@ invAcc a i ('[':t) = invAcc a (i+1 + g) (drop g t) -- TODO check reads in f
invAcc a i s@(c:t) = let writeAcc = getWrite i s
matchLen = (length $ (\(v,_,_) -> v) (fromJust writeAcc))
in if isNothing writeAcc
then invAcc a (i+1) t -- no assignment in rest str
then invAcc a (i+1) t -- no assignment in rest str TODO check for reads here
else invAcc (a ++ [fromJust writeAcc]) (i+1+matchLen) (drop matchLen t) -- assignment in accumStr, advance offset to end
invAcc a _ _ = map (\(_,s,_) -> s) a
@ -208,6 +208,18 @@ getWrite offset s = ((Tdfa.matchOnceText §~ "^(\\**[[:word:]]+)[[:blank:]]*=")
let m = match ! 1 -- extract the match group (0 = the whole match)
in Just (fst m, (offset+(fst (snd m)), offset+(length (fst m))), False)
getRead :: Int -> String -> Maybe (String, Slice)
getRead offset s = ((Tdfa.matchOnceText §~ "^(\\**[[:word:]]+)") s) >>= matchToString
where matchToString (before, match, after) =
let m = match ! 1 -- extract the match group (0 = the whole match)
in Just (fst m, (offset+(fst (snd m)), offset+(length (fst m))))
isUnassigned :: String -> [(String,Slice,Bool)] -> Bool
isUnassigned s = null . filter (\(t,_,_) -> t == s)
markRead :: String -> [(String,Slice,Bool)] -> [(String,Slice,Bool)]
--markRead s a =
enterBlock :: [(String,Slice,Bool)] -> [(String,Slice,Bool)]
enterBlock = map (\(v,s,b) -> ('*':v,s,b))