From db1c16c2cbf13b713c4976d03f04e4d2d7bec42d Mon Sep 17 00:00:00 2001 From: Adam Sampson Date: Mon, 30 Apr 2007 02:51:46 +0000 Subject: [PATCH] Do away with operandNotTable -- it's not needed now we have state, and it breaks stuff --- fco2/Parse.hs | 16 +++------------- fco2/SYNTAX | 5 +---- fco2/testcases/lit-slice.occ | 16 ++++++++++++++++ fco2/testcases/pri-par.occ | 7 +++++++ 4 files changed, 27 insertions(+), 17 deletions(-) create mode 100644 fco2/testcases/lit-slice.occ create mode 100644 fco2/testcases/pri-par.occ diff --git a/fco2/Parse.hs b/fco2/Parse.hs index ba89be0..99c8760 100644 --- a/fco2/Parse.hs +++ b/fco2/Parse.hs @@ -986,8 +986,7 @@ conversionMode :: OccParser (A.ConversionMode, A.Expression) conversionMode = do { sROUND; o <- noTypeContext operand; return (A.Round, o) } <|> do { sTRUNC; o <- noTypeContext operand; return (A.Trunc, o) } - -- This uses operandNotTable to resolve the "x[y]" ambiguity. - <|> do { o <- noTypeContext operandNotTable; return (A.DefaultConversion, o) } + <|> do { o <- noTypeContext operand; return (A.DefaultConversion, o) } "conversion mode and operand" --}}} --{{{ operands @@ -997,16 +996,6 @@ operand operand' :: OccParser A.Expression operand' - = table - <|> operandNotTable' - "operand'" - -operandNotTable :: OccParser A.Expression -operandNotTable - = maybeSubscripted "operand other than table" operandNotTable' A.SubscriptedExpr typeOfExpression - -operandNotTable' :: OccParser A.Expression -operandNotTable' = do { m <- md; v <- variable; return $ A.ExprVariable m v } <|> literal <|> do { sLeftR; e <- expression; sRightR; return e } @@ -1021,7 +1010,8 @@ operandNotTable' <|> do { m <- md; sOFFSETOF; sLeftR; t <- dataType; sComma; f <- fieldName; sRightR; return $ A.OffsetOf m t f } <|> do { m <- md; sTRUE; return $ A.True m } <|> do { m <- md; sFALSE; return $ A.False m } - "operand other than table'" + <|> table + "operand" --}}} --{{{ variables, channels, timers, ports variable :: OccParser A.Variable diff --git a/fco2/SYNTAX b/fco2/SYNTAX index d23dd72..3302c7b 100644 --- a/fco2/SYNTAX +++ b/fco2/SYNTAX @@ -3,10 +3,7 @@ Bugs in the ordered syntax in the occam2.1 manual -- Things I've worked around in Parse.hs -x[y] is ambiguous -- fixed by splitting operand into a version that permits -tables and a version that doesn't. - -x ! y is ambiguous. +"x[y]" and "x ! y" are both ambiguous unless you have an idea of what x is. "SIZE cs" where cs is an array of channels isn't allowed. diff --git a/fco2/testcases/lit-slice.occ b/fco2/testcases/lit-slice.occ new file mode 100644 index 0000000..4fa5fd0 --- /dev/null +++ b/fco2/testcases/lit-slice.occ @@ -0,0 +1,16 @@ +-- from cgtest07 +PROC P () + BYTE b: + [1]BYTE bs: + INT n: + SEQ + -- With extra brackets... + ASSERT ((INT 'e') = (INT ("Hello"[INT ([BYTE 10, BYTE 10, BYTE 1][42 \ 10])]))) + -- Bits of it + b := BYTE 10 + bs := [BYTE 10] + -- But this triggers the operandNotTable problem + n := INT [BYTE 10][0] + -- As it appeared (in occam2.1-legal form) in the cgtest + ASSERT ((INT 'e') = (INT ("Hello"[INT [BYTE 10, BYTE 10, BYTE 1][42 \ 10]]))) +: diff --git a/fco2/testcases/pri-par.occ b/fco2/testcases/pri-par.occ new file mode 100644 index 0000000..626d044 --- /dev/null +++ b/fco2/testcases/pri-par.occ @@ -0,0 +1,7 @@ +PROC P () + PRI PAR + SKIP + SKIP + SKIP + SKIP +: