From 4dd62417dc64609e0c37633fbbba52e82c221b2e Mon Sep 17 00:00:00 2001 From: krasimir Date: Thu, 19 Jun 2008 12:48:29 +0000 Subject: split the Exp type to Tree and Expr --- src-3.0/PGF/Parsing/FCFG/Active.hs | 4 ++-- src-3.0/PGF/Parsing/FCFG/Incremental.hs | 6 +++--- src-3.0/PGF/Parsing/FCFG/Utilities.hs | 12 ++++++------ 3 files changed, 11 insertions(+), 11 deletions(-) (limited to 'src-3.0/PGF/Parsing/FCFG') diff --git a/src-3.0/PGF/Parsing/FCFG/Active.hs b/src-3.0/PGF/Parsing/FCFG/Active.hs index 80cfccdee..4386bfdd1 100644 --- a/src-3.0/PGF/Parsing/FCFG/Active.hs +++ b/src-3.0/PGF/Parsing/FCFG/Active.hs @@ -32,8 +32,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] -> [Exp] -parse strategy pinfo start toks = nubsort $ filteredForests >>= forest2exps +parse :: String -> ParserInfo -> CId -> [FToken] -> [Tree] +parse strategy pinfo start toks = nubsort $ filteredForests >>= forest2trees where inTokens = input toks starts = Map.findWithDefault [] start (startupCats pinfo) diff --git a/src-3.0/PGF/Parsing/FCFG/Incremental.hs b/src-3.0/PGF/Parsing/FCFG/Incremental.hs index 16a5e8875..fff5f0212 100644 --- a/src-3.0/PGF/Parsing/FCFG/Incremental.hs +++ b/src-3.0/PGF/Parsing/FCFG/Incremental.hs @@ -25,7 +25,7 @@ import PGF.Data import PGF.Parsing.FCFG.Utilities import Debug.Trace -parse :: ParserInfo -> CId -> [FToken] -> [Exp] +parse :: ParserInfo -> CId -> [FToken] -> [Tree] parse pinfo start toks = extractExps (foldl' nextState (initState pinfo start) toks) start initState :: ParserInfo -> CId -> ParseState @@ -82,7 +82,7 @@ getCompletions (State pinfo chart items) w = | isPrefixOf w tok = fromMaybe map (MM.insert' tok item map) | otherwise = map -extractExps :: ParseState -> CId -> [Exp] +extractExps :: ParseState -> CId -> [Tree] extractExps (State pinfo chart items) start = exps where (_,st) = process (\_ _ -> id) (allRules pinfo) (Set.toList items) ((),chart) @@ -103,7 +103,7 @@ extractExps (State pinfo chart items) start = exps if fn == wildCId then go (Set.insert fid rec) (head args) else do args <- mapM (go (Set.insert fid rec)) args - return (EApp fn args) + return (Fun fn args) process fn !rules [] acc_chart = acc_chart process fn !rules (item:items) acc_chart = univRule item acc_chart diff --git a/src-3.0/PGF/Parsing/FCFG/Utilities.hs b/src-3.0/PGF/Parsing/FCFG/Utilities.hs index e435c6154..4187d0f24 100644 --- a/src-3.0/PGF/Parsing/FCFG/Utilities.hs +++ b/src-3.0/PGF/Parsing/FCFG/Utilities.hs @@ -179,9 +179,9 @@ applyProfileToForest (FFloat f) = [FFloat f] applyProfileToForest (FMeta) = [FMeta] -forest2exps :: SyntaxForest CId -> [Exp] -forest2exps (FNode n forests) = map (EApp n) $ forests >>= mapM forest2exps -forest2exps (FString s) = [EStr s] -forest2exps (FInt n) = [EInt n] -forest2exps (FFloat f) = [EFloat f] -forest2exps (FMeta) = [EMeta 0] +forest2trees :: SyntaxForest CId -> [Tree] +forest2trees (FNode n forests) = map (Fun n) $ forests >>= mapM forest2trees +forest2trees (FString s) = [Lit (LStr s)] +forest2trees (FInt n) = [Lit (LInt n)] +forest2trees (FFloat f) = [Lit (LFlt f)] +forest2trees (FMeta) = [Meta 0] -- cgit v1.2.3