diff --git a/common/AST.hs b/common/AST.hs index 91e7ca7..935431c 100644 --- a/common/AST.hs +++ b/common/AST.hs @@ -316,6 +316,12 @@ data Replicator = data Choice = Choice Meta Expression Process deriving (Show, Eq, Typeable, Data) +-- | A mode of waiting -- either for a specified duration, or until a specified time. +data WaitMode = + WaitFor + | WaitUntil + deriving (Show, Eq, Typeable, Data) + -- | A guard in an @ALT@. data Alternative = -- | A plain guard. @@ -467,6 +473,7 @@ data Process = | Output Meta Variable [OutputItem] | OutputCase Meta Variable Name [OutputItem] | GetTime Meta Variable + | Wait Meta WaitMode Expression | Skip Meta | Stop Meta -- | The main process. diff --git a/frontends/ParseRainTest.hs b/frontends/ParseRainTest.hs index b01cb87..5fd78d8 100644 --- a/frontends/ParseRainTest.hs +++ b/frontends/ParseRainTest.hs @@ -610,6 +610,14 @@ testTime = ,fail ("now t",RP.statement) ,fail ("now ;",RP.statement) ,fail ("now t + t;",RP.statement) + + ,pass ("wait for t;",RP.statement, assertPatternMatch "testTime 1" $ tag3 A.Wait DontCare A.WaitFor (exprVariablePattern "t")) + ,pass ("wait until t;",RP.statement, assertPatternMatch "testTime 2" $ tag3 A.Wait DontCare A.WaitUntil (exprVariablePattern "t")) + ,pass ("wait until t + t;",RP.statement, assertPatternMatch "testTime 3" $ tag3 A.Wait DontCare A.WaitUntil $ buildExprPattern $ Dy (Var "t") A.Plus (Var "t")) + ,fail ("waitfor t;",RP.statement) + ,fail ("waituntil t;",RP.statement) + ,fail ("wait for t",RP.statement) + ,fail ("until t;",RP.statement) ] --Returns the list of tests: