diff options
author | Marvin | 2023-09-19 17:32:36 +0200 |
---|---|---|
committer | GitHub | 2023-09-19 17:32:36 +0200 |
commit | 457b31355be1a5ce2086c43126f35e91b5a2cbdc (patch) | |
tree | 365fbf42ce9c0a218f66b8f410eb992aae845821 /app | |
parent | 1ec6f5b8e86ce9265b7bdcd1d5a9e1b4ca29afd5 (diff) | |
parent | 8a8f82d20803bc6a9d626d337d0021db55804e5c (diff) |
Merge pull request #1 from marvinborner/transpiler
Transpiler
Diffstat (limited to 'app')
-rw-r--r-- | app/Main.hs | 27 |
1 files changed, 21 insertions, 6 deletions
diff --git a/app/Main.hs b/app/Main.hs index 6e1c43f..60a44f0 100644 --- a/app/Main.hs +++ b/app/Main.hs @@ -4,16 +4,31 @@ module Main import Lib import System.Environment ( getArgs ) +import Term +import Transpile -main :: IO () --- main = mapM_ (bruteForce "...") [1 .. 10] -main = do - args <- getArgs - file <- readFile (head args) +transpile :: String -> IO () +transpile path = do + file <- readFile path + let term = fromBLC file + let ski = transpileSKI term + let birb = transpileBirb ski + putStrLn $ concatMap show birb + +reduce :: String -> IO () +reduce path = do + file <- readFile path let termified = fromBirbs file let rebirbified = fromTerm termified putStrLn $ "input: " ++ rebirbified normalBirbs <- nf termified let retermified = fromTerm normalBirbs putStrLn $ "reduced: " ++ retermified - return () + +main :: IO () +main = do + args <- getArgs + case args of + ["transpile", path] -> transpile path + ["reduce" , path] -> reduce path + _ -> putStrLn "Usage: birb [transpile|reduce] <file>" |