summaryrefslogtreecommitdiff
path: root/src/Grasp
diff options
context:
space:
mode:
Diffstat (limited to 'src/Grasp')
-rw-r--r--src/Grasp/Interpreter.hs52
1 files changed, 51 insertions, 1 deletions
diff --git a/src/Grasp/Interpreter.hs b/src/Grasp/Interpreter.hs
index e84cfc5..5086078 100644
--- a/src/Grasp/Interpreter.hs
+++ b/src/Grasp/Interpreter.hs
@@ -3,9 +3,11 @@ module Grasp.Interpreter (
) where
+import Text.Read( readMaybe )
import Data.Graph.Inductive.Graph( Node, LNode, LEdge, (&) )
import qualified Data.Graph.Inductive.Graph as Graph
import Data.List
+import Data.Maybe
import Grasp.Types
import Grasp.Parser
@@ -74,7 +76,7 @@ execute g (cur:rest) out =
"getc" -> getcI g cur
"putc" -> putcI g cur
"gets" -> getsI g cur
- "puts" -> puts g cur
+ "puts" -> putsI g cur
x | isInteger x -> implicitPushI g cur
@@ -85,24 +87,72 @@ execute g (cur:rest) out =
isInteger :: String -> Bool
+isInteger x =
+ let check = readMaybe x :: Maybe Int
+ in if (isJust check) then True else False
+
+
+
+reLabel :: GraspProgram -> Node -> String -> GraspProgram
+reLabel g n s =
+ let (mc,d) = Graph.match n g
+ c = fromJust mc
+ c' = (\(w,x,y,z) -> (w,x,s,z)) $ c
+ in if (isNothing mc) then g else c' & d
+
+
setI :: GraspProgram -> IP -> (GraspProgram, IP)
+setI g ip = (g,ip)
+
newI :: GraspProgram -> IP -> (GraspProgram, IP)
+newI g ip = (g,ip)
+
delI :: GraspProgram -> IP -> (GraspProgram, IP)
+delI g ip = (g,ip)
+
pushI :: GraspProgram -> IP -> (GraspProgram, IP)
+pushI g ip = (g,ip)
+
popI :: GraspProgram -> IP -> (GraspProgram, IP)
+popI g ip = (g,ip)
+
pickI :: GraspProgram -> IP -> (GraspProgram, IP)
+pickI g ip = (g,ip)
+
callI :: GraspProgram -> IP -> (GraspProgram, IP)
+callI g ip = (g,ip)
+
retI :: GraspProgram -> IP -> (GraspProgram, IP)
+retI g ip = (g,ip)
+
addI :: GraspProgram -> IP -> (GraspProgram, IP)
+addI g ip = (g,ip)
+
mulI :: GraspProgram -> IP -> (GraspProgram, IP)
+mulI g ip = (g,ip)
+
subI :: GraspProgram -> IP -> (GraspProgram, IP)
+subI g ip = (g,ip)
+
divI :: GraspProgram -> IP -> (GraspProgram, IP)
+divI g ip = (g,ip)
+
modI :: GraspProgram -> IP -> (GraspProgram, IP)
+modI g ip = (g,ip)
+
getcI :: GraspProgram -> IP -> (GraspProgram, IP)
+getcI g ip = (g,ip)
+
putcI :: GraspProgram -> IP -> (GraspProgram, IP)
+putcI g ip = (g,ip)
+
getsI :: GraspProgram -> IP -> (GraspProgram, IP)
+getsI g ip = (g,ip)
+
putsI :: GraspProgram -> IP -> (GraspProgram, IP)
+putsI g ip = (g,ip)
implicitPushI :: GraspProgram -> IP -> (GraspProgram, IP)
+implicitPushI g ip = (g,ip)