mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-23 03:32:51 -06:00
Renamed transfer compiler and interpreter.
This commit is contained in:
37
transfer/trci.hs
Normal file
37
transfer/trci.hs
Normal file
@@ -0,0 +1,37 @@
|
||||
import Transfer.InterpreterAPI
|
||||
import Transfer.Interpreter (prEnv)
|
||||
|
||||
import Control.Monad (when)
|
||||
import Data.List (partition, isPrefixOf)
|
||||
import System.Environment (getArgs)
|
||||
import System.IO (isEOF)
|
||||
|
||||
interpretLoop :: Env -> IO ()
|
||||
interpretLoop env =
|
||||
do
|
||||
eof <- isEOF
|
||||
if eof
|
||||
then return ()
|
||||
else do
|
||||
line <- getLine
|
||||
r <- evaluateString env line
|
||||
putStrLn r
|
||||
interpretLoop env
|
||||
|
||||
runMain :: Env -> IO ()
|
||||
runMain env = do
|
||||
r <- evaluateString env "main"
|
||||
putStrLn r
|
||||
|
||||
main :: IO ()
|
||||
main = do args <- getArgs
|
||||
let (flags,files) = partition ("-" `isPrefixOf`) args
|
||||
env <- case files of
|
||||
[f] -> loadFile f
|
||||
_ -> fail "Usage: trci [-i] <file>"
|
||||
when ("-v" `elem` flags) $ do
|
||||
putStrLn "Top-level environment:"
|
||||
putStrLn (prEnv env)
|
||||
if "-i" `elem` flags
|
||||
then interpretLoop env
|
||||
else runMain env
|
||||
Reference in New Issue
Block a user