Merge branch 'noaccum' of https://bitbucket.org/prosa16/ass3 into noaccum

This commit is contained in:
Johannes Winklehner 2016-08-29 14:18:20 +02:00
commit acf48765ff
2 changed files with 10 additions and 2 deletions

View file

@ -1,7 +1,9 @@
{
error = "0";
fact = { % number num -> number; set error if something is wrong
continue = {} + ("test 1 -ge " + num).syscall;
"num = a"
% num = "b"
continue = {} + ("test 1 -ge " + num).syscall;
[ continue = "0" :
[ {} + ("test 0 = " + num).syscall # "0" :
*error = "1";

View file

@ -198,6 +198,12 @@ invAcc a i ('[':t) = map snd (filter (\x -> isUnassigned x a) r) ++ invAcc (mark
-- all variables with false at the end of a block are unused
invAcc a i ('.':t) = invAcc a (i+1 + g) (drop g t)
where g = length $ fst $ fromJust $ getRead 0 t
invAcc a i ('"':t) = invAcc a (i+1 + g) (drop g t)
where g = if isJust next then 1 + (fromJust next) else length t
next = elemIndex '"' t
invAcc a i ('%':t) = invAcc a (i+1 + g) (drop g t)
where g = if isJust next then 1 + (fromJust next) else length t
next = elemIndex '\n' t
invAcc a i s@(c:t) = let writeAcc = getWrite i s
matchLen = (length $ (\(v,_,_) -> v) (fromJust writeAcc))
readAcc = getRead i s
@ -208,7 +214,7 @@ invAcc a i s@(c:t) = let writeAcc = getWrite i s
else if isUnassigned (fromJust readAcc) a -- no assignment in rest str
then (snd (fromJust readAcc)) : (invAcc a (i+readLen) (drop readLen s))
else invAcc (markRead (fromJust readAcc) a) (i+readLen) (drop readLen s)
else invAcc (a ++ [fromJust writeAcc]) (i+matchLen) (drop matchLen s) -- assignment in accumStr, advance offset to end
else invAcc (fromJust writeAcc: a) (i+matchLen) (drop matchLen s) -- assignment in accumStr, advance offset to end
invAcc _ _ _ = []
getReads :: Int -> String -> [(String,Slice)]