Added a new function to CompState that allows you to specify a custom error when lookupName fails, and changed one example of this in ParseOccam

This commit is contained in:
Neil Brown 2007-08-24 15:04:31 +00:00
parent f5041b801c
commit b1daf41ecf
2 changed files with 7 additions and 3 deletions

View File

@ -122,11 +122,15 @@ defineName n nd
-- | Find the definition of a name.
lookupName :: (CSM m, Die m) => A.Name -> m A.NameDef
lookupName n
lookupName n = lookupNameOrError n (die $ "cannot find name " ++ A.nameName n)
lookupNameOrError :: CSM m => A.Name -> m A.NameDef -> m A.NameDef
lookupNameOrError n err
= do ps <- get
case Map.lookup (A.nameName n) (csNames ps) of
Just nd -> return nd
Nothing -> die $ "cannot find name " ++ A.nameName n
Nothing -> err
--}}}
--{{{ warnings

View File

@ -1218,7 +1218,7 @@ allocation
p <- placement
sColon
eol
nd <- lookupName n
nd <- lookupNameOrError n $ dieP m ("Attempted to PLACE unknown variable: " ++ (show $ A.nameName n))
defineName n $ nd { A.ndPlacement = p }
return []
<?> "allocation"