From eb0fefec28cf9c089c55f1ef5de9c772faa61786 Mon Sep 17 00:00:00 2001 From: krasimir Date: Mon, 20 Oct 2008 08:42:39 +0000 Subject: preparation for dep. types. The -cat option can take any type instead of just a category. The PGF API is generalized as well. --- src/PGF/Parsing/FCFG/Active.hs | 4 ++-- src/PGF/Parsing/FCFG/Incremental.hs | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src/PGF/Parsing/FCFG') diff --git a/src/PGF/Parsing/FCFG/Active.hs b/src/PGF/Parsing/FCFG/Active.hs index 0927a719b..ad1db7220 100644 --- a/src/PGF/Parsing/FCFG/Active.hs +++ b/src/PGF/Parsing/FCFG/Active.hs @@ -37,8 +37,8 @@ makeFinalEdge cat 0 0 = (cat, [EmptyRange]) makeFinalEdge cat i j = (cat, [makeRange i j]) -- | the list of categories = possible starting categories -parse :: String -> ParserInfo -> CId -> [FToken] -> [Tree] -parse strategy pinfo start toks = nubsort $ filteredForests >>= forest2trees +parse :: String -> ParserInfo -> Type -> [FToken] -> [Tree] +parse strategy pinfo (DTyp _ start _) toks = nubsort $ filteredForests >>= forest2trees where inTokens = input toks starts = Map.findWithDefault [] start (startCats pinfo) diff --git a/src/PGF/Parsing/FCFG/Incremental.hs b/src/PGF/Parsing/FCFG/Incremental.hs index e5f64365f..38c2e6c95 100644 --- a/src/PGF/Parsing/FCFG/Incremental.hs +++ b/src/PGF/Parsing/FCFG/Incremental.hs @@ -22,11 +22,11 @@ import PGF.CId import PGF.Data import Debug.Trace -parse :: ParserInfo -> CId -> [String] -> [Tree] -parse pinfo start toks = maybe [] (\ps -> extractExps ps start) (foldM nextState (initState pinfo start) toks) +parse :: ParserInfo -> Type -> [String] -> [Tree] +parse pinfo typ toks = maybe [] (\ps -> extractExps ps typ) (foldM nextState (initState pinfo typ) toks) -initState :: ParserInfo -> CId -> ParseState -initState pinfo start = +initState :: ParserInfo -> Type -> ParseState +initState pinfo (DTyp _ start _) = let items = do cat <- fromMaybe [] (Map.lookup start (startCats pinfo)) (funid,args) <- foldForest (\funid args -> (:) (funid,args)) (\_ _ args -> args) @@ -97,8 +97,8 @@ getCompletions (State pinfo chart items) w = | isPrefixOf w tok = Map.insertWith Set.union tok (Set.singleton item) map | otherwise = map -extractExps :: ParseState -> CId -> [Tree] -extractExps (State pinfo chart items) start = exps +extractExps :: ParseState -> Type -> [Tree] +extractExps (State pinfo chart items) (DTyp _ start _) = exps where (_,st) = process (\_ _ -> id) (sequences pinfo) (functions pinfo) (Set.toList items) () chart -- cgit v1.2.3