summaryrefslogtreecommitdiffstats
path: root/src/ltypes.hs
diff options
context:
space:
mode:
authorJan Tuomi <jans.tuomi@gmail.com>2022-01-30 18:48:29 +0200
committerJan Tuomi <jans.tuomi@gmail.com>2022-01-30 18:48:29 +0200
commit542b0d035444416cae8994f89d1ae11c4e4c5df9 (patch)
tree3c930e750a679b834fe5373ae8249ae1e7676f67 /src/ltypes.hs
parent3fbe17312a7b1474b290c129ebeca9ee7c773c6e (diff)
Move interpreter stuff under interpreter.hs
Diffstat (limited to 'src/ltypes.hs')
-rw-r--r--src/ltypes.hs30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/ltypes.hs b/src/ltypes.hs
index bb7e0de..27fdd35 100644
--- a/src/ltypes.hs
+++ b/src/ltypes.hs
@@ -1,5 +1,7 @@
module LTypes where
+import Data.Map (Map)
+import qualified Data.Map as M
import Utils
data LWord
@@ -22,3 +24,31 @@ reprWord (LChar a) = show a
reprWord (LLabel a) = a
reprWord (LStringLitRef a) = "StrLit(" ++ a ++ ")"
reprWord (LPhrase a) = "P[ " ++ map reprWord a $> unwords ++ " ]"
+
+data LState = LState
+ { lDict :: Map String LWord,
+ lStack :: [LWord],
+ lPhraseDepth :: Int,
+ lDefs :: Map String [LWord],
+ lSource :: [LWord],
+ lStrLitRefMap :: Map String [LWord]
+ }
+ deriving (Show)
+
+data Config = Config
+ { configFileNameM :: Maybe String,
+ configDebugMode :: Bool
+ }
+
+data ExecStep = ExecContinue | ExecExit
+
+debugState Config {configDebugMode = mode} state =
+ if mode
+ then do
+ putStrLn $ "stack: " ++ unwords (map reprWord (lStack state))
+ putStrLn $ "source: " ++ unwords (map reprWord (lSource state))
+ putStrLn $ "defs: " ++ unwords (M.keys (lDefs state))
+ putStrLn $ "dict: " ++ unwords (M.keys (lDict state))
+ putStrLn $ "lPhraseDepth: " ++ show (lPhraseDepth state)
+ putStrLn ""
+ else pure ()