]> gitweb @ CieloNegro.org - Lucu.git/blobdiff - Network/HTTP/Lucu/Parser.hs
multipart/form-data and more
[Lucu.git] / Network / HTTP / Lucu / Parser.hs
index 44cf1558584932f6f71f59609069b3da4a5fa949..bbe16a3d80b8bd3d4da6f2263fbe995f9cf3fd75 100644 (file)
@@ -167,7 +167,7 @@ infixr 0 <|>
 (<|>) :: Parser a -> Parser a -> Parser a
 f <|> g
     = f `seq` g `seq`
-      Parser $! do saved <- get -- 状態を保存
+      Parser $! do saved  <- get -- 状態を保存
                    result <- runParser f
                    case result of
                      Success a    -> return $! Success a
@@ -185,8 +185,17 @@ oneOf = foldl (<|>) failP . map char
 
 
 notFollowedBy :: Parser a -> Parser ()
-notFollowedBy p = p `seq`
-                  (p >> failP) <|> return ()
+notFollowedBy p
+    = p `seq`
+      Parser $! do saved  <- get -- 状態を保存
+                   result <- runParser p
+                   case result of
+                     Success a    -> do put saved -- 状態を復歸
+                                        return IllegalInput
+                     IllegalInput -> do put saved -- 状態を復歸
+                                        return $! Success ()
+                     ReachedEOF   -> do put saved -- 状態を復歸
+                                        return $! Success ()
 
 
 digit :: Parser Char