ref: 5307a307eab96ac5bae24418e2bc6b9f258aa9b7
parent: 725a051580be423d4b35f7afa0a99c03a99a73dc
author: Lennart Augustsson <lennart.augustsson@epicgames.com>
date: Mon Nov 20 13:31:11 EST 2023
Better defn processing.
--- a/src/MicroHs/Interactive.hs
+++ b/src/MicroHs/Interactive.hs
@@ -118,13 +118,21 @@
(ls, _, _) <- get
-- Try adding the line as a definition
let lls = ls ++ line ++ "\n"
- defTest <- tryCompile lls
- case defTest of
- Right _ -> updateLines (const lls)
- Left _ ->
- -- Try parsing it as an expression expressions, make it a definition
+ case parse pTop "" lls of
+ Right _ -> do
+-- liftIO $ putStrLn "pTop succeeded"
+ -- Can parse as a definition, so compile it and report any errors.
+ defTest <- tryCompile lls
+ case defTest of
+ Right _ -> updateLines (const lls)
+ Left e -> liftIO $ err e
+ Left _ -> do
+-- liftIO $ putStrLn "pTop failed"
+ -- Cannot parse as a definition.
+ -- Try parsing it as an expression, and make it a definition
case parse pExprTop "" line of
Right _ -> do
+-- liftIO $ putStrLn "pExprTop succeeded"
exprTest <- tryCompile (ls ++ "\n" ++ mkIt line)
case exprTest of
Right m -> evalExpr m
--
⑨