mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-22 19:22:50 -06:00
"Committed_by_peb"
This commit is contained in:
@@ -5,9 +5,9 @@
|
|||||||
-- Stability : (stable)
|
-- Stability : (stable)
|
||||||
-- Portability : (portable)
|
-- Portability : (portable)
|
||||||
--
|
--
|
||||||
-- > CVS $Date: 2005/02/18 19:21:07 $
|
-- > CVS $Date: 2005/03/21 13:54:24 $
|
||||||
-- > CVS $Author: peb $
|
-- > CVS $Author: peb $
|
||||||
-- > CVS $Revision: 1.5 $
|
-- > CVS $Revision: 1.6 $
|
||||||
--
|
--
|
||||||
-- Bottom-up Kilbury chart parser from "Pure Functional Parsing", chapter 5.
|
-- Bottom-up Kilbury chart parser from "Pure Functional Parsing", chapter 5.
|
||||||
-- OBSOLETE -- should use new MCFG parsers instead
|
-- OBSOLETE -- should use new MCFG parsers instead
|
||||||
@@ -15,9 +15,9 @@
|
|||||||
|
|
||||||
module ChartParser (chartParser) where
|
module ChartParser (chartParser) where
|
||||||
|
|
||||||
import Tracing
|
-- import Tracing
|
||||||
import PrintParser
|
-- import PrintParser
|
||||||
import PrintSimplifiedTerm
|
-- import PrintSimplifiedTerm
|
||||||
|
|
||||||
import Operations
|
import Operations
|
||||||
import CF
|
import CF
|
||||||
@@ -117,11 +117,11 @@ chartParser0 (productions, terminal) = cparse
|
|||||||
| otherwise = [cats]
|
| otherwise = [cats]
|
||||||
|
|
||||||
cparse :: Category -> [Token] -> ([ParseTree], String)
|
cparse :: Category -> [Token] -> ([ParseTree], String)
|
||||||
cparse start input = trace "ChartParser" $
|
cparse start input = -- trace "ChartParser" $
|
||||||
case lookup (0, length input, start) $
|
case lookup (0, length input, start) $
|
||||||
tracePrt "#edgeTrees" (prt . map (length.snd)) $
|
-- tracePrt "#edgeTrees" (prt . map (length.snd)) $
|
||||||
edgeTrees of
|
edgeTrees of
|
||||||
Just trees -> tracePrt "#trees" (prt . length . fst) $
|
Just trees -> -- tracePrt "#trees" (prt . length . fst) $
|
||||||
(trees, "Chart:" ++++ prChart passiveEdges)
|
(trees, "Chart:" ++++ prChart passiveEdges)
|
||||||
Nothing -> ([], "Chart:" ++++ prChart passiveEdges)
|
Nothing -> ([], "Chart:" ++++ prChart passiveEdges)
|
||||||
where
|
where
|
||||||
@@ -136,7 +136,7 @@ chartParser0 (productions, terminal) = cparse
|
|||||||
(i, b, a:bs) <- elems state ]
|
(i, b, a:bs) <- elems state ]
|
||||||
|
|
||||||
initialChart :: Chart
|
initialChart :: Chart
|
||||||
initialChart = tracePrt "#initialChart" (prt . map (length.elems)) $
|
initialChart = -- tracePrt "#initialChart" (prt . map (length.elems)) $
|
||||||
emptySet : map initialState (zip [0..] input)
|
emptySet : map initialState (zip [0..] input)
|
||||||
where initialState (j, sym) = makeSet [ (j, cat, []) |
|
where initialState (j, sym) = makeSet [ (j, cat, []) |
|
||||||
(cat, _) <- terminal sym ]
|
(cat, _) <- terminal sym ]
|
||||||
@@ -151,12 +151,12 @@ chartParser0 (productions, terminal) = cparse
|
|||||||
a `elemSet` emptyCats ]
|
a `elemSet` emptyCats ]
|
||||||
|
|
||||||
passiveEdges :: [Passive]
|
passiveEdges :: [Passive]
|
||||||
passiveEdges = tracePrt "#passiveEdges" (prt . length) $
|
passiveEdges = -- tracePrt "#passiveEdges" (prt . length) $
|
||||||
[ (i, j, cat) |
|
[ (i, j, cat) |
|
||||||
(j, state) <- zip [0..] $
|
(j, state) <- zip [0..] $
|
||||||
tracePrt "#passiveChart"
|
-- tracePrt "#passiveChart"
|
||||||
(prt . map (length.filter (\(_,_,x)->null x).elems)) $
|
-- (prt . map (length.filter (\(_,_,x)->null x).elems)) $
|
||||||
tracePrt "#activeChart" (prt . map (length.elems)) $
|
-- tracePrt "#activeChart" (prt . map (length.elems)) $
|
||||||
finalChart,
|
finalChart,
|
||||||
(i, cat, []) <- elems state ]
|
(i, cat, []) <- elems state ]
|
||||||
++
|
++
|
||||||
@@ -190,9 +190,11 @@ chartParser0 (productions, terminal) = cparse
|
|||||||
tree <- trees ]
|
tree <- trees ]
|
||||||
|
|
||||||
|
|
||||||
|
{-
|
||||||
instance Print ParseTree where
|
instance Print ParseTree where
|
||||||
prt (Node name cat trees) = prt name++"."++prt cat++"^{"++prtSep "," trees++"}"
|
prt (Node name cat trees) = prt name++"."++prt cat++"^{"++prtSep "," trees++"}"
|
||||||
prt (Leaf token) = prt token
|
prt (Leaf token) = prt token
|
||||||
|
-}
|
||||||
|
|
||||||
-- AR 10/12/2002
|
-- AR 10/12/2002
|
||||||
|
|
||||||
|
|||||||
@@ -5,9 +5,9 @@
|
|||||||
-- Stability : (stable)
|
-- Stability : (stable)
|
||||||
-- Portability : (portable)
|
-- Portability : (portable)
|
||||||
--
|
--
|
||||||
-- > CVS $Date: 2005/03/18 10:17:10 $
|
-- > CVS $Date: 2005/03/21 13:54:24 $
|
||||||
-- > CVS $Author: peb $
|
-- > CVS $Author: peb $
|
||||||
-- > CVS $Revision: 1.8 $
|
-- > CVS $Revision: 1.9 $
|
||||||
--
|
--
|
||||||
-- Handles printing a CFGrammar in CFGM format.
|
-- Handles printing a CFGrammar in CFGM format.
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
@@ -19,13 +19,13 @@ import qualified PrintCFG
|
|||||||
import Ident
|
import Ident
|
||||||
import GFC
|
import GFC
|
||||||
import Modules
|
import Modules
|
||||||
import qualified ConvertGrammar as Cnv
|
import qualified GF.Conversion.ConvertGrammar as Cnv
|
||||||
import qualified PrintParser as Prt
|
import qualified GF.Parsing.PrintParser as Prt
|
||||||
import qualified CFGrammar
|
import qualified GF.Conversion.CFGrammar as CFGrammar
|
||||||
import qualified GrammarTypes as GT
|
import qualified GF.Conversion.GrammarTypes as GT
|
||||||
import qualified AbsCFG
|
import qualified AbsCFG
|
||||||
import qualified Parser
|
import qualified GF.Parsing.Parser as Parser
|
||||||
import qualified PrintParser
|
import qualified GF.Parsing.PrintParser as PrintParser
|
||||||
import ErrM
|
import ErrM
|
||||||
import qualified Option
|
import qualified Option
|
||||||
|
|
||||||
|
|||||||
@@ -5,9 +5,9 @@
|
|||||||
-- Stability : (stable)
|
-- Stability : (stable)
|
||||||
-- Portability : (portable)
|
-- Portability : (portable)
|
||||||
--
|
--
|
||||||
-- > CVS $Date: 2005/03/18 10:17:10 $
|
-- > CVS $Date: 2005/03/21 13:54:24 $
|
||||||
-- > CVS $Author: peb $
|
-- > CVS $Author: peb $
|
||||||
-- > CVS $Revision: 1.38 $
|
-- > CVS $Revision: 1.39 $
|
||||||
--
|
--
|
||||||
-- (Description of the module)
|
-- (Description of the module)
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
@@ -36,7 +36,7 @@ import Arch (ModTime)
|
|||||||
|
|
||||||
-- peb 25/5-04
|
-- peb 25/5-04
|
||||||
-- import CFtoCFG
|
-- import CFtoCFG
|
||||||
import qualified ConvertGrammar as Cnv
|
import qualified GF.Conversion.ConvertGrammar as Cnv
|
||||||
|
|
||||||
import List (nub,nubBy)
|
import List (nub,nubBy)
|
||||||
|
|
||||||
|
|||||||
@@ -5,9 +5,9 @@
|
|||||||
-- Stability : (stable)
|
-- Stability : (stable)
|
||||||
-- Portability : (portable)
|
-- Portability : (portable)
|
||||||
--
|
--
|
||||||
-- > CVS $Date: 2005/03/18 10:17:10 $
|
-- > CVS $Date: 2005/03/21 13:54:44 $
|
||||||
-- > CVS $Author: peb $
|
-- > CVS $Author: peb $
|
||||||
-- > CVS $Revision: 1.11 $
|
-- > CVS $Revision: 1.12 $
|
||||||
--
|
--
|
||||||
-- 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,10 @@ module PrGSL (gslPrinter) where
|
|||||||
|
|
||||||
import SRG
|
import SRG
|
||||||
import Ident
|
import Ident
|
||||||
import CFGrammar
|
import GF.Conversion.CFGrammar
|
||||||
import Parser (Symbol(..))
|
import GF.Parsing.Parser (Symbol(..))
|
||||||
import GrammarTypes
|
import GF.Conversion.GrammarTypes
|
||||||
import PrintParser
|
import GF.Parsing.PrintParser
|
||||||
import Option
|
import Option
|
||||||
|
|
||||||
import Data.Char (toUpper,toLower)
|
import Data.Char (toUpper,toLower)
|
||||||
|
|||||||
@@ -5,9 +5,9 @@
|
|||||||
-- Stability : (stable)
|
-- Stability : (stable)
|
||||||
-- Portability : (portable)
|
-- Portability : (portable)
|
||||||
--
|
--
|
||||||
-- > CVS $Date: 2005/03/18 10:17:11 $
|
-- > CVS $Date: 2005/03/21 13:54:44 $
|
||||||
-- > CVS $Author: peb $
|
-- > CVS $Author: peb $
|
||||||
-- > CVS $Revision: 1.5 $
|
-- > CVS $Revision: 1.6 $
|
||||||
--
|
--
|
||||||
-- This module prints a CFG as a JSGF grammar.
|
-- This module prints a CFG as a JSGF grammar.
|
||||||
--
|
--
|
||||||
@@ -21,10 +21,10 @@ module PrJSGF (jsgfPrinter) where
|
|||||||
|
|
||||||
import SRG
|
import SRG
|
||||||
import Ident
|
import Ident
|
||||||
import CFGrammar
|
import GF.Conversion.CFGrammar
|
||||||
import Parser (Symbol(..))
|
import GF.Parsing.Parser (Symbol(..))
|
||||||
import GrammarTypes
|
import GF.Conversion.GrammarTypes
|
||||||
import PrintParser
|
import GF.Parsing.PrintParser
|
||||||
import Option
|
import Option
|
||||||
|
|
||||||
jsgfPrinter :: Ident -- ^ Grammar name
|
jsgfPrinter :: Ident -- ^ Grammar name
|
||||||
|
|||||||
@@ -5,9 +5,9 @@
|
|||||||
-- Stability : (stable)
|
-- Stability : (stable)
|
||||||
-- Portability : (portable)
|
-- Portability : (portable)
|
||||||
--
|
--
|
||||||
-- > CVS $Date: 2005/03/18 10:17:11 $
|
-- > CVS $Date: 2005/03/21 13:54:44 $
|
||||||
-- > CVS $Author: peb $
|
-- > CVS $Author: peb $
|
||||||
-- > CVS $Revision: 1.7 $
|
-- > CVS $Revision: 1.8 $
|
||||||
--
|
--
|
||||||
-- Representation of, conversion to, and utilities for
|
-- Representation of, conversion to, and utilities for
|
||||||
-- printing of a general Speech Recognition Grammar.
|
-- printing of a general Speech Recognition Grammar.
|
||||||
@@ -21,10 +21,10 @@
|
|||||||
module SRG where
|
module SRG where
|
||||||
|
|
||||||
import Ident
|
import Ident
|
||||||
import CFGrammar
|
import GF.Conversion.CFGrammar
|
||||||
import Parser (Symbol(..))
|
import GF.Parsing.Parser (Symbol(..))
|
||||||
import GrammarTypes
|
import GF.Conversion.GrammarTypes
|
||||||
import PrintParser
|
import GF.Parsing.PrintParser
|
||||||
import TransformCFG
|
import TransformCFG
|
||||||
import Option
|
import Option
|
||||||
|
|
||||||
|
|||||||
@@ -5,9 +5,9 @@
|
|||||||
-- Stability : (stable)
|
-- Stability : (stable)
|
||||||
-- Portability : (portable)
|
-- Portability : (portable)
|
||||||
--
|
--
|
||||||
-- > CVS $Date: 2005/03/18 10:17:11 $
|
-- > CVS $Date: 2005/03/21 13:54:44 $
|
||||||
-- > CVS $Author: peb $
|
-- > CVS $Author: peb $
|
||||||
-- > CVS $Revision: 1.5 $
|
-- > CVS $Revision: 1.6 $
|
||||||
--
|
--
|
||||||
-- This module does some useful transformations on CFGs.
|
-- This module does some useful transformations on CFGs.
|
||||||
--
|
--
|
||||||
@@ -17,10 +17,10 @@
|
|||||||
module TransformCFG (makeNice, CFRule_) where
|
module TransformCFG (makeNice, CFRule_) where
|
||||||
|
|
||||||
import Ident
|
import Ident
|
||||||
import CFGrammar
|
import GF.Conversion.CFGrammar
|
||||||
import Parser (Symbol(..))
|
import GF.Parsing.Parser (Symbol(..))
|
||||||
import GrammarTypes
|
import GF.Conversion.GrammarTypes
|
||||||
import PrintParser
|
import GF.Parsing.PrintParser
|
||||||
|
|
||||||
import Data.FiniteMap
|
import Data.FiniteMap
|
||||||
import Data.List
|
import Data.List
|
||||||
|
|||||||
@@ -5,9 +5,9 @@
|
|||||||
-- Stability : (stable)
|
-- Stability : (stable)
|
||||||
-- Portability : (portable)
|
-- Portability : (portable)
|
||||||
--
|
--
|
||||||
-- > CVS $Date: 2005/03/02 14:25:45 $
|
-- > CVS $Date: 2005/03/21 13:54:44 $
|
||||||
-- > CVS $Author: aarne $
|
-- > CVS $Author: peb $
|
||||||
-- > CVS $Revision: 1.44 $
|
-- > CVS $Revision: 1.45 $
|
||||||
--
|
--
|
||||||
-- A database for customizable GF shell commands.
|
-- A database for customizable GF shell commands.
|
||||||
--
|
--
|
||||||
@@ -66,15 +66,15 @@ import GrammarToHaskell
|
|||||||
|
|
||||||
-- the cf parsing algorithms
|
-- the cf parsing algorithms
|
||||||
import ChartParser -- or some other CF Parser
|
import ChartParser -- or some other CF Parser
|
||||||
import qualified ParseCF as PCF
|
import qualified GF.Parsing.ParseCF as PCF
|
||||||
--import qualified ParseGFCviaCFG as PGFC
|
--import qualified ParseGFCviaCFG as PGFC
|
||||||
--import NewChartParser
|
--import NewChartParser
|
||||||
--import NewerChartParser
|
--import NewerChartParser
|
||||||
|
|
||||||
-- grammar conversions -- peb 19/4-04
|
-- grammar conversions -- peb 19/4-04
|
||||||
-- see also customGrammarPrinter
|
-- see also customGrammarPrinter
|
||||||
import qualified ConvertGrammar as Cnv
|
import qualified GF.Conversion.ConvertGrammar as Cnv
|
||||||
import qualified PrintParser as Prt
|
import qualified GF.Parsing.PrintParser as Prt
|
||||||
|
|
||||||
import GFC
|
import GFC
|
||||||
import qualified MkGFC as MC
|
import qualified MkGFC as MC
|
||||||
|
|||||||
@@ -5,9 +5,9 @@
|
|||||||
-- Stability : (stable)
|
-- Stability : (stable)
|
||||||
-- Portability : (portable)
|
-- Portability : (portable)
|
||||||
--
|
--
|
||||||
-- > CVS $Date: 2005/02/24 11:46:39 $
|
-- > CVS $Date: 2005/03/21 13:54:45 $
|
||||||
-- > CVS $Author: peb $
|
-- > CVS $Author: peb $
|
||||||
-- > CVS $Revision: 1.14 $
|
-- > CVS $Revision: 1.15 $
|
||||||
--
|
--
|
||||||
-- (Description of the module)
|
-- (Description of the module)
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
@@ -35,7 +35,7 @@ import Custom
|
|||||||
import ShellState
|
import ShellState
|
||||||
|
|
||||||
import PPrCF (prCFTree)
|
import PPrCF (prCFTree)
|
||||||
import qualified ParseGFC as N
|
import qualified GF.Parsing.ParseGFC as N
|
||||||
|
|
||||||
import Operations
|
import Operations
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user