check grammar should process the definitions in dependency order. This also ensures that the list of parameters for some parameter type is complete

This commit is contained in:
krasimir
2009-11-07 15:30:57 +00:00
parent 7c513609f0
commit 2a22325678
2 changed files with 24 additions and 33 deletions
+4 -20
View File
@@ -140,28 +140,12 @@ allOrigInfos gr m = errVal [] $ do
where
look = lookupOrigInfo gr m
lookupParams :: SourceGrammar -> Ident -> Ident -> Err ([Param],Maybe [Term])
lookupParams gr = look True where
look isTop m c = do
mo <- lookupModule gr m
info <- lookupIdentInfo mo c
case info of
ResParam (Just psm) m -> return (psm,m)
AnyInd _ n -> look False n c
_ -> Bad $ render (ppIdent c <+> text "has no parameters defined in resource" <+> ppIdent m)
lookExt m c =
checks [look False n c | n <- allExtensions gr m]
lookupParamValues :: SourceGrammar -> Ident -> Ident -> Err [Term]
lookupParamValues gr m c = do
(ps,mpv) <- lookupParams gr m c
case mpv of
Just ts -> return ts
_ -> liftM concat $ mapM mkPar ps
where
mkPar (f,co) = do
vs <- liftM combinations $ mapM (\(_,_,ty) -> allParamValues gr ty) co
return $ map (mkApp (QC m f)) vs
(_,info) <- lookupOrigInfo gr m c
case info of
ResParam _ (Just pvs) -> return pvs
_ -> Bad $ render (ppIdent c <+> text "has no parameter values defined in resource" <+> ppIdent m)
allParamValues :: SourceGrammar -> Type -> Err [Term]
allParamValues cnc ptyp = case ptyp of