Removed "run" from the Rain syntax, and adopted the occam approach instead

This commit is contained in:
Neil Brown 2008-03-25 17:32:54 +00:00
parent 4429dfc051
commit f0a90a3024
3 changed files with 16 additions and 17 deletions

View File

@ -39,7 +39,7 @@ $hexDigit = [0-9 a-f A-F]
| ".." | "++"
| "process" | "function"
| "pareach" | "seqeach" | "par" | "seq"
| "run" | "return" | "now"
| "return" | "now"
| "wait" | "for" | "until"
| "if" | "while" | "else"
| "pri" | "alt"

View File

@ -53,9 +53,10 @@ instance Die (GenParser tok st) where
dieReport (Just m, err) = fail $ packMeta m err
dieReport (Nothing, err) = fail err
sLeftQ, sRightQ, sLeftR, sRightR, sLeftC, sRightC, sSemiColon, sColon, sComma, sIn, sOut, sDots,
sPar, sSeq, sAlt, sPri, sSeqeach, sPareach, sChannel, sOne2One, sIf, sElse, sWhile, sProcess, sFunction, sRun, sReturn, sWait, sFor, sUntil
:: RainParser Meta
sLeftQ, sRightQ, sLeftR, sRightR, sLeftC, sRightC, sSemiColon, sColon,
sComma, sIn, sOut, sDots, sPar, sSeq, sAlt, sPri, sSeqeach, sPareach,
sChannel, sOne2One, sIf, sElse, sWhile, sProcess, sFunction, sReturn,
sWait, sFor, sUntil :: RainParser Meta
--{{{ Symbols
sLeftQ = reserved "["
@ -87,7 +88,6 @@ sElse = reserved "else"
sWhile = reserved "while"
sProcess = reserved "process"
sFunction = reserved "function"
sRun = reserved "run"
sReturn = reserved "return"
sWait = reserved "wait"
sFor = reserved "for"
@ -424,11 +424,10 @@ tuple :: RainParser [A.Expression]
tuple = do { sLeftR ; items <- expression `sepBy` sComma ; sRightR ; return items }
runProcess :: RainParser A.Process
runProcess = do m <- sRun
(mProcess,processName) <- identifier
runProcess = do (mProcess,processName) <- identifier
items <- tuple
sSemiColon
return $ A.ProcCall m A.Name {A.nameName = processName, A.nameMeta = mProcess, A.nameType = A.ProcName} (map convertItem items)
return $ A.ProcCall mProcess A.Name {A.nameName = processName, A.nameMeta = mProcess, A.nameType = A.ProcName} (map convertItem items)
where
convertItem :: A.Expression -> A.Actual
convertItem (A.ExprVariable _ v) = A.ActualVariable v
@ -456,7 +455,7 @@ statement
}
<|> block
<|> each
<|> runProcess
<|> try runProcess
<|> do {m <- reserved "now" ; dest <- lvalue ; sSemiColon ; return $ A.Input
m (A.Variable m rainTimerName) $ A.InputTimerRead m $ A.InVariable m dest}
<|> do {(m,wm) <- waitStatement False; return $ A.Input m (A.Variable m

View File

@ -675,16 +675,16 @@ testAlt =
testRun :: [ParseTest A.Process]
testRun =
[
pass ("run foo();",RP.statement,assertPatternMatch "testRun 1" $ tag3 A.ProcCall DontCare (procNamePattern "foo") ([] :: [A.Actual]))
,pass ("run foo(c);",RP.statement,assertPatternMatch "testRun 2" $ tag3 A.ProcCall DontCare (procNamePattern "foo")
pass ("foo();",RP.statement,assertPatternMatch "testRun 1" $ tag3 A.ProcCall DontCare (procNamePattern "foo") ([] :: [A.Actual]))
,pass ("foo(c);",RP.statement,assertPatternMatch "testRun 2" $ tag3 A.ProcCall DontCare (procNamePattern "foo")
[tag1 A.ActualVariable (variablePattern "c")])
,pass ("run foo(c,0+x);",RP.statement,assertPatternMatch "testRun 3" $ tag3 A.ProcCall DontCare (procNamePattern "foo")
,pass ("foo(c,0+x);",RP.statement,assertPatternMatch "testRun 3" $ tag3 A.ProcCall DontCare (procNamePattern "foo")
[tag1 A.ActualVariable (variablePattern "c"),tag1 A.ActualExpression $ tag4 A.Dyadic DontCare A.Plus (intLiteralPattern 0) (exprVariablePattern "x")])
,fail ("run",RP.statement)
,fail ("run;",RP.statement)
,fail ("run ();",RP.statement)
,fail ("run foo()",RP.statement)
,fail ("run foo(,);",RP.statement)
,fail ("",RP.statement)
,fail (";",RP.statement)
,fail ("();",RP.statement)
,fail ("foo()",RP.statement)
,fail ("foo(,);",RP.statement)
]