metavariables made unique in type checking

This commit is contained in:
aarne
2009-01-30 16:52:38 +00:00
parent 92bb971ea3
commit 241e13247d
3 changed files with 14 additions and 4 deletions

View File

@@ -211,7 +211,7 @@ pp. 115-131,
//A philosophical study of the medieval thesis that// //A philosophical study of the medieval thesis that//
//grammar is the same in all languages and the difference is only in words.// //grammar is the same in all languages and the difference is only in words.//
J Khegai. J. Khegai.
GF parallel resource grammars and Russian. GF parallel resource grammars and Russian.
In proceedings of ACL2006 In proceedings of ACL2006
(The joint conference of the International Committee on Computational (The joint conference of the International Committee on Computational

View File

@@ -10,7 +10,10 @@ module PGF.Expr(Tree(..), Literal(..),
Value(..), Env, eval, apply, Value(..), Env, eval, apply,
-- helpers -- helpers
pStr,pFactor pStr,pFactor,
-- refresh metavariables
newMetas
) where ) where
import PGF.CId import PGF.CId
@@ -250,4 +253,11 @@ apply :: Value -> Value -> Value
apply (VClosure env (EAbs x e)) v = eval (Map.insert x v env) e apply (VClosure env (EAbs x e)) v = eval (Map.insert x v env) e
apply v0 v = VApp v0 v apply v0 v = VApp v0 v
--- use composOp and state monad...
newMetas :: Expr -> Expr
newMetas = fst . metas 0 where
metas i exp = case exp of
EAbs x e -> let (f,j) = metas i e in (EAbs x f, j)
EApp f a -> let (g,j) = metas i f ; (b,k) = metas j a in (EApp g b,k)
EMeta _ -> (EMeta i, i+1)
_ -> (exp,i)

View File

@@ -28,7 +28,7 @@ import Data.List (partition,sort,groupBy)
import Debug.Trace import Debug.Trace
typecheck :: PGF -> Tree -> [Tree] typecheck :: PGF -> Tree -> [Tree]
typecheck pgf t = case inferExpr pgf (tree2expr t) of typecheck pgf t = case inferExpr pgf (newMetas (tree2expr t)) of
Ok t -> [expr2tree t] Ok t -> [expr2tree t]
Bad s -> trace s [] Bad s -> trace s []