From 1cdf171251a56baf0867b65a95c9bd59801ff912 Mon Sep 17 00:00:00 2001 From: krasimir Date: Fri, 11 Sep 2009 13:45:34 +0000 Subject: polish the PGF API and make Expr and Type abstract types. Tree is a type synonym of Expr --- src/PGF/Parsing/FCFG/Incremental.hs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'src/PGF/Parsing') 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 -- cgit v1.2.3