mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-18 09:19:32 -06:00
*** empty log message ***
This commit is contained in:
@@ -20,6 +20,9 @@ import Option
|
||||
import Ident
|
||||
import Arch (ModTime)
|
||||
|
||||
-- peb 25/5-04
|
||||
import CFtoCFG
|
||||
|
||||
import List (nub,nubBy)
|
||||
|
||||
-- AR 11/11/2001 -- 17/6/2003 (for modules) ---- unfinished
|
||||
@@ -32,6 +35,8 @@ data ShellState = ShSt {
|
||||
canModules :: CanonGrammar , -- compiled abstracts and concretes
|
||||
srcModules :: G.SourceGrammar , -- saved resource modules
|
||||
cfs :: [(Ident,CF)] , -- context-free grammars
|
||||
-- peb 25/5-04:
|
||||
cfParserInfos :: [(Ident, CFParserInfo)], -- parser information
|
||||
morphos :: [(Ident,Morpho)], -- morphologies
|
||||
gloptions :: Options, -- global options
|
||||
readFiles :: [(FilePath,ModTime)],-- files read
|
||||
@@ -54,6 +59,7 @@ emptyShellState = ShSt {
|
||||
canModules = M.emptyMGrammar,
|
||||
srcModules = M.emptyMGrammar,
|
||||
cfs = [],
|
||||
cfParserInfos = [], -- peb 25/5-04
|
||||
morphos = [],
|
||||
gloptions = noOptions,
|
||||
readFiles = [],
|
||||
@@ -72,7 +78,7 @@ data StateGrammar = StGr {
|
||||
cncId :: Ident,
|
||||
grammar :: CanonGrammar,
|
||||
cf :: CF,
|
||||
---- parser :: StaticParserInfo,
|
||||
cfParserInfo :: CFParserInfo, -- peb 25/5-04
|
||||
morpho :: Morpho,
|
||||
loptions :: Options
|
||||
}
|
||||
@@ -82,6 +88,7 @@ emptyStateGrammar = StGr {
|
||||
cncId = identC "#EMPTY", ---
|
||||
grammar = M.emptyMGrammar,
|
||||
cf = emptyCF,
|
||||
cfParserInfo = emptyParserInfo, -- peb 25/5-04
|
||||
morpho = emptyMorpho,
|
||||
loptions = noOptions
|
||||
}
|
||||
@@ -89,6 +96,7 @@ emptyStateGrammar = StGr {
|
||||
-- analysing shell grammar into parts
|
||||
stateGrammarST = grammar
|
||||
stateCF = cf
|
||||
stateParserInfo= cfParserInfo
|
||||
stateMorpho = morpho
|
||||
stateOptions = loptions
|
||||
stateGrammarWords = allMorphoWords . stateMorpho
|
||||
@@ -119,6 +127,7 @@ updateShellState opts sh (gr,(sgr,rts)) = do
|
||||
concr0 = ifNull Nothing (return . last) concrs
|
||||
notInrts f = notElem f $ map fst rts
|
||||
cfs <- mapM (canon2cf opts cgr) concrs --- would not need to update all...
|
||||
let parserInfos = map cf2parserInfo cfs -- peb 25/5-04
|
||||
|
||||
let funs = funRulesOf cgr
|
||||
let cats = allCatsOf cgr
|
||||
@@ -137,6 +146,7 @@ updateShellState opts sh (gr,(sgr,rts)) = do
|
||||
canModules = cgr,
|
||||
srcModules = src,
|
||||
cfs = zip concrs cfs,
|
||||
cfParserInfos = zip concrs parserInfos, -- peb 25/5-04
|
||||
morphos = zip concrs (map (mkMorpho cgr) concrs),
|
||||
gloptions = opts,
|
||||
readFiles = [ft | ft@(f,_) <- readFiles sh, notInrts f] ++ rts,
|
||||
@@ -181,6 +191,7 @@ purgeShellState sh = ShSt {
|
||||
canModules = M.MGrammar $ purge $ M.modules $ canModules sh,
|
||||
srcModules = M.emptyMGrammar,
|
||||
cfs = cfs sh,
|
||||
cfParserInfos = cfParserInfos sh, -- peb 25/5-04
|
||||
morphos = morphos sh,
|
||||
gloptions = gloptions sh,
|
||||
readFiles = [],
|
||||
@@ -237,6 +248,7 @@ stateGrammarOfLang st l = StGr {
|
||||
cncId = l,
|
||||
grammar = can,
|
||||
cf = maybe emptyCF id (lookup l (cfs st)),
|
||||
cfParserInfo = maybe emptyParserInfo id (lookup l (cfParserInfos st)), -- peb 25/5-04
|
||||
morpho = maybe emptyMorpho id (lookup l (morphos st)),
|
||||
loptions = errVal noOptions $ lookupOptionsCan can
|
||||
}
|
||||
@@ -266,6 +278,7 @@ stateAbstractGrammar st = StGr {
|
||||
cncId = identC "#Cnc", ---
|
||||
grammar = canModules st, ---- only abstarct ones
|
||||
cf = emptyCF,
|
||||
cfParserInfo = emptyParserInfo,
|
||||
morpho = emptyMorpho,
|
||||
loptions = gloptions st ----
|
||||
}
|
||||
@@ -387,8 +400,8 @@ languageOn = languageOnOff True
|
||||
languageOff = languageOnOff False
|
||||
|
||||
languageOnOff :: Bool -> Language -> ShellStateOper
|
||||
languageOnOff b lang (ShSt a c cs cg sg cfs ms os fs cats sts) =
|
||||
ShSt a c cs' cg sg cfs ms os fs cats sts where
|
||||
languageOnOff b lang (ShSt a c cs cg sg cfs pinfs ms os fs cats sts) =
|
||||
ShSt a c cs' cg sg cfs pinfs ms os fs cats sts where
|
||||
cs' = [if lang==l then ((l,c),b) else i | i@((l,c),_) <- cs]
|
||||
|
||||
{-
|
||||
@@ -405,12 +418,12 @@ removeLanguage :: Language -> ShellStateOper
|
||||
removeLanguage lang (ShSt (ab,gs,os)) = ShSt (ab,removeAssoc lang gs, os)
|
||||
-}
|
||||
changeOptions :: (Options -> Options) -> ShellStateOper
|
||||
changeOptions f (ShSt a c cs can src cfs ms os ff ts ss) =
|
||||
ShSt a c cs can src cfs ms (f os) ff ts ss
|
||||
changeOptions f (ShSt a c cs can src cfs pinfs ms os ff ts ss) =
|
||||
ShSt a c cs can src cfs pinfs ms (f os) ff ts ss
|
||||
|
||||
changeModTimes :: [(FilePath,ModTime)] -> ShellStateOper
|
||||
changeModTimes mfs (ShSt a c cs can src cfs ms os ff ts ss) =
|
||||
ShSt a c cs can src cfs ms os ff' ts ss
|
||||
changeModTimes mfs (ShSt a c cs can src cfs pinfs ms os ff ts ss) =
|
||||
ShSt a c cs can src cfs pinfs ms os ff' ts ss
|
||||
where
|
||||
ff' = mfs ++ [mf | mf@(f,_) <- ff, notElem f (map fst mfs)]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user