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.
|
-- | Find the definition of a name.
|
||||||
lookupName :: (CSM m, Die m) => A.Name -> m A.NameDef
|
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
|
= do ps <- get
|
||||||
case Map.lookup (A.nameName n) (csNames ps) of
|
case Map.lookup (A.nameName n) (csNames ps) of
|
||||||
Just nd -> return nd
|
Just nd -> return nd
|
||||||
Nothing -> die $ "cannot find name " ++ A.nameName n
|
Nothing -> err
|
||||||
|
|
||||||
--}}}
|
--}}}
|
||||||
|
|
||||||
--{{{ warnings
|
--{{{ warnings
|
||||||
|
|
|
@ -1218,7 +1218,7 @@ allocation
|
||||||
p <- placement
|
p <- placement
|
||||||
sColon
|
sColon
|
||||||
eol
|
eol
|
||||||
nd <- lookupName n
|
nd <- lookupNameOrError n $ dieP m ("Attempted to PLACE unknown variable: " ++ (show $ A.nameName n))
|
||||||
defineName n $ nd { A.ndPlacement = p }
|
defineName n $ nd { A.ndPlacement = p }
|
||||||
return []
|
return []
|
||||||
<?> "allocation"
|
<?> "allocation"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user