diff options
author | Jed Barber <jjbarber@y7mail.com> | 2014-05-17 10:59:51 +1000 |
---|---|---|
committer | Jed Barber <jjbarber@y7mail.com> | 2014-05-17 10:59:51 +1000 |
commit | 24271f7e6fa7c7c7ea896f465b31497becac4976 (patch) | |
tree | 7d70548bac1e33f9932d28c1ce75c8aca95845a2 | |
parent | a7a8aa3125818b7ba7913cb1deac690aced0f3db (diff) |
del instruction complete
-rw-r--r-- | src/Grasp/Interpreter.hs | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/Grasp/Interpreter.hs b/src/Grasp/Interpreter.hs index e8896cf..35a3de0 100644 --- a/src/Grasp/Interpreter.hs +++ b/src/Grasp/Interpreter.hs @@ -180,7 +180,25 @@ newI g ip = do delI :: GraspProgram -> IP -> IO (GraspProgram, IP) -delI g ip = return (g,ip) +delI g ip = do + let node = fst . head $ ip + edges = Graph.out g node + + tailN = targetNodes (getByLabel "tail" edges) + headN = targetNodes (getByLabel "head" edges) + labelL = targetLabels g (getByLabel "label" edges) + + edgesToDel = filter (\(x,y,z) -> x `elem` tailN && + (headN == [] || y `elem` headN) && + (labelL == [] || z `elem` labelL)) (Graph.labEdges g) + + g' = foldl' (\gr e -> Graph.delLEdge e gr) g edgesToDel + + ip' <- updateIP ip (targetLNodes g' (getByLabel "next" (Graph.out g' node))) + + return (g',ip') + + pushI :: GraspProgram -> IP -> IO (GraspProgram, IP) pushI g ip = return (g,ip) |