diff options
Diffstat (limited to 'src/ltypes.hs')
| -rw-r--r-- | src/ltypes.hs | 30 |
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 () |
