diff options
| author | John J. Camilleri <john@digitalgrammars.com> | 2021-05-03 20:36:31 +0200 |
|---|---|---|
| committer | John J. Camilleri <john@digitalgrammars.com> | 2021-05-03 20:36:31 +0200 |
| commit | 437bd8e7f956ec645aa5261cbb9085741c8398cd (patch) | |
| tree | afe6a8424e0e85f4a9d8f72c1bfc2bae78662a1b /src/runtime/haskell-bind/test.hs | |
| parent | e56d1b29593bef6ea3a70b50287df3e3438207d7 (diff) | |
Add proper error handling in complete
Diffstat (limited to 'src/runtime/haskell-bind/test.hs')
| -rw-r--r-- | src/runtime/haskell-bind/test.hs | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/runtime/haskell-bind/test.hs b/src/runtime/haskell-bind/test.hs index 26836445f..4d345c90c 100644 --- a/src/runtime/haskell-bind/test.hs +++ b/src/runtime/haskell-bind/test.hs @@ -4,9 +4,15 @@ import qualified Data.Map as M main :: IO () main = do pgf <- readPGF "/Users/john/repositories/GF/contrib/foods/Foods.pgf" - let Just concr = M.lookup "FoodsEng" (languages pgf) - let pr = complete concr (startCat pgf) "" "th" Nothing - case pr of - ParseOk x -> print x - ParseFailed _ _ -> putStrLn "parse failed" - ParseIncomplete -> putStrLn "input incomplete" + let + Just concr = M.lookup "FoodsEng" (languages pgf) + loop = do + putStr "> " + tks <- words <$> getLine + let pr = complete concr (startCat pgf) (unwords (init tks)) (last tks) Nothing + case pr of + ParseOk x -> print x + ParseFailed x s -> putStrLn $ "parse failed at " ++ show x ++ " " ++ s + ParseIncomplete -> putStrLn "input incomplete" + loop + loop |
