mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-20 08:32:50 -06:00
Updates for editor. Dummies for hugs.
This commit is contained in:
@@ -20,6 +20,7 @@ import Randomized (mkRandomTree)
|
|||||||
import Zipper
|
import Zipper
|
||||||
|
|
||||||
import MMacros
|
import MMacros
|
||||||
|
import qualified Macros as M
|
||||||
import TypeCheck
|
import TypeCheck
|
||||||
import CMacros
|
import CMacros
|
||||||
|
|
||||||
@@ -126,8 +127,10 @@ optFile2grammarE = optFile2grammar
|
|||||||
string2treeInState :: GFGrammar -> String -> State -> Err Tree
|
string2treeInState :: GFGrammar -> String -> State -> Err Tree
|
||||||
string2treeInState gr s st = do
|
string2treeInState gr s st = do
|
||||||
let metas = allMetas st
|
let metas = allMetas st
|
||||||
t <- pTerm s
|
xs = map fst $ actBinds st
|
||||||
annotate (grammar gr) $ qualifTerm (absId gr) $ refreshMetas metas t
|
t0 <- pTerm s
|
||||||
|
let t = qualifTerm (absId gr) $ M.mkAbs xs $ refreshMetas metas $ t0
|
||||||
|
annotateExpInState (grammar gr) t st
|
||||||
|
|
||||||
string2srcTerm :: G.SourceGrammar -> I.Ident -> String -> Err G.Term
|
string2srcTerm :: G.SourceGrammar -> I.Ident -> String -> Err G.Term
|
||||||
string2srcTerm gr m s = do
|
string2srcTerm gr m s = do
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import qualified AbsGFC as A
|
|||||||
import qualified GFC as G
|
import qualified GFC as G
|
||||||
import GetGrammar
|
import GetGrammar
|
||||||
import Macros
|
import Macros
|
||||||
|
import MMacros
|
||||||
|
|
||||||
import Operations
|
import Operations
|
||||||
|
|
||||||
@@ -46,9 +47,7 @@ string2formsAndTerm s = case s of
|
|||||||
-}
|
-}
|
||||||
|
|
||||||
string2ident :: String -> Err Ident
|
string2ident :: String -> Err Ident
|
||||||
string2ident s = return $ case s of
|
string2ident s = return $ string2var s
|
||||||
c:'_':i -> identV (readIntArg i,[c]) ---
|
|
||||||
_ -> zIdent s
|
|
||||||
|
|
||||||
{-
|
{-
|
||||||
-- reads the Haskell datatype
|
-- reads the Haskell datatype
|
||||||
|
|||||||
@@ -73,9 +73,9 @@ refsForType compat gr binds val =
|
|||||||
funRulesOf :: GFCGrammar -> [(Fun,Type)]
|
funRulesOf :: GFCGrammar -> [(Fun,Type)]
|
||||||
funRulesOf gr =
|
funRulesOf gr =
|
||||||
---- funRulesForLiterals ++
|
---- funRulesForLiterals ++
|
||||||
[((i,f),typ) | (i, ModMod m) <- modules gr,
|
[((i,f),typ) | (i, ModMod m) <- modules gr,
|
||||||
mtype m == MTAbstract,
|
mtype m == MTAbstract,
|
||||||
(f, C.AbsFun typ _) <- tree2list (jments m)]
|
(f, C.AbsFun typ _) <- tree2list (jments m)]
|
||||||
|
|
||||||
allCatsOf :: GFCGrammar -> [(Cat,Context)]
|
allCatsOf :: GFCGrammar -> [(Cat,Context)]
|
||||||
allCatsOf gr =
|
allCatsOf gr =
|
||||||
|
|||||||
@@ -255,14 +255,20 @@ identVar (Vr x) = return x
|
|||||||
identVar _ = Bad "not a variable"
|
identVar _ = Bad "not a variable"
|
||||||
|
|
||||||
|
|
||||||
-- light-weight rename for user interaction
|
-- light-weight rename for user interaction; also change names of internal vars
|
||||||
|
|
||||||
qualifTerm :: Ident -> Term -> Term
|
qualifTerm :: Ident -> Term -> Term
|
||||||
qualifTerm m = qualif [] where
|
qualifTerm m = qualif [] where
|
||||||
qualif xs t = case t of
|
qualif xs t = case t of
|
||||||
Abs x b -> Abs x $ qualif (x:xs) b
|
Abs x b -> let x' = chV x in Abs x' $ qualif (x':xs) b
|
||||||
Prod x a b -> Prod x (qualif xs a) $ qualif (x:xs) b
|
Prod x a b -> Prod x (qualif xs a) $ qualif (x:xs) b
|
||||||
Vr x | notElem x xs -> Q m x
|
Vr x -> let x' = chV x in if (elem x' xs) then (Vr x') else (Q m x)
|
||||||
Cn c -> Q m c
|
Cn c -> Q m c
|
||||||
Con c -> QC m c
|
Con c -> QC m c
|
||||||
_ -> composSafeOp (qualif xs) t
|
_ -> composSafeOp (qualif xs) t
|
||||||
|
chV x = string2var $ prIdent x
|
||||||
|
|
||||||
|
string2var :: String -> Ident
|
||||||
|
string2var s = case s of
|
||||||
|
c:'_':i -> identV (readIntArg i,[c]) ---
|
||||||
|
_ -> zIdent s
|
||||||
|
|||||||
@@ -123,6 +123,7 @@ possibleConstraint gr (u,v) = errVal True $ do
|
|||||||
where
|
where
|
||||||
cts t u = isUnknown t || isUnknown u || case (t,u) of
|
cts t u = isUnknown t || isUnknown u || case (t,u) of
|
||||||
(Q m c, Q n d) -> c == d || notCan (m,c) || notCan (n,d)
|
(Q m c, Q n d) -> c == d || notCan (m,c) || notCan (n,d)
|
||||||
|
(QC m c, QC n d) -> c == d
|
||||||
(App f a, App g b) -> cts f g && cts a b
|
(App f a, App g b) -> cts f g && cts a b
|
||||||
(Abs x b, Abs y c) -> cts b c
|
(Abs x b, Abs y c) -> cts b c
|
||||||
(Prod x a f, Prod y b g) -> cts a b && cts f g
|
(Prod x a f, Prod y b g) -> cts a b && cts f g
|
||||||
|
|||||||
@@ -78,9 +78,9 @@ pCommand = pCommandWords . words where
|
|||||||
"c" : s : _ -> CTermCommand s
|
"c" : s : _ -> CTermCommand s
|
||||||
"a" : _ -> CRefineRandom --- *a*leatoire
|
"a" : _ -> CRefineRandom --- *a*leatoire
|
||||||
"m" : _ -> CMenu
|
"m" : _ -> CMenu
|
||||||
---- "ml" : s : _ -> changeMenuLanguage s
|
"ml" : s : _ -> changeMenuLanguage s
|
||||||
---- "ms" : s : _ -> changeMenuSize s
|
"ms" : s : _ -> changeMenuSize s
|
||||||
---- "mt" : s : _ -> changeMenuTyped s
|
"mt" : s : _ -> changeMenuTyped s
|
||||||
"v" : _ -> CView
|
"v" : _ -> CView
|
||||||
"q" : _ -> CQuit
|
"q" : _ -> CQuit
|
||||||
"h" : _ -> CHelp initEditMsg
|
"h" : _ -> CHelp initEditMsg
|
||||||
|
|||||||
@@ -3,9 +3,8 @@ module Commands where
|
|||||||
import Operations
|
import Operations
|
||||||
import Zipper
|
import Zipper
|
||||||
|
|
||||||
import qualified Grammar as G ---- Cat
|
import qualified Grammar as G ---- Cat, Fun
|
||||||
import GFC
|
import GFC
|
||||||
import qualified AbsGFC ---- Atom
|
|
||||||
import CMacros
|
import CMacros
|
||||||
import LookAbs
|
import LookAbs
|
||||||
import Values (loc2treeFocus)----
|
import Values (loc2treeFocus)----
|
||||||
@@ -19,7 +18,6 @@ import qualified Ident as I
|
|||||||
import qualified PShell
|
import qualified PShell
|
||||||
import qualified Macros as M
|
import qualified Macros as M
|
||||||
import PrGrammar
|
import PrGrammar
|
||||||
import TypeCheck ---- tree2exp
|
|
||||||
import PGrammar
|
import PGrammar
|
||||||
import IOGrammar
|
import IOGrammar
|
||||||
import UseIO
|
import UseIO
|
||||||
@@ -400,7 +398,6 @@ displaySStateJavaX env state = unlines $ tagXML "gfedit" $ concat [
|
|||||||
lin (n,gr) = (n, map uni $ linearizeState noWrap opts gr zipper) where
|
lin (n,gr) = (n, map uni $ linearizeState noWrap opts gr zipper) where
|
||||||
uni = optEncodeUTF8 n gr . mkUnicode
|
uni = optEncodeUTF8 n gr . mkUnicode
|
||||||
exp = prprTree $ loc2tree zipper
|
exp = prprTree $ loc2tree zipper
|
||||||
--- xml = prExpXML gr $ tree2exp $ loc2tree zipper --- better: dir. from zipper
|
|
||||||
zipper = stateSState state
|
zipper = stateSState state
|
||||||
linAll = map lin lgrs
|
linAll = map lin lgrs
|
||||||
gr = firstStateGrammar env
|
gr = firstStateGrammar env
|
||||||
|
|||||||
@@ -1 +1 @@
|
|||||||
module Today where today = "Mon Oct 6 11:34:26 CEST 2003"
|
module Today where today = "Tue Oct 7 17:59:46 CEST 2003"
|
||||||
|
|||||||
Reference in New Issue
Block a user