23 lines
466 B
Haskell
23 lines
466 B
Haskell
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
|
|
|
|
getRight :: ParseResult -> Expr
|
|
getRight (Right r) = r
|
|
|
|
getResult :: String -> Int
|
|
getResult str = evalExpr (getRight (parseExpr str))
|
|
|
|
main = do
|
|
fileName <- fmap head getArgs
|
|
contents <- readFile fileName
|
|
let result = getResult contents
|
|
print result
|