From 3d897a70fddcdce5cfc94e37f000f3070a964bef Mon Sep 17 00:00:00 2001 From: Adam Sampson Date: Thu, 3 May 2007 02:43:01 +0000 Subject: [PATCH] Rework (but don't yet fix) formalArgSet --- fco2/Parse.hs | 23 +++++++++++------------ fco2/testcases/datatype-formals.occ | 16 ++++++++++++++++ 2 files changed, 27 insertions(+), 12 deletions(-) create mode 100644 fco2/testcases/datatype-formals.occ diff --git a/fco2/Parse.hs b/fco2/Parse.hs index 58b9567..788e317 100644 --- a/fco2/Parse.hs +++ b/fco2/Parse.hs @@ -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 diff --git a/fco2/testcases/datatype-formals.occ b/fco2/testcases/datatype-formals.occ new file mode 100644 index 0000000..e81732a --- /dev/null +++ b/fco2/testcases/datatype-formals.occ @@ -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) +: