Handle ending ;
[kaleidoscope-hs-old.git] / AST.hs
diff --git a/AST.hs b/AST.hs
index 73523d6d4c8a37cef977d5614d355aaac13756af..6b9928d5b13fa0d67c848b8c3c0e446c2babb4f4 100644 (file)
--- 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