Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Merge branch 'master' of github.com:ekmett/parsers

  • Loading branch information...
commit e1b5623f14b578101009bd9716762d51b29c5b07 2 parents baea5e2 + 45b5780
Edward Kmett authored
Showing with 23 additions and 16 deletions.
  1. +2 −0  .gitignore
  2. +20 −15 src/Text/Parser/Char.hs
  3. +1 −1  src/Text/Parser/Token.hs
2  .gitignore
View
@@ -1,4 +1,6 @@
dist
+.cabal-sandbox
+cabal.sandbox.config
docs
wiki
TAGS
35 src/Text/Parser/Char.hs
View
@@ -25,21 +25,22 @@
module Text.Parser.Char
(
-- * Combinators
- oneOf -- :: CharParsing m => [Char] -> m Char
- , noneOf -- :: CharParsing m => [Char] -> m Char
- , oneOfSet -- :: CharParsing m => CharSet -> m Char
- , noneOfSet -- :: CharParsing m => CharSet -> m Char
- , spaces -- :: CharParsing m => m ()
- , space -- :: CharParsing m => m Char
- , newline -- :: CharParsing m => m Char
- , tab -- :: CharParsing m => m Char
- , upper -- :: CharParsing m => m Char
- , lower -- :: CharParsing m => m Char
- , alphaNum -- :: CharParsing m => m Char
- , letter -- :: CharParsing m => m Char
- , digit -- :: CharParsing m => m Char
- , hexDigit -- :: CharParsing m => m Char
- , octDigit -- :: CharParsing m => m Char
+ oneOf -- :: CharParsing m => [Char] -> m Char
+ , noneOf -- :: CharParsing m => [Char] -> m Char
+ , oneOfSet -- :: CharParsing m => CharSet -> m Char
+ , noneOfSet -- :: CharParsing m => CharSet -> m Char
+ , spaces -- :: CharParsing m => m ()
+ , space -- :: CharParsing m => m Char
+ , newline -- :: CharParsing m => m Char
+ , tab -- :: CharParsing m => m Char
+ , upper -- :: CharParsing m => m Char
+ , lower -- :: CharParsing m => m Char
+ , alphaNum -- :: CharParsing m => m Char
+ , letter -- :: CharParsing m => m Char
+ , digit -- :: CharParsing m => m Char
+ , hexDigit -- :: CharParsing m => m Char
+ , octDigit -- :: CharParsing m => m Char
+ , satisfyRange -- :: CharParsing m => Char -> Char -> m Char
-- * Class
, CharParsing(..)
) where
@@ -167,6 +168,10 @@ octDigit :: CharParsing m => m Char
octDigit = satisfy isOctDigit <?> "octal digit"
{-# INLINE octDigit #-}
+satisfyRange :: CharParsing m => Char -> Char -> m Char
+satisfyRange a z = satisfy (\c -> c >= a && c <= z)
+{-# INLINE satisfyRange #-}
+
-- | Additional functionality needed to parse character streams.
class Parsing m => CharParsing m where
-- | Parse a single character of the input, with UTF-8 decoding
2  src/Text/Parser/Token.hs
View
@@ -549,7 +549,7 @@ charLetter = satisfy (\c -> (c /= '\'') && (c /= '\\') && (c > '\026'))
escapeCode :: TokenParsing m => m Char
escapeCode = (charEsc <|> charNum <|> charAscii <|> charControl) <?> "escape code"
where
- charControl = (\c -> toEnum (fromEnum c - fromEnum 'A')) <$> (char '^' *> upper)
+ charControl = (\c -> toEnum (fromEnum c - fromEnum '@')) <$> (char '^' *> (upper <|> char '@'))
charNum = toEnum . fromInteger <$> num where
num = decimal
<|> (char 'o' *> number 8 octDigit)
Please sign in to comment.
Something went wrong with that request. Please try again.