diff options
| author | John J. Camilleri <john@digitalgrammars.com> | 2021-05-03 20:51:24 +0200 |
|---|---|---|
| committer | John J. Camilleri <john@digitalgrammars.com> | 2021-05-03 20:51:24 +0200 |
| commit | 588cd6ddb16350ed947a975a28315806164fe651 (patch) | |
| tree | dbfb71588537966dc48d50e5b61eee51fa604cbb /src/runtime | |
| parent | 437bd8e7f956ec645aa5261cbb9085741c8398cd (diff) | |
Improvement to test script, distinguishes when input ends with whitespace
Diffstat (limited to 'src/runtime')
| -rw-r--r-- | src/runtime/haskell-bind/test.hs | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/runtime/haskell-bind/test.hs b/src/runtime/haskell-bind/test.hs index 4d345c90c..1c0c9fa87 100644 --- a/src/runtime/haskell-bind/test.hs +++ b/src/runtime/haskell-bind/test.hs @@ -1,4 +1,6 @@ import PGF2 +import qualified Data.Char as C +import qualified Data.List as L import qualified Data.Map as M main :: IO () @@ -8,8 +10,13 @@ main = do 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 + input <- getLine + let + (sent,pfx) = + if C.isSpace (last input) + then (input, "") + else let toks = words input in (unwords (init toks), last toks) + let pr = complete concr (startCat pgf) sent pfx Nothing case pr of ParseOk x -> print x ParseFailed x s -> putStrLn $ "parse failed at " ++ show x ++ " " ++ s |
