Added a wait statement to the AST, and added Rain tests for parsing wait statements

This commit is contained in:
Neil Brown 2007-09-26 23:00:09 +00:00
parent a12d46401a
commit 13584ed2cb
2 changed files with 15 additions and 0 deletions

View File

@ -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.

View File

@ -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: