diff options
| author | Mirek Kratochvil <exa.exa@gmail.com> | 2022-11-16 15:17:10 +0100 |
|---|---|---|
| committer | Mirek Kratochvil <exa.exa@gmail.com> | 2022-11-16 15:17:10 +0100 |
| commit | 6f123999e01fc1c26742f4c9f575b392693d2847 (patch) | |
| tree | ec84f2027888213ca91533538c93599690bf800a /app/Compiler.hs | |
| parent | e86aa4faadc79cb5366d3eaeb8970d33b980d6d3 (diff) | |
| download | prlg-6f123999e01fc1c26742f4c9f575b392693d2847.tar.gz prlg-6f123999e01fc1c26742f4c9f575b392693d2847.tar.bz2 | |
compile cuts
Diffstat (limited to 'app/Compiler.hs')
| -rw-r--r-- | app/Compiler.hs | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/app/Compiler.hs b/app/Compiler.hs index 1adefc3..ecbd003 100644 --- a/app/Compiler.hs +++ b/app/Compiler.hs @@ -36,11 +36,13 @@ variablizePrlg void vs (LiteralI i) | Just idx <- elemIndex i vs = VarI idx i | otherwise = LiteralI i -compileGoals :: Id -> PrlgInt -> [Code] -compileGoals andop = go +compileGoals :: Id -> Int -> PrlgInt -> [Code] +compileGoals andop cut = go where go p@(CallI x args) | x == andop = concatMap go args + go p@(LiteralI x) + | x == cut = [[Cut]] go x = [compileGoal x] compileGoal :: PrlgInt -> Code @@ -58,4 +60,5 @@ seqGoals [] = [NoGoal] seqGoals [[Cut]] = [Cut, NoGoal] seqGoals [x] = [Goal] ++ x ++ [LastCall] seqGoals [x, [Cut]] = [Goal] ++ x ++ [LastCall, Cut] +seqGoals ([Cut]:xs) = [Cut] ++ seqGoals xs seqGoals (x:xs) = [Goal] ++ x ++ [Call] ++ seqGoals xs |
