2024-12-18 18:55:51 -06:00
|
|
|
module Main where
|
|
|
|
|
2024-12-29 21:49:57 -06:00
|
|
|
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)
|
2024-12-18 18:55:51 -06:00
|
|
|
|
|
|
|
import Text.Megaparsec (runParser)
|
2024-12-29 21:49:57 -06:00
|
|
|
import System.Console.CmdArgs
|
2024-12-18 18:55:51 -06:00
|
|
|
|
2024-12-29 20:29:41 -06:00
|
|
|
import qualified Data.Map as Map
|
|
|
|
|
2024-12-29 21:49:57 -06:00
|
|
|
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"
|
|
|
|
|
2024-12-18 18:55:51 -06:00
|
|
|
main :: IO ()
|
2024-12-27 19:27:04 -06:00
|
|
|
main = do
|
2024-12-29 21:49:57 -06:00
|
|
|
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
|
|
|
|
|