Commit 77b34556 authored by Bastian Kauschke's avatar Bastian Kauschke
Browse files

correctly parse `Z^X` as int-valued

parent 22c05629
......@@ -215,10 +215,13 @@ parseFactorExpr inner = (Const <$> parseConstExpr) <|> (parseIdOrExp inner)
parseConstExpr :: MonadParser m => m ConstSet
parseConstExpr =
((L.symbol "Z" <|> L.symbol "ℤ") >> return IntSet) <|>
((L.symbol "N" <|> L.symbol "ℕ") >> return NatSet) <|>
(FiniteNatSet <$> L.decimal) <|>
((ExplicitSet . V.fromList) <$> (L.braces (L.name `sepBy` L.comma)))
-- We have use `try` here to prevent us from erroneously parsing the `Z` of `Z^X` as an `IntSet`.
try (
(((L.symbol "Z" <|> L.symbol "ℤ") >> return IntSet) <|>
((L.symbol "N" <|> L.symbol "ℕ") >> return NatSet) <|>
(FiniteNatSet <$> L.decimal) <|>
((ExplicitSet . V.fromList) <$> (L.braces (L.name `sepBy` L.comma)))) <* notFollowedBy (L.symbol "^")
)
parseIdOrExp :: MonadParser m => m a -> m (Factor a)
parseIdOrExp inner = do
......
Supports Markdown
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