Rework (but don't yet fix) formalArgSet

This commit is contained in:
Adam Sampson 2007-05-03 02:43:01 +00:00
parent 200619042d
commit 3d897a70fd
2 changed files with 27 additions and 12 deletions

View File

@ -1437,20 +1437,19 @@ formalList
return $ concat fs
<?> "formal list"
formalItem :: OccParser (A.AbbrevMode, A.Type) -> OccParser A.Name -> OccParser [A.Formal]
formalItem spec name
= do (am, t) <- spec
ns <- sepBy1NE name sComma
return [A.Formal am t n | n <- ns]
formalArgSet :: OccParser [A.Formal]
formalArgSet
= do (am, t) <- formalVariableType
ns <- sepBy1NE newVariableName sComma
return [A.Formal am t n | n <- ns]
<|> do t <- channelSpecifier
ns <- sepBy1NE newChannelName sComma
return [A.Formal A.Abbrev t n | n <- ns]
<|> do t <- timerSpecifier
ns <- sepBy1NE newTimerName sComma
return [A.Formal A.Abbrev t n | n <- ns]
<|> do t <- portSpecifier
ns <- sepBy1NE newPortName sComma
return [A.Formal A.Abbrev t n | n <- ns]
= formalItem formalVariableType newVariableName
<|> formalItem (aa channelSpecifier) newChannelName
<|> formalItem (aa timerSpecifier) newTimerName
<|> formalItem (aa portSpecifier) newPortName
where aa = liftM (\t -> (A.Abbrev, t))
formalVariableType :: OccParser (A.AbbrevMode, A.Type)
formalVariableType

View File

@ -0,0 +1,16 @@
DATA TYPE MYINT IS INT:
-- This next line falls in the category of awkward things to parse.
-- The problem is that:
-- PROC copy.MYINT (VAL MYINT x, MYINT)
-- would be a perfectly legal (if silly) thing to say, so we have to make
-- sure we try this interpretation first:
PROC copy.MYINT (VAL MYINT x, MYINT y)
y := x
:
PROC P ()
MYINT a, b:
SEQ
a := 42
copy.MYINT (a, b)
ASSERT (b = 42)
: