1
0
forked from GitHub/gf-core

Move checkPredefError from GF.Compile.Compute.ConcreteLazy to GF.Grammar.Macros

Also simplified its type.
This commit is contained in:
hallgren
2013-11-29 14:43:01 +00:00
parent d7f3aab994
commit 6f590a3f2c
4 changed files with 9 additions and 9 deletions

View File

@@ -519,12 +519,6 @@ getArgType t = case t of
V ty _ -> return ty
T (TComp ty) _ -> return ty
_ -> fail (render (text "cannot get argument type of table" $$ nest 2 (ppTerm Unqualified 0 t)))
checkPredefError :: SourceGrammar -> Term -> Err Term
checkPredefError sgr t =
case t of
Error s -> fail ("Error: "++s)
_ -> return t
{-
-- Old

View File

@@ -119,7 +119,7 @@ partEval opts = if flag optNewComp opts
partEvalNew opts gr (context, val) trm =
errIn (render (text "partial evaluation" <+> ppTerm Qualified 0 trm)) $
checkPredefError gr trm
checkPredefError trm
partEvalOld opts gr (context, val) trm = errIn (render (text "partial evaluation" <+> ppTerm Qualified 0 trm)) $ do
let vars = map (\(bt,x,t) -> x) context
@@ -130,7 +130,7 @@ partEvalOld opts gr (context, val) trm = errIn (render (text "partial evaluation
trm3 <- if rightType trm2
then computeTerm gr subst trm2 -- compute twice??
else recordExpand val trm2 >>= computeTerm gr subst
trm4 <- checkPredefError gr trm3
trm4 <- checkPredefError trm3
return $ mkAbs [(Explicit,v) | v <- vars] trm4
where
-- don't eta expand records of right length (correct by type checking)

View File

@@ -225,6 +225,12 @@ isPredefConstant t = case t of
Q (mod,_) | mod == cPredef || mod == cPredefAbs -> True
_ -> False
checkPredefError :: Monad m => Term -> m Term
checkPredefError t =
case t of
Error s -> fail ("Error: "++s)
_ -> return t
cnPredef :: Ident -> Term
cnPredef f = Q (cPredef,f)

View File

@@ -332,7 +332,7 @@ checkComputeTerm' new sgr t = do
t1 <- if new
then return (CN.normalForm (CN.resourceValues sgr) (L NoLoc identW) t)
else computeConcrete sgr t
checkPredefError sgr t1
checkPredefError t1
fetchCommand :: GFEnv -> IO String
fetchCommand gfenv = do