summaryrefslogtreecommitdiff
path: root/app/Interpreter.hs
diff options
context:
space:
mode:
authorMirek Kratochvil <exa.exa@gmail.com>2022-10-16 21:49:59 +0200
committerMirek Kratochvil <exa.exa@gmail.com>2022-10-16 21:49:59 +0200
commit865d63a103d119e51a4fba3a0d185ff1c6394176 (patch)
treec9156491488db6985e370e4d080c2ac6504aae61 /app/Interpreter.hs
parentcbd6aa4021f744be7301e9d5b6fce2c6c98c46ae (diff)
downloadprlg-865d63a103d119e51a4fba3a0d185ff1c6394176.tar.gz
prlg-865d63a103d119e51a4fba3a0d185ff1c6394176.tar.bz2
some small stuff
Diffstat (limited to 'app/Interpreter.hs')
-rw-r--r--app/Interpreter.hs16
1 files changed, 13 insertions, 3 deletions
diff --git a/app/Interpreter.hs b/app/Interpreter.hs
index 81ecb3d..7df773e 100644
--- a/app/Interpreter.hs
+++ b/app/Interpreter.hs
@@ -5,11 +5,21 @@ import qualified Data.Map as M
{- VAM 2P, done the lazy way -}
data StrTable =
- StrTable Int (M.Map Int String)
+ StrTable Int (M.Map String Int) (M.Map Int String)
+ deriving Show
+
+emptystrtable = StrTable 0 M.empty M.empty
+
+strtablize t@(StrTable nxt fwd rev) str =
+ case fwd M.!? str of
+ Just i -> (t, i)
+ _ -> (StrTable (nxt + 1) (M.insert str nxt fwd) (M.insert nxt str rev), nxt)
+
+data Id = Id {str::Int,arity::Int} deriving (Show, Eq, Ord)
data Datum
= Atom Int -- unifies a constant
- | Struct (Int, Int) -- unifies a structure with arity
+ | Struct Id -- unifies a structure with arity
-- | VoidVar -- unifies with anything
-- | LocalVar Int -- unifies with a local variable (possibly making a new one when it's not in use yet)
-- | Ref Int -- unifies with the referenced value on the heap (not to be used in code)
@@ -26,7 +36,7 @@ data Instr
type Code = [Instr]
-type Defs = M.Map (Int, Int) [Code]
+type Defs = M.Map Id [Code]
data Cho =
Cho