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

@@ -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