
Hi, Could some one point out what I'm doing wrong below. This is a parser which takes an arithmetic expression built up from single digits. Turns 3*4+2 into (3*4)+2 etc.It giving me the last expression in a do statement or parse error on -> (+++) :: Parser a -> Parser a -> Parser a expr :: term( '+' expr |"") term -> factor('*' term |"") expr :: Parser Int expr = do t <- term do char '+' e <- expr return (t + e) +++ return t term :: Parser Int term = do f <- factor do char '*' t <- term return (f * t) +++ return f factor :: Parser Int factor = do d <- digit return (digitToInt d) +++ do char '(' e <- expr char ')' return e eval :: String -> Int eval xs = fst(head(parse expr xs)) John