summaryrefslogtreecommitdiff
path: root/src/runtime/haskell-bind/test.hs
blob: 4d345c90c6be14c6459c514c7b34d4ae7d1a7cf9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import PGF2
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)
    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