Rain: changed the declaration parser to also return a Meta tag
This commit is contained in:
parent
cab4ec2113
commit
5adbf7fcfc
|
@ -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 ;
|
||||
|
|
|
@ -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 =
|
||||
|
|
Loading…
Reference in New Issue
Block a user