From 3fbe17312a7b1474b290c129ebeca9ee7c773c6e Mon Sep 17 00:00:00 2001 From: Jan Tuomi Date: Sun, 30 Jan 2022 14:34:53 +0200 Subject: Add string interpolation sugar --- src/main.hs | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) (limited to 'src/main.hs') 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} -- cgit v1.3