diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Parser.hs | 17 |
1 files changed, 5 insertions, 12 deletions
diff --git a/src/Parser.hs b/src/Parser.hs index e328b6e..0891481 100644 --- a/src/Parser.hs +++ b/src/Parser.hs @@ -79,16 +79,9 @@ pMultiMatOp s op = do Parsec.sepBy1 pFormulaInner (Parsec.space *> Parsec.string s *> Parsec.space) - return $ foldl1 op (term : terms) - -pBinMatOp :: String -> (Formula -> Formula -> Formula) -> Parser Formula -pBinMatOp s op = do - x <- pFormulaInner - _ <- Parsec.space - _ <- Parsec.string s - _ <- Parsec.space - y <- pFormulaInner - return $ op x y + -- Imp is right-associative, whereas And/Or/Iff can be either, so + -- use right-associative for everything. + return $ foldr1 op (term : terms) pNot :: Parser Formula pNot = Not <$> (Parsec.char '~' *> pFormulaInner) @@ -115,8 +108,8 @@ pFormulaInner = (Parsec.char ')') ( Parsec.try (pMultiMatOp "&" And) <|> Parsec.try (pMultiMatOp "|" Or) - <|> Parsec.try (pBinMatOp "<->" Iff) - <|> Parsec.try (pBinMatOp "->" Imp) + <|> Parsec.try (pMultiMatOp "<->" Iff) + <|> Parsec.try (pMultiMatOp "->" Imp) ) <|> Parsec.try pQuantifier |