From 54c04ad7c6305b18a81f88564ef90a8e2efbb821 Mon Sep 17 00:00:00 2001 From: Armin Friedl Date: Mon, 29 Aug 2016 13:37:10 +0200 Subject: [PATCH 1/2] jump over strings/comments --- examples/example2 | 4 +++- src/App/Fontifier.hs | 8 +++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/examples/example2 b/examples/example2 index 8171948..82ce655 100644 --- a/examples/example2 +++ b/examples/example2 @@ -1,7 +1,9 @@ { error = "0"; fact = { % number num -> number; set error if something is wrong - continue = {} + ("test 1 -ge " + num).syscall; + "continue = a" + % continue = "b" + continue = {} + ("test 1 -ge " + num).syscall; [ continue = "0" : [ {} + ("test 0 = " + num).syscall # "0" : *error = "1"; diff --git a/src/App/Fontifier.hs b/src/App/Fontifier.hs index c2440c2..198fc87 100644 --- a/src/App/Fontifier.hs +++ b/src/App/Fontifier.hs @@ -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) From 5828a9c0676c9679638707d09b18239d43858793 Mon Sep 17 00:00:00 2001 From: Armin Friedl Date: Mon, 29 Aug 2016 13:39:26 +0200 Subject: [PATCH 2/2] better example --- examples/example2 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/example2 b/examples/example2 index 82ce655..1ed18e2 100644 --- a/examples/example2 +++ b/examples/example2 @@ -1,8 +1,8 @@ { error = "0"; fact = { % number num -> number; set error if something is wrong - "continue = a" - % continue = "b" + "num = a" + % num = "b" continue = {} + ("test 1 -ge " + num).syscall; [ continue = "0" : [ {} + ("test 0 = " + num).syscall # "0" :