Commit 88ad3ed0 authored by Hans-Peter Deifel's avatar Hans-Peter Deifel 🐢
Browse files

Merge branch 'group-valued-int' into 'master'

reenable GroupValued Int parsing

Closes #4

See merge request !22
parents ec4013e5 fe31375c
{a, b}xZ^X
q1: (a, {q3: 2})
q2: (a, {q3: 2})
q3: (b, {q2: 1})
Block 0: q1, q2
Block 1: q3
......@@ -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
......
......@@ -18,14 +18,14 @@ import Data.Float.Utils ( EqDouble )
spec :: Spec
spec = do
paseIntSpec
parseIntSpec
parseMorphismPointIntSpec
parseMorphismPointDoubleSpec
parseMorphismPointComplexSpec
parseMorphismPointRationalSpec
paseIntSpec :: Spec
paseIntSpec = describe "Int-valued parser" $ do
parseIntSpec :: Spec
parseIntSpec = describe "Int-valued parser" $ do
it "parses Z^X" $
parseFunctorExpression [[functorExprParser intValued]] "" "Z^X"
`shouldParse` (Functor 1 (GroupValued Variable))
......
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