From 5adbf7fcfceed5ebbab1ae018257f16e1de05d6e Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Thu, 23 Aug 2007 14:58:11 +0000 Subject: [PATCH] Rain: changed the declaration parser to also return a Meta tag --- RainParse.hs | 4 ++-- RainParseTest.hs | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/RainParse.hs b/RainParse.hs index 762036b..d21c091 100644 --- a/RainParse.hs +++ b/RainParse.hs @@ -245,9 +245,9 @@ tupleDef = do {sLeftR ; tm <- sepBy tupleDefMember sComma ; sRightR ; return tm} tupleDefMember :: RainParser (A.Name,A.Type) tupleDefMember = do {t <- dataType ; sColon ; n <- name ; return (n,t)} -declaration :: RainParser (A.Structured -> A.Structured) +declaration :: RainParser (Meta,A.Structured -> A.Structured) declaration = do {t <- dataType; sColon ; n <- name ; sSemiColon ; - return $ A.Spec (findMeta t) $ A.Specification (findMeta t) n $ A.Declaration (findMeta t) t } + return (findMeta t, A.Spec (findMeta t) $ A.Specification (findMeta t) n $ A.Declaration (findMeta t) t) } topLevelDecl :: RainParser A.Structured topLevelDecl = do {m <- sProcess ; procName <- name ; params <- tupleDef ; body <- block ; diff --git a/RainParseTest.hs b/RainParseTest.hs index 91158f3..dde0b84 100644 --- a/RainParseTest.hs +++ b/RainParseTest.hs @@ -252,7 +252,7 @@ testDataType = ,fail ("int?int",RP.dataType) ] -testDecl :: [ParseTest (A.Structured -> A.Structured)] +testDecl :: [ParseTest (Meta, A.Structured -> A.Structured)] testDecl = [ passd ("bool: b;",0,tag3 A.Specification DontCare (simpleNamePattern "b") $ tag2 A.Declaration DontCare A.Bool) @@ -268,10 +268,10 @@ testDecl = ,fail ("bool:?b;",RP.declaration) ] where - passd :: (String,Int,Pattern) -> ParseTest (A.Structured -> A.Structured) + passd :: (String,Int,Pattern) -> ParseTest (Meta, A.Structured -> A.Structured) passd (code,index,exp) = pass(code,RP.declaration,check ("testDecl " ++ (show index)) exp) - check :: String -> Pattern -> (A.Structured -> A.Structured) -> Assertion - check msg spec act = assertPatternMatch msg (tag3 A.Spec DontCare spec $ A.Several m []) (act $ A.Several m []) + check :: String -> Pattern -> (Meta, A.Structured -> A.Structured) -> Assertion + check msg spec (_,act) = assertPatternMatch msg (tag3 A.Spec DontCare spec $ A.Several m []) (act $ A.Several m []) testComm :: [ParseTest A.Process] testComm =