mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-24 02:12:50 -06:00
Move transfer into the GF repo.
This commit is contained in:
26
transfer/run_core.hs
Normal file
26
transfer/run_core.hs
Normal file
@@ -0,0 +1,26 @@
|
||||
import Transfer.InterpreterAPI
|
||||
|
||||
import Data.List (partition, isPrefixOf)
|
||||
import System.Environment (getArgs)
|
||||
|
||||
interpretLoop :: Env -> IO ()
|
||||
interpretLoop env = 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: run_core [-i] <file>"
|
||||
if "-i" `elem` flags
|
||||
then interpretLoop env
|
||||
else runMain env
|
||||
Reference in New Issue
Block a user