Merge branch 'noaccum' of https://bitbucket.org/prosa16/ass3 into noaccum
This commit is contained in:
commit
acf48765ff
2 changed files with 10 additions and 2 deletions
|
@ -1,7 +1,9 @@
|
||||||
{
|
{
|
||||||
error = "0";
|
error = "0";
|
||||||
fact = { % number num -> number; set error if something is wrong
|
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" :
|
[ continue = "0" :
|
||||||
[ {} + ("test 0 = " + num).syscall # "0" :
|
[ {} + ("test 0 = " + num).syscall # "0" :
|
||||||
*error = "1";
|
*error = "1";
|
||||||
|
|
|
@ -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
|
-- all variables with false at the end of a block are unused
|
||||||
invAcc a i ('.':t) = invAcc a (i+1 + g) (drop g t)
|
invAcc a i ('.':t) = invAcc a (i+1 + g) (drop g t)
|
||||||
where g = length $ fst $ fromJust $ getRead 0 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
|
invAcc a i s@(c:t) = let writeAcc = getWrite i s
|
||||||
matchLen = (length $ (\(v,_,_) -> v) (fromJust writeAcc))
|
matchLen = (length $ (\(v,_,_) -> v) (fromJust writeAcc))
|
||||||
readAcc = getRead i s
|
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
|
else if isUnassigned (fromJust readAcc) a -- no assignment in rest str
|
||||||
then (snd (fromJust readAcc)) : (invAcc a (i+readLen) (drop readLen s))
|
then (snd (fromJust readAcc)) : (invAcc a (i+readLen) (drop readLen s))
|
||||||
else invAcc (markRead (fromJust readAcc) 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 _ _ _ = []
|
invAcc _ _ _ = []
|
||||||
|
|
||||||
getReads :: Int -> String -> [(String,Slice)]
|
getReads :: Int -> String -> [(String,Slice)]
|
||||||
|
|
Loading…
Reference in a new issue