From 4573d104425a79b8b00ebcccb2e94c62275285ea Mon Sep 17 00:00:00 2001 From: krasimir Date: Tue, 14 Oct 2008 08:00:50 +0000 Subject: the new optimized incremental parser and the common subexpression elimination optimization in PMCFG --- src/GFI.hs | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/GFI.hs') diff --git a/src/GFI.hs b/src/GFI.hs index 03fbb184f..1e9cfba2f 100644 --- a/src/GFI.hs +++ b/src/GFI.hs @@ -25,6 +25,7 @@ import qualified Text.ParserCombinators.ReadP as RP import System.Cmd import System.CPUTime import Control.Exception +import Control.Monad import Data.Version import GF.System.Signal --import System.IO.Error (try) @@ -203,9 +204,10 @@ wordCompletion gfenv line0 prefix0 p = -> do mb_state0 <- try (evaluate (initState pgf (optLang opts) (optCat opts))) case mb_state0 of Right state0 -> let ws = words (take (length s - length prefix) s) - state = foldl nextState state0 ws - compls = getCompletions state prefix - in ret ' ' (map (encode gfenv) (Map.keys compls)) + in case foldM nextState state0 ws of + Nothing -> ret ' ' [] + Just state -> let compls = getCompletions state prefix + in ret ' ' (map (encode gfenv) (Map.keys compls)) Left _ -> ret ' ' [] CmplOpt (Just (Command n _ _)) pref -> case Map.lookup n (commands cmdEnv) of -- cgit v1.2.3