summaryrefslogtreecommitdiff
path: root/src/PGF/Parsing/FCFG
diff options
context:
space:
mode:
authorkrasimir <krasimir@chalmers.se>2009-09-11 13:45:34 +0000
committerkrasimir <krasimir@chalmers.se>2009-09-11 13:45:34 +0000
commit1cdf171251a56baf0867b65a95c9bd59801ff912 (patch)
tree837e65fa23f3041c3bbf4b7f1dbfcf63990e09a1 /src/PGF/Parsing/FCFG
parent28a7c4b5c7659dc18166e06e914fb0a81c1c43bc (diff)
polish the PGF API and make Expr and Type abstract types. Tree is a type synonym of Expr
Diffstat (limited to 'src/PGF/Parsing/FCFG')
-rw-r--r--src/PGF/Parsing/FCFG/Incremental.hs11
1 files changed, 6 insertions, 5 deletions
diff --git a/src/PGF/Parsing/FCFG/Incremental.hs b/src/PGF/Parsing/FCFG/Incremental.hs
index dbc738a05..cae0ad80f 100644
--- a/src/PGF/Parsing/FCFG/Incremental.hs
+++ b/src/PGF/Parsing/FCFG/Incremental.hs
@@ -4,7 +4,7 @@ module PGF.Parsing.FCFG.Incremental
, initState
, nextState
, getCompletions
- , extractExps
+ , extractTrees
, parse
) where
@@ -21,12 +21,13 @@ import Control.Monad
import GF.Data.SortedList
import PGF.CId
import PGF.Data
+import PGF.Expr(Tree)
import PGF.Macros
import PGF.TypeCheck
import Debug.Trace
parse :: PGF -> Language -> Type -> [String] -> [Expr]
-parse pgf lang typ toks = maybe [] (\ps -> extractExps ps typ) (foldM nextState (initState pgf lang typ) toks)
+parse pgf lang typ toks = maybe [] (\ps -> extractTrees ps typ) (foldM nextState (initState pgf lang typ) toks)
-- | Creates an initial parsing state for a given language and
-- startup category.
@@ -43,7 +44,7 @@ initState pgf lang (DTyp _ start _) =
pinfo =
case lookParser pgf lang of
Just pinfo -> pinfo
- _ -> error ("Unknown language: " ++ prCId lang)
+ _ -> error ("Unknown language: " ++ showCId lang)
in State pgf
pinfo
@@ -97,8 +98,8 @@ getCompletions (State pgf pinfo chart items) w =
-- that spans the whole input consumed so far. The trees are also
-- limited by the category specified, which is usually
-- the same as the startup category.
-extractExps :: ParseState -> Type -> [Expr]
-extractExps (State pgf pinfo chart items) ty@(DTyp _ start _) =
+extractTrees :: ParseState -> Type -> [Tree]
+extractTrees (State pgf pinfo chart items) ty@(DTyp _ start _) =
nubsort [e1 | e <- exps, Right e1 <- [checkExpr pgf e ty]]
where
(mb_agenda,acc) = TMap.decompose items