diff --git a/src/bin/TutorialD/Interpreter/RelationalExpr.hs b/src/bin/TutorialD/Interpreter/RelationalExpr.hs index 7f9dffd5..b0b542b5 100644 --- a/src/bin/TutorialD/Interpreter/RelationalExpr.hs +++ b/src/bin/TutorialD/Interpreter/RelationalExpr.hs @@ -102,7 +102,11 @@ ungroupP = do extendP :: RelationalMarkerExpr a => Parser (RelationalExprBase a -> RelationalExprBase a) extendP = do reservedOp ":" - Extend <$> braces extendTupleExpressionP + extends <- braces (sepBy extendTupleExpressionP comma) + case extends of + [] -> pure (Restrict TruePredicate) + extends' -> + pure $ \expr -> foldl (\acc ext -> Extend ext acc) expr extends' semijoinP :: RelationalMarkerExpr a => Parser (RelationalExprBase a -> RelationalExprBase a -> RelationalExprBase a) semijoinP = do diff --git a/test/TutorialD/Interpreter.hs b/test/TutorialD/Interpreter.hs index fe9f997f..87ae6fa7 100644 --- a/test/TutorialD/Interpreter.hs +++ b/test/TutorialD/Interpreter.hs @@ -121,7 +121,8 @@ simpleRelTests = TestCase $ do ("x:=relation{tuple{a 5}} : {b:=6}", mkRelationFromTuples simpleDAttributes [RelationTuple simpleDAttributes (V.fromList [IntegerAtom 5, IntegerAtom 6])]), ("x:=relation{tuple{a 5}} : {b:=add(@a,5)}", mkRelationFromTuples simpleDAttributes [RelationTuple simpleDAttributes (V.fromList [IntegerAtom 5, IntegerAtom 10])]), ("x:=relation{tuple{a 5}} : {b:=add(@a,\"spam\")}", Left (AtomFunctionTypeError "add" 2 IntegerAtomType TextAtomType)), - ("x:=relation{tuple{a 5}} : {b:=add(add(@a,2),5)}", mkRelationFromTuples simpleDAttributes [RelationTuple simpleDAttributes (V.fromList [IntegerAtom 5, IntegerAtom 12])]) + ("x:=relation{tuple{a 5}} : {b:=add(add(@a,2),5)}", mkRelationFromTuples simpleDAttributes [RelationTuple simpleDAttributes (V.fromList [IntegerAtom 5, IntegerAtom 12])]), + ("x:=false:{a:=1,b:=2}", mkRelationFromTuples simpleDAttributes []) ] simpleAAttributes = A.attributesFromList [Attribute "a" IntegerAtomType] simpleBAttributes = A.attributesFromList [Attribute "d" IntegerAtomType]