From 9b947899eea2852e9855fa30595e7a3176b70875 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Sat, 28 Sep 2024 19:53:42 +0200 Subject: Optional arguments and "flush" as a builtin --- src/Parser/Core.hs | 9 +++++---- src/Parser/Statement.hs | 6 ------ 2 files changed, 5 insertions(+), 10 deletions(-) (limited to 'src/Parser') diff --git a/src/Parser/Core.hs b/src/Parser/Core.hs index f40889a..cb66529 100644 --- a/src/Parser/Core.hs +++ b/src/Parser/Core.hs @@ -139,13 +139,14 @@ unifyExpr off pa expr = if showType ( Just (ArgumentKeyword kw), SomeArgumentType atype ) = "`" <> kw <> " <" <> textExprType atype <> ">'" err = parseError . FancyError off . S.singleton . ErrorFail . T.unpack - defaults <- forM (M.toAscList remaining) $ \case - arg@(_, SomeArgumentType NoDefault) -> err $ "missing " <> showType arg <> " argument" - (kw, SomeArgumentType (ExprDefault def)) -> return (kw, SomeExpr def) + defaults <- fmap catMaybes $ forM (M.toAscList remaining) $ \case + arg@(_, SomeArgumentType RequiredArgument) -> err $ "missing " <> showType arg <> " argument" + (_, SomeArgumentType OptionalArgument) -> return Nothing + (kw, SomeArgumentType (ExprDefault def)) -> return $ Just ( kw, SomeExpr def ) (kw, SomeArgumentType atype@ContextDefault) -> do SomeExpr context <- gets testContext context' <- unifyExpr off atype context - return (kw, SomeExpr context') + return $ Just ( kw, SomeExpr context' ) return (FunctionEval $ ArgsApp (FunctionArguments $ M.fromAscList defaults) expr) | Just (Refl :: DynamicType :~: b) <- eqT diff --git a/src/Parser/Statement.hs b/src/Parser/Statement.hs index 67ffd76..c7cdf5a 100644 --- a/src/Parser/Statement.hs +++ b/src/Parser/Statement.hs @@ -320,11 +320,6 @@ testExpect = command "expect" $ Expect <*> param "capture" <*> innerBlock -testFlush :: TestParser [TestStep] -testFlush = command "flush" $ Flush - <$> paramOrContext "from" - <*> param "" - testDisconnectNode :: TestParser [TestStep] testDisconnectNode = command "disconnect_node" $ DisconnectNode <$> paramOrContext "" @@ -372,7 +367,6 @@ testStep = choice , testNode , testSpawn , testExpect - , testFlush , testDisconnectNode , testDisconnectNodes , testDisconnectUpstream -- cgit v1.2.3