diff options
| author | krasimir <krasimir@chalmers.se> | 2010-08-24 15:58:22 +0000 |
|---|---|---|
| committer | krasimir <krasimir@chalmers.se> | 2010-08-24 15:58:22 +0000 |
| commit | d3a686627704c3c73d86f5d31bf3669e5c793b35 (patch) | |
| tree | ed4ad7e0e81c05da8363f952439fd32aac158f98 /src/runtime | |
| parent | 4df7b0493507d18ab17edde930240bed2d06771b (diff) | |
more advanced complete function in the PGFService
Diffstat (limited to 'src/runtime')
| -rw-r--r-- | src/runtime/haskell/PGF.hs | 33 |
1 files changed, 0 insertions, 33 deletions
diff --git a/src/runtime/haskell/PGF.hs b/src/runtime/haskell/PGF.hs index 9bdfd8b23..0a110f83d 100644 --- a/src/runtime/haskell/PGF.hs +++ b/src/runtime/haskell/PGF.hs @@ -79,7 +79,6 @@ module PGF( TcError(..), ppTcError, -- ** Low level parsing API - complete, Parse.ParseState, Parse.initState, Parse.nextState, Parse.getCompletions, Parse.recoveryStates, Parse.ParseInput(..), Parse.simpleParseInput, Parse.mkParseInput, @@ -208,14 +207,6 @@ functions :: PGF -> [CId] -- | The type of a given function functionType :: PGF -> CId -> Maybe Type --- | Complete the last word in the given string. If the input --- is empty or ends in whitespace, the last word is considred --- to be the empty string. This means that the completions --- will be all possible next words. -complete :: PGF -> Language -> Type -> String - -> [String] -- ^ Possible completions, - -- including the given input. - --------------------------------------------------- -- Implementation @@ -274,30 +265,6 @@ functionType pgf fun = Just (ty,_,_) -> Just ty Nothing -> Nothing -complete pgf from typ input = - let (ws,prefix) = tokensAndPrefix input - state0 = Parse.initState pgf from typ - in case loop state0 ws of - Nothing -> [] - Just state -> (if null prefix && isSuccessful state then [unwords ws ++ " "] else []) - ++ [unwords (ws++[c]) ++ " " | c <- Map.keys (Parse.getCompletions state prefix)] - where - isSuccessful state = - case Parse.getParseOutput state typ of - (Parse.ParseOk ts, _) -> not (null ts) - _ -> False - - tokensAndPrefix :: String -> ([String],String) - tokensAndPrefix s | not (null s) && isSpace (last s) = (ws, "") - | null ws = ([],"") - | otherwise = (init ws, last ws) - where ws = words s - - loop ps [] = Just ps - loop ps (t:ts) = case Parse.nextState ps (Parse.simpleParseInput t) of - Left es -> Nothing - Right ps -> loop ps ts - -- | Converts an expression to normal form compute :: PGF -> Expr -> Expr compute pgf = PGF.Data.normalForm (funs (abstract pgf),const Nothing) 0 [] |
