leaveBlock done

This commit is contained in:
Johannes Winklehner 2016-08-29 09:34:24 +02:00
parent 5d696eaf8d
commit c82c4dc85d

View file

@ -186,7 +186,7 @@ invalidAccesses = invAcc [] "" 0
-- :: CurrentAssignments -> AccumulatorString -> GlobalIndex
invAcc :: [(String,Slice,Bool)] -> String -> Int -> CheckString -> Slices
invAcc a accumStr i ('{':t) = invAcc (enterBlock a) "" (i+1+(length accumStr)) t
invAcc a accumStr i ('}':t) = invAcc (leaveBlock a) "" (i+1+(length accumStr)) t
invAcc a accumStr i ('}':t) = getUnread a ++ invAcc (leaveBlock a) "" (i+1+(length accumStr)) t
invAcc a accumStr i ('[':t) = invAcc a accumStr (i+1 + g) (drop g t) -- TODO check reads in first part
where g = fromJust (elemIndex ':' t)
-- when reading an assignment :word: =
@ -218,7 +218,14 @@ enterBlock = map (\(v,s,b) -> ('*':v,s,b))
-- remove 1 * from each variable name
-- if it cannot be removed, remove the variable
leaveBlock :: [(String,Slice,Bool)] -> [(String,Slice,Bool)]
leaveBlock a = a
leaveBlock = map (\(v,s,b) -> (tail v,s,b)) . filter (\(v,_,_) -> head v == '*')
-- add all unread assignments to the result slices
getUnread :: [(String,Slice,Bool)] -> Slices
getUnread [] = []
getUnread ((v,s,b):ss)
| b = getUnread ss
| otherwise = s:getUnread ss
{- General Fontification Utilities -}