X-Git-Url: http://git.cielonegro.org/gitweb.cgi?a=blobdiff_plain;f=Network%2FHTTP%2FLucu%2FParser%2FHttp.hs;h=78e48181c9f251023b4c11f88630e8b26b85e1d1;hb=9ac730212cb361eb10e5fe4ad0eec6758e2b200a;hp=77dbe7f225bb2b6c3950b497815efa077d6c98b2;hpb=636a3b3334f1ede61dc1e6faa2c4a021ea9bbd5c;p=Lucu.git diff --git a/Network/HTTP/Lucu/Parser/Http.hs b/Network/HTTP/Lucu/Parser/Http.hs index 77dbe7f..78e4818 100644 --- a/Network/HTTP/Lucu/Parser/Http.hs +++ b/Network/HTTP/Lucu/Parser/Http.hs @@ -17,17 +17,17 @@ module Network.HTTP.Lucu.Parser.Http ) where -import Data.List import Network.HTTP.Lucu.Parser --- |@'isCtl' c@ is False iff @0x20 <= @c@ < 0x7F@. +-- |@'isCtl' c@ is 'Prelude.False' iff @0x20 <= @c@ < 0x7F@. isCtl :: Char -> Bool isCtl c | c < '\x1f' = True | c >= '\x7f' = True | otherwise = False --- |@'isSeparator' c@ is True iff c is one of HTTP separators. +-- |@'isSeparator' c@ is 'Prelude.True' iff c is one of HTTP +-- separators. isSeparator :: Char -> Bool isSeparator '(' = True isSeparator ')' = True @@ -50,7 +50,7 @@ isSeparator ' ' = True isSeparator '\t' = True isSeparator _ = False --- |@'isChar' c@ is True iff @c <= 0x7f@. +-- |@'isChar' c@ is 'Prelude.True' iff @c <= 0x7f@. isChar :: Char -> Bool isChar c | c <= '\x7f' = True @@ -66,11 +66,10 @@ isToken c = c `seq` -- ('Network.HTTP.Lucu.Parser.char' \',\')@ but it allows any -- occurrences of LWS before and after each tokens. listOf :: Parser a -> Parser [a] -listOf p = p `seq` - do many lws - sepBy p $! do many lws - char ',' - many lws +listOf !p = do _ <- many lws + sepBy p $! do _ <- many lws + _ <- char ',' + many lws -- |'token' is equivalent to @'Network.HTTP.Lucu.Parser.many1' $ -- 'Network.HTTP.Lucu.Parser.satisfy' 'isToken'@ @@ -86,7 +85,7 @@ lws = do s <- option "" crlf -- |'text' accepts one character which doesn't satisfy 'isCtl'. text :: Parser Char -text = satisfy (\ c -> not (isCtl c)) +text = satisfy (not . isCtl) -- |'separator' accepts one character which satisfies 'isSeparator'. separator :: Parser Char @@ -95,15 +94,15 @@ separator = satisfy isSeparator -- |'quotedStr' accepts a string surrounded by double quotation -- marks. Quotes can be escaped by backslashes. quotedStr :: Parser String -quotedStr = do char '"' +quotedStr = do _ <- char '"' xs <- many (qdtext <|> quotedPair) - char '"' + _ <- char '"' return $ foldr (++) "" xs where qdtext = do c <- satisfy (/= '"') return [c] - quotedPair = do q <- char '\\' + quotedPair = do _ <- char '\\' c <- satisfy isChar return [c] @@ -111,14 +110,14 @@ quotedStr = do char '"' qvalue :: Parser Double qvalue = do x <- char '0' xs <- option "" - $ do x <- char '.' - xs <- many digit -- 本當は三文字までに制限 - return (x:xs) + $ do y <- char '.' + ys <- many digit -- 本當は三文字までに制限 + return (y:ys) return $ read (x:xs) <|> do x <- char '1' xs <- option "" - $ do x <- char '.' - xs <- many (char '0') -- 本當は三文字までに制限 - return (x:xs) + $ do y <- char '.' + ys <- many (char '0') -- 本當は三文字までに制限 + return (y:ys) return $ read (x:xs)