jump over strings/comments

This commit is contained in:
Armin Friedl 2016-08-29 13:37:10 +02:00
parent 380ed86ccf
commit 54c04ad7c6
2 changed files with 10 additions and 2 deletions

View file

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

View file

@ -197,6 +197,12 @@ invAcc a i ('[':t) = invAcc a (i+1 + g) (drop g t) -- TODO check reads in f
-- 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
@ -207,7 +213,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 _ _ _ = []
getWrite :: Int -> String -> Maybe (String, Slice, Bool)