From 28fb6ccc86a08929ed9841847934c55c598ee085 Mon Sep 17 00:00:00 2001 From: Johannes Winklehner Date: Mon, 29 Aug 2016 11:55:15 +0200 Subject: [PATCH] started getRead --- src/App/Fontifier.hs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/App/Fontifier.hs b/src/App/Fontifier.hs index 7121da3..f5776e1 100644 --- a/src/App/Fontifier.hs +++ b/src/App/Fontifier.hs @@ -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))