summaryrefslogtreecommitdiffstats
path: root/src/main.hs
diff options
context:
space:
mode:
authorJan Tuomi <jans.tuomi@gmail.com>2022-01-30 14:34:53 +0200
committerJan Tuomi <jans.tuomi@gmail.com>2022-01-30 14:34:53 +0200
commit3fbe17312a7b1474b290c129ebeca9ee7c773c6e (patch)
treeec80a2805fe2b4e64563219483e44fdc1b5697b9 /src/main.hs
parent477579b5e8c7297efefc1ccabf8ead7c024ac4dc (diff)
Add string interpolation sugar
Diffstat (limited to 'src/main.hs')
-rw-r--r--src/main.hs11
1 files changed, 5 insertions, 6 deletions
diff --git a/src/main.hs b/src/main.hs
index e14e5ac..c67cea0 100644
--- a/src/main.hs
+++ b/src/main.hs
@@ -34,7 +34,7 @@ data LState = LState
lPhraseDepth :: Int,
lDefs :: Map String [LWord],
lSource :: [LWord],
- lStrLitRefMap :: Map String String
+ lStrLitRefMap :: Map String [LWord]
}
deriving (Show)
@@ -100,11 +100,10 @@ interpretWord state@LState {lStack = stack} word@(LBool _) = pure $ state {lStac
interpretWord state@LState {lStack = stack} word@(LChar _) = pure $ state {lStack = word : stack}
interpretWord state@LState {lStack = stack} word@(LLabel _) = pure $ state {lStack = word : stack}
interpretWord state@LState {lStack = stack} word@(LPhrase _) = pure $ state {lStack = word : stack}
-interpretWord state@LState {lStack = stack, lStrLitRefMap = strLitRefMap} (LStringLitRef ref) =
- let strLit = strLitRefMap ! ref
- chars = strLit $> map LChar
- word = LPhrase chars
- in pure $ state {lStack = word : stack}
+-- string literals
+interpretWord state@LState {lSource = source, lStrLitRefMap = strLitRefMap} (LStringLitRef ref) =
+ let strLitP = strLitRefMap ! ref
+ in pure $ state {lSource = strLitP ++ source}
-- phrase markers are always evaled
interpretWord state@LState {lStack = stack, lPhraseDepth = phraseDepth} word@(LSymbol "[") =
pure $ state {lPhraseDepth = phraseDepth + 1, lStack = word : stack}