summaryrefslogtreecommitdiff
path: root/src/runtime/haskell/PGF.hs
diff options
context:
space:
mode:
authorkrasimir <krasimir@chalmers.se>2010-07-01 08:51:59 +0000
committerkrasimir <krasimir@chalmers.se>2010-07-01 08:51:59 +0000
commit5ae7be358daf169a3852d93f36c30c4ce7d0363e (patch)
treedcbc25272686a5e04da654c657bd140c349aac2b /src/runtime/haskell/PGF.hs
parent706b215fce733ab4e342bce4fc9cc37c16f9875c (diff)
redesign the open-literals API
Diffstat (limited to 'src/runtime/haskell/PGF.hs')
-rw-r--r--src/runtime/haskell/PGF.hs22
1 files changed, 11 insertions, 11 deletions
diff --git a/src/runtime/haskell/PGF.hs b/src/runtime/haskell/PGF.hs
index a4d9f4aa1..3b8eced42 100644
--- a/src/runtime/haskell/PGF.hs
+++ b/src/runtime/haskell/PGF.hs
@@ -80,8 +80,8 @@ module PGF(
complete,
Parse.ParseState,
Parse.initState, Parse.nextState, Parse.getCompletions, Parse.recoveryStates,
- Parse.acceptsLiteral, Parse.feedLiteral,
- Parse.ParseResult(..), Parse.getParseResult,
+ Parse.ParseInput(..), Parse.simpleParseInput, Parse.mkParseInput,
+ Parse.ParseOutput(..), Parse.getParseOutput,
-- ** Generation
generateRandom, generateAll, generateAllDepth,
@@ -155,10 +155,10 @@ parseAll :: PGF -> Type -> String -> [[Tree]]
parseAllLang :: PGF -> Type -> String -> [(Language,[Tree])]
-- | The same as 'parse' but returns more detailed information
-parse_ :: PGF -> Language -> Type -> String -> (Parse.ParseResult,BracketedString)
+parse_ :: PGF -> Language -> Type -> String -> (Parse.ParseOutput,BracketedString)
-- | This is an experimental function. Use it on your own risk
-parseWithRecovery :: PGF -> Language -> Type -> [Type] -> String -> (Parse.ParseResult,BracketedString)
+parseWithRecovery :: PGF -> Language -> Type -> [Type] -> String -> (Parse.ParseOutput,BracketedString)
-- | The same as 'generateAllDepth' but does not limit
-- the depth in the generation, and doesn't give an initial expression.
@@ -223,13 +223,13 @@ readPGF f = decodeFile f
parse pgf lang typ s =
case parse_ pgf lang typ s of
- (Parse.ParseResult ts,_) -> ts
- _ -> []
+ (Parse.ParseOk ts,_) -> ts
+ _ -> []
parseAll mgr typ = map snd . parseAllLang mgr typ
parseAllLang mgr typ s =
- [(lang,ts) | lang <- languages mgr, (Parse.ParseResult ts,_) <- [parse_ mgr lang typ s]]
+ [(lang,ts) | lang <- languages mgr, (Parse.ParseOk ts,_) <- [parse_ mgr lang typ s]]
parse_ pgf lang typ s =
case Map.lookup lang (concretes pgf) of
@@ -281,9 +281,9 @@ complete pgf from typ input =
++ [unwords (ws++[c]) ++ " " | c <- Map.keys (Parse.getCompletions state prefix)]
where
isSuccessful state =
- case Parse.getParseResult state typ of
- (Parse.ParseResult ts, _) -> not (null ts)
- _ -> False
+ 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, "")
@@ -292,7 +292,7 @@ complete pgf from typ input =
where ws = words s
loop ps [] = Just ps
- loop ps (t:ts) = case Parse.nextState ps t of
+ loop ps (t:ts) = case Parse.nextState ps (Parse.simpleParseInput t) of
Left es -> Nothing
Right ps -> loop ps ts