mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-21 09:02:50 -06:00
Devel/GF3: experimentally putting together all functionalities for the first time
This commit is contained in:
@@ -76,9 +76,10 @@ 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 (gfcc2parsers gfcc))
|
||||
|
||||
gfcc2parsers gfcc =
|
||||
[(lang, buildFCFPInfo fcfg) | (CId lang,fcfg) <- convertGrammar gfcc]
|
||||
|
||||
file2gfcc f =
|
||||
readFileIf f >>= err (error) (return . mkGFCC) . pGrammar . myLexer
|
||||
@@ -117,6 +118,8 @@ categories mgr = [c | CId c <- Map.keys (cats (abstract (gfcc mgr)))]
|
||||
|
||||
startCat mgr = "S" ----
|
||||
|
||||
emptyMultiGrammar = MultiGrammar emptyGFCC []
|
||||
|
||||
------------ for internal use only
|
||||
|
||||
linearThis = GF.GFCC.API.linearize
|
||||
|
||||
@@ -96,12 +96,22 @@ printGFCC gfcc0 = compactPrintGFCC $ printTree $ Grm
|
||||
-- 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 {
|
||||
unionGFCC one two = case absname one of
|
||||
CId "" -> two -- extending empty grammar
|
||||
n | n == absname two -> one { -- extending grammar with same abstract
|
||||
concretes = Data.Map.union (concretes two) (concretes one),
|
||||
cncnames = Data.List.union (cncnames two) (cncnames one)}
|
||||
else one
|
||||
cncnames = Data.List.union (cncnames two) (cncnames one)
|
||||
}
|
||||
_ -> one -- abstracts don't match ---- print error msg
|
||||
|
||||
emptyGFCC :: GFCC
|
||||
emptyGFCC = GFCC {
|
||||
absname = CId "",
|
||||
cncnames = [] ,
|
||||
abstract = error "empty grammar, no abstract",
|
||||
concretes = empty
|
||||
}
|
||||
|
||||
|
||||
-- default map and filter are for Map here
|
||||
lmap = Prelude.map
|
||||
|
||||
Reference in New Issue
Block a user