From: Luke Lau Date: Sun, 10 Mar 2019 17:04:29 +0000 (+0000) Subject: Handle ending ; X-Git-Url: https://git.lukelau.me/?p=kaleidoscope-hs-old.git;a=commitdiff_plain;h=4b03cb96fd234ca3e85581e218668f68afc16375 Handle ending ; --- diff --git a/AST.hs b/AST.hs index 73523d6..6b9928d 100644 --- a/AST.hs +++ b/AST.hs @@ -8,10 +8,14 @@ newtype Program = Program [AST] deriving Show instance Read Program where - readPrec = fmap Program $ lift $ sepBy1 (readS_to_P reads) $ do + readPrec = fmap Program $ lift $ do + asts <- sepBy1 (readS_to_P reads) $ do skipSpaces char ';' skipSpaces + optional $ char ';' + skipSpaces + return asts data AST = Function String [String] Expr | Eval Expr