@@ -13,6 +13,7 @@ import qualified Data.HashSet as HS
1313import qualified Data.Map as M
1414import Control.Applicative ((<$), (<*), (*>), liftA, liftA2)
1515import Control.Monad.State
16+import System.Console.Readline
1617
1718lexer :: Token.TokenParser ()
1819lexer = Token.makeTokenParser tutD
@@ -126,3 +127,15 @@ example9 = "relA := relation { SNO CHAR }"
126127interpret :: RelVarContext -> String -> (Either RelationalError Relation, RelVarContext)
127128interpret context tutdstring = runState (eval (parseString tutdstring)) context
128129
130+reprLoop :: RelVarContext -> IO ()
131+reprLoop context = do
132+ maybeLine <- readline "TutorialD: "
133+ case maybeLine of
134+ Nothing -> return ()
135+ Just line -> do
136+ addHistory line
137+ case fst (interpret context line) of
138+ Right rel -> putStrLn $ show rel
139+ Left err -> putStrLn $ show err
140+ reprLoop context
141+