Commit bfddd560 authored by Philipp Meyer's avatar Philipp Meyer

Fixed parsing and display of parentheses

parent 1cca0e05
......@@ -137,9 +137,10 @@ termOperatorTable =
]
termAtom :: Parser Term
termAtom = parens term
termAtom = (Var <$> ident)
<|> (Const <$> integer)
<|> (Var <$> ident)
<|> parens term
<?> "basic term"
term :: Parser Term
term = buildExpressionParser termOperatorTable termAtom <?> "term"
......@@ -167,10 +168,11 @@ formOperatorTable =
]
formAtom :: Parser Formula
formAtom = parens formula
formAtom = try linIneq
<|> (reserved "true" *> return FTrue)
<|> (reserved "false" *> return FFalse)
<|> linIneq
<|> parens formula
<?> "basic formula"
formula :: Parser Formula
formula = buildExpressionParser formOperatorTable formAtom <?> "formula"
......
......@@ -20,10 +20,10 @@ data Term = Var String
instance Show Term where
show (Var x) = x
show (Const c) = show c
show (Minus t) = "-(" ++ show t ++ ")"
show (t :+: u) = show t ++ " + " ++ show u
show (t :-: u) = show t ++ " - " ++ show u
show (t :*: u) = "(" ++ show t ++ ") * (" ++ show u ++ ")"
show (Minus t) = "-" ++ show t
show (t :+: u) = "(" ++ show t ++ " + " ++ show u ++ ")"
show (t :-: u) = "(" ++ show t ++ " - " ++ show u ++ ")"
show (t :*: u) = show t ++ " * " ++ show u
data Op = Gt | Ge | Eq | Ne | Le | Lt
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment