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:
parent
f5041b801c
commit
b1daf41ecf
|
@ -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
|
||||
|
|
|
@ -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"
|
||||
|
|
Loading…
Reference in New Issue
Block a user