module Main where import Compiler import Eval (evalTricu, result) import Library (library) import Parser (parseTricu) import REPL (repl) import Research (T) import Text.Megaparsec (runParser) import System.Console.CmdArgs import qualified Data.Map as Map data TricuArgs = Repl | Compile { file :: FilePath } deriving (Show, Data, Typeable) replMode :: TricuArgs replMode = Repl &= help "Start interactive REPL" &= auto &= name "repl" compileMode :: TricuArgs compileMode = Compile { file = def &= typ "FILE" &= help "Relative or absolute path to compile" } &= help "Compile a file and return the result of the expression in the final line" &= explicit &= name "compile" main :: IO () main = do args <- cmdArgs $ modes [replMode, compileMode] &= help "tricu: Exploring Tree Calculus" &= program "tricu" &= summary "tricu - compiler and repl" case args of Repl -> do putStrLn "Welcome to the tricu REPL" putStrLn "You can exit with `CTRL+D` or the `:_exit` command.`" repl library Compile filePath -> do result <- evaluateFile filePath print result