summaryrefslogtreecommitdiff
path: root/src/GFI.hs
diff options
context:
space:
mode:
authorkrasimir <krasimir@chalmers.se>2009-10-23 08:35:32 +0000
committerkrasimir <krasimir@chalmers.se>2009-10-23 08:35:32 +0000
commitd5f4669aec26c6a580a28b05a6005425ad663555 (patch)
treea0ea03cadac7cce788e3359ed48434837fcd0fcd /src/GFI.hs
parent70b5e2a93037603f9f5b20c46e9ad15a95a7c097 (diff)
experimental robust parser
Diffstat (limited to 'src/GFI.hs')
-rw-r--r--src/GFI.hs8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/GFI.hs b/src/GFI.hs
index 7b98f0ff8..727e91209 100644
--- a/src/GFI.hs
+++ b/src/GFI.hs
@@ -262,7 +262,7 @@ wordCompletion gfenv line0 prefix0 p =
-> do mb_state0 <- try (evaluate (initState pgf (optLang opts) (optType opts)))
case mb_state0 of
Right state0 -> let ws = words (take (length s - length prefix) s)
- in case foldM nextState state0 ws of
+ in case loop state0 ws of
Nothing -> ret ' ' []
Just state -> let compls = getCompletions state prefix
in ret ' ' (map (encode gfenv) (Map.keys compls))
@@ -295,7 +295,11 @@ wordCompletion gfenv line0 prefix0 p =
Just ty -> ty
Nothing -> error ("Can't parse '"++str++"' as type")
-
+ loop ps [] = Just ps
+ loop ps (t:ts) = case nextState ps t of
+ Left es -> Nothing
+ Right ps -> loop ps ts
+
ret c [x] = return [x++[c]]
ret _ xs = return xs