module Data.JustParse.Char (
char,
anyChar,
caseInsensitiveChar,
ascii,
latin1,
control,
space,
lower,
upper,
alpha,
alphaNum,
print,
digit,
octDigit,
hexDigit,
string,
caseInsensitiveString,
eol
) where
import Prelude hiding (print)
import Data.Char
import Data.JustParse.Internal
import Data.JustParse.Combinator
char :: Stream s Char => Char -> Parser s Char
char = token
anyChar :: Stream s Char => Parser s Char
anyChar = anyToken
caseInsensitiveChar :: Stream s Char => Char -> Parser s Char
caseInsensitiveChar c = char (toUpper c) <|> char (toLower c)
ascii :: Stream s Char => Parser s Char
ascii = satisfy isAscii
latin1 :: Stream s Char => Parser s Char
latin1 = satisfy isLatin1
control :: Stream s Char => Parser s Char
control = satisfy isControl
space :: Stream s Char => Parser s Char
space = satisfy isSpace
lower :: Stream s Char => Parser s Char
lower = satisfy isLower
upper :: Stream s Char => Parser s Char
upper = satisfy isUpper
alpha :: Stream s Char => Parser s Char
alpha = satisfy isAlpha
alphaNum :: Stream s Char => Parser s Char
alphaNum = satisfy isAlphaNum
print :: Stream s Char => Parser s Char
print = satisfy isPrint
digit :: Stream s Char => Parser s Char
digit = satisfy isDigit
octDigit :: Stream s Char => Parser s Char
octDigit = satisfy isOctDigit
hexDigit :: Stream s Char => Parser s Char
hexDigit = satisfy isHexDigit
string :: Stream s Char => String -> Parser s String
string = mapM char
caseInsensitiveString :: Stream s Char => String -> Parser s String
caseInsensitiveString = mapM caseInsensitiveChar
eol :: Stream s Char => Parser s String
eol = choice [string "\r\n", string "\n\r", string "\n"]
instance Eq t => Stream [t] t where
uncons [] = Nothing
uncons (x:xs) = Just (x, xs)