mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-09 04:59:31 -06:00
remove some redundant dependencies from FCFG
This commit is contained in:
@@ -2,7 +2,7 @@ module GF.Canon.GFCC.FCFGParsing (parserLang,buildPInfo,FCFPInfo) where
|
||||
|
||||
import GF.Canon.GFCC.DataGFCC
|
||||
import GF.Canon.GFCC.AbsGFCC
|
||||
import GF.Conversion.SimpleToFCFG (convertGrammarCId,FCat(..))
|
||||
import GF.Conversion.SimpleToFCFG (convertGrammar,FCat(..))
|
||||
|
||||
--import GF.System.Tracing
|
||||
--import GF.Infra.Print
|
||||
@@ -35,11 +35,9 @@ import qualified GF.Parsing.FCFG as PF
|
||||
import GF.Canon.GFCC.ErrM
|
||||
import GF.Infra.PrintClass
|
||||
|
||||
--convertGrammarCId :: Grammar -> [(CId,FGrammar)]
|
||||
|
||||
parserLang :: GFCC -> CId -> CFCat -> [CFTok] -> Err [Exp]
|
||||
parserLang mgr lang = parse info where
|
||||
fcfgs = convertGrammarCId mgr
|
||||
fcfgs = convertGrammar mgr
|
||||
info = buildPInfo $ maybe (error "no parser") id $ lookup lang fcfgs
|
||||
|
||||
type CFTok = String ----
|
||||
|
||||
@@ -23,14 +23,14 @@ import GF.Canon.GFCC.PrintGFCC
|
||||
import GF.Canon.GFCC.ErrM
|
||||
import GF.Canon.GFCC.FCFGParsing
|
||||
import qualified GF.Canon.GFCC.GenGFCC as G
|
||||
import GF.Conversion.SimpleToFCFG (convertGrammarCId,FCat(..)) ----
|
||||
import GF.Conversion.SimpleToFCFG (convertGrammar,FCat(..))
|
||||
|
||||
--import GF.Data.Operations
|
||||
--import GF.Infra.UseIO
|
||||
import qualified Data.Map as Map
|
||||
import System.Random (newStdGen)
|
||||
import System.Directory (doesFileExist)
|
||||
import System
|
||||
|
||||
|
||||
-- This API is meant to be used when embedding GF grammars in Haskell
|
||||
-- programs. The embedded system is supposed to use the
|
||||
@@ -73,7 +73,7 @@ startCat :: MultiGrammar -> Category
|
||||
|
||||
file2grammar f = do
|
||||
gfcc <- file2gfcc f
|
||||
let fcfgs = convertGrammarCId gfcc
|
||||
let fcfgs = convertGrammar gfcc
|
||||
return (MultiGrammar gfcc [(lang, buildPInfo fcfg) | (CId lang,fcfg) <- fcfgs])
|
||||
|
||||
file2gfcc f =
|
||||
|
||||
@@ -4,7 +4,7 @@ module GF.Canon.GFCC.ParGFCC where
|
||||
import GF.Canon.GFCC.AbsGFCC
|
||||
import GF.Canon.GFCC.LexGFCC
|
||||
import GF.Canon.GFCC.ErrM
|
||||
import Array
|
||||
import Data.Array
|
||||
#if __GLASGOW_HASKELL__ >= 503
|
||||
import GHC.Exts
|
||||
#else
|
||||
|
||||
@@ -4,7 +4,7 @@ module GF.Canon.GFCC.PrintGFCC where
|
||||
-- pretty-printer generated by the BNF converter
|
||||
|
||||
import GF.Canon.GFCC.AbsGFCC
|
||||
import Char
|
||||
import Data.Char
|
||||
|
||||
-- the top-level printing method
|
||||
printTree :: Print a => a -> String
|
||||
|
||||
@@ -17,6 +17,8 @@ module GF.Compile.ShellState where
|
||||
import GF.Data.Operations
|
||||
import GF.Canon.GFC
|
||||
import GF.Canon.AbsGFC
|
||||
import GF.Canon.GFCC.AbsGFCC(CId(CId))
|
||||
import GF.Canon.GFCC.DataGFCC(mkGFCC)
|
||||
import GF.Canon.CanonToGFCC as C2GFCC
|
||||
import GF.Grammar.Macros
|
||||
import GF.Grammar.MMacros
|
||||
@@ -260,7 +262,7 @@ updateShellState opts ign mcnc sh ((_,sgr,gr,eenv),rts) = do
|
||||
|
||||
let fromGFC = snd . snd . Cnv.convertGFC opts
|
||||
(mcfgs, cfgs) = unzip $ map (curry fromGFC cgr) concrs
|
||||
fcfgs = FCnv.convertGrammar (C2GFCC.mkCanon2gfccNoUTF8 cgr)
|
||||
fcfgs = [(IC id,g) | (CId id,g) <- FCnv.convertGrammar (mkGFCC (C2GFCC.mkCanon2gfccNoUTF8 cgr))]
|
||||
pInfos = zipWith3 Prs.buildPInfo mcfgs (map snd fcfgs) cfgs
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
module GF.Conversion.FTypes where
|
||||
|
||||
import qualified GF.Infra.Ident as Ident (Ident(..), wildIdent, isWildIdent)
|
||||
import qualified GF.Canon.GFCC.AbsGFCC as AbsGFCC (CId(..))
|
||||
|
||||
import GF.Formalism.FCFG
|
||||
|
||||
@@ -13,11 +13,9 @@
|
||||
|
||||
|
||||
module GF.Conversion.SimpleToFCFG
|
||||
(convertGrammar,convertGrammarCId,FCat(..)) where
|
||||
(convertGrammar,FCat(..)) where
|
||||
|
||||
import GF.System.Tracing
|
||||
import GF.Infra.PrintClass
|
||||
import GF.Infra.Ident
|
||||
|
||||
import Control.Monad
|
||||
|
||||
@@ -42,13 +40,8 @@ import Data.Maybe
|
||||
|
||||
type FToken = String
|
||||
|
||||
convertGrammar :: Grammar -> [(Ident,FCFGrammar FCat FName FToken)]
|
||||
convertGrammar g = [(IC c, f) | (CId c,f) <- convertGrammarCId (mkGFCC g)]
|
||||
|
||||
-- this is more native for GFCC
|
||||
|
||||
convertGrammarCId :: GFCC -> [(CId,FCFGrammar FCat FName FToken)]
|
||||
convertGrammarCId gfcc = [(cncname,convert abs_defs conc) |
|
||||
convertGrammar :: GFCC -> [(CId,FCFGrammar FCat FName FToken)]
|
||||
convertGrammar gfcc = [(cncname,convert abs_defs conc) |
|
||||
cncname <- cncnames gfcc, conc <- Map.lookup cncname (concretes gfcc)]
|
||||
where
|
||||
|
||||
|
||||
@@ -13,9 +13,6 @@ import Control.Monad (liftM)
|
||||
import Data.List (groupBy)
|
||||
import Data.Array
|
||||
|
||||
import GF.Formalism.Utilities
|
||||
--import GF.Formalism.GCFG
|
||||
|
||||
import GF.Infra.PrintClass
|
||||
|
||||
|
||||
|
||||
@@ -43,7 +43,6 @@ filterCats syms = [ cat | Cat cat <- syms ]
|
||||
filterToks :: [Symbol c t] -> [t]
|
||||
filterToks syms = [ tok | Tok tok <- syms ]
|
||||
|
||||
|
||||
------------------------------------------------------------
|
||||
-- * edges
|
||||
|
||||
|
||||
@@ -13,8 +13,6 @@ module GF.Parsing.FCFG
|
||||
import GF.Data.Operations (Err(..))
|
||||
|
||||
import GF.Formalism.Utilities
|
||||
import GF.Formalism.GCFG
|
||||
import GF.Formalism.MCFG
|
||||
import GF.Parsing.FCFG.PInfo
|
||||
|
||||
import qualified GF.Parsing.FCFG.Active as Active
|
||||
|
||||
@@ -14,12 +14,9 @@ import GF.Data.Assoc
|
||||
import GF.Data.SortedList
|
||||
import GF.Data.Utilities
|
||||
|
||||
import GF.Formalism.GCFG
|
||||
import GF.Formalism.FCFG
|
||||
import GF.Formalism.MCFG(Lin(..))
|
||||
import GF.Formalism.Utilities
|
||||
|
||||
import GF.Infra.Ident
|
||||
import GF.Infra.PrintClass
|
||||
|
||||
import GF.Parsing.FCFG.Range
|
||||
|
||||
@@ -9,11 +9,8 @@
|
||||
|
||||
module GF.Parsing.FCFG.PInfo where
|
||||
|
||||
import GF.System.Tracing
|
||||
import GF.Infra.PrintClass
|
||||
|
||||
import GF.Formalism.Utilities
|
||||
import GF.Formalism.GCFG
|
||||
import GF.Formalism.FCFG
|
||||
import GF.Data.SortedList
|
||||
import GF.Data.Assoc
|
||||
@@ -73,8 +70,6 @@ getLeftCornerCat lins
|
||||
|
||||
buildFCFPInfo :: (Ord c, Ord n, Ord t) => (t -> (c,SyntaxNode RuleId RangeRec)) -> FCFGrammar c n t -> FCFPInfo c n t
|
||||
buildFCFPInfo lexer grammar =
|
||||
traceCalcFirst grammar $
|
||||
tracePrt "MCFG.PInfo - parser info" (prt) $
|
||||
FCFPInfo { allRules = allrules
|
||||
, topdownRules = topdownrules
|
||||
-- , emptyRules = emptyrules
|
||||
|
||||
Reference in New Issue
Block a user