module Data.Aeson.JSONPath.Parser.Common
( pSpaces
, pUnicodeChar
)
where
import qualified Text.ParserCombinators.Parsec as P
import Data.Char (ord)
import Prelude
pSpaces :: P.Parser [Char]
pSpaces :: Parser String
pSpaces = ParsecT String () Identity Char -> Parser String
forall s u (m :: * -> *) a. ParsecT s u m a -> ParsecT s u m [a]
P.many (String -> ParsecT String () Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
String -> ParsecT s u m Char
P.oneOf String
" \n\r\t")
pUnicodeChar :: P.Parser Char
pUnicodeChar :: ParsecT String () Identity Char
pUnicodeChar = (Char -> Bool) -> ParsecT String () Identity Char
forall s (m :: * -> *) u.
Stream s m Char =>
(Char -> Bool) -> ParsecT s u m Char
P.satisfy Char -> Bool
inRange
where
inRange :: Char -> Bool
inRange Char
c = let code :: Int
code = Char -> Int
ord Char
c in
(Int
code Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Int
0x80 Bool -> Bool -> Bool
&& Int
code Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= Int
0xD7FF) Bool -> Bool -> Bool
||
(Int
code Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
>= Int
0xE000 Bool -> Bool -> Bool
&& Int
code Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= Int
0x10FFFF)