Add "SimpleT" t output form
This new output form allows easy piping to the decode function of the tricu executable. Includes a new test for roundtrip evaluation of map, compilation to tree calculus terms, and decoding back to a human readable string.
This commit is contained in:
21
src/Main.hs
21
src/Main.hs
@@ -1,13 +1,13 @@
|
||||
module Main where
|
||||
|
||||
import Compiler
|
||||
import Eval (evalTricu, result, toAST)
|
||||
import Library (library)
|
||||
import Parser (parseTricu)
|
||||
import Eval (evalTricu, result)
|
||||
import Library (library)
|
||||
import Parser (parseTricu)
|
||||
import REPL
|
||||
import Research
|
||||
|
||||
import Text.Megaparsec (runParser)
|
||||
import Text.Megaparsec (runParser)
|
||||
import System.Console.CmdArgs
|
||||
|
||||
import qualified Data.Map as Map
|
||||
@@ -18,9 +18,6 @@ data TricuArgs
|
||||
| Decode { input :: Maybe FilePath }
|
||||
deriving (Show, Data, Typeable)
|
||||
|
||||
data CompiledForm = TreeCalculus | AST | Ternary | Ascii
|
||||
deriving (Show, Data, Typeable)
|
||||
|
||||
replMode :: TricuArgs
|
||||
replMode = Repl
|
||||
&= help "Start interactive REPL"
|
||||
@@ -33,8 +30,8 @@ compileMode = Compile
|
||||
&= help "Relative or absolute path to file input for compilation" &= name "f"
|
||||
, output = def &= typ "OUTPUT"
|
||||
&= help "Optional output file path for resulting output" &= name "o"
|
||||
, form = TreeCalculus &= typ "FORM"
|
||||
&= help "Output form: (tree|ast|ternary|ascii)"
|
||||
, form = FSL &= typ "FORM"
|
||||
&= help "Output form: (fsl|tree|ast|ternary|ascii)"
|
||||
&= name "t"
|
||||
}
|
||||
&= help "Compile a file and return the result of the expression in the final line"
|
||||
@@ -75,9 +72,3 @@ main = do
|
||||
Just inputPath -> readFile inputPath
|
||||
Nothing -> getContents
|
||||
putStrLn $ decodeResult $ result $ evalTricu library $ parseTricu value
|
||||
|
||||
formatResult :: CompiledForm -> T -> String
|
||||
formatResult TreeCalculus = show
|
||||
formatResult AST = show . toAST
|
||||
formatResult Ternary = toTernaryString
|
||||
formatResult Ascii = toAscii
|
||||
|
||||
Reference in New Issue
Block a user