diff options
| author | bjorn <bjorn@bringert.net> | 2008-09-26 13:17:21 +0000 |
|---|---|---|
| committer | bjorn <bjorn@bringert.net> | 2008-09-26 13:17:21 +0000 |
| commit | 804232aebc2cfe52fa2f9451dfc3b10516e92b98 (patch) | |
| tree | c2884beade233db461e6e10b21d2935986deed95 /src/server/MainFastCGI.hs | |
| parent | b0dde31f00a5bc4df496d15008e6c3d525925d3a (diff) | |
Added 'complete' function to the PGF API. This is a higher-level API to the completion functionality.
Diffstat (limited to 'src/server/MainFastCGI.hs')
| -rw-r--r-- | src/server/MainFastCGI.hs | 16 |
1 files changed, 1 insertions, 15 deletions
diff --git a/src/server/MainFastCGI.hs b/src/server/MainFastCGI.hs index 47aabacf3..ed3e8278e 100644 --- a/src/server/MainFastCGI.hs +++ b/src/server/MainFastCGI.hs @@ -123,24 +123,10 @@ parse' pgf input mcat mfrom = complete' :: PGF -> String -> Maybe PGF.Category -> Maybe PGF.Language -> [(PGF.Language,[String])] complete' pgf input mcat mfrom = - [(from,ss) | from <- froms, PGF.canParse pgf from, let ss = complete pgf from cat input, not (null ss)] + [(from,ss) | from <- froms, PGF.canParse pgf from, let ss = PGF.complete pgf from cat input, not (null ss)] where froms = maybe (PGF.languages pgf) (:[]) mfrom cat = fromMaybe (PGF.startCat pgf) mcat -complete :: PGF -> PGF.Language -> PGF.Category -> String -> [String] -complete pgf from cat input = - let (ws,prefix) = tokensAndPrefix input - state0 = PGF.initState pgf from cat - state = foldl PGF.nextState state0 ws - compls = PGF.getCompletions state prefix - in [unwords (ws++[c]) ++ " " | c <- Map.keys compls] - -tokensAndPrefix :: String -> ([String],String) -tokensAndPrefix s | not (null s) && isSpace (last s) = (words s, "") - | null ws = ([],"") - | otherwise = (init ws, last ws) - where ws = words s - linearize' :: PGF -> Maybe PGF.Language -> PGF.Tree -> [(PGF.Language,String)] linearize' pgf mto tree = case mto of |
