From ed4dcb61f8a13a3cbfee1c30ea2cb12b5fd3c1ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Roman=20Smr=C5=BE?= Date: Sat, 8 Oct 2022 22:29:35 +0200 Subject: Node command to declare new node variable --- src/Main.hs | 4 ++++ src/Parser.hs | 6 ++++++ src/Test.hs | 1 + 3 files changed, 11 insertions(+) diff --git a/src/Main.hs b/src/Main.hs index fda0bb9..494b028 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -317,6 +317,10 @@ evalSteps = mapM_ $ \case value <- eval expr withVar name value $ evalSteps inner + DeclNode name@(TypedVarName vname) inner -> do + createNode name $ \node -> do + withVar vname node $ evalSteps inner + Spawn (TypedVarName vname@(VarName tname)) nname inner -> do either createNode ((>>=) . eval) nname $ \node -> do let pname = ProcName tname diff --git a/src/Parser.hs b/src/Parser.hs index 7773bae..a33b429 100644 --- a/src/Parser.hs +++ b/src/Parser.hs @@ -476,6 +476,11 @@ testLocal = do indent <- L.indentGuard scn GT ref localState $ testBlock indent +testNode :: TestParser [TestStep] +testNode = command "node" $ DeclNode + <$> param "" + <*> innerBlock + testSpawn :: TestParser [TestStep] testSpawn = command "spawn" $ Spawn <$> param "as" @@ -528,6 +533,7 @@ testStep :: TestParser [TestStep] testStep = choice [ letStatement , testLocal + , testNode , testSpawn , testSend , testExpect diff --git a/src/Test.hs b/src/Test.hs index 5a45930..6b04fac 100644 --- a/src/Test.hs +++ b/src/Test.hs @@ -33,6 +33,7 @@ data Test = Test } data TestStep = forall a. ExprType a => Let SourceLine VarName (Expr a) [TestStep] + | DeclNode (TypedVarName Node) [TestStep] | Spawn (TypedVarName Process) (Either (TypedVarName Node) (Expr Node)) [TestStep] | Send (Expr Process) (Expr Text) | Expect SourceLine (Expr Process) (Expr Regex) [TypedVarName Text] [TestStep] -- cgit v1.2.3