forked from GitHub/gf-core
Added dir for parsing.
This commit is contained in:
@@ -187,13 +187,23 @@ optionsOfLang st = stateOptions . stateGrammarOfLang st
|
|||||||
-- the last introduced grammar, stored in options, is the default for operations
|
-- the last introduced grammar, stored in options, is the default for operations
|
||||||
|
|
||||||
firstStateGrammar :: ShellState -> StateGrammar
|
firstStateGrammar :: ShellState -> StateGrammar
|
||||||
firstStateGrammar st = errVal emptyStateGrammar $ do
|
firstStateGrammar st = errVal (stateAbstractGrammar st) $ do
|
||||||
concr <- maybeErr "no concrete syntax" $ concrete st
|
concr <- maybeErr "no concrete syntax" $ concrete st
|
||||||
return $ stateGrammarOfLang st concr
|
return $ stateGrammarOfLang st concr
|
||||||
|
|
||||||
mkStateGrammar :: ShellState -> Language -> StateGrammar
|
mkStateGrammar :: ShellState -> Language -> StateGrammar
|
||||||
mkStateGrammar = stateGrammarOfLang
|
mkStateGrammar = stateGrammarOfLang
|
||||||
|
|
||||||
|
stateAbstractGrammar :: ShellState -> StateGrammar
|
||||||
|
stateAbstractGrammar st = StGr {
|
||||||
|
absId = maybe (identC "Abs") id (abstract st), ---
|
||||||
|
cncId = identC "#Cnc", ---
|
||||||
|
grammar = canModules st, ---- only abstarct ones
|
||||||
|
cf = emptyCF,
|
||||||
|
morpho = emptyMorpho
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
-- analysing shell state into parts
|
-- analysing shell state into parts
|
||||||
globalOptions = gloptions
|
globalOptions = gloptions
|
||||||
allLanguages = map fst . concretes
|
allLanguages = map fst . concretes
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ computeAbsTerm :: GFCGrammar -> Exp -> Err Exp
|
|||||||
computeAbsTerm gr = computeAbsTermIn gr []
|
computeAbsTerm gr = computeAbsTermIn gr []
|
||||||
|
|
||||||
computeAbsTermIn :: GFCGrammar -> [Ident] -> Exp -> Err Exp
|
computeAbsTermIn :: GFCGrammar -> [Ident] -> Exp -> Err Exp
|
||||||
computeAbsTermIn gr = compt where
|
computeAbsTermIn gr xs e = errIn ("computing" +++ prt e) $ compt xs e where
|
||||||
compt vv t = case t of
|
compt vv t = case t of
|
||||||
Prod x a b -> liftM2 (Prod x) (compt vv a) (compt (x:vv) b)
|
Prod x a b -> liftM2 (Prod x) (compt vv a) (compt (x:vv) b)
|
||||||
Abs x b -> liftM (Abs x) (compt (x:vv) b)
|
Abs x b -> liftM (Abs x) (compt (x:vv) b)
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ import Monad
|
|||||||
type GFCGrammar = C.CanonGrammar
|
type GFCGrammar = C.CanonGrammar
|
||||||
|
|
||||||
lookupAbsDef :: GFCGrammar -> Ident -> Ident -> Err (Maybe Term)
|
lookupAbsDef :: GFCGrammar -> Ident -> Ident -> Err (Maybe Term)
|
||||||
lookupAbsDef gr m c = do
|
lookupAbsDef gr m c = errIn ("looking up absdef of" +++ prt c) $ do
|
||||||
mi <- lookupModule gr m
|
mi <- lookupModule gr m
|
||||||
case mi of
|
case mi of
|
||||||
ModMod mo -> do
|
ModMod mo -> do
|
||||||
@@ -25,7 +25,7 @@ lookupAbsDef gr m c = do
|
|||||||
_ -> Bad $ prt m +++ "is not an abstract module"
|
_ -> Bad $ prt m +++ "is not an abstract module"
|
||||||
|
|
||||||
lookupFunType :: GFCGrammar -> Ident -> Ident -> Err Type
|
lookupFunType :: GFCGrammar -> Ident -> Ident -> Err Type
|
||||||
lookupFunType gr m c = do
|
lookupFunType gr m c = errIn ("looking up funtype of" +++ prt c) $ do
|
||||||
mi <- lookupModule gr m
|
mi <- lookupModule gr m
|
||||||
case mi of
|
case mi of
|
||||||
ModMod mo -> do
|
ModMod mo -> do
|
||||||
@@ -37,7 +37,7 @@ lookupFunType gr m c = do
|
|||||||
_ -> Bad $ prt m +++ "is not an abstract module"
|
_ -> Bad $ prt m +++ "is not an abstract module"
|
||||||
|
|
||||||
lookupCatContext :: GFCGrammar -> Ident -> Ident -> Err Context
|
lookupCatContext :: GFCGrammar -> Ident -> Ident -> Err Context
|
||||||
lookupCatContext gr m c = do
|
lookupCatContext gr m c = errIn ("looking up context of cat" +++ prt c) $ do
|
||||||
mi <- lookupModule gr m
|
mi <- lookupModule gr m
|
||||||
case mi of
|
case mi of
|
||||||
ModMod mo -> do
|
ModMod mo -> do
|
||||||
|
|||||||
@@ -118,6 +118,7 @@ inferExp :: Theory -> TCEnv -> Exp -> Err (AExp, Val, [(Val,Val)])
|
|||||||
inferExp th tenv@(k,rho,gamma) e = case e of
|
inferExp th tenv@(k,rho,gamma) e = case e of
|
||||||
Vr x -> mkAnnot (AVr x) $ noConstr $ lookupVar gamma x
|
Vr x -> mkAnnot (AVr x) $ noConstr $ lookupVar gamma x
|
||||||
Q m c -> mkAnnot (ACn (m,c)) $ noConstr $ lookupConst th (m,c)
|
Q m c -> mkAnnot (ACn (m,c)) $ noConstr $ lookupConst th (m,c)
|
||||||
|
QC m c -> mkAnnot (ACn (m,c)) $ noConstr $ lookupConst th (m,c) ----
|
||||||
Sort _ -> return (AType, vType, [])
|
Sort _ -> return (AType, vType, [])
|
||||||
App f t -> do
|
App f t -> do
|
||||||
(f',w,csf) <- inferExp th tenv f
|
(f',w,csf) <- inferExp th tenv f
|
||||||
@@ -187,6 +188,9 @@ checkPatt th tenv exp val = do
|
|||||||
Q m c -> do
|
Q m c -> do
|
||||||
typ <- lookupConst th (m,c)
|
typ <- lookupConst th (m,c)
|
||||||
return $ (ACn (m,c) typ, typ, [])
|
return $ (ACn (m,c) typ, typ, [])
|
||||||
|
QC m c -> do
|
||||||
|
typ <- lookupConst th (m,c)
|
||||||
|
return $ (ACn (m,c) typ, typ, []) ----
|
||||||
App f t -> do
|
App f t -> do
|
||||||
(f',w,csf) <- checkExpP tenv f val
|
(f',w,csf) <- checkExpP tenv f val
|
||||||
typ <- whnf w
|
typ <- whnf w
|
||||||
|
|||||||
@@ -231,7 +231,7 @@ editAsTermCommand gr c e = err (const []) singleton $ do
|
|||||||
return $ tree2exp $ loc2tree t'
|
return $ tree2exp $ loc2tree t'
|
||||||
|
|
||||||
exp2termCommand :: GFCGrammar -> (Exp -> Err Exp) -> Tree -> Err Tree
|
exp2termCommand :: GFCGrammar -> (Exp -> Err Exp) -> Tree -> Err Tree
|
||||||
exp2termCommand gr f t = do
|
exp2termCommand gr f t = errIn ("modifying term" +++ prt t) $ do
|
||||||
let exp = tree2exp t
|
let exp = tree2exp t
|
||||||
exp2 <- f exp
|
exp2 <- f exp
|
||||||
annotate gr exp2
|
annotate gr exp2
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
module Today where today = "Wed Oct 1 15:37:15 CEST 2003"
|
module Today where today = "Thu Oct 2 09:28:27 CEST 2003"
|
||||||
|
|||||||
Reference in New Issue
Block a user