1
0
forked from GitHub/gf-core

unionGFCC, to put together GFCC grs with same abstract

This commit is contained in:
aarne
2007-11-05 13:48:51 +00:00
parent fe49c9f1bf
commit 5315d8851d
4 changed files with 26 additions and 3 deletions

View File

@@ -81,7 +81,7 @@ oper
s = table {
VPFinite t Simul => vf (vfin t) (\_ -> []) ;
VPFinite t Anter => vf (habet t) vpart ; --# notpresent
VPInfinit Anter _=> vf (\_ -> []) (\a -> habere ++ vpart a) ; --# notpresent
VPInfinit Anter b=> vf (\_ -> []) (\a -> habere ++ vpart a) ; --# notpresent
VPImperat => vf vimp (\_ -> []) ;
VPGerund => vf (\_ -> []) (\_ -> vger) ;
VPInfinit Simul b=> vf (\_ -> []) (\_ -> vinf b)

View File

@@ -6,6 +6,7 @@ import GF.Devel.GFCCtoJS
import GF.GFCC.OptimizeGFCC
import GF.GFCC.CheckGFCC
import GF.GFCC.DataGFCC
import GF.GFCC.ParGFCC
import GF.Devel.UseIO
import GF.Infra.Option
@@ -31,6 +32,14 @@ main = do
writeFile js (gfcc2js gc)
putStrLn $ "wrote file " ++ js
else return ()
-- gfc -o target.gfcc source_1.gfcc ... source_n.gfcc
_ | all ((=="gfcc") . fileSuffix) fs && oElem (iOpt "o") opts -> do
let target:sources = fs
gfccs <- mapM file2gfcc sources
let gfcc = foldl1 unionGFCC gfccs
writeFile target (printGFCC gfcc)
_ -> do
mapM_ (batchCompile opts) (map return fs)
putStrLn "Done."
@@ -40,3 +49,5 @@ check gfcc = do
putStrLn $ if b then "OK" else "Corrupted GFCC"
return gc
file2gfcc f =
readFileIf f >>= err (error) (return . mkGFCC) . pGrammar . myLexer

View File

@@ -77,7 +77,8 @@ startCat :: MultiGrammar -> Category
file2grammar f = do
gfcc <- file2gfcc f
let fcfgs = convertGrammar gfcc
return (MultiGrammar gfcc [(lang, buildFCFPInfo fcfg) | (CId lang,fcfg) <- fcfgs])
return (MultiGrammar gfcc
[(lang, buildFCFPInfo fcfg) | (CId lang,fcfg) <- fcfgs])
file2gfcc f =
readFileIf f >>= err (error) (return . mkGFCC) . pGrammar . myLexer

View File

@@ -21,7 +21,7 @@ data Abstr = Abstr {
aflags :: Map CId String, -- value of a flag
funs :: Map CId (Type,Exp), -- type and def of a fun
cats :: Map CId [Hypo], -- context of a cat
catfuns :: Map CId [CId] -- funs yielding a cat (redundant, for fast lookup)
catfuns :: Map CId [CId] -- funs to a cat (redundant, for fast lookup)
}
data Concr = Concr {
@@ -92,6 +92,17 @@ printGFCC gfcc0 = compactPrintGFCC $ printTree $ Grm
[Lin f v | (f,v) <- assocs (printnames cnc)]
gfcc = utf8GFCC gfcc0
-- merge two GFCCs; fails is differens absnames; priority to second arg
unionGFCC :: GFCC -> GFCC -> GFCC
unionGFCC one two =
if absname one == absname two
then one {
concretes = Data.Map.union (concretes two) (concretes one),
cncnames = Data.List.union (cncnames two) (cncnames one)}
else one
-- default map and filter are for Map here
lmap = Prelude.map
lfilter = Prelude.filter