mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-21 09:02:50 -06:00
unionGFCC, to put together GFCC grs with same abstract
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user