mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-24 10:22:50 -06:00
Removed some dead code from gsl and cfgm generation.
This commit is contained in:
@@ -5,9 +5,9 @@
|
|||||||
-- Stability : (stable)
|
-- Stability : (stable)
|
||||||
-- Portability : (portable)
|
-- Portability : (portable)
|
||||||
--
|
--
|
||||||
-- > CVS $Date: 2005/04/14 18:38:36 $
|
-- > CVS $Date: 2005/04/15 09:45:32 $
|
||||||
-- > CVS $Author: peb $
|
-- > CVS $Author: bringert $
|
||||||
-- > CVS $Revision: 1.14 $
|
-- > CVS $Revision: 1.15 $
|
||||||
--
|
--
|
||||||
-- Handles printing a CFGrammar in CFGM format.
|
-- Handles printing a CFGrammar in CFGM format.
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
@@ -20,12 +20,6 @@ import Ident
|
|||||||
import GFC
|
import GFC
|
||||||
import Modules
|
import Modules
|
||||||
|
|
||||||
-- import qualified GF.OldParsing.ConvertGrammar as Cnv
|
|
||||||
-- import qualified GF.Printing.PrintParser as Prt
|
|
||||||
-- import qualified GF.OldParsing.CFGrammar as CFGrammar
|
|
||||||
-- import qualified GF.OldParsing.GrammarTypes as GT
|
|
||||||
-- import qualified AbsCFG
|
|
||||||
-- import qualified GF.OldParsing.Utilities as Parser
|
|
||||||
import qualified GF.Conversion.GFC as Cnv
|
import qualified GF.Conversion.GFC as Cnv
|
||||||
import GF.Infra.Print (prt)
|
import GF.Infra.Print (prt)
|
||||||
import GF.Formalism.CFG (CFRule(..))
|
import GF.Formalism.CFG (CFRule(..))
|
||||||
@@ -39,7 +33,6 @@ import qualified Option
|
|||||||
import List (intersperse)
|
import List (intersperse)
|
||||||
import Maybe (listToMaybe, maybe)
|
import Maybe (listToMaybe, maybe)
|
||||||
|
|
||||||
-- | FIXME: fix warning about bad -printer= value
|
|
||||||
prCanonAsCFGM :: CanonGrammar -> String
|
prCanonAsCFGM :: CanonGrammar -> String
|
||||||
prCanonAsCFGM gr = unlines $ map (uncurry (prLangAsCFGM gr)) xs
|
prCanonAsCFGM gr = unlines $ map (uncurry (prLangAsCFGM gr)) xs
|
||||||
where
|
where
|
||||||
@@ -60,17 +53,6 @@ prLangAsCFGM gr i start = prCFGrammarAsCFGM (Cnv.gfc2cfg (gr, i)) i start
|
|||||||
-- prLangAsCFGM gr i start = prCFGrammarAsCFGM (Cnv.cfg (Cnv.pInfo opts gr i)) i start
|
-- prLangAsCFGM gr i start = prCFGrammarAsCFGM (Cnv.cfg (Cnv.pInfo opts gr i)) i start
|
||||||
-- where opts = Option.Opts [Option.gfcConversion "nondet"]
|
-- where opts = Option.Opts [Option.gfcConversion "nondet"]
|
||||||
|
|
||||||
{-
|
|
||||||
prCFGrammarAsCFGM :: GT.CFGrammar -> Ident -> Maybe String -> String
|
|
||||||
prCFGrammarAsCFGM gr i@(IC lang) start = (header . startcat . rules . footer) ""
|
|
||||||
where
|
|
||||||
header = showString "grammar " . showString lang . showString "\n"
|
|
||||||
startcat = maybe id (\s -> showString "startcat " . showString (s++"{}.s") . showString ";\n") start
|
|
||||||
rules0 = map prt gr
|
|
||||||
rules = showString $ concat $ map (\l -> init l++";\n") rules0
|
|
||||||
footer = showString "end grammar\n"
|
|
||||||
-}
|
|
||||||
|
|
||||||
prCFGrammarAsCFGM :: GT.CGrammar -> Ident -> Maybe String -> String
|
prCFGrammarAsCFGM :: GT.CGrammar -> Ident -> Maybe String -> String
|
||||||
prCFGrammarAsCFGM gr i start = PrintCFG.printTree $ cfGrammarToCFGM gr i start
|
prCFGrammarAsCFGM gr i start = PrintCFG.printTree $ cfGrammarToCFGM gr i start
|
||||||
|
|
||||||
@@ -79,7 +61,6 @@ cfGrammarToCFGM gr i start = AbsCFG.Grammar (identToCFGMIdent i) flags (map rule
|
|||||||
where flags = maybe [] (\c -> [AbsCFG.StartCat $ strToCFGMCat (c++"{}.s")]) start
|
where flags = maybe [] (\c -> [AbsCFG.StartCat $ strToCFGMCat (c++"{}.s")]) start
|
||||||
|
|
||||||
ruleToCFGMRule :: GT.CRule -> AbsCFG.Rule
|
ruleToCFGMRule :: GT.CRule -> AbsCFG.Rule
|
||||||
-- new version, without the MCFName constructor:
|
|
||||||
ruleToCFGMRule (CFRule c rhs (GT.Name fun profile))
|
ruleToCFGMRule (CFRule c rhs (GT.Name fun profile))
|
||||||
= AbsCFG.Rule fun' p' c' rhs'
|
= AbsCFG.Rule fun' p' c' rhs'
|
||||||
where
|
where
|
||||||
@@ -88,22 +69,11 @@ ruleToCFGMRule (CFRule c rhs (GT.Name fun profile))
|
|||||||
c' = catToCFGMCat c
|
c' = catToCFGMCat c
|
||||||
rhs' = map symbolToGFCMSymbol rhs
|
rhs' = map symbolToGFCMSymbol rhs
|
||||||
|
|
||||||
{- old version, with the MCFName constructor:
|
|
||||||
ruleToCFGMRule (CFGrammar.Rule c rhs (GT.CFName (GT.MCFName fun cat args) lbl profile))
|
|
||||||
= AbsCFG.Rule fun' n' p' c' rhs'
|
|
||||||
where
|
|
||||||
fun' = identToCFGMIdent fun
|
|
||||||
n' = strToCFGMName (prt cat ++ concat [ "/" ++ prt arg | arg <- args ] ++ prt lbl)
|
|
||||||
p' = profileToCFGMProfile profile
|
|
||||||
c' = catToCFGMCat c
|
|
||||||
rhs' = map symbolToGFCMSymbol rhs
|
|
||||||
-}
|
|
||||||
|
|
||||||
profileToCFGMProfile :: [GT.Profile a] -> AbsCFG.Profile
|
profileToCFGMProfile :: [GT.Profile a] -> AbsCFG.Profile
|
||||||
profileToCFGMProfile = AbsCFG.Profile . map cnvProfile
|
profileToCFGMProfile = AbsCFG.Profile . map cnvProfile
|
||||||
where cnvProfile (GT.Unify ns) = AbsCFG.Ints $ map fromIntegral ns
|
where cnvProfile (GT.Unify ns) = AbsCFG.Ints $ map fromIntegral ns
|
||||||
cnvProfile (GT.Constant a) = AbsCFG.Ints []
|
cnvProfile (GT.Constant a) = AbsCFG.Ints []
|
||||||
-- this should be replaced with a new constructor in 'AbsCFG'
|
-- FIXME: this should be replaced with a new constructor in 'AbsCFG'
|
||||||
|
|
||||||
identToCFGMIdent :: Ident -> AbsCFG.Ident
|
identToCFGMIdent :: Ident -> AbsCFG.Ident
|
||||||
identToCFGMIdent = AbsCFG.Ident . prt
|
identToCFGMIdent = AbsCFG.Ident . prt
|
||||||
|
|||||||
@@ -5,9 +5,9 @@
|
|||||||
-- Stability : (stable)
|
-- Stability : (stable)
|
||||||
-- Portability : (portable)
|
-- Portability : (portable)
|
||||||
--
|
--
|
||||||
-- > CVS $Date: 2005/04/14 18:38:36 $
|
-- > CVS $Date: 2005/04/15 09:45:32 $
|
||||||
-- > CVS $Author: peb $
|
-- > CVS $Author: bringert $
|
||||||
-- > CVS $Revision: 1.16 $
|
-- > CVS $Revision: 1.17 $
|
||||||
--
|
--
|
||||||
-- This module prints a CFG as a Nuance GSL 2.0 grammar.
|
-- This module prints a CFG as a Nuance GSL 2.0 grammar.
|
||||||
--
|
--
|
||||||
@@ -19,10 +19,7 @@ module PrGSL (gslPrinter) where
|
|||||||
|
|
||||||
import SRG
|
import SRG
|
||||||
import Ident
|
import Ident
|
||||||
-- import GF.OldParsing.CFGrammar
|
|
||||||
-- import GF.OldParsing.Utilities (Symbol(..))
|
|
||||||
-- import GF.OldParsing.GrammarTypes
|
|
||||||
-- import GF.Printing.PrintParser
|
|
||||||
import GF.Formalism.CFG
|
import GF.Formalism.CFG
|
||||||
import GF.Formalism.Utilities (Symbol(..))
|
import GF.Formalism.Utilities (Symbol(..))
|
||||||
import GF.Conversion.Types
|
import GF.Conversion.Types
|
||||||
|
|||||||
@@ -5,9 +5,9 @@
|
|||||||
-- Stability : (stable)
|
-- Stability : (stable)
|
||||||
-- Portability : (portable)
|
-- Portability : (portable)
|
||||||
--
|
--
|
||||||
-- > CVS $Date: 2005/04/14 18:38:36 $
|
-- > CVS $Date: 2005/04/15 09:45:32 $
|
||||||
-- > CVS $Author: peb $
|
-- > CVS $Author: bringert $
|
||||||
-- > CVS $Revision: 1.10 $
|
-- > CVS $Revision: 1.11 $
|
||||||
--
|
--
|
||||||
-- This module prints a CFG as a JSGF grammar.
|
-- This module prints a CFG as a JSGF grammar.
|
||||||
--
|
--
|
||||||
@@ -21,10 +21,6 @@ module PrJSGF (jsgfPrinter) where
|
|||||||
|
|
||||||
import SRG
|
import SRG
|
||||||
import Ident
|
import Ident
|
||||||
-- import GF.OldParsing.CFGrammar
|
|
||||||
-- import GF.OldParsing.Utilities (Symbol(..))
|
|
||||||
-- import GF.OldParsing.GrammarTypes
|
|
||||||
-- import GF.Printing.PrintParser
|
|
||||||
import GF.Formalism.CFG
|
import GF.Formalism.CFG
|
||||||
import GF.Formalism.Utilities (Symbol(..))
|
import GF.Formalism.Utilities (Symbol(..))
|
||||||
import GF.Conversion.Types
|
import GF.Conversion.Types
|
||||||
|
|||||||
@@ -5,9 +5,9 @@
|
|||||||
-- Stability : (stable)
|
-- Stability : (stable)
|
||||||
-- Portability : (portable)
|
-- Portability : (portable)
|
||||||
--
|
--
|
||||||
-- > CVS $Date: 2005/04/14 18:38:36 $
|
-- > CVS $Date: 2005/04/15 09:45:32 $
|
||||||
-- > CVS $Author: peb $
|
-- > CVS $Author: bringert $
|
||||||
-- > CVS $Revision: 1.10 $
|
-- > CVS $Revision: 1.11 $
|
||||||
--
|
--
|
||||||
-- This module does some useful transformations on CFGs.
|
-- This module does some useful transformations on CFGs.
|
||||||
--
|
--
|
||||||
@@ -19,10 +19,6 @@
|
|||||||
module TransformCFG (makeNice, CFRule_) where
|
module TransformCFG (makeNice, CFRule_) where
|
||||||
|
|
||||||
import Ident
|
import Ident
|
||||||
-- import GF.OldParsing.CFGrammar
|
|
||||||
-- import GF.OldParsing.Utilities (Symbol(..))
|
|
||||||
-- import GF.OldParsing.GrammarTypes
|
|
||||||
-- import GF.Printing.PrintParser
|
|
||||||
import GF.Formalism.CFG
|
import GF.Formalism.CFG
|
||||||
import GF.Formalism.Utilities (Symbol(..), mapSymbol)
|
import GF.Formalism.Utilities (Symbol(..), mapSymbol)
|
||||||
import GF.Conversion.Types
|
import GF.Conversion.Types
|
||||||
@@ -35,7 +31,7 @@ import Data.Maybe (fromJust)
|
|||||||
import Debug.Trace
|
import Debug.Trace
|
||||||
|
|
||||||
|
|
||||||
-- | not very nice to get replace the structured CFCat type with a simple string
|
-- | not very nice to replace the structured CFCat type with a simple string
|
||||||
type CFRule_ = CFRule Cat_ Name Token
|
type CFRule_ = CFRule Cat_ Name Token
|
||||||
type Cat_ = String
|
type Cat_ = String
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user