tricu/src/Main.hs

48 lines
1.1 KiB
Haskell
Raw Normal View History

module Main where
import Compiler
2024-12-29 20:29:41 -06:00
import Eval (evalTricu, result)
import Library (library)
import Parser (parseTricu)
import REPL (repl)
import Research (T)
import Text.Megaparsec (runParser)
import System.Console.CmdArgs
2024-12-29 20:29:41 -06:00
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 Map.empty
Compile filePath -> do
result <- evaluateFile filePath
print result