parent
af50529dc1
commit
3388e3f97e
15
app/Main.hs
15
app/Main.hs
|
@ -1,21 +1,22 @@
|
|||
module Main (main) where
|
||||
|
||||
import Control.Monad
|
||||
import Data.Either
|
||||
import Eval.Expression
|
||||
import Objects.Expression
|
||||
import Parser.Expression
|
||||
import System.Environment
|
||||
import System.IO
|
||||
import Text.Megaparsec
|
||||
|
||||
parseResult :: ParseResult
|
||||
parseResult = parseExpr "2+3*4"
|
||||
|
||||
getRight :: ParseResult -> Expr
|
||||
getRight (Right r) = r
|
||||
|
||||
expr = getRight parseResult
|
||||
|
||||
result = evalExpr expr
|
||||
getResult :: String -> Int
|
||||
getResult str = evalExpr (getRight (parseExpr str))
|
||||
|
||||
main = do
|
||||
print result
|
||||
fileName <- fmap head getArgs
|
||||
contents <- readFile fileName
|
||||
let result = getResult contents
|
||||
print result
|
||||
|
|
Reference in New Issue