mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-05-19 08:02:51 -06:00
Changed PGF.complete to include the given input if it can be parsed as a complete tree.
This commit is contained in:
@@ -197,7 +197,7 @@ startCat :: PGF -> Type
|
|||||||
-- to be the empty string. This means that the completions
|
-- to be the empty string. This means that the completions
|
||||||
-- will be all possible next words.
|
-- will be all possible next words.
|
||||||
complete :: PGF -> Language -> Type -> String
|
complete :: PGF -> Language -> Type -> String
|
||||||
-> [String] -- ^ Possible word completions of,
|
-> [String] -- ^ Possible completions,
|
||||||
-- including the given input.
|
-- including the given input.
|
||||||
|
|
||||||
|
|
||||||
@@ -275,11 +275,12 @@ complete pgf from typ input =
|
|||||||
state0 = initState pgf from typ
|
state0 = initState pgf from typ
|
||||||
in case foldM Incremental.nextState state0 ws of
|
in case foldM Incremental.nextState state0 ws of
|
||||||
Nothing -> []
|
Nothing -> []
|
||||||
Just state -> let compls = Incremental.getCompletions state prefix
|
Just state ->
|
||||||
in [unwords (ws++[c]) ++ " " | c <- Map.keys compls]
|
(if null prefix && not (null (extractExps state typ)) then [unwords ws ++ " "] else [])
|
||||||
|
++ [unwords (ws++[c]) ++ " " | c <- Map.keys (Incremental.getCompletions state prefix)]
|
||||||
where
|
where
|
||||||
tokensAndPrefix :: String -> ([String],String)
|
tokensAndPrefix :: String -> ([String],String)
|
||||||
tokensAndPrefix s | not (null s) && isSpace (last s) = (words s, "")
|
tokensAndPrefix s | not (null s) && isSpace (last s) = (ws, "")
|
||||||
| null ws = ([],"")
|
| null ws = ([],"")
|
||||||
| otherwise = (init ws, last ws)
|
| otherwise = (init ws, last ws)
|
||||||
where ws = words s
|
where ws = words s
|
||||||
|
|||||||
Reference in New Issue
Block a user