Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

19 lines (15 sloc) 0.496 kb
module Main where
import Prelude hiding (lex)
import Lexer
import Parser
reduceExp :: Exp -> Int
reduceExp e =
case e of
Plus a b -> (reduceExp a) + (reduceExp b)
Minus a b -> (reduceExp a) - (reduceExp b)
Times a b -> (reduceExp a) * (reduceExp b)
Div a b -> (reduceExp a) `div` (reduceExp b)
Paren a -> reduceExp a
Negate a -> negate $ reduceExp a
Intg a -> a
main = getContents >>= print . reduceExp . parse . lex
Jump to Line
Something went wrong with that request. Please try again.