summaryrefslogtreecommitdiff
path: root/app/Parser.hs
diff options
context:
space:
mode:
authorMirek Kratochvil <exa.exa@gmail.com>2022-12-14 20:47:29 +0100
committerMirek Kratochvil <exa.exa@gmail.com>2022-12-14 20:47:29 +0100
commit71992db7d0e51f87934f7d9c0cf9ddbd3a8d0300 (patch)
treed5ff9dbc6c74512def6a2329642790baef0bde4a /app/Parser.hs
parent60ff47250b5064c38b8f4889766696cb4a5683b0 (diff)
downloadprlg-71992db7d0e51f87934f7d9c0cf9ddbd3a8d0300.tar.gz
prlg-71992db7d0e51f87934f7d9c0cf9ddbd3a8d0300.tar.bz2
lists
Diffstat (limited to 'app/Parser.hs')
-rw-r--r--app/Parser.hs7
1 files changed, 4 insertions, 3 deletions
diff --git a/app/Parser.hs b/app/Parser.hs
index a9e4473..864cdc5 100644
--- a/app/Parser.hs
+++ b/app/Parser.hs
@@ -145,7 +145,7 @@ instance TraversableStream [Lexeme] where
data PAST
= Call String [[PAST]]
| Seq [PAST]
- | List [PAST] (Maybe [PAST])
+ | List [[PAST]] (Maybe [PAST])
| Literal String
deriving (Show, Eq)
@@ -181,7 +181,7 @@ list = do
free lBracket
choice
[ List [] Nothing <$ free rBracket
- , do items <- some seqItem
+ , do items <- splitOn [Literal ","] <$> some seqItem
choice
[ List items Nothing <$ free rBracket
, List items . Just <$>
@@ -223,7 +223,8 @@ shuntPrlg :: Ops -> PAST -> ShuntResult
shuntPrlg ot = shuntPrlg' (("", Op 0 $ Infix X Y) : ot)
shuntPrlg' :: Ops -> PAST -> ShuntResult
-shuntPrlg' ot (List _ _) = err "no lists yet"
+shuntPrlg' ot (List hs t) =
+ ListS <$> traverse (shunt ot) hs <*> traverse (shunt ot) t
shuntPrlg' ot (Seq ss) = shunt ot ss
shuntPrlg' ot (Literal s) = pure (LiteralS s)
shuntPrlg' ot (Call fn ss) = CallS fn <$> traverse (shunt ot) ss