summaryrefslogtreecommitdiff
path: root/src/GF/Devel/GFCCInterpreter.hs
blob: b2b17dba7e2b806e27070b92f0e5390315b43ed5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
module Main where

import GF.Command.Interpreter
import GF.Command.Commands
import GF.GFCC.API
import System (getArgs)
import Data.Char (isDigit)

-- Simple translation application built on GFCC. AR 7/9/2006 -- 19/9/2007

main :: IO ()
main = do
  file:_  <- getArgs
  grammar <- file2grammar file
  let env = CommandEnv grammar (allCommands grammar)
  printHelp grammar
  loop env

loop :: CommandEnv -> IO ()
loop env = do
  s <- getLine
  if s == "q" then return () else do
    interpretCommandLine env s
    loop env

printHelp grammar = do
  putStrLn $ "languages:  " ++ unwords (languages grammar)
  putStrLn $ "categories: " ++ unwords (categories grammar)