mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-22 11:19:32 -06:00
Added PGF.Macros.mapConcretes
This commit is contained in:
@@ -41,7 +41,9 @@ import qualified Data.Set as Set
|
|||||||
import Data.List(nub)
|
import Data.List(nub)
|
||||||
|
|
||||||
import PGF.Check
|
import PGF.Check
|
||||||
|
import PGF.CId
|
||||||
import PGF.Data
|
import PGF.Data
|
||||||
|
import PGF.Macros
|
||||||
|
|
||||||
|
|
||||||
-- | Compiles a number of source files and builds a 'PGF' structure for them.
|
-- | Compiles a number of source files and builds a 'PGF' structure for them.
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ mkCanon2gfcc opts cnc gr =
|
|||||||
|
|
||||||
-- Adds parsers for all concretes
|
-- Adds parsers for all concretes
|
||||||
addParsers :: Options -> D.PGF -> D.PGF
|
addParsers :: Options -> D.PGF -> D.PGF
|
||||||
addParsers opts pgf = pgf { D.concretes = Map.map conv (D.concretes pgf) }
|
addParsers opts pgf = CM.mapConcretes conv pgf
|
||||||
where
|
where
|
||||||
conv cnc = cnc { D.parser = Just pinfo }
|
conv cnc = cnc { D.parser = Just pinfo }
|
||||||
where
|
where
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ module GF.Compile.OptimizeGFCC where
|
|||||||
|
|
||||||
import PGF.CId
|
import PGF.CId
|
||||||
import PGF.Data
|
import PGF.Data
|
||||||
|
import PGF.Macros
|
||||||
|
|
||||||
import GF.Data.Operations
|
import GF.Data.Operations
|
||||||
|
|
||||||
@@ -16,9 +17,7 @@ optPGF :: PGF -> PGF
|
|||||||
optPGF = cseOptimize . suffixOptimize
|
optPGF = cseOptimize . suffixOptimize
|
||||||
|
|
||||||
suffixOptimize :: PGF -> PGF
|
suffixOptimize :: PGF -> PGF
|
||||||
suffixOptimize pgf = pgf {
|
suffixOptimize = mapConcretes opt
|
||||||
concretes = Map.map opt (concretes pgf)
|
|
||||||
}
|
|
||||||
where
|
where
|
||||||
opt cnc = cnc {
|
opt cnc = cnc {
|
||||||
lins = Map.map optTerm (lins cnc),
|
lins = Map.map optTerm (lins cnc),
|
||||||
@@ -27,9 +26,7 @@ suffixOptimize pgf = pgf {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cseOptimize :: PGF -> PGF
|
cseOptimize :: PGF -> PGF
|
||||||
cseOptimize pgf = pgf {
|
cseOptimize = mapConcretes subex
|
||||||
concretes = Map.map subex (concretes pgf)
|
|
||||||
}
|
|
||||||
|
|
||||||
-- analyse word form lists into prefix + suffixes
|
-- analyse word form lists into prefix + suffixes
|
||||||
-- suffix sets can later be shared by subex elim
|
-- suffix sets can later be shared by subex elim
|
||||||
|
|||||||
@@ -10,6 +10,9 @@ import Data.List
|
|||||||
|
|
||||||
-- operations for manipulating PGF grammars and objects
|
-- operations for manipulating PGF grammars and objects
|
||||||
|
|
||||||
|
mapConcretes :: (Concr -> Concr) -> PGF -> PGF
|
||||||
|
mapConcretes f pgf = pgf { concretes = Map.map f (concretes pgf) }
|
||||||
|
|
||||||
lookLin :: PGF -> CId -> CId -> Term
|
lookLin :: PGF -> CId -> CId -> Term
|
||||||
lookLin pgf lang fun =
|
lookLin pgf lang fun =
|
||||||
lookMap tm0 fun $ lins $ lookMap (error "no lang") lang $ concretes pgf
|
lookMap tm0 fun $ lins $ lookMap (error "no lang") lang $ concretes pgf
|
||||||
|
|||||||
Reference in New Issue
Block a user