Skip to content

Commit

Permalink
repl: Parse nil and require eof after parsed expr
Browse files Browse the repository at this point in the history
  • Loading branch information
paulcadman committed Dec 21, 2023
1 parent 5ae1d4b commit 0c20daf
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Juvix/Compiler/Nockma/Translation/FromSource.hs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ runParserProgram :: FilePath -> Text -> Either MegaparsecError (N.Program Natura
runParserProgram = runParserFor program

runParserFor :: Parser a -> FilePath -> Text -> Either MegaparsecError a
runParserFor p f input = case P.runParser p f input of
runParserFor p f input = case P.runParser (p <* eof) f input of
Left err -> Left (MegaparsecError err)
Right t -> Right t

Expand Down Expand Up @@ -86,12 +86,16 @@ atomBool =
symbol "false" $> N.nockFalse
]

atomNil :: Parser (N.Atom Natural)
atomNil = symbol "nil" $> N.nockNil

atom :: Parser (N.Atom Natural)
atom =
atomOp
<|> atomNat
<|> atomDirection
<|> atomBool
<|> atomNil

cell :: Parser (N.Cell Natural)
cell = do
Expand Down

0 comments on commit 0c20daf

Please sign in to comment.