summaryrefslogtreecommitdiff
path: root/src-3.0/GF/Compile
diff options
context:
space:
mode:
authorkrasimir <krasimir@chalmers.se>2008-05-30 11:15:33 +0000
committerkrasimir <krasimir@chalmers.se>2008-05-30 11:15:33 +0000
commit8bb0c32a9cf2cbad0375ab5886b7f2be37109477 (patch)
tree2290b07d391a1da4e94ee367b445a6b2f64ca2cd /src-3.0/GF/Compile
parent1172539a9544ed999c565053b79cf6a30ec14de4 (diff)
replace GFCC with PGF in (almost) all places
Diffstat (limited to 'src-3.0/GF/Compile')
-rw-r--r--src-3.0/GF/Compile/Export.hs16
-rw-r--r--src-3.0/GF/Compile/GFCCtoHaskell.hs6
-rw-r--r--src-3.0/GF/Compile/GFCCtoJS.hs14
-rw-r--r--src-3.0/GF/Compile/GrammarToGFCC.hs20
-rw-r--r--src-3.0/GF/Compile/OptimizeGFCC.hs16
5 files changed, 36 insertions, 36 deletions
diff --git a/src-3.0/GF/Compile/Export.hs b/src-3.0/GF/Compile/Export.hs
index 2b36b10a9..ab5dcb393 100644
--- a/src-3.0/GF/Compile/Export.hs
+++ b/src-3.0/GF/Compile/Export.hs
@@ -1,8 +1,8 @@
module GF.Compile.Export where
-import PGF.Data (GFCC)
+import PGF.Data (PGF)
import PGF.Raw.Print (printTree)
-import PGF.Raw.Convert (fromGFCC)
+import PGF.Raw.Convert (fromPGF)
import GF.Compile.GFCCtoHaskell
import GF.Compile.GFCCtoJS
import GF.Infra.Option
@@ -10,13 +10,13 @@ import GF.Text.UTF8
-- top-level access to code generation
-prGFCC :: OutputFormat -> GFCC -> String
-prGFCC fmt gr = case fmt of
- FmtGFCC -> printGFCC gr
- FmtJavaScript -> gfcc2js gr
+prPGF :: OutputFormat -> PGF -> String
+prPGF fmt gr = case fmt of
+ FmtPGF -> printPGF gr
+ FmtJavaScript -> pgf2js gr
FmtHaskell -> grammar2haskell gr
FmtHaskellGADT -> grammar2haskellGADT gr
-printGFCC :: GFCC -> String
-printGFCC = encodeUTF8 . printTree . fromGFCC
+printPGF :: PGF -> String
+printPGF = encodeUTF8 . printTree . fromPGF
diff --git a/src-3.0/GF/Compile/GFCCtoHaskell.hs b/src-3.0/GF/Compile/GFCCtoHaskell.hs
index 9a5fb7ca2..94210b65e 100644
--- a/src-3.0/GF/Compile/GFCCtoHaskell.hs
+++ b/src-3.0/GF/Compile/GFCCtoHaskell.hs
@@ -27,12 +27,12 @@ import Data.List --(isPrefixOf, find, intersperse)
import qualified Data.Map as Map
-- | the main function
-grammar2haskell :: GFCC -> String
+grammar2haskell :: PGF -> String
grammar2haskell gr = encodeUTF8 $ foldr (++++) [] $
haskPreamble ++ [datatypes gr', gfinstances gr']
where gr' = hSkeleton gr
-grammar2haskellGADT :: GFCC -> String
+grammar2haskellGADT :: PGF -> String
grammar2haskellGADT gr = encodeUTF8 $ foldr (++++) [] $
["{-# OPTIONS_GHC -fglasgow-exts #-}"] ++
haskPreamble ++ [datatypesGADT gr', gfinstances gr']
@@ -173,7 +173,7 @@ fInstance m (cat,rules) =
--type HSkeleton = [(OIdent, [(OIdent, [OIdent])])]
-hSkeleton :: GFCC -> (String,HSkeleton)
+hSkeleton :: PGF -> (String,HSkeleton)
hSkeleton gr =
(prCId (absname gr),
[(prCId c, [(prCId f, map prCId cs) | (f, (cs,_)) <- fs]) |
diff --git a/src-3.0/GF/Compile/GFCCtoJS.hs b/src-3.0/GF/Compile/GFCCtoJS.hs
index 1c24627a3..024de7273 100644
--- a/src-3.0/GF/Compile/GFCCtoJS.hs
+++ b/src-3.0/GF/Compile/GFCCtoJS.hs
@@ -1,4 +1,4 @@
-module GF.Compile.GFCCtoJS (gfcc2js) where
+module GF.Compile.GFCCtoJS (pgf2js) where
import PGF.CId
import PGF.Data
@@ -16,14 +16,14 @@ import qualified Data.Array as Array
import Data.Maybe (fromMaybe)
import qualified Data.Map as Map
-gfcc2js :: GFCC -> String
-gfcc2js gfcc =
+pgf2js :: PGF -> String
+pgf2js pgf =
encodeUTF8 $ JS.printTree $ JS.Program [JS.ElStmt $ JS.SDeclOrExpr $ JS.Decl [JS.DInit (JS.Ident n) grammar]]
where
- n = prCId $ absname gfcc
- as = abstract gfcc
- cs = Map.assocs (concretes gfcc)
- start = M.lookStartCat gfcc
+ n = prCId $ absname pgf
+ as = abstract pgf
+ cs = Map.assocs (concretes pgf)
+ start = M.lookStartCat pgf
grammar = new "GFGrammar" [js_abstract, js_concrete]
js_abstract = abstract2js start as
js_concrete = JS.EObj $ map (concrete2js start n) cs
diff --git a/src-3.0/GF/Compile/GrammarToGFCC.hs b/src-3.0/GF/Compile/GrammarToGFCC.hs
index 677354280..bf87d42fe 100644
--- a/src-3.0/GF/Compile/GrammarToGFCC.hs
+++ b/src-3.0/GF/Compile/GrammarToGFCC.hs
@@ -37,13 +37,13 @@ import Debug.Trace ----
traceD s t = t
--- the main function: generate GFCC from GF.
+-- the main function: generate PGF from GF.
prGrammar2gfcc :: Options -> String -> SourceGrammar -> (String,String)
-prGrammar2gfcc opts cnc gr = (abs,printGFCC gc) where
+prGrammar2gfcc opts cnc gr = (abs,printPGF gc) where
(abs,gc) = mkCanon2gfcc opts cnc gr
-mkCanon2gfcc :: Options -> String -> SourceGrammar -> (String,D.GFCC)
+mkCanon2gfcc :: Options -> String -> SourceGrammar -> (String,D.PGF)
mkCanon2gfcc opts cnc gr =
(prIdent abs, (canon2gfcc opts pars . reorder abs . canon2canon abs) gr)
where
@@ -51,18 +51,18 @@ mkCanon2gfcc opts cnc gr =
pars = mkParamLincat gr
-- Adds parsers for all concretes
-addParsers :: D.GFCC -> D.GFCC
-addParsers gfcc = gfcc { D.concretes = Map.map conv (D.concretes gfcc) }
+addParsers :: D.PGF -> D.PGF
+addParsers pgf = pgf { D.concretes = Map.map conv (D.concretes pgf) }
where
- conv cnc = cnc { D.parser = Just (buildParserInfo (convertConcrete (D.abstract gfcc) cnc)) }
+ conv cnc = cnc { D.parser = Just (buildParserInfo (convertConcrete (D.abstract pgf) cnc)) }
--- Generate GFCC from GFCM.
+-- Generate PGF from GFCM.
-- this assumes a grammar translated by canon2canon
-canon2gfcc :: Options -> (Ident -> Ident -> C.Term) -> SourceGrammar -> D.GFCC
+canon2gfcc :: Options -> (Ident -> Ident -> C.Term) -> SourceGrammar -> D.PGF
canon2gfcc opts pars cgr@(M.MGrammar ((a,M.ModMod abm):cms)) =
(if dump opts DumpCanon then trace (prGrammar cgr) else id) $
- D.GFCC an cns gflags abs cncs
+ D.PGF an cns gflags abs cncs
where
-- abstract
an = (i2i a)
@@ -176,7 +176,7 @@ mkTerm tr = case tr of
C.S ts -> concatMap flats ts
_ -> [t]
--- encoding GFCC-internal lincats as terms
+-- encoding PGF-internal lincats as terms
mkCType :: Type -> C.Term
mkCType t = case t of
EInt i -> C.C $ fromInteger i
diff --git a/src-3.0/GF/Compile/OptimizeGFCC.hs b/src-3.0/GF/Compile/OptimizeGFCC.hs
index 16cdf9ac3..c73d5bbcb 100644
--- a/src-3.0/GF/Compile/OptimizeGFCC.hs
+++ b/src-3.0/GF/Compile/OptimizeGFCC.hs
@@ -12,12 +12,12 @@ import qualified Data.Map as Map
-- back-end optimization:
-- suffix analysis followed by common subexpression elimination
-optGFCC :: GFCC -> GFCC
-optGFCC = cseOptimize . suffixOptimize
+optPGF :: PGF -> PGF
+optPGF = cseOptimize . suffixOptimize
-suffixOptimize :: GFCC -> GFCC
-suffixOptimize gfcc = gfcc {
- concretes = Map.map opt (concretes gfcc)
+suffixOptimize :: PGF -> PGF
+suffixOptimize pgf = pgf {
+ concretes = Map.map opt (concretes pgf)
}
where
opt cnc = cnc {
@@ -26,9 +26,9 @@ suffixOptimize gfcc = gfcc {
printnames = Map.map optTerm (printnames cnc)
}
-cseOptimize :: GFCC -> GFCC
-cseOptimize gfcc = gfcc {
- concretes = Map.map subex (concretes gfcc)
+cseOptimize :: PGF -> PGF
+cseOptimize pgf = pgf {
+ concretes = Map.map subex (concretes pgf)
}
-- analyse word form lists into prefix + suffixes