diff options
| author | krasimir <krasimir@chalmers.se> | 2008-06-03 06:59:44 +0000 |
|---|---|---|
| committer | krasimir <krasimir@chalmers.se> | 2008-06-03 06:59:44 +0000 |
| commit | ac8fa4fd5f8e996eb65f26d39b4bd4558a818cf8 (patch) | |
| tree | 8b518478b98582f4403a9b6929247d0f02a6b972 /src-3.0/PGF/Parsing/FCFG/Active.hs | |
| parent | c161e0e4df906185521f75aebcd26b117f8ab48f (diff) | |
Hackish version of the incremental parser
Diffstat (limited to 'src-3.0/PGF/Parsing/FCFG/Active.hs')
| -rw-r--r-- | src-3.0/PGF/Parsing/FCFG/Active.hs | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/src-3.0/PGF/Parsing/FCFG/Active.hs b/src-3.0/PGF/Parsing/FCFG/Active.hs index 71352c725..80cfccdee 100644 --- a/src-3.0/PGF/Parsing/FCFG/Active.hs +++ b/src-3.0/PGF/Parsing/FCFG/Active.hs @@ -7,7 +7,7 @@ -- MCFG parsing, the active algorithm ----------------------------------------------------------------------------- -module PGF.Parsing.FCFG.Active (FCFParser, parse, makeFinalEdge) where +module PGF.Parsing.FCFG.Active (parse) where import GF.Data.Assoc import GF.Data.SortedList @@ -32,17 +32,20 @@ makeFinalEdge cat 0 0 = (cat, [EmptyRange]) makeFinalEdge cat i j = (cat, [makeRange i j]) -- | the list of categories = possible starting categories -type FCFParser = ParserInfo - -> [FCat] - -> Input FToken - -> SyntaxChart (CId,[Profile]) (FCat,RangeRec) - - -parse :: String -> FCFParser -parse strategy pinfo starts toks = xchart2syntaxchart chart pinfo - where chart = process strategy pinfo toks axioms emptyXChart - axioms | isBU strategy = literals pinfo toks ++ initialBU pinfo toks - | isTD strategy = literals pinfo toks ++ initialTD pinfo starts toks +parse :: String -> ParserInfo -> CId -> [FToken] -> [Exp] +parse strategy pinfo start toks = nubsort $ filteredForests >>= forest2exps + where + inTokens = input toks + starts = Map.findWithDefault [] start (startupCats pinfo) + schart = xchart2syntaxchart chart pinfo + (i,j) = inputBounds inTokens + finalEdges = [makeFinalEdge cat i j | cat <- starts] + forests = chart2forests schart (const False) finalEdges + filteredForests = forests >>= applyProfileToForest + + chart = process strategy pinfo inTokens axioms emptyXChart + axioms | isBU strategy = literals pinfo inTokens ++ initialBU pinfo inTokens + | isTD strategy = literals pinfo inTokens ++ initialTD pinfo starts inTokens isBU s = s=="b" isTD s = s=="t" |
