{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE FunctionalDependencies #-}
{-# LANGUAGE MultiParamTypeClasses #-}
{-# LANGUAGE PostfixOperators #-}
{-# LANGUAGE Safe #-}
{-# OPTIONS_GHC -fno-warn-missing-signatures #-}
{-# OPTIONS_GHC -fno-warn-name-shadowing #-}
module Data.YAML.Token
( tokenize
, Token(..)
, Code(..)
, Encoding(..)
) where
import qualified Data.ByteString.Lazy.Char8 as BLC
import qualified Data.DList as D
import Prelude hiding ((*), (+), (-), (/), (^))
import qualified Prelude
import Data.YAML.Token.Encoding (Encoding (..), decode)
import Util hiding (empty)
import qualified Util
infixl 6 .+
(.+) :: Int -> Int -> Int
.+ :: Int -> Int -> Int
(.+) = Int -> Int -> Int
forall a. Num a => a -> a -> a
(Prelude.+)
infixl 6 .-
(.-) :: Int -> Int -> Int
.- :: Int -> Int -> Int
(.-) = Int -> Int -> Int
forall a. Num a => a -> a -> a
(Prelude.-)
infixl 8 ^.
(^.) :: record -> (record -> value) -> value
record
record ^. :: forall record value. record -> (record -> value) -> value
^. record -> value
field = record -> value
field record
record
data Code = Bom
| Text
| Meta
| Break
| LineFeed
| LineFold
| Indicator
| White
| Indent
| DirectivesEnd
| DocumentEnd
| BeginEscape
| EndEscape
|
|
| BeginDirective
| EndDirective
| BeginTag
| EndTag
| BeginHandle
| EndHandle
| BeginAnchor
| EndAnchor
| BeginProperties
| EndProperties
| BeginAlias
| EndAlias
| BeginScalar
| EndScalar
| BeginSequence
| EndSequence
| BeginMapping
| EndMapping
| BeginPair
| EndPair
| BeginNode
| EndNode
| BeginDocument
| EndDocument
| BeginStream
| EndStream
| Error
| Unparsed
| Detected
deriving (Int -> Code -> ShowS
[Code] -> ShowS
Code -> String
(Int -> Code -> ShowS)
-> (Code -> String) -> ([Code] -> ShowS) -> Show Code
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Code] -> ShowS
$cshowList :: [Code] -> ShowS
show :: Code -> String
$cshow :: Code -> String
showsPrec :: Int -> Code -> ShowS
$cshowsPrec :: Int -> Code -> ShowS
Show,Code -> Code -> Bool
(Code -> Code -> Bool) -> (Code -> Code -> Bool) -> Eq Code
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Code -> Code -> Bool
$c/= :: Code -> Code -> Bool
== :: Code -> Code -> Bool
$c== :: Code -> Code -> Bool
Eq,(forall x. Code -> Rep Code x)
-> (forall x. Rep Code x -> Code) -> Generic Code
forall x. Rep Code x -> Code
forall x. Code -> Rep Code x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Code x -> Code
$cfrom :: forall x. Code -> Rep Code x
Generic)
instance NFData Code where
rnf :: Code -> ()
rnf Code
x = Code -> () -> ()
seq Code
x ()
data Token = Token {
Token -> Int
tByteOffset :: !Int,
Token -> Int
tCharOffset :: !Int,
Token -> Int
tLine :: !Int,
Token -> Int
tLineChar :: !Int,
Token -> Code
tCode :: !Code,
Token -> String
tText :: !String
} deriving (Int -> Token -> ShowS
[Token] -> ShowS
Token -> String
(Int -> Token -> ShowS)
-> (Token -> String) -> ([Token] -> ShowS) -> Show Token
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Token] -> ShowS
$cshowList :: [Token] -> ShowS
show :: Token -> String
$cshow :: Token -> String
showsPrec :: Int -> Token -> ShowS
$cshowsPrec :: Int -> Token -> ShowS
Show,(forall x. Token -> Rep Token x)
-> (forall x. Rep Token x -> Token) -> Generic Token
forall x. Rep Token x -> Token
forall x. Token -> Rep Token x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Token x -> Token
$cfrom :: forall x. Token -> Rep Token x
Generic)
instance NFData Token where
rnf :: Token -> ()
rnf Token { tText :: Token -> String
tText = String
txt } = String -> ()
forall a. NFData a => a -> ()
rnf String
txt
newtype Parser result = Parser (State -> Reply result)
applyParser :: Parser result -> State -> Reply result
applyParser :: forall result. Parser result -> State -> Reply result
applyParser (Parser State -> Reply result
p) State
s = State -> Reply result
p State
s
data Result result = Failed String
| Result result
| More (Parser result)
data Reply result = Reply {
forall result. Reply result -> Result result
rResult :: !(Result result),
forall result. Reply result -> DList Token
rTokens :: !(D.DList Token),
forall result. Reply result -> Maybe Decision
rCommit :: !(Maybe Decision),
forall result. Reply result -> State
rState :: !State
}
type Pattern = Parser ()
data State = State {
State -> Encoding
sEncoding :: !Encoding,
State -> Decision
sDecision :: !Decision,
State -> Int
sLimit :: !Int,
State -> Maybe Pattern
sForbidden :: !(Maybe Pattern),
State -> Bool
sIsPeek :: !Bool,
State -> Bool
sIsSol :: !Bool,
State -> String
sChars :: ![Char],
State -> Int
sCharsByteOffset :: !Int,
State -> Int
sCharsCharOffset :: !Int,
State -> Int
sCharsLine :: !Int,
State -> Int
sCharsLineChar :: !Int,
State -> Int
sByteOffset :: !Int,
State -> Int
sCharOffset :: !Int,
State -> Int
sLine :: !Int,
State -> Int
sLineChar :: !Int,
State -> Code
sCode :: !Code,
State -> Char
sLast :: !Char,
State -> [(Int, Char)]
sInput :: ![(Int, Char)]
}
initialState :: BLC.ByteString -> State
initialState :: ByteString -> State
initialState ByteString
input
= State { sEncoding :: Encoding
sEncoding = Encoding
encoding
, sDecision :: Decision
sDecision = Decision
DeNone
, sLimit :: Int
sLimit = -Int
1
, sForbidden :: Maybe Pattern
sForbidden = Maybe Pattern
forall a. Maybe a
Nothing
, sIsPeek :: Bool
sIsPeek = Bool
False
, sIsSol :: Bool
sIsSol = Bool
True
, sChars :: String
sChars = []
, sCharsByteOffset :: Int
sCharsByteOffset = -Int
1
, sCharsCharOffset :: Int
sCharsCharOffset = -Int
1
, sCharsLine :: Int
sCharsLine = -Int
1
, sCharsLineChar :: Int
sCharsLineChar = -Int
1
, sByteOffset :: Int
sByteOffset = Int
0
, sCharOffset :: Int
sCharOffset = Int
0
, sLine :: Int
sLine = Int
1
, sLineChar :: Int
sLineChar = Int
0
, sCode :: Code
sCode = Code
Unparsed
, sLast :: Char
sLast = Char
' '
, sInput :: [(Int, Char)]
sInput = [(Int, Char)]
decoded
}
where
(Encoding
encoding, [(Int, Char)]
decoded) = ByteString -> (Encoding, [(Int, Char)])
decode ByteString
input
setLimit :: Int -> State -> State
setLimit :: Int -> State -> State
setLimit Int
limit State
state = State
state { sLimit :: Int
sLimit = Int
limit }
{-# INLINE setLimit #-}
setForbidden :: Maybe Pattern -> State -> State
setForbidden :: Maybe Pattern -> State -> State
setForbidden Maybe Pattern
forbidden State
state = State
state { sForbidden :: Maybe Pattern
sForbidden = Maybe Pattern
forbidden }
{-# INLINE setForbidden #-}
setCode :: Code -> State -> State
setCode :: Code -> State -> State
setCode Code
code State
state = State
state { sCode :: Code
sCode = Code
code }
{-# INLINE setCode #-}
class Match parameter result | parameter -> result where
match :: parameter -> Parser result
instance Match (Parser result) result where
match :: Parser result -> Parser result
match = Parser result -> Parser result
forall a. a -> a
id
instance Match Char () where
match :: Char -> Pattern
match Char
code = (Char -> Bool) -> Pattern
nextIf (Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
code)
instance Match (Char, Char) () where
match :: (Char, Char) -> Pattern
match (Char
low, Char
high) = (Char -> Bool) -> Pattern
nextIf ((Char -> Bool) -> Pattern) -> (Char -> Bool) -> Pattern
forall a b. (a -> b) -> a -> b
$ \ Char
code -> Char
low Char -> Char -> Bool
forall a. Ord a => a -> a -> Bool
<= Char
code Bool -> Bool -> Bool
&& Char
code Char -> Char -> Bool
forall a. Ord a => a -> a -> Bool
<= Char
high
instance Match String () where
match :: String -> Pattern
match = (Char -> Pattern -> Pattern) -> Pattern -> String -> Pattern
forall (t :: * -> *) a b.
Foldable t =>
(a -> b -> b) -> b -> t a -> b
foldr Char -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
(&) Pattern
empty
returnReply :: State -> result -> Reply result
returnReply :: forall result. State -> result -> Reply result
returnReply State
state result
result = Reply { rResult :: Result result
rResult = result -> Result result
forall result. result -> Result result
Result result
result,
rTokens :: DList Token
rTokens = DList Token
forall a. DList a
D.empty,
rCommit :: Maybe Decision
rCommit = Maybe Decision
forall a. Maybe a
Nothing,
rState :: State
rState = State
state }
tokenReply :: State -> Token -> Reply ()
tokenReply :: State -> Token -> Reply ()
tokenReply State
state Token
token = Reply { rResult :: Result ()
rResult = () -> Result ()
forall result. result -> Result result
Result (),
rTokens :: DList Token
rTokens = Token -> DList Token
forall a. a -> DList a
D.singleton Token
token,
rCommit :: Maybe Decision
rCommit = Maybe Decision
forall a. Maybe a
Nothing,
rState :: State
rState = State
state { sCharsByteOffset :: Int
sCharsByteOffset = -Int
1,
sCharsCharOffset :: Int
sCharsCharOffset = -Int
1,
sCharsLine :: Int
sCharsLine = -Int
1,
sCharsLineChar :: Int
sCharsLineChar = -Int
1,
sChars :: String
sChars = [] } }
failReply :: State -> String -> Reply result
failReply :: forall result. State -> String -> Reply result
failReply State
state String
message = Reply { rResult :: Result result
rResult = String -> Result result
forall result. String -> Result result
Failed String
message,
rTokens :: DList Token
rTokens = DList Token
forall a. DList a
D.empty,
rCommit :: Maybe Decision
rCommit = Maybe Decision
forall a. Maybe a
Nothing,
rState :: State
rState = State
state }
unexpectedReply :: State -> Reply result
unexpectedReply :: forall result. State -> Reply result
unexpectedReply State
state = case State
stateState -> (State -> [(Int, Char)]) -> [(Int, Char)]
forall record value. record -> (record -> value) -> value
^.State -> [(Int, Char)]
sInput of
((Int
_, Char
char):[(Int, Char)]
_) -> State -> String -> Reply result
forall result. State -> String -> Reply result
failReply State
state (String -> Reply result) -> String -> Reply result
forall a b. (a -> b) -> a -> b
$ String
"Unexpected '" String -> ShowS
forall a. [a] -> [a] -> [a]
++ [Char
char] String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
"'"
[] -> State -> String -> Reply result
forall result. State -> String -> Reply result
failReply State
state String
"Unexpected end of input"
instance Functor Parser where
fmap :: forall a b. (a -> b) -> Parser a -> Parser b
fmap a -> b
g Parser a
f = (State -> Reply b) -> Parser b
forall result. (State -> Reply result) -> Parser result
Parser ((State -> Reply b) -> Parser b) -> (State -> Reply b) -> Parser b
forall a b. (a -> b) -> a -> b
$ \State
state ->
let reply :: Reply a
reply = Parser a -> State -> Reply a
forall result. Parser result -> State -> Reply result
applyParser Parser a
f State
state
in case Reply a
replyReply a -> (Reply a -> Result a) -> Result a
forall record value. record -> (record -> value) -> value
^.Reply a -> Result a
forall result. Reply result -> Result result
rResult of
Failed String
message -> Reply a
reply { rResult :: Result b
rResult = String -> Result b
forall result. String -> Result result
Failed String
message }
Result a
x -> Reply a
reply { rResult :: Result b
rResult = b -> Result b
forall result. result -> Result result
Result (a -> b
g a
x) }
More Parser a
parser -> Reply a
reply { rResult :: Result b
rResult = Parser b -> Result b
forall result. Parser result -> Result result
More (Parser b -> Result b) -> Parser b -> Result b
forall a b. (a -> b) -> a -> b
$ (a -> b) -> Parser a -> Parser b
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap a -> b
g Parser a
parser }
instance Applicative Parser where
pure :: forall a. a -> Parser a
pure a
result = (State -> Reply a) -> Parser a
forall result. (State -> Reply result) -> Parser result
Parser ((State -> Reply a) -> Parser a) -> (State -> Reply a) -> Parser a
forall a b. (a -> b) -> a -> b
$ \State
state -> State -> a -> Reply a
forall result. State -> result -> Reply result
returnReply State
state a
result
<*> :: forall a b. Parser (a -> b) -> Parser a -> Parser b
(<*>) = Parser (a -> b) -> Parser a -> Parser b
forall (m :: * -> *) a b. Monad m => m (a -> b) -> m a -> m b
ap
Parser a
left *> :: forall a b. Parser a -> Parser b -> Parser b
*> Parser b
right = (State -> Reply b) -> Parser b
forall result. (State -> Reply result) -> Parser result
Parser ((State -> Reply b) -> Parser b) -> (State -> Reply b) -> Parser b
forall a b. (a -> b) -> a -> b
$ \State
state ->
let reply :: Reply a
reply = Parser a -> State -> Reply a
forall result. Parser result -> State -> Reply result
applyParser Parser a
left State
state
in case Reply a
replyReply a -> (Reply a -> Result a) -> Result a
forall record value. record -> (record -> value) -> value
^.Reply a -> Result a
forall result. Reply result -> Result result
rResult of
Failed String
message -> Reply a
reply { rResult :: Result b
rResult = String -> Result b
forall result. String -> Result result
Failed String
message }
Result a
_ -> Reply a
reply { rResult :: Result b
rResult = Parser b -> Result b
forall result. Parser result -> Result result
More Parser b
right }
More Parser a
parser -> Reply a
reply { rResult :: Result b
rResult = Parser b -> Result b
forall result. Parser result -> Result result
More (Parser b -> Result b) -> Parser b -> Result b
forall a b. (a -> b) -> a -> b
$ Parser a
parser Parser a -> Parser b -> Parser b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Parser b
right }
instance Monad Parser where
return :: forall a. a -> Parser a
return = a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure
Parser a
left >>= :: forall a b. Parser a -> (a -> Parser b) -> Parser b
>>= a -> Parser b
right = (State -> Reply b) -> Parser b
forall result. (State -> Reply result) -> Parser result
Parser ((State -> Reply b) -> Parser b) -> (State -> Reply b) -> Parser b
forall a b. (a -> b) -> a -> b
$ \State
state ->
let reply :: Reply a
reply = Parser a -> State -> Reply a
forall result. Parser result -> State -> Reply result
applyParser Parser a
left State
state
in case Reply a
replyReply a -> (Reply a -> Result a) -> Result a
forall record value. record -> (record -> value) -> value
^.Reply a -> Result a
forall result. Reply result -> Result result
rResult of
Failed String
message -> Reply a
reply { rResult :: Result b
rResult = String -> Result b
forall result. String -> Result result
Failed String
message }
Result a
value -> Reply a
reply { rResult :: Result b
rResult = Parser b -> Result b
forall result. Parser result -> Result result
More (Parser b -> Result b) -> Parser b -> Result b
forall a b. (a -> b) -> a -> b
$ a -> Parser b
right a
value }
More Parser a
parser -> Reply a
reply { rResult :: Result b
rResult = Parser b -> Result b
forall result. Parser result -> Result result
More (Parser b -> Result b) -> Parser b -> Result b
forall a b. (a -> b) -> a -> b
$ Parser a
parser Parser a -> (a -> Parser b) -> Parser b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= a -> Parser b
right }
>> :: forall a b. Parser a -> Parser b -> Parser b
(>>) = Parser a -> Parser b -> Parser b
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
(*>)
pfail :: String -> Parser a
pfail :: forall a. String -> Parser a
pfail String
message = (State -> Reply a) -> Parser a
forall result. (State -> Reply result) -> Parser result
Parser ((State -> Reply a) -> Parser a) -> (State -> Reply a) -> Parser a
forall a b. (a -> b) -> a -> b
$ \State
state -> State -> String -> Reply a
forall result. State -> String -> Reply result
failReply State
state String
message
infix 3 ^
infix 3 %
infix 3 <%
infix 3 !
infix 3 ?!
infixl 3 -
infixr 2 &
infixr 1 /
infix 0 ?
infix 0 *
infix 0 +
infix 0 <?
infix 0 >?
infix 0 >!
(%) :: (Match match result) => match -> Int -> Pattern
match
parser % :: forall match result. Match match result => match -> Int -> Pattern
% Int
n
| Int
n Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= Int
0 = Pattern
empty
| Bool
otherwise = Parser result
parser' Parser result -> Pattern -> Pattern
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> (Parser result
parser' Parser result -> Int -> Pattern
forall match result. Match match result => match -> Int -> Pattern
% Int
n Int -> Int -> Int
.- Int
1)
where
parser' :: Parser result
parser' = match -> Parser result
forall parameter result.
Match parameter result =>
parameter -> Parser result
match match
parser
(<%) :: (Match match result) => match -> Int -> Pattern
match
parser <% :: forall match result. Match match result => match -> Int -> Pattern
<% Int
n = case Int
n Int -> Int -> Ordering
forall a. Ord a => a -> a -> Ordering
`compare` Int
1 of
Ordering
LT -> String -> Pattern
forall a. String -> Parser a
pfail String
"Fewer than 0 repetitions"
Ordering
EQ -> match -> Maybe String -> Pattern
forall match result.
Match match result =>
match -> Maybe String -> Pattern
reject match
parser Maybe String
forall a. Maybe a
Nothing
Ordering
GT -> Decision
DeLess Decision -> Pattern -> Pattern
forall match result.
Match match result =>
Decision -> match -> Parser result
^ ( ((match
parser match -> Decision -> Pattern
forall match result.
Match match result =>
match -> Decision -> Pattern
! Decision
DeLess) Pattern -> Pattern -> Pattern
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> (match
parser match -> Int -> Pattern
forall match result. Match match result => match -> Int -> Pattern
<% Int
n Int -> Int -> Int
.- Int
1)) Pattern -> Pattern -> Pattern
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Pattern
empty )
data Decision = DeNone
| DeStar
| DeLess
| DeDirective
| DeDoc
| DeEscape
| DeEscaped
| DeFold
| DeKey
|
| DeMore
| DeNode
| DePair
deriving (Int -> Decision -> ShowS
[Decision] -> ShowS
Decision -> String
(Int -> Decision -> ShowS)
-> (Decision -> String) -> ([Decision] -> ShowS) -> Show Decision
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Decision] -> ShowS
$cshowList :: [Decision] -> ShowS
show :: Decision -> String
$cshow :: Decision -> String
showsPrec :: Int -> Decision -> ShowS
$cshowsPrec :: Int -> Decision -> ShowS
Show,Decision -> Decision -> Bool
(Decision -> Decision -> Bool)
-> (Decision -> Decision -> Bool) -> Eq Decision
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Decision -> Decision -> Bool
$c/= :: Decision -> Decision -> Bool
== :: Decision -> Decision -> Bool
$c== :: Decision -> Decision -> Bool
Eq)
(^) :: (Match match result) => Decision -> match -> Parser result
Decision
decision ^ :: forall match result.
Match match result =>
Decision -> match -> Parser result
^ match
parser = Decision -> Parser result -> Parser result
forall result. Decision -> Parser result -> Parser result
choice Decision
decision (Parser result -> Parser result) -> Parser result -> Parser result
forall a b. (a -> b) -> a -> b
$ match -> Parser result
forall parameter result.
Match parameter result =>
parameter -> Parser result
match match
parser
(!) :: (Match match result) => match -> Decision -> Pattern
match
parser ! :: forall match result.
Match match result =>
match -> Decision -> Pattern
! Decision
decision = match -> Parser result
forall parameter result.
Match parameter result =>
parameter -> Parser result
match match
parser Parser result -> Pattern -> Pattern
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Decision -> Pattern
commit Decision
decision
(?!) :: (Match match result) => match -> Decision -> Pattern
match
parser ?! :: forall match result.
Match match result =>
match -> Decision -> Pattern
?! Decision
decision = match -> Parser result
forall parameter result.
Match parameter result =>
parameter -> Parser result
peek match
parser Parser result -> Pattern -> Pattern
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Decision -> Pattern
commit Decision
decision
(<?) :: (Match match result) => match -> Parser result
<? :: forall parameter result.
Match parameter result =>
parameter -> Parser result
(<?) match
lookbehind = match -> Parser result
forall parameter result.
Match parameter result =>
parameter -> Parser result
prev match
lookbehind
(>?) :: (Match match result) => match -> Parser result
>? :: forall parameter result.
Match parameter result =>
parameter -> Parser result
(>?) match
lookahead = match -> Parser result
forall parameter result.
Match parameter result =>
parameter -> Parser result
peek match
lookahead
(>!) :: (Match match result) => match -> Pattern
>! :: forall match result. Match match result => match -> Pattern
(>!) match
lookahead = match -> Maybe String -> Pattern
forall match result.
Match match result =>
match -> Maybe String -> Pattern
reject match
lookahead Maybe String
forall a. Maybe a
Nothing
(-) :: (Match match1 result1, Match match2 result2) => match1 -> match2 -> Parser result1
match1
parser - :: forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result1
- match2
rejected = match2 -> Maybe String -> Pattern
forall match result.
Match match result =>
match -> Maybe String -> Pattern
reject match2
rejected Maybe String
forall a. Maybe a
Nothing Pattern -> Parser result1 -> Parser result1
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> match1 -> Parser result1
forall parameter result.
Match parameter result =>
parameter -> Parser result
match match1
parser
(&) :: (Match match1 result1, Match match2 result2) => match1 -> match2 -> Parser result2
match1
before & :: forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& match2
after = match1 -> Parser result1
forall parameter result.
Match parameter result =>
parameter -> Parser result
match match1
before Parser result1 -> Parser result2 -> Parser result2
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> match2 -> Parser result2
forall parameter result.
Match parameter result =>
parameter -> Parser result
match match2
after
(/) :: (Match match1 result, Match match2 result) => match1 -> match2 -> Parser result
match1
first / :: forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ match2
second = (State -> Reply result) -> Parser result
forall result. (State -> Reply result) -> Parser result
Parser ((State -> Reply result) -> Parser result)
-> (State -> Reply result) -> Parser result
forall a b. (a -> b) -> a -> b
$ Parser result -> State -> Reply result
forall result. Parser result -> State -> Reply result
applyParser (match1 -> Parser result
forall parameter result.
Match parameter result =>
parameter -> Parser result
match match1
first Parser result -> Parser result -> Parser result
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> match2 -> Parser result
forall parameter result.
Match parameter result =>
parameter -> Parser result
match match2
second)
(?) :: (Match match result) => match -> Pattern
? :: forall match result. Match match result => match -> Pattern
(?) match
optional = (match -> Parser result
forall parameter result.
Match parameter result =>
parameter -> Parser result
match match
optional Parser result -> Pattern -> Pattern
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Pattern
empty) Pattern -> Pattern -> Pattern
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Pattern
empty
(*) :: (Match match result) => match -> Pattern
* :: forall match result. Match match result => match -> Pattern
(*) match
parser = Decision
DeStar Decision -> Pattern -> Pattern
forall match result.
Match match result =>
Decision -> match -> Parser result
^ Pattern
zomParser
where
zomParser :: Pattern
zomParser = ((match
parser match -> Decision -> Pattern
forall match result.
Match match result =>
match -> Decision -> Pattern
! Decision
DeStar) Pattern -> Pattern -> Pattern
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Pattern -> Pattern
forall parameter result.
Match parameter result =>
parameter -> Parser result
match Pattern
zomParser) Pattern -> Pattern -> Pattern
forall (f :: * -> *) a. Alternative f => f a -> f a -> f a
<|> Pattern
empty
(+) :: (Match match result) => match -> Pattern
+ :: forall match result. Match match result => match -> Pattern
(+) match
parser = match -> Parser result
forall parameter result.
Match parameter result =>
parameter -> Parser result
match match
parser Parser result -> Pattern -> Pattern
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> (match
parser *)
instance Alternative Parser where
empty :: forall a. Parser a
empty = String -> Parser a
forall a. String -> Parser a
pfail String
"empty"
Parser a
left <|> :: forall a. Parser a -> Parser a -> Parser a
<|> Parser a
right = (State -> Reply a) -> Parser a
forall result. (State -> Reply result) -> Parser result
Parser ((State -> Reply a) -> Parser a) -> (State -> Reply a) -> Parser a
forall a b. (a -> b) -> a -> b
$ \State
state -> State -> DList Token -> Parser a -> Parser a -> State -> Reply a
forall {result}.
State
-> DList Token
-> Parser result
-> Parser result
-> State
-> Reply result
decideParser State
state DList Token
forall a. DList a
D.empty Parser a
left Parser a
right State
state
where
decideParser :: State
-> DList Token
-> Parser result
-> Parser result
-> State
-> Reply result
decideParser State
point DList Token
tokens Parser result
left Parser result
right State
state =
let reply :: Reply result
reply = Parser result -> State -> Reply result
forall result. Parser result -> State -> Reply result
applyParser Parser result
left State
state
tokens' :: DList Token
tokens' = DList Token -> DList Token -> DList Token
forall a. DList a -> DList a -> DList a
D.append DList Token
tokens (DList Token -> DList Token) -> DList Token -> DList Token
forall a b. (a -> b) -> a -> b
$ Reply result
replyReply result -> (Reply result -> DList Token) -> DList Token
forall record value. record -> (record -> value) -> value
^.Reply result -> DList Token
forall result. Reply result -> DList Token
rTokens
in case (Reply result
replyReply result -> (Reply result -> Result result) -> Result result
forall record value. record -> (record -> value) -> value
^.Reply result -> Result result
forall result. Reply result -> Result result
rResult, Reply result
replyReply result -> (Reply result -> Maybe Decision) -> Maybe Decision
forall record value. record -> (record -> value) -> value
^.Reply result -> Maybe Decision
forall result. Reply result -> Maybe Decision
rCommit) of
(Failed String
_, Maybe Decision
_) -> Reply { rState :: State
rState = State
point,
rTokens :: DList Token
rTokens = DList Token
forall a. DList a
D.empty,
rResult :: Result result
rResult = Parser result -> Result result
forall result. Parser result -> Result result
More Parser result
right,
rCommit :: Maybe Decision
rCommit = Maybe Decision
forall a. Maybe a
Nothing }
(Result result
_, Maybe Decision
_) -> Reply result
reply { rTokens :: DList Token
rTokens = DList Token
tokens' }
(More Parser result
_, Just Decision
_) -> Reply result
reply { rTokens :: DList Token
rTokens = DList Token
tokens' }
(More Parser result
left', Maybe Decision
Nothing) -> State
-> DList Token
-> Parser result
-> Parser result
-> State
-> Reply result
decideParser State
point DList Token
tokens' Parser result
left' Parser result
right (Reply result
replyReply result -> (Reply result -> State) -> State
forall record value. record -> (record -> value) -> value
^.Reply result -> State
forall result. Reply result -> State
rState)
choice :: Decision -> Parser result -> Parser result
choice :: forall result. Decision -> Parser result -> Parser result
choice Decision
decision Parser result
parser = (State -> Reply result) -> Parser result
forall result. (State -> Reply result) -> Parser result
Parser ((State -> Reply result) -> Parser result)
-> (State -> Reply result) -> Parser result
forall a b. (a -> b) -> a -> b
$ \ State
state ->
Parser result -> State -> Reply result
forall result. Parser result -> State -> Reply result
applyParser (Decision -> Decision -> Parser result -> Parser result
forall {result}.
Decision -> Decision -> Parser result -> Parser result
choiceParser (State
stateState -> (State -> Decision) -> Decision
forall record value. record -> (record -> value) -> value
^.State -> Decision
sDecision) Decision
decision Parser result
parser) State
state { sDecision :: Decision
sDecision = Decision
decision }
where choiceParser :: Decision -> Decision -> Parser result -> Parser result
choiceParser Decision
parentDecision Decision
makingDecision Parser result
parser = (State -> Reply result) -> Parser result
forall result. (State -> Reply result) -> Parser result
Parser ((State -> Reply result) -> Parser result)
-> (State -> Reply result) -> Parser result
forall a b. (a -> b) -> a -> b
$ \ State
state ->
let reply :: Reply result
reply = Parser result -> State -> Reply result
forall result. Parser result -> State -> Reply result
applyParser Parser result
parser State
state
commit' :: Maybe Decision
commit' = case Reply result
replyReply result -> (Reply result -> Maybe Decision) -> Maybe Decision
forall record value. record -> (record -> value) -> value
^.Reply result -> Maybe Decision
forall result. Reply result -> Maybe Decision
rCommit of
Maybe Decision
Nothing -> Maybe Decision
forall a. Maybe a
Nothing
Just Decision
decision | Decision
decision Decision -> Decision -> Bool
forall a. Eq a => a -> a -> Bool
== Decision
makingDecision -> Maybe Decision
forall a. Maybe a
Nothing
| Bool
otherwise -> Reply result
replyReply result -> (Reply result -> Maybe Decision) -> Maybe Decision
forall record value. record -> (record -> value) -> value
^.Reply result -> Maybe Decision
forall result. Reply result -> Maybe Decision
rCommit
reply' :: Reply result
reply' = case Reply result
replyReply result -> (Reply result -> Result result) -> Result result
forall record value. record -> (record -> value) -> value
^.Reply result -> Result result
forall result. Reply result -> Result result
rResult of
More Parser result
parser' -> Reply result
reply { rCommit :: Maybe Decision
rCommit = Maybe Decision
commit',
rResult :: Result result
rResult = Parser result -> Result result
forall result. Parser result -> Result result
More (Parser result -> Result result) -> Parser result -> Result result
forall a b. (a -> b) -> a -> b
$ Decision -> Decision -> Parser result -> Parser result
choiceParser Decision
parentDecision Decision
makingDecision Parser result
parser' }
Result result
_ -> Reply result
reply { rCommit :: Maybe Decision
rCommit = Maybe Decision
commit',
rState :: State
rState = (Reply result
replyReply result -> (Reply result -> State) -> State
forall record value. record -> (record -> value) -> value
^.Reply result -> State
forall result. Reply result -> State
rState) { sDecision :: Decision
sDecision = Decision
parentDecision } }
in Reply result
reply'
recovery :: (Match match1 result) => match1 -> Parser result -> Parser result
recovery :: forall match1 result.
Match match1 result =>
match1 -> Parser result -> Parser result
recovery match1
pattern Parser result
recover =
(State -> Reply result) -> Parser result
forall result. (State -> Reply result) -> Parser result
Parser ((State -> Reply result) -> Parser result)
-> (State -> Reply result) -> Parser result
forall a b. (a -> b) -> a -> b
$ \ State
state ->
let reply :: Reply result
reply = Parser result -> State -> Reply result
forall result. Parser result -> State -> Reply result
applyParser (match1 -> Parser result
forall parameter result.
Match parameter result =>
parameter -> Parser result
match match1
pattern) State
state
in if State
stateState -> (State -> Bool) -> Bool
forall record value. record -> (record -> value) -> value
^.State -> Bool
sIsPeek
then Reply result
reply
else case Reply result
replyReply result -> (Reply result -> Result result) -> Result result
forall record value. record -> (record -> value) -> value
^.Reply result -> Result result
forall result. Reply result -> Result result
rResult of
Result result
_ -> Reply result
reply
More Parser result
more -> Reply result
reply { rResult :: Result result
rResult = Parser result -> Result result
forall result. Parser result -> Result result
More (Parser result -> Result result) -> Parser result -> Result result
forall a b. (a -> b) -> a -> b
$ Parser result
more Parser result -> Parser result -> Parser result
forall match1 result.
Match match1 result =>
match1 -> Parser result -> Parser result
`recovery` Parser result
recover }
Failed String
message -> Reply result
reply { rResult :: Result result
rResult = Parser result -> Result result
forall result. Parser result -> Result result
More (Parser result -> Result result) -> Parser result -> Result result
forall a b. (a -> b) -> a -> b
$ Code -> String -> Pattern
fake Code
Error String
message Pattern -> Pattern -> Pattern
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Pattern
unparsed Pattern -> Parser result -> Parser result
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Parser result
recover }
where unparsed :: Pattern
unparsed = (State -> Reply ()) -> Pattern
forall result. (State -> Reply result) -> Parser result
Parser ((State -> Reply ()) -> Pattern) -> (State -> Reply ()) -> Pattern
forall a b. (a -> b) -> a -> b
$ \ State
state -> Pattern -> State -> Reply ()
forall result. Parser result -> State -> Reply result
applyParser (Pattern -> Pattern
forall parameter result.
Match parameter result =>
parameter -> Parser result
match Pattern
finishToken) (State -> Reply ()) -> State -> Reply ()
forall a b. (a -> b) -> a -> b
$ State
state { sCode :: Code
sCode = Code
Unparsed }
prev :: (Match match result) => match -> Parser result
prev :: forall parameter result.
Match parameter result =>
parameter -> Parser result
prev match
parser = (State -> Reply result) -> Parser result
forall result. (State -> Reply result) -> Parser result
Parser ((State -> Reply result) -> Parser result)
-> (State -> Reply result) -> Parser result
forall a b. (a -> b) -> a -> b
$ \ State
state ->
State -> Parser result -> State -> Reply result
forall {result}. State -> Parser result -> State -> Reply result
prevParser State
state (match -> Parser result
forall parameter result.
Match parameter result =>
parameter -> Parser result
match match
parser) State
state { sIsPeek :: Bool
sIsPeek = Bool
True, sInput :: [(Int, Char)]
sInput = (-Int
1, State
stateState -> (State -> Char) -> Char
forall record value. record -> (record -> value) -> value
^.State -> Char
sLast) (Int, Char) -> [(Int, Char)] -> [(Int, Char)]
forall a. a -> [a] -> [a]
: State
stateState -> (State -> [(Int, Char)]) -> [(Int, Char)]
forall record value. record -> (record -> value) -> value
^.State -> [(Int, Char)]
sInput }
where prevParser :: State -> Parser result -> State -> Reply result
prevParser State
point Parser result
parser State
state =
let reply :: Reply result
reply = Parser result -> State -> Reply result
forall result. Parser result -> State -> Reply result
applyParser Parser result
parser State
state
in case Reply result
replyReply result -> (Reply result -> Result result) -> Result result
forall record value. record -> (record -> value) -> value
^.Reply result -> Result result
forall result. Reply result -> Result result
rResult of
Failed String
message -> State -> String -> Reply result
forall result. State -> String -> Reply result
failReply State
point String
message
Result result
value -> State -> result -> Reply result
forall result. State -> result -> Reply result
returnReply State
point result
value
More Parser result
parser' -> State -> Parser result -> State -> Reply result
prevParser State
point Parser result
parser' (State -> Reply result) -> State -> Reply result
forall a b. (a -> b) -> a -> b
$ Reply result
replyReply result -> (Reply result -> State) -> State
forall record value. record -> (record -> value) -> value
^.Reply result -> State
forall result. Reply result -> State
rState
peek :: (Match match result) => match -> Parser result
peek :: forall parameter result.
Match parameter result =>
parameter -> Parser result
peek match
parser = (State -> Reply result) -> Parser result
forall result. (State -> Reply result) -> Parser result
Parser ((State -> Reply result) -> Parser result)
-> (State -> Reply result) -> Parser result
forall a b. (a -> b) -> a -> b
$ \ State
state ->
State -> Parser result -> State -> Reply result
forall {result}. State -> Parser result -> State -> Reply result
peekParser State
state (match -> Parser result
forall parameter result.
Match parameter result =>
parameter -> Parser result
match match
parser) State
state { sIsPeek :: Bool
sIsPeek = Bool
True }
where peekParser :: State -> Parser result -> State -> Reply result
peekParser State
point Parser result
parser State
state =
let reply :: Reply result
reply = Parser result -> State -> Reply result
forall result. Parser result -> State -> Reply result
applyParser Parser result
parser State
state
in case Reply result
replyReply result -> (Reply result -> Result result) -> Result result
forall record value. record -> (record -> value) -> value
^.Reply result -> Result result
forall result. Reply result -> Result result
rResult of
Failed String
message -> State -> String -> Reply result
forall result. State -> String -> Reply result
failReply State
point String
message
Result result
value -> State -> result -> Reply result
forall result. State -> result -> Reply result
returnReply State
point result
value
More Parser result
parser' -> State -> Parser result -> State -> Reply result
peekParser State
point Parser result
parser' (State -> Reply result) -> State -> Reply result
forall a b. (a -> b) -> a -> b
$ Reply result
replyReply result -> (Reply result -> State) -> State
forall record value. record -> (record -> value) -> value
^.Reply result -> State
forall result. Reply result -> State
rState
reject :: (Match match result) => match -> Maybe String -> Pattern
reject :: forall match result.
Match match result =>
match -> Maybe String -> Pattern
reject match
parser Maybe String
name = (State -> Reply ()) -> Pattern
forall result. (State -> Reply result) -> Parser result
Parser ((State -> Reply ()) -> Pattern) -> (State -> Reply ()) -> Pattern
forall a b. (a -> b) -> a -> b
$ \ State
state ->
State -> Maybe String -> Parser result -> State -> Reply ()
forall {result}.
State -> Maybe String -> Parser result -> State -> Reply ()
rejectParser State
state Maybe String
name (match -> Parser result
forall parameter result.
Match parameter result =>
parameter -> Parser result
match match
parser) State
state { sIsPeek :: Bool
sIsPeek = Bool
True }
where
rejectParser :: State -> Maybe String -> Parser result -> State -> Reply ()
rejectParser State
point Maybe String
name Parser result
parser State
state =
let reply :: Reply result
reply = Parser result -> State -> Reply result
forall result. Parser result -> State -> Reply result
applyParser Parser result
parser State
state
in case Reply result
replyReply result -> (Reply result -> Result result) -> Result result
forall record value. record -> (record -> value) -> value
^.Reply result -> Result result
forall result. Reply result -> Result result
rResult of
Failed String
_message -> State -> () -> Reply ()
forall result. State -> result -> Reply result
returnReply State
point ()
Result result
_value -> case Maybe String
name of
Maybe String
Nothing -> State -> Reply ()
forall result. State -> Reply result
unexpectedReply State
point
Just String
text -> State -> String -> Reply ()
forall result. State -> String -> Reply result
failReply State
point (String -> Reply ()) -> String -> Reply ()
forall a b. (a -> b) -> a -> b
$ String
"Unexpected " String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
text
More Parser result
parser' -> State -> Maybe String -> Parser result -> State -> Reply ()
rejectParser State
point Maybe String
name Parser result
parser' (State -> Reply ()) -> State -> Reply ()
forall a b. (a -> b) -> a -> b
$ Reply result
replyReply result -> (Reply result -> State) -> State
forall record value. record -> (record -> value) -> value
^.Reply result -> State
forall result. Reply result -> State
rState
upto :: Pattern -> Pattern
upto :: Pattern -> Pattern
upto Pattern
parser = ( ( Pattern
parser >!) Pattern -> Pattern -> Pattern
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> (Char -> Bool) -> Pattern
nextIf (Bool -> Char -> Bool
forall a b. a -> b -> a
const Bool
True) *)
nonEmpty :: (Match match result) => match -> Parser result
nonEmpty :: forall parameter result.
Match parameter result =>
parameter -> Parser result
nonEmpty match
parser = (State -> Reply result) -> Parser result
forall result. (State -> Reply result) -> Parser result
Parser ((State -> Reply result) -> Parser result)
-> (State -> Reply result) -> Parser result
forall a b. (a -> b) -> a -> b
$ \ State
state ->
Parser result -> State -> Reply result
forall result. Parser result -> State -> Reply result
applyParser (Int -> Parser result -> Parser result
forall {result}. Int -> Parser result -> Parser result
nonEmptyParser (State
stateState -> (State -> Int) -> Int
forall record value. record -> (record -> value) -> value
^.State -> Int
sCharOffset) (match -> Parser result
forall parameter result.
Match parameter result =>
parameter -> Parser result
match match
parser)) State
state
where
nonEmptyParser :: Int -> Parser result -> Parser result
nonEmptyParser Int
offset Parser result
parser = (State -> Reply result) -> Parser result
forall result. (State -> Reply result) -> Parser result
Parser ((State -> Reply result) -> Parser result)
-> (State -> Reply result) -> Parser result
forall a b. (a -> b) -> a -> b
$ \ State
state ->
let reply :: Reply result
reply = Parser result -> State -> Reply result
forall result. Parser result -> State -> Reply result
applyParser Parser result
parser State
state
state' :: State
state' = Reply result
replyReply result -> (Reply result -> State) -> State
forall record value. record -> (record -> value) -> value
^.Reply result -> State
forall result. Reply result -> State
rState
in case Reply result
replyReply result -> (Reply result -> Result result) -> Result result
forall record value. record -> (record -> value) -> value
^.Reply result -> Result result
forall result. Reply result -> Result result
rResult of
Failed String
_message -> Reply result
reply
Result result
_value -> if State
state'State -> (State -> Int) -> Int
forall record value. record -> (record -> value) -> value
^.State -> Int
sCharOffset Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
> Int
offset
then Reply result
reply
else State -> String -> Reply result
forall result. State -> String -> Reply result
failReply State
state' String
"Matched empty pattern"
More Parser result
parser' -> Reply result
reply { rResult :: Result result
rResult = Parser result -> Result result
forall result. Parser result -> Result result
More (Parser result -> Result result) -> Parser result -> Result result
forall a b. (a -> b) -> a -> b
$ Int -> Parser result -> Parser result
nonEmptyParser Int
offset Parser result
parser' }
empty :: Pattern
empty :: Pattern
empty = () -> Pattern
forall (m :: * -> *) a. Monad m => a -> m a
return ()
eof :: Pattern
eof :: Pattern
eof = (State -> Reply ()) -> Pattern
forall result. (State -> Reply result) -> Parser result
Parser ((State -> Reply ()) -> Pattern) -> (State -> Reply ()) -> Pattern
forall a b. (a -> b) -> a -> b
$ \ State
state ->
if [(Int, Char)] -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null (State
stateState -> (State -> [(Int, Char)]) -> [(Int, Char)]
forall record value. record -> (record -> value) -> value
^.State -> [(Int, Char)]
sInput)
then State -> () -> Reply ()
forall result. State -> result -> Reply result
returnReply State
state ()
else State -> Reply ()
forall result. State -> Reply result
unexpectedReply State
state
sol :: Pattern
sol :: Pattern
sol = (State -> Reply ()) -> Pattern
forall result. (State -> Reply result) -> Parser result
Parser ((State -> Reply ()) -> Pattern) -> (State -> Reply ()) -> Pattern
forall a b. (a -> b) -> a -> b
$ \ State
state ->
if State
stateState -> (State -> Bool) -> Bool
forall record value. record -> (record -> value) -> value
^.State -> Bool
sIsSol
then State -> () -> Reply ()
forall result. State -> result -> Reply result
returnReply State
state ()
else State -> String -> Reply ()
forall result. State -> String -> Reply result
failReply State
state String
"Expected start of line"
commit :: Decision -> Pattern
commit :: Decision -> Pattern
commit Decision
decision = (State -> Reply ()) -> Pattern
forall result. (State -> Reply result) -> Parser result
Parser ((State -> Reply ()) -> Pattern) -> (State -> Reply ()) -> Pattern
forall a b. (a -> b) -> a -> b
$ \ State
state ->
Reply { rState :: State
rState = State
state,
rTokens :: DList Token
rTokens = DList Token
forall a. DList a
D.empty,
rResult :: Result ()
rResult = () -> Result ()
forall result. result -> Result result
Result (),
rCommit :: Maybe Decision
rCommit = Decision -> Maybe Decision
forall a. a -> Maybe a
Just Decision
decision }
nextLine :: Pattern
nextLine :: Pattern
nextLine = (State -> Reply ()) -> Pattern
forall result. (State -> Reply result) -> Parser result
Parser ((State -> Reply ()) -> Pattern) -> (State -> Reply ()) -> Pattern
forall a b. (a -> b) -> a -> b
$ \ State
state ->
State -> () -> Reply ()
forall result. State -> result -> Reply result
returnReply State
state { sIsSol :: Bool
sIsSol = Bool
True,
sLine :: Int
sLine = State
stateState -> (State -> Int) -> Int
forall record value. record -> (record -> value) -> value
^.State -> Int
sLine Int -> Int -> Int
.+ Int
1,
sLineChar :: Int
sLineChar = Int
0 }
()
with :: (value -> State -> State) -> (State -> value) -> value -> Parser result -> Parser result
with :: forall value result.
(value -> State -> State)
-> (State -> value) -> value -> Parser result -> Parser result
with value -> State -> State
setField State -> value
getField value
value Parser result
parser = (State -> Reply result) -> Parser result
forall result. (State -> Reply result) -> Parser result
Parser ((State -> Reply result) -> Parser result)
-> (State -> Reply result) -> Parser result
forall a b. (a -> b) -> a -> b
$ \ State
state ->
let value' :: value
value' = State -> value
getField State
state
Parser State -> Reply result
parser' = value
value' value -> Parser result -> Parser result
`seq` value -> Parser result -> Parser result
forall {result}. value -> Parser result -> Parser result
withParser value
value' Parser result
parser
in State -> Reply result
parser' (State -> Reply result) -> State -> Reply result
forall a b. (a -> b) -> a -> b
$ value -> State -> State
setField value
value State
state
where
withParser :: value -> Parser result -> Parser result
withParser value
parentValue Parser result
parser = (State -> Reply result) -> Parser result
forall result. (State -> Reply result) -> Parser result
Parser ((State -> Reply result) -> Parser result)
-> (State -> Reply result) -> Parser result
forall a b. (a -> b) -> a -> b
$ \ State
state ->
let reply :: Reply result
reply = Parser result -> State -> Reply result
forall result. Parser result -> State -> Reply result
applyParser Parser result
parser State
state
in case Reply result
replyReply result -> (Reply result -> Result result) -> Result result
forall record value. record -> (record -> value) -> value
^.Reply result -> Result result
forall result. Reply result -> Result result
rResult of
Failed String
_ -> Reply result
reply { rState :: State
rState = value -> State -> State
setField value
parentValue (State -> State) -> State -> State
forall a b. (a -> b) -> a -> b
$ Reply result
replyReply result -> (Reply result -> State) -> State
forall record value. record -> (record -> value) -> value
^.Reply result -> State
forall result. Reply result -> State
rState }
Result result
_ -> Reply result
reply { rState :: State
rState = value -> State -> State
setField value
parentValue (State -> State) -> State -> State
forall a b. (a -> b) -> a -> b
$ Reply result
replyReply result -> (Reply result -> State) -> State
forall record value. record -> (record -> value) -> value
^.Reply result -> State
forall result. Reply result -> State
rState }
More Parser result
parser' -> Reply result
reply { rResult :: Result result
rResult = Parser result -> Result result
forall result. Parser result -> Result result
More (Parser result -> Result result) -> Parser result -> Result result
forall a b. (a -> b) -> a -> b
$ value -> Parser result -> Parser result
withParser value
parentValue Parser result
parser' }
{-# INLINE with #-}
forbidding :: (Match match1 result1) => match1 -> Parser result1 -> Parser result1
forbidding :: forall match1 result.
Match match1 result =>
match1 -> Parser result -> Parser result
forbidding match1
parser Parser result1
forbidden = (Maybe Pattern -> State -> State)
-> (State -> Maybe Pattern)
-> Maybe Pattern
-> Parser result1
-> Parser result1
forall value result.
(value -> State -> State)
-> (State -> value) -> value -> Parser result -> Parser result
with Maybe Pattern -> State -> State
setForbidden State -> Maybe Pattern
sForbidden (Pattern -> Maybe Pattern
forall a. a -> Maybe a
Just (Pattern -> Maybe Pattern) -> Pattern -> Maybe Pattern
forall a b. (a -> b) -> a -> b
$ Parser result1
forbidden Parser result1 -> Pattern -> Pattern
forall (f :: * -> *) a b. Applicative f => f a -> f b -> f b
*> Pattern
empty) (match1 -> Parser result1
forall parameter result.
Match parameter result =>
parameter -> Parser result
match match1
parser)
limitedTo :: (Match match result) => match -> Int -> Parser result
limitedTo :: forall match result.
Match match result =>
match -> Int -> Parser result
limitedTo match
parser Int
limit = (Int -> State -> State)
-> (State -> Int) -> Int -> Parser result -> Parser result
forall value result.
(value -> State -> State)
-> (State -> value) -> value -> Parser result -> Parser result
with Int -> State -> State
setLimit State -> Int
sLimit Int
limit (match -> Parser result
forall parameter result.
Match parameter result =>
parameter -> Parser result
match match
parser)
nextIf :: (Char -> Bool) -> Pattern
nextIf :: (Char -> Bool) -> Pattern
nextIf Char -> Bool
test = (State -> Reply ()) -> Pattern
forall result. (State -> Reply result) -> Parser result
Parser ((State -> Reply ()) -> Pattern) -> (State -> Reply ()) -> Pattern
forall a b. (a -> b) -> a -> b
$ \ State
state ->
case State
stateState -> (State -> Maybe Pattern) -> Maybe Pattern
forall record value. record -> (record -> value) -> value
^.State -> Maybe Pattern
sForbidden of
Maybe Pattern
Nothing -> State -> Reply ()
limitedNextIf State
state
Just Pattern
parser -> let reply :: Reply ()
reply = Pattern -> State -> Reply ()
forall result. Parser result -> State -> Reply result
applyParser (Pattern -> Maybe String -> Pattern
forall match result.
Match match result =>
match -> Maybe String -> Pattern
reject Pattern
parser (Maybe String -> Pattern) -> Maybe String -> Pattern
forall a b. (a -> b) -> a -> b
$ String -> Maybe String
forall a. a -> Maybe a
Just String
"forbidden pattern") State
state { sForbidden :: Maybe Pattern
sForbidden = Maybe Pattern
forall a. Maybe a
Nothing }
in case Reply ()
replyReply () -> (Reply () -> Result ()) -> Result ()
forall record value. record -> (record -> value) -> value
^.Reply () -> Result ()
forall result. Reply result -> Result result
rResult of
Failed String
_ -> Reply ()
reply
Result ()
_ -> State -> Reply ()
limitedNextIf State
state
More Pattern
_ -> String -> Reply ()
forall a. HasCallStack => String -> a
error String
"unexpected Result More _ pattern"
where
limitedNextIf :: State -> Reply ()
limitedNextIf State
state =
case State
stateState -> (State -> Int) -> Int
forall record value. record -> (record -> value) -> value
^.State -> Int
sLimit of
-1 -> State -> Reply ()
consumeNextIf State
state
Int
0 -> State -> String -> Reply ()
forall result. State -> String -> Reply result
failReply State
state String
"Lookahead limit reached"
Int
_limit -> State -> Reply ()
consumeNextIf State
state { sLimit :: Int
sLimit = State
stateState -> (State -> Int) -> Int
forall record value. record -> (record -> value) -> value
^.State -> Int
sLimit Int -> Int -> Int
.- Int
1 }
consumeNextIf :: State -> Reply ()
consumeNextIf State
state =
case State
stateState -> (State -> [(Int, Char)]) -> [(Int, Char)]
forall record value. record -> (record -> value) -> value
^.State -> [(Int, Char)]
sInput of
((Int
offset, Char
char):[(Int, Char)]
rest) | Char -> Bool
test Char
char -> let chars :: String
chars = if State
stateState -> (State -> Bool) -> Bool
forall record value. record -> (record -> value) -> value
^.State -> Bool
sIsPeek then [] else Char
charChar -> ShowS
forall a. a -> [a] -> [a]
:(State
stateState -> (State -> String) -> String
forall record value. record -> (record -> value) -> value
^.State -> String
sChars)
byte_offset :: Int
byte_offset = (State -> Int) -> (State -> Int) -> Int
forall {a}. Num a => (State -> a) -> (State -> a) -> a
charsOf State -> Int
sByteOffset State -> Int
sCharsByteOffset
char_offset :: Int
char_offset = (State -> Int) -> (State -> Int) -> Int
forall {a}. Num a => (State -> a) -> (State -> a) -> a
charsOf State -> Int
sCharOffset State -> Int
sCharsCharOffset
line :: Int
line = (State -> Int) -> (State -> Int) -> Int
forall {a}. Num a => (State -> a) -> (State -> a) -> a
charsOf State -> Int
sLine State -> Int
sCharsLine
line_char :: Int
line_char = (State -> Int) -> (State -> Int) -> Int
forall {a}. Num a => (State -> a) -> (State -> a) -> a
charsOf State -> Int
sLineChar State -> Int
sCharsLineChar
is_sol :: Bool
is_sol = Char
char Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== Char
'\xFEFF' Bool -> Bool -> Bool
&& State
stateState -> (State -> Bool) -> Bool
forall record value. record -> (record -> value) -> value
^.State -> Bool
sIsSol
state' :: State
state' = State
state { sInput :: [(Int, Char)]
sInput = [(Int, Char)]
rest,
sLast :: Char
sLast = Char
char,
sChars :: String
sChars = String
chars,
sCharsByteOffset :: Int
sCharsByteOffset = Int
byte_offset,
sCharsCharOffset :: Int
sCharsCharOffset = Int
char_offset,
sCharsLine :: Int
sCharsLine = Int
line,
sCharsLineChar :: Int
sCharsLineChar = Int
line_char,
sIsSol :: Bool
sIsSol = Bool
is_sol,
sByteOffset :: Int
sByteOffset = Int
offset,
sCharOffset :: Int
sCharOffset = State
stateState -> (State -> Int) -> Int
forall record value. record -> (record -> value) -> value
^.State -> Int
sCharOffset Int -> Int -> Int
.+ Int
1,
sLineChar :: Int
sLineChar = State
stateState -> (State -> Int) -> Int
forall record value. record -> (record -> value) -> value
^.State -> Int
sLineChar Int -> Int -> Int
.+ Int
1 }
in State -> () -> Reply ()
forall result. State -> result -> Reply result
returnReply State
state' ()
| Bool
otherwise -> State -> Reply ()
forall result. State -> Reply result
unexpectedReply State
state
[] -> State -> Reply ()
forall result. State -> Reply result
unexpectedReply State
state
where
charsOf :: (State -> a) -> (State -> a) -> a
charsOf State -> a
field State -> a
charsField
| State
stateState -> (State -> Bool) -> Bool
forall record value. record -> (record -> value) -> value
^.State -> Bool
sIsPeek = -a
1
| String -> Bool
forall (t :: * -> *) a. Foldable t => t a -> Bool
null (State
stateState -> (State -> String) -> String
forall record value. record -> (record -> value) -> value
^.State -> String
sChars) = State
stateState -> (State -> a) -> a
forall record value. record -> (record -> value) -> value
^.State -> a
field
| Bool
otherwise = State
stateState -> (State -> a) -> a
forall record value. record -> (record -> value) -> value
^.State -> a
charsField
finishToken :: Pattern
finishToken :: Pattern
finishToken = (State -> Reply ()) -> Pattern
forall result. (State -> Reply result) -> Parser result
Parser ((State -> Reply ()) -> Pattern) -> (State -> Reply ()) -> Pattern
forall a b. (a -> b) -> a -> b
$ \ State
state ->
let state' :: State
state' = State
state { sChars :: String
sChars = [],
sCharsByteOffset :: Int
sCharsByteOffset = -Int
1,
sCharsCharOffset :: Int
sCharsCharOffset = -Int
1,
sCharsLine :: Int
sCharsLine = -Int
1,
sCharsLineChar :: Int
sCharsLineChar = -Int
1 }
in if State
stateState -> (State -> Bool) -> Bool
forall record value. record -> (record -> value) -> value
^.State -> Bool
sIsPeek
then State -> () -> Reply ()
forall result. State -> result -> Reply result
returnReply State
state' ()
else case State
stateState -> (State -> String) -> String
forall record value. record -> (record -> value) -> value
^.State -> String
sChars of
[] -> State -> () -> Reply ()
forall result. State -> result -> Reply result
returnReply State
state' ()
chars :: String
chars@(Char
_:String
_) -> State -> Token -> Reply ()
tokenReply State
state' Token { tByteOffset :: Int
tByteOffset = State
stateState -> (State -> Int) -> Int
forall record value. record -> (record -> value) -> value
^.State -> Int
sCharsByteOffset,
tCharOffset :: Int
tCharOffset = State
stateState -> (State -> Int) -> Int
forall record value. record -> (record -> value) -> value
^.State -> Int
sCharsCharOffset,
tLine :: Int
tLine = State
stateState -> (State -> Int) -> Int
forall record value. record -> (record -> value) -> value
^.State -> Int
sCharsLine,
tLineChar :: Int
tLineChar = State
stateState -> (State -> Int) -> Int
forall record value. record -> (record -> value) -> value
^.State -> Int
sCharsLineChar,
tCode :: Code
tCode = State
stateState -> (State -> Code) -> Code
forall record value. record -> (record -> value) -> value
^.State -> Code
sCode,
tText :: String
tText = ShowS
forall a. [a] -> [a]
reverse String
chars }
wrap :: (Match match result) => match -> Parser result
wrap :: forall parameter result.
Match parameter result =>
parameter -> Parser result
wrap match
parser = do result
result <- match -> Parser result
forall parameter result.
Match parameter result =>
parameter -> Parser result
match match
parser
Pattern
finishToken
Pattern
eof
result -> Parser result
forall (m :: * -> *) a. Monad m => a -> m a
return result
result
token :: (Match match result) => Code -> match -> Pattern
token :: forall match result. Match match result => Code -> match -> Pattern
token Code
code match
parser = Pattern
finishToken Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& (Code -> State -> State)
-> (State -> Code) -> Code -> Pattern -> Pattern
forall value result.
(value -> State -> State)
-> (State -> value) -> value -> Parser result -> Parser result
with Code -> State -> State
setCode State -> Code
sCode Code
code (match
parser match -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Pattern
finishToken)
fake :: Code -> String -> Pattern
fake :: Code -> String -> Pattern
fake Code
code String
text = (State -> Reply ()) -> Pattern
forall result. (State -> Reply result) -> Parser result
Parser ((State -> Reply ()) -> Pattern) -> (State -> Reply ()) -> Pattern
forall a b. (a -> b) -> a -> b
$ \ State
state ->
if State
stateState -> (State -> Bool) -> Bool
forall record value. record -> (record -> value) -> value
^.State -> Bool
sIsPeek
then State -> () -> Reply ()
forall result. State -> result -> Reply result
returnReply State
state ()
else State -> Token -> Reply ()
tokenReply State
state Token { tByteOffset :: Int
tByteOffset = State -> (State -> Int) -> (State -> Int) -> Int
forall {t} {t}. (Eq t, Num t) => t -> (t -> t) -> (t -> t) -> t
value State
state State -> Int
sByteOffset State -> Int
sCharsByteOffset,
tCharOffset :: Int
tCharOffset = State -> (State -> Int) -> (State -> Int) -> Int
forall {t} {t}. (Eq t, Num t) => t -> (t -> t) -> (t -> t) -> t
value State
state State -> Int
sCharOffset State -> Int
sCharsCharOffset,
tLine :: Int
tLine = State -> (State -> Int) -> (State -> Int) -> Int
forall {t} {t}. (Eq t, Num t) => t -> (t -> t) -> (t -> t) -> t
value State
state State -> Int
sLine State -> Int
sCharsLine,
tLineChar :: Int
tLineChar = State -> (State -> Int) -> (State -> Int) -> Int
forall {t} {t}. (Eq t, Num t) => t -> (t -> t) -> (t -> t) -> t
value State
state State -> Int
sLineChar State -> Int
sCharsLineChar,
tCode :: Code
tCode = Code
code,
tText :: String
tText = String
text }
where value :: t -> (t -> t) -> (t -> t) -> t
value t
state t -> t
field1 t -> t
field2 =
if t -> t
field2 t
state t -> t -> Bool
forall a. Eq a => a -> a -> Bool
== -t
1
then t -> t
field1 t
state
else t -> t
field2 t
state
meta :: (Match match result) => match -> Pattern
meta :: forall match result. Match match result => match -> Pattern
meta match
parser = Code -> match -> Pattern
forall match result. Match match result => Code -> match -> Pattern
token Code
Meta match
parser
indicator :: (Match match result) => match -> Pattern
indicator :: forall match result. Match match result => match -> Pattern
indicator match
parser = Code -> match -> Pattern
forall match result. Match match result => Code -> match -> Pattern
token Code
Indicator (match -> Pattern) -> match -> Pattern
forall a b. (a -> b) -> a -> b
$ match
parser
text :: (Match match result) => match -> Pattern
text :: forall match result. Match match result => match -> Pattern
text match
parser = Code -> match -> Pattern
forall match result. Match match result => Code -> match -> Pattern
token Code
Text match
parser
emptyToken :: Code -> Pattern
emptyToken :: Code -> Pattern
emptyToken Code
code = Pattern
finishToken Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Code -> Pattern
parser Code
code
where parser :: Code -> Pattern
parser Code
code = (State -> Reply ()) -> Pattern
forall result. (State -> Reply result) -> Parser result
Parser ((State -> Reply ()) -> Pattern) -> (State -> Reply ()) -> Pattern
forall a b. (a -> b) -> a -> b
$ \ State
state ->
if State
stateState -> (State -> Bool) -> Bool
forall record value. record -> (record -> value) -> value
^.State -> Bool
sIsPeek
then State -> () -> Reply ()
forall result. State -> result -> Reply result
returnReply State
state ()
else State -> Token -> Reply ()
tokenReply State
state Token { tByteOffset :: Int
tByteOffset = State
stateState -> (State -> Int) -> Int
forall record value. record -> (record -> value) -> value
^.State -> Int
sByteOffset,
tCharOffset :: Int
tCharOffset = State
stateState -> (State -> Int) -> Int
forall record value. record -> (record -> value) -> value
^.State -> Int
sCharOffset,
tLine :: Int
tLine = State
stateState -> (State -> Int) -> Int
forall record value. record -> (record -> value) -> value
^.State -> Int
sLine,
tLineChar :: Int
tLineChar = State
stateState -> (State -> Int) -> Int
forall record value. record -> (record -> value) -> value
^.State -> Int
sLineChar,
tCode :: Code
tCode = Code
code,
tText :: String
tText = String
"" }
wrapTokens :: Code -> Code -> Pattern -> Pattern
wrapTokens :: Code -> Code -> Pattern -> Pattern
wrapTokens Code
beginCode Code
endCode Pattern
pattern = Code -> Pattern
emptyToken Code
beginCode
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Pattern -> Pattern -> Pattern
forall match result.
Match match result =>
match -> Pattern -> Parser result
prefixErrorWith Pattern
pattern (Code -> Pattern
emptyToken Code
endCode)
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Code -> Pattern
emptyToken Code
endCode
prefixErrorWith :: (Match match result) => match -> Pattern -> Parser result
prefixErrorWith :: forall match result.
Match match result =>
match -> Pattern -> Parser result
prefixErrorWith match
pattern Pattern
prefix =
(State -> Reply result) -> Parser result
forall result. (State -> Reply result) -> Parser result
Parser ((State -> Reply result) -> Parser result)
-> (State -> Reply result) -> Parser result
forall a b. (a -> b) -> a -> b
$ \ State
state ->
let reply :: Reply result
reply = Parser result -> State -> Reply result
forall result. Parser result -> State -> Reply result
applyParser (match -> Parser result
forall parameter result.
Match parameter result =>
parameter -> Parser result
match match
pattern) State
state
in case Reply result
replyReply result -> (Reply result -> Result result) -> Result result
forall record value. record -> (record -> value) -> value
^.Reply result -> Result result
forall result. Reply result -> Result result
rResult of
Result result
_ -> Reply result
reply
More Parser result
more -> Reply result
reply { rResult :: Result result
rResult = Parser result -> Result result
forall result. Parser result -> Result result
More (Parser result -> Result result) -> Parser result -> Result result
forall a b. (a -> b) -> a -> b
$ Parser result -> Pattern -> Parser result
forall match result.
Match match result =>
match -> Pattern -> Parser result
prefixErrorWith Parser result
more Pattern
prefix }
Failed String
message -> Reply result
reply { rResult :: Result result
rResult = Parser result -> Result result
forall result. Parser result -> Result result
More (Parser result -> Result result) -> Parser result -> Result result
forall a b. (a -> b) -> a -> b
$ Pattern
prefix Pattern -> Parser result -> Parser result
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& (String -> Parser result
forall a. String -> Parser a
pfail String
message :: Parser result) }
data Context = BlockOut
| BlockIn
| FlowOut
| FlowIn
| BlockKey
| FlowKey
data Chomp = Strip
| Clip
| Keep
type Tokenizer = BLC.ByteString -> Bool -> [Token]
patternTokenizer :: Pattern -> Tokenizer
patternTokenizer :: Pattern -> Tokenizer
patternTokenizer Pattern
pattern ByteString
input Bool
withFollowing =
DList Token -> [Token]
forall a. DList a -> [a]
D.toList (DList Token -> [Token]) -> DList Token -> [Token]
forall a b. (a -> b) -> a -> b
$ Pattern -> State -> DList Token
forall {result}. Parser result -> State -> DList Token
patternParser (Pattern -> Pattern
forall parameter result.
Match parameter result =>
parameter -> Parser result
wrap Pattern
pattern) (ByteString -> State
initialState ByteString
input)
where
patternParser :: Parser result -> State -> DList Token
patternParser Parser result
parser State
state =
let reply :: Reply result
reply = Parser result -> State -> Reply result
forall result. Parser result -> State -> Reply result
applyParser Parser result
parser State
state
tokens :: DList Token
tokens = Reply result -> DList Token
forall result. Reply result -> DList Token
commitBugs Reply result
reply
state' :: State
state' = Reply result
replyReply result -> (Reply result -> State) -> State
forall record value. record -> (record -> value) -> value
^.Reply result -> State
forall result. Reply result -> State
rState
in case Reply result
replyReply result -> (Reply result -> Result result) -> Result result
forall record value. record -> (record -> value) -> value
^.Reply result -> Result result
forall result. Reply result -> Result result
rResult of
Failed String
message -> DList Token -> State -> String -> Bool -> DList Token
errorTokens DList Token
tokens State
state' String
message Bool
withFollowing
Result result
_ -> DList Token
tokens
More Parser result
parser' -> DList Token -> DList Token -> DList Token
forall a. DList a -> DList a -> DList a
D.append DList Token
tokens (DList Token -> DList Token) -> DList Token -> DList Token
forall a b. (a -> b) -> a -> b
$ Parser result -> State -> DList Token
patternParser Parser result
parser' State
state'
errorTokens :: D.DList Token -> State -> String -> Bool -> D.DList Token
errorTokens :: DList Token -> State -> String -> Bool -> DList Token
errorTokens DList Token
tokens State
state String
message Bool
withFollowing =
let tokens' :: DList Token
tokens' = DList Token -> DList Token -> DList Token
forall a. DList a -> DList a -> DList a
D.append DList Token
tokens (DList Token -> DList Token) -> DList Token -> DList Token
forall a b. (a -> b) -> a -> b
$ Token -> DList Token
forall a. a -> DList a
D.singleton Token { tByteOffset :: Int
tByteOffset = State
stateState -> (State -> Int) -> Int
forall record value. record -> (record -> value) -> value
^.State -> Int
sByteOffset,
tCharOffset :: Int
tCharOffset = State
stateState -> (State -> Int) -> Int
forall record value. record -> (record -> value) -> value
^.State -> Int
sCharOffset,
tLine :: Int
tLine = State
stateState -> (State -> Int) -> Int
forall record value. record -> (record -> value) -> value
^.State -> Int
sLine,
tLineChar :: Int
tLineChar = State
stateState -> (State -> Int) -> Int
forall record value. record -> (record -> value) -> value
^.State -> Int
sLineChar,
tCode :: Code
tCode = Code
Error,
tText :: String
tText = String
message }
in if Bool
withFollowing Bool -> Bool -> Bool
&& State
stateState -> (State -> [(Int, Char)]) -> [(Int, Char)]
forall record value. record -> (record -> value) -> value
^.State -> [(Int, Char)]
sInput [(Int, Char)] -> [(Int, Char)] -> Bool
forall a. Eq a => a -> a -> Bool
/= []
then DList Token -> DList Token -> DList Token
forall a. DList a -> DList a -> DList a
D.append DList Token
tokens' (DList Token -> DList Token) -> DList Token -> DList Token
forall a b. (a -> b) -> a -> b
$ Token -> DList Token
forall a. a -> DList a
D.singleton Token { tByteOffset :: Int
tByteOffset = State
stateState -> (State -> Int) -> Int
forall record value. record -> (record -> value) -> value
^.State -> Int
sByteOffset,
tCharOffset :: Int
tCharOffset = State
stateState -> (State -> Int) -> Int
forall record value. record -> (record -> value) -> value
^.State -> Int
sCharOffset,
tLine :: Int
tLine = State
stateState -> (State -> Int) -> Int
forall record value. record -> (record -> value) -> value
^.State -> Int
sLine,
tLineChar :: Int
tLineChar = State
stateState -> (State -> Int) -> Int
forall record value. record -> (record -> value) -> value
^.State -> Int
sLineChar,
tCode :: Code
tCode = Code
Unparsed,
tText :: String
tText = ((Int, Char) -> Char) -> [(Int, Char)] -> String
forall a b. (a -> b) -> [a] -> [b]
map (Int, Char) -> Char
forall a b. (a, b) -> b
snd ([(Int, Char)] -> String) -> [(Int, Char)] -> String
forall a b. (a -> b) -> a -> b
$ State
stateState -> (State -> [(Int, Char)]) -> [(Int, Char)]
forall record value. record -> (record -> value) -> value
^.State -> [(Int, Char)]
sInput }
else DList Token
tokens'
commitBugs :: Reply result -> D.DList Token
commitBugs :: forall result. Reply result -> DList Token
commitBugs Reply result
reply =
let tokens :: DList Token
tokens = Reply result
replyReply result -> (Reply result -> DList Token) -> DList Token
forall record value. record -> (record -> value) -> value
^.Reply result -> DList Token
forall result. Reply result -> DList Token
rTokens
state :: State
state = Reply result
replyReply result -> (Reply result -> State) -> State
forall record value. record -> (record -> value) -> value
^.Reply result -> State
forall result. Reply result -> State
rState
in case Reply result
replyReply result -> (Reply result -> Maybe Decision) -> Maybe Decision
forall record value. record -> (record -> value) -> value
^.Reply result -> Maybe Decision
forall result. Reply result -> Maybe Decision
rCommit of
Maybe Decision
Nothing -> DList Token
tokens
Just Decision
commit -> DList Token -> DList Token -> DList Token
forall a. DList a -> DList a -> DList a
D.append DList Token
tokens (DList Token -> DList Token) -> DList Token -> DList Token
forall a b. (a -> b) -> a -> b
$ Token -> DList Token
forall a. a -> DList a
D.singleton Token { tByteOffset :: Int
tByteOffset = State
stateState -> (State -> Int) -> Int
forall record value. record -> (record -> value) -> value
^.State -> Int
sByteOffset,
tCharOffset :: Int
tCharOffset = State
stateState -> (State -> Int) -> Int
forall record value. record -> (record -> value) -> value
^.State -> Int
sCharOffset,
tLine :: Int
tLine = State
stateState -> (State -> Int) -> Int
forall record value. record -> (record -> value) -> value
^.State -> Int
sLine,
tLineChar :: Int
tLineChar = State
stateState -> (State -> Int) -> Int
forall record value. record -> (record -> value) -> value
^.State -> Int
sLineChar,
tCode :: Code
tCode = Code
Error,
tText :: String
tText = String
"Commit to " String -> ShowS
forall a. [a] -> [a] -> [a]
++ Decision -> String
forall a. Show a => a -> String
show Decision
commit String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
" was made outside it" }
tokenize :: BLC.ByteString -> Bool -> [Token]
tokenize :: Tokenizer
tokenize = Pattern -> Tokenizer
patternTokenizer Pattern
l_yaml_stream
bom :: Match match1 result1 => match1 -> Parser ()
bom :: forall match result. Match match result => match -> Pattern
bom match1
code = match1
code
match1 -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ((State -> Reply ()) -> Pattern
forall result. (State -> Reply result) -> Parser result
Parser ((State -> Reply ()) -> Pattern) -> (State -> Reply ()) -> Pattern
forall a b. (a -> b) -> a -> b
$ \ State
state -> let text :: String
text = case State
stateState -> (State -> Encoding) -> Encoding
forall record value. record -> (record -> value) -> value
^.State -> Encoding
sEncoding of
Encoding
UTF8 -> String
"TF-8"
Encoding
UTF16LE -> String
"TF-16LE"
Encoding
UTF16BE -> String
"TF-16BE"
Encoding
UTF32LE -> String
"TF-32LE"
Encoding
UTF32BE -> String
"TF-32BE"
in Pattern -> State -> Reply ()
forall result. Parser result -> State -> Reply result
applyParser (Code -> String -> Pattern
fake Code
Bom String
text) State
state)
na :: Int
na :: Int
na = String -> Int
forall a. HasCallStack => String -> a
error String
"Accessing non-applicable indentation"
asInteger :: Parser Int
asInteger :: Parser Int
asInteger = (State -> Reply Int) -> Parser Int
forall result. (State -> Reply result) -> Parser result
Parser ((State -> Reply Int) -> Parser Int)
-> (State -> Reply Int) -> Parser Int
forall a b. (a -> b) -> a -> b
$ \ State
state -> State -> Int -> Reply Int
forall result. State -> result -> Reply result
returnReply State
state (Int -> Reply Int) -> Int -> Reply Int
forall a b. (a -> b) -> a -> b
$ Char -> Int
ord (State
stateState -> (State -> Char) -> Char
forall record value. record -> (record -> value) -> value
^.State -> Char
sLast) Int -> Int -> Int
.- Int
48
result :: result -> Parser result
result :: forall a. a -> Parser a
result = result -> Parser result
forall (m :: * -> *) a. Monad m => a -> m a
return
c_printable :: Pattern
c_printable = Char
'\x9' Char -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Char
'\xA' Char -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Char
'\xD' Char -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ (Char
'\x20', Char
'\x7E')
(Char, Char) -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Char
'\x85' Char -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ (Char
'\xA0', Char
'\xD7FF') (Char, Char) -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ (Char
'\xE000', Char
'\xFFFD')
(Char, Char) -> (Char, Char) -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ (Char
'\x10000', Char
'\x10FFFF')
nb_json :: Pattern
nb_json = Char
'\x9' Char -> (Char, Char) -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ (Char
'\x20', Char
'\x10FFFF')
c_byte_order_mark :: Pattern
c_byte_order_mark = Char -> Pattern
forall match result. Match match result => match -> Pattern
bom Char
'\xFEFF'
c_sequence_entry :: Pattern
c_sequence_entry = Char -> Pattern
forall match result. Match match result => match -> Pattern
indicator Char
'-'
c_mapping_key :: Pattern
c_mapping_key = Char -> Pattern
forall match result. Match match result => match -> Pattern
indicator Char
'?'
c_mapping_value :: Pattern
c_mapping_value = Char -> Pattern
forall match result. Match match result => match -> Pattern
indicator Char
':'
c_collect_entry :: Pattern
c_collect_entry = Char -> Pattern
forall match result. Match match result => match -> Pattern
indicator Char
','
c_sequence_start :: Pattern
c_sequence_start = Char -> Pattern
forall match result. Match match result => match -> Pattern
indicator Char
'['
c_sequence_end :: Pattern
c_sequence_end = Char -> Pattern
forall match result. Match match result => match -> Pattern
indicator Char
']'
c_mapping_start :: Pattern
c_mapping_start = Char -> Pattern
forall match result. Match match result => match -> Pattern
indicator Char
'{'
c_mapping_end :: Pattern
c_mapping_end = Char -> Pattern
forall match result. Match match result => match -> Pattern
indicator Char
'}'
= Char -> Pattern
forall match result. Match match result => match -> Pattern
indicator Char
'#'
c_anchor :: Pattern
c_anchor = Char -> Pattern
forall match result. Match match result => match -> Pattern
indicator Char
'&'
c_alias :: Pattern
c_alias = Char -> Pattern
forall match result. Match match result => match -> Pattern
indicator Char
'*'
c_tag :: Pattern
c_tag = Char -> Pattern
forall match result. Match match result => match -> Pattern
indicator Char
'!'
c_literal :: Pattern
c_literal = Char -> Pattern
forall match result. Match match result => match -> Pattern
indicator Char
'|'
c_folded :: Pattern
c_folded = Char -> Pattern
forall match result. Match match result => match -> Pattern
indicator Char
'>'
c_single_quote :: Pattern
c_single_quote = Char -> Pattern
forall match result. Match match result => match -> Pattern
indicator Char
'\''
c_double_quote :: Pattern
c_double_quote = Char -> Pattern
forall match result. Match match result => match -> Pattern
indicator Char
'"'
c_directive :: Pattern
c_directive = Char -> Pattern
forall match result. Match match result => match -> Pattern
indicator Char
'%'
c_reserved :: Pattern
c_reserved = Pattern -> Pattern
forall match result. Match match result => match -> Pattern
indicator ( Char
'@' Char -> Char -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Char
'`' )
c_indicator :: Pattern
c_indicator = Pattern
c_sequence_entry Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
c_mapping_key Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
c_mapping_value Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
c_collect_entry
Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
c_sequence_start Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
c_sequence_end Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
c_mapping_start Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
c_mapping_end
Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
c_comment Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
c_anchor Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
c_alias Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
c_tag
Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
c_literal Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
c_folded Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
c_single_quote Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
c_double_quote
Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
c_directive Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
c_reserved
c_flow_indicator :: Pattern
c_flow_indicator = Pattern
c_collect_entry Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
c_sequence_start Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
c_sequence_end Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
c_mapping_start Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
c_mapping_end
b_line_feed :: Char
b_line_feed = Char
'\xA'
b_carriage_return :: Char
b_carriage_return = Char
'\xD'
b_char :: Pattern
b_char = Char
b_line_feed Char -> Char -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Char
b_carriage_return
nb_char :: Pattern
nb_char = Pattern
c_printable Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result1
- Pattern
b_char Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result1
- Pattern
c_byte_order_mark
b_break :: Pattern
b_break = ( Char
b_carriage_return Char -> Char -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Char
b_line_feed
Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Char
b_carriage_return
Char -> Char -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Char
b_line_feed )
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Pattern
nextLine
b_as_line_feed :: Pattern
b_as_line_feed = Code -> Pattern -> Pattern
forall match result. Match match result => Code -> match -> Pattern
token Code
LineFeed Pattern
b_break
b_non_content :: Pattern
b_non_content = Code -> Pattern -> Pattern
forall match result. Match match result => Code -> match -> Pattern
token Code
Break Pattern
b_break
s_space :: Char
s_space = Char
'\x20'
s_tab :: Char
s_tab = Char
'\x9'
s_white :: Pattern
s_white = Char
s_space Char -> Char -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Char
s_tab
ns_char :: Pattern
ns_char = Pattern
nb_char Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result1
- Pattern
s_white
ns_dec_digit :: (Char, Char)
ns_dec_digit = (Char
'\x30', Char
'\x39')
ns_hex_digit :: Pattern
ns_hex_digit = (Char, Char)
ns_dec_digit
(Char, Char) -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ (Char
'\x41', Char
'\x46') (Char, Char) -> (Char, Char) -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ (Char
'\x61', Char
'\x66')
ns_ascii_letter :: Pattern
ns_ascii_letter = (Char
'\x41', Char
'\x5A') (Char, Char) -> (Char, Char) -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ (Char
'\x61', Char
'\x7A')
ns_word_char :: Pattern
ns_word_char = (Char, Char)
ns_dec_digit (Char, Char) -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
ns_ascii_letter Pattern -> Char -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Char
'-'
ns_uri_char :: Pattern
ns_uri_char = Decision
DeEscape
Decision -> Pattern -> Pattern
forall match result.
Match match result =>
Decision -> match -> Parser result
^ ( Char
'%' Char -> Decision -> Pattern
forall match result.
Match match result =>
match -> Decision -> Pattern
! Decision
DeEscape Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Pattern
ns_hex_digit Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Pattern
ns_hex_digit Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
ns_word_char Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Char
'#'
Char -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Char
';' Char -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Char
'/' Char -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Char
'?' Char -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Char
':' Char -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Char
'@' Char -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Char
'&' Char -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Char
'=' Char -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Char
'+' Char -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Char
'$' Char -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Char
','
Char -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Char
'_' Char -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Char
'.' Char -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Char
'!' Char -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Char
'~' Char -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Char
'*' Char -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Char
'\'' Char -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Char
'(' Char -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Char
')' Char -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Char
'[' Char -> Char -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Char
']' )
ns_tag_char :: Pattern
ns_tag_char = Pattern
ns_uri_char Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result1
- Pattern
c_tag Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result1
- Pattern
c_flow_indicator
c_escape :: Pattern
c_escape = Char -> Pattern
forall match result. Match match result => match -> Pattern
indicator Char
'\\'
ns_esc_null :: Pattern
ns_esc_null = Char -> Pattern
forall match result. Match match result => match -> Pattern
meta Char
'0'
ns_esc_bell :: Pattern
ns_esc_bell = Char -> Pattern
forall match result. Match match result => match -> Pattern
meta Char
'a'
ns_esc_backspace :: Pattern
ns_esc_backspace = Char -> Pattern
forall match result. Match match result => match -> Pattern
meta Char
'b'
ns_esc_horizontal_tab :: Pattern
ns_esc_horizontal_tab = Pattern -> Pattern
forall match result. Match match result => match -> Pattern
meta ( Char
't' Char -> Char -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Char
'\x9' )
ns_esc_line_feed :: Pattern
ns_esc_line_feed = Char -> Pattern
forall match result. Match match result => match -> Pattern
meta Char
'n'
ns_esc_vertical_tab :: Pattern
ns_esc_vertical_tab = Char -> Pattern
forall match result. Match match result => match -> Pattern
meta Char
'v'
ns_esc_form_feed :: Pattern
ns_esc_form_feed = Char -> Pattern
forall match result. Match match result => match -> Pattern
meta Char
'f'
ns_esc_carriage_return :: Pattern
ns_esc_carriage_return = Char -> Pattern
forall match result. Match match result => match -> Pattern
meta Char
'r'
ns_esc_escape :: Pattern
ns_esc_escape = Char -> Pattern
forall match result. Match match result => match -> Pattern
meta Char
'e'
ns_esc_space :: Pattern
ns_esc_space = Char -> Pattern
forall match result. Match match result => match -> Pattern
meta Char
'\x20'
ns_esc_double_quote :: Pattern
ns_esc_double_quote = Char -> Pattern
forall match result. Match match result => match -> Pattern
meta Char
'"'
ns_esc_slash :: Pattern
ns_esc_slash = Char -> Pattern
forall match result. Match match result => match -> Pattern
meta Char
'/'
ns_esc_backslash :: Pattern
ns_esc_backslash = Char -> Pattern
forall match result. Match match result => match -> Pattern
meta Char
'\\'
ns_esc_next_line :: Pattern
ns_esc_next_line = Char -> Pattern
forall match result. Match match result => match -> Pattern
meta Char
'N'
ns_esc_non_breaking_space :: Pattern
ns_esc_non_breaking_space = Char -> Pattern
forall match result. Match match result => match -> Pattern
meta Char
'_'
ns_esc_line_separator :: Pattern
ns_esc_line_separator = Char -> Pattern
forall match result. Match match result => match -> Pattern
meta Char
'L'
ns_esc_paragraph_separator :: Pattern
ns_esc_paragraph_separator = Char -> Pattern
forall match result. Match match result => match -> Pattern
meta Char
'P'
ns_esc_8_bit :: Pattern
ns_esc_8_bit = Char -> Pattern
forall match result. Match match result => match -> Pattern
indicator Char
'x' Pattern -> Decision -> Pattern
forall match result.
Match match result =>
match -> Decision -> Pattern
! Decision
DeEscaped Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Pattern -> Pattern
forall match result. Match match result => match -> Pattern
meta ( Pattern
ns_hex_digit Pattern -> Int -> Pattern
forall match result. Match match result => match -> Int -> Pattern
% Int
2 )
ns_esc_16_bit :: Pattern
ns_esc_16_bit = Char -> Pattern
forall match result. Match match result => match -> Pattern
indicator Char
'u' Pattern -> Decision -> Pattern
forall match result.
Match match result =>
match -> Decision -> Pattern
! Decision
DeEscaped Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Pattern -> Pattern
forall match result. Match match result => match -> Pattern
meta ( Pattern
ns_hex_digit Pattern -> Int -> Pattern
forall match result. Match match result => match -> Int -> Pattern
% Int
4 )
ns_esc_32_bit :: Pattern
ns_esc_32_bit = Char -> Pattern
forall match result. Match match result => match -> Pattern
indicator Char
'U' Pattern -> Decision -> Pattern
forall match result.
Match match result =>
match -> Decision -> Pattern
! Decision
DeEscaped Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Pattern -> Pattern
forall match result. Match match result => match -> Pattern
meta ( Pattern
ns_hex_digit Pattern -> Int -> Pattern
forall match result. Match match result => match -> Int -> Pattern
% Int
8 )
c_ns_esc_char :: Pattern
c_ns_esc_char = Code -> Code -> Pattern -> Pattern
wrapTokens Code
BeginEscape Code
EndEscape
(Pattern -> Pattern) -> Pattern -> Pattern
forall a b. (a -> b) -> a -> b
$ Pattern
c_escape Pattern -> Decision -> Pattern
forall match result.
Match match result =>
match -> Decision -> Pattern
! Decision
DeEscape
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Decision
DeEscaped
Decision -> Pattern -> Pattern
forall match result.
Match match result =>
Decision -> match -> Parser result
^ ( Pattern
ns_esc_null Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
ns_esc_bell Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
ns_esc_backspace
Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
ns_esc_horizontal_tab Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
ns_esc_line_feed
Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
ns_esc_vertical_tab Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
ns_esc_form_feed
Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
ns_esc_carriage_return Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
ns_esc_escape Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
ns_esc_space
Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
ns_esc_double_quote Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
ns_esc_slash Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
ns_esc_backslash
Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
ns_esc_next_line Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
ns_esc_non_breaking_space
Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
ns_esc_line_separator Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
ns_esc_paragraph_separator
Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
ns_esc_8_bit Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
ns_esc_16_bit Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
ns_esc_32_bit )
s_indent :: Int -> Pattern
s_indent Int
n = Code -> Pattern -> Pattern
forall match result. Match match result => Code -> match -> Pattern
token Code
Indent ( Char
s_space Char -> Int -> Pattern
forall match result. Match match result => match -> Int -> Pattern
% Int
n )
s_indent_lt :: Int -> Pattern
s_indent_lt Int
n = Code -> Pattern -> Pattern
forall match result. Match match result => Code -> match -> Pattern
token Code
Indent ( Char
s_space Char -> Int -> Pattern
forall match result. Match match result => match -> Int -> Pattern
<% Int
n )
s_indent_le :: Int -> Pattern
s_indent_le Int
n = Code -> Pattern -> Pattern
forall match result. Match match result => Code -> match -> Pattern
token Code
Indent ( Char
s_space Char -> Int -> Pattern
forall match result. Match match result => match -> Int -> Pattern
<% (Int
n Int -> Int -> Int
.+ Int
1) )
s_separate_in_line :: Pattern
s_separate_in_line = Code -> Pattern -> Pattern
forall match result. Match match result => Code -> match -> Pattern
token Code
White ( Pattern
s_white +) Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
sol
s_line_prefix :: Int -> Context -> Pattern
s_line_prefix Int
n Context
c = case Context
c of
Context
BlockOut -> Int -> Pattern
s_block_line_prefix Int
n
Context
BlockIn -> Int -> Pattern
s_block_line_prefix Int
n
Context
FlowOut -> Int -> Pattern
s_flow_line_prefix Int
n
Context
FlowIn -> Int -> Pattern
s_flow_line_prefix Int
n
Context
_ -> String -> Pattern
forall a. HasCallStack => String -> a
error String
"unexpected node style pattern in s_line_prefix"
s_block_line_prefix :: Int -> Pattern
s_block_line_prefix Int
n = Int -> Pattern
s_indent Int
n
s_flow_line_prefix :: Int -> Pattern
s_flow_line_prefix Int
n = Int -> Pattern
s_indent Int
n Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Pattern
s_separate_in_line ?)
l_empty :: Int -> Context -> Pattern
l_empty Int
n Context
c = ( Int -> Context -> Pattern
s_line_prefix Int
n Context
c Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Int -> Pattern
s_indent_lt Int
n )
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Pattern
b_as_line_feed
b_l_trimmed :: Int -> Context -> Pattern
b_l_trimmed Int
n Context
c = Pattern
b_non_content Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Int -> Context -> Pattern
l_empty Int
n Context
c +)
b_as_space :: Pattern
b_as_space = Code -> Pattern -> Pattern
forall match result. Match match result => Code -> match -> Pattern
token Code
LineFold Pattern
b_break
b_l_folded :: Int -> Context -> Pattern
b_l_folded Int
n Context
c = Int -> Context -> Pattern
b_l_trimmed Int
n Context
c Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
b_as_space
s_flow_folded :: Int -> Pattern
s_flow_folded Int
n = ( Pattern
s_separate_in_line ?) Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Int -> Context -> Pattern
b_l_folded Int
n Context
FlowIn
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Int -> Pattern
s_flow_line_prefix Int
n
= Code -> Code -> Pattern -> Pattern
wrapTokens Code
BeginComment Code
EndComment
(Pattern -> Pattern) -> Pattern -> Pattern
forall a b. (a -> b) -> a -> b
$ Pattern
c_comment Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Pattern -> Pattern
forall match result. Match match result => match -> Pattern
meta ( Pattern
nb_char *)
= Pattern
b_non_content Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
eof
= ( Pattern
s_separate_in_line Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Pattern
c_nb_comment_text ?) ?)
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Pattern
b_comment
= Pattern
s_separate_in_line Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Pattern
c_nb_comment_text ?) Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Pattern
b_comment
= ( Pattern
s_b_comment Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
sol )
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Pattern -> Pattern
forall parameter result.
Match parameter result =>
parameter -> Parser result
nonEmpty Pattern
l_comment *)
s_separate :: Int -> Context -> Pattern
s_separate Int
n Context
c = case Context
c of
Context
BlockOut -> Int -> Pattern
s_separate_lines Int
n
Context
BlockIn -> Int -> Pattern
s_separate_lines Int
n
Context
FlowOut -> Int -> Pattern
s_separate_lines Int
n
Context
FlowIn -> Int -> Pattern
s_separate_lines Int
n
Context
BlockKey -> Pattern
s_separate_in_line
Context
FlowKey -> Pattern
s_separate_in_line
s_separate_lines :: Int -> Pattern
s_separate_lines Int
n = Pattern
s_l_comments Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Int -> Pattern
s_flow_line_prefix Int
n
Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
s_separate_in_line
l_directive :: Pattern
l_directive = ( Code -> Code -> Pattern -> Pattern
wrapTokens Code
BeginDirective Code
EndDirective
(Pattern -> Pattern) -> Pattern -> Pattern
forall a b. (a -> b) -> a -> b
$ Pattern
c_directive Pattern -> Decision -> Pattern
forall match result.
Match match result =>
match -> Decision -> Pattern
! Decision
DeDoc
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Decision
DeDirective
Decision -> Pattern -> Pattern
forall match result.
Match match result =>
Decision -> match -> Parser result
^ ( Pattern
ns_yaml_directive
Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
ns_tag_directive
Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
ns_reserved_directive ) )
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Pattern
s_l_comments
ns_reserved_directive :: Pattern
ns_reserved_directive = Pattern
ns_directive_name
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Pattern
s_separate_in_line Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Pattern
ns_directive_parameter *)
ns_directive_name :: Pattern
ns_directive_name = Pattern -> Pattern
forall match result. Match match result => match -> Pattern
meta ( Pattern
ns_char +)
ns_directive_parameter :: Pattern
ns_directive_parameter = Pattern -> Pattern
forall match result. Match match result => match -> Pattern
meta ( Pattern
ns_char +)
ns_yaml_directive :: Pattern
ns_yaml_directive = String -> Pattern
forall match result. Match match result => match -> Pattern
meta [ Char
'Y', Char
'A', Char
'M', Char
'L' ] Pattern -> Decision -> Pattern
forall match result.
Match match result =>
match -> Decision -> Pattern
! Decision
DeDirective
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Pattern
s_separate_in_line Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Pattern
ns_yaml_version
ns_yaml_version :: Pattern
ns_yaml_version = Pattern -> Pattern
forall match result. Match match result => match -> Pattern
meta ( ( (Char, Char)
ns_dec_digit +) Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Char
'.' Char -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( (Char, Char)
ns_dec_digit +) )
ns_tag_directive :: Pattern
ns_tag_directive = String -> Pattern
forall match result. Match match result => match -> Pattern
meta [ Char
'T', Char
'A', Char
'G' ] Pattern -> Decision -> Pattern
forall match result.
Match match result =>
match -> Decision -> Pattern
! Decision
DeDirective
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Pattern
s_separate_in_line Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Pattern
c_tag_handle
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Pattern
s_separate_in_line Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Pattern
ns_tag_prefix
c_tag_handle :: Pattern
c_tag_handle = Pattern
c_named_tag_handle
Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
c_secondary_tag_handle
Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
c_primary_tag_handle
c_primary_tag_handle :: Pattern
c_primary_tag_handle = Code -> Code -> Pattern -> Pattern
wrapTokens Code
BeginHandle Code
EndHandle
(Pattern -> Pattern) -> Pattern -> Pattern
forall a b. (a -> b) -> a -> b
$ Pattern
c_tag
c_secondary_tag_handle :: Pattern
c_secondary_tag_handle = Code -> Code -> Pattern -> Pattern
wrapTokens Code
BeginHandle Code
EndHandle
(Pattern -> Pattern) -> Pattern -> Pattern
forall a b. (a -> b) -> a -> b
$ Pattern
c_tag Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Pattern
c_tag
c_named_tag_handle :: Pattern
c_named_tag_handle = Code -> Code -> Pattern -> Pattern
wrapTokens Code
BeginHandle Code
EndHandle
(Pattern -> Pattern) -> Pattern -> Pattern
forall a b. (a -> b) -> a -> b
$ Pattern
c_tag Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Pattern -> Pattern
forall match result. Match match result => match -> Pattern
meta ( Pattern
ns_word_char +) Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Pattern
c_tag
ns_tag_prefix :: Pattern
ns_tag_prefix = Code -> Code -> Pattern -> Pattern
wrapTokens Code
BeginTag Code
EndTag
(Pattern -> Pattern) -> Pattern -> Pattern
forall a b. (a -> b) -> a -> b
$ ( Pattern
c_ns_local_tag_prefix Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
ns_global_tag_prefix )
c_ns_local_tag_prefix :: Pattern
c_ns_local_tag_prefix = Pattern
c_tag Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Pattern -> Pattern
forall match result. Match match result => match -> Pattern
meta ( Pattern
ns_uri_char *)
ns_global_tag_prefix :: Pattern
ns_global_tag_prefix = Pattern -> Pattern
forall match result. Match match result => match -> Pattern
meta ( Pattern
ns_tag_char Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Pattern
ns_uri_char *) )
c_ns_properties :: Int -> Context -> Pattern
c_ns_properties Int
n Context
c = Code -> Code -> Pattern -> Pattern
wrapTokens Code
BeginProperties Code
EndProperties
(Pattern -> Pattern) -> Pattern -> Pattern
forall a b. (a -> b) -> a -> b
$ ( Pattern
c_ns_tag_property
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Int -> Context -> Pattern
s_separate Int
n Context
c Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Pattern
c_ns_anchor_property ?) )
Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ ( Pattern
c_ns_anchor_property
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Int -> Context -> Pattern
s_separate Int
n Context
c Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Pattern
c_ns_tag_property ?) )
c_ns_tag_property :: Pattern
c_ns_tag_property = Code -> Code -> Pattern -> Pattern
wrapTokens Code
BeginTag Code
EndTag
(Pattern -> Pattern) -> Pattern -> Pattern
forall a b. (a -> b) -> a -> b
$ Pattern
c_verbatim_tag
Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
c_ns_shorthand_tag
Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
c_non_specific_tag
c_verbatim_tag :: Pattern
c_verbatim_tag = Pattern
c_tag Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Char -> Pattern
forall match result. Match match result => match -> Pattern
indicator Char
'<' Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Pattern -> Pattern
forall match result. Match match result => match -> Pattern
meta ( Pattern
ns_uri_char +) Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Char -> Pattern
forall match result. Match match result => match -> Pattern
indicator Char
'>'
c_ns_shorthand_tag :: Pattern
c_ns_shorthand_tag = Pattern
c_tag_handle Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Pattern -> Pattern
forall match result. Match match result => match -> Pattern
meta ( Pattern
ns_tag_char +)
c_non_specific_tag :: Pattern
c_non_specific_tag = Pattern
c_tag
c_ns_anchor_property :: Pattern
c_ns_anchor_property = Code -> Code -> Pattern -> Pattern
wrapTokens Code
BeginAnchor Code
EndAnchor
(Pattern -> Pattern) -> Pattern -> Pattern
forall a b. (a -> b) -> a -> b
$ Pattern
c_anchor Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Pattern
ns_anchor_name
ns_anchor_char :: Pattern
ns_anchor_char = Pattern
ns_char Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result1
- Pattern
c_flow_indicator
ns_anchor_name :: Pattern
ns_anchor_name = Pattern -> Pattern
forall match result. Match match result => match -> Pattern
meta ( Pattern
ns_anchor_char +)
c_ns_alias_node :: Pattern
c_ns_alias_node = Code -> Code -> Pattern -> Pattern
wrapTokens Code
BeginAlias Code
EndAlias
(Pattern -> Pattern) -> Pattern -> Pattern
forall a b. (a -> b) -> a -> b
$ Pattern
c_alias Pattern -> Decision -> Pattern
forall match result.
Match match result =>
match -> Decision -> Pattern
! Decision
DeNode Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Pattern
ns_anchor_name
e_scalar :: Pattern
e_scalar = Code -> Code -> Pattern -> Pattern
wrapTokens Code
BeginScalar Code
EndScalar Pattern
empty
e_node :: Pattern
e_node = Code -> Code -> Pattern -> Pattern
wrapTokens Code
BeginNode Code
EndNode Pattern
e_scalar
nb_double_char :: Pattern
nb_double_char = Decision
DeEscape Decision -> Pattern -> Pattern
forall match result.
Match match result =>
Decision -> match -> Parser result
^ ( Pattern
c_ns_esc_char Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ ( Pattern
nb_json Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result1
- Pattern
c_escape Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result1
- Pattern
c_double_quote ) )
ns_double_char :: Pattern
ns_double_char = Pattern
nb_double_char Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result1
- Pattern
s_white
c_double_quoted :: Int -> Context -> Pattern
c_double_quoted Int
n Context
c = Code -> Code -> Pattern -> Pattern
wrapTokens Code
BeginScalar Code
EndScalar
(Pattern -> Pattern) -> Pattern -> Pattern
forall a b. (a -> b) -> a -> b
$ Pattern
c_double_quote Pattern -> Decision -> Pattern
forall match result.
Match match result =>
match -> Decision -> Pattern
! Decision
DeNode Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Pattern -> Pattern
forall match result. Match match result => match -> Pattern
text ( Int -> Context -> Pattern
nb_double_text Int
n Context
c ) Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Pattern
c_double_quote
nb_double_text :: Int -> Context -> Pattern
nb_double_text Int
n Context
c = case Context
c of
Context
FlowOut -> Int -> Pattern
nb_double_multi_line Int
n
Context
FlowIn -> Int -> Pattern
nb_double_multi_line Int
n
Context
BlockKey -> Pattern
nb_double_one_line
Context
FlowKey -> Pattern
nb_double_one_line
Context
_ -> String -> Pattern
forall a. HasCallStack => String -> a
error String
"unexpected node style pattern in nb_double_text"
nb_double_one_line :: Pattern
nb_double_one_line = ( Pattern
nb_double_char *)
s_double_escaped :: Int -> Pattern
s_double_escaped Int
n = ( Pattern
s_white *)
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Code -> Code -> Pattern -> Pattern
wrapTokens Code
BeginEscape Code
EndEscape ( Pattern
c_escape Pattern -> Decision -> Pattern
forall match result.
Match match result =>
match -> Decision -> Pattern
! Decision
DeEscape Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Pattern
b_non_content )
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Int -> Context -> Pattern
l_empty Int
n Context
FlowIn *)
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Int -> Pattern
s_flow_line_prefix Int
n
s_double_break :: Int -> Pattern
s_double_break Int
n = Decision
DeEscape Decision -> Pattern -> Pattern
forall match result.
Match match result =>
Decision -> match -> Parser result
^ ( Int -> Pattern
s_double_escaped Int
n Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Int -> Pattern
s_flow_folded Int
n )
nb_ns_double_in_line :: Pattern
nb_ns_double_in_line = ( ( Pattern
s_white *) Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Pattern
ns_double_char *)
s_double_next_line :: Int -> Pattern
s_double_next_line Int
n = Int -> Pattern
s_double_break Int
n
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Pattern
ns_double_char Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Pattern
nb_ns_double_in_line
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Int -> Pattern
s_double_next_line Int
n Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ ( Pattern
s_white *) ) ?)
nb_double_multi_line :: Int -> Pattern
nb_double_multi_line Int
n = Pattern
nb_ns_double_in_line
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Int -> Pattern
s_double_next_line Int
n Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ ( Pattern
s_white *) )
c_quoted_quote :: Pattern
c_quoted_quote = Code -> Code -> Pattern -> Pattern
wrapTokens Code
BeginEscape Code
EndEscape
(Pattern -> Pattern) -> Pattern -> Pattern
forall a b. (a -> b) -> a -> b
$ Pattern
c_single_quote Pattern -> Decision -> Pattern
forall match result.
Match match result =>
match -> Decision -> Pattern
! Decision
DeEscape Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Char -> Pattern
forall match result. Match match result => match -> Pattern
meta Char
'\''
nb_single_char :: Pattern
nb_single_char = Decision
DeEscape Decision -> Pattern -> Pattern
forall match result.
Match match result =>
Decision -> match -> Parser result
^ ( Pattern
c_quoted_quote Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ ( Pattern
nb_json Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result1
- Pattern
c_single_quote ) )
ns_single_char :: Pattern
ns_single_char = Pattern
nb_single_char Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result1
- Pattern
s_white
c_single_quoted :: Int -> Context -> Pattern
c_single_quoted Int
n Context
c = Code -> Code -> Pattern -> Pattern
wrapTokens Code
BeginScalar Code
EndScalar
(Pattern -> Pattern) -> Pattern -> Pattern
forall a b. (a -> b) -> a -> b
$ Pattern
c_single_quote Pattern -> Decision -> Pattern
forall match result.
Match match result =>
match -> Decision -> Pattern
! Decision
DeNode Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Pattern -> Pattern
forall match result. Match match result => match -> Pattern
text ( Int -> Context -> Pattern
nb_single_text Int
n Context
c ) Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Pattern
c_single_quote
nb_single_text :: Int -> Context -> Pattern
nb_single_text Int
n Context
c = case Context
c of
Context
FlowOut -> Int -> Pattern
nb_single_multi_line Int
n
Context
FlowIn -> Int -> Pattern
nb_single_multi_line Int
n
Context
BlockKey -> Pattern
nb_single_one_line
Context
FlowKey -> Pattern
nb_single_one_line
Context
_ -> String -> Pattern
forall a. HasCallStack => String -> a
error String
"unexpected node style pattern in nb_single_text"
nb_single_one_line :: Pattern
nb_single_one_line = ( Pattern
nb_single_char *)
nb_ns_single_in_line :: Pattern
nb_ns_single_in_line = ( ( Pattern
s_white *) Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Pattern
ns_single_char *)
s_single_next_line :: Int -> Pattern
s_single_next_line Int
n = Int -> Pattern
s_flow_folded Int
n
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Pattern
ns_single_char Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Pattern
nb_ns_single_in_line
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Int -> Pattern
s_single_next_line Int
n Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ ( Pattern
s_white *) ) ?)
nb_single_multi_line :: Int -> Pattern
nb_single_multi_line Int
n = Pattern
nb_ns_single_in_line
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Int -> Pattern
s_single_next_line Int
n Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ ( Pattern
s_white *) )
ns_plain_first :: Context -> Pattern
ns_plain_first Context
_c = Pattern
ns_char Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result1
- Pattern
c_indicator
Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ ( Char
':' Char -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Char
'?' Char -> Char -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Char
'-' ) Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( (Context -> Pattern
ns_plain_safe Context
_c) >?)
ns_plain_safe :: Context -> Pattern
ns_plain_safe Context
c = case Context
c of
Context
FlowOut -> Pattern
ns_plain_safe_out
Context
FlowIn -> Pattern
ns_plain_safe_in
Context
BlockKey -> Pattern
ns_plain_safe_out
Context
FlowKey -> Pattern
ns_plain_safe_in
Context
_ -> String -> Pattern
forall a. HasCallStack => String -> a
error String
"unexpected node style pattern in ns_plain_safe"
ns_plain_safe_out :: Pattern
ns_plain_safe_out = Pattern
ns_char
ns_plain_safe_in :: Pattern
ns_plain_safe_in = Pattern
ns_char Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result1
- Pattern
c_flow_indicator
ns_plain_char :: Context -> Pattern
ns_plain_char Context
c = Context -> Pattern
ns_plain_safe Context
c Pattern -> Char -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result1
- Char
':' Pattern -> Char -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result1
- Char
'#'
Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ ( Pattern
ns_char <?) Pattern -> Char -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Char
'#'
Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Char
':' Char -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( (Context -> Pattern
ns_plain_safe Context
c) >?)
ns_plain :: Int -> Context -> Pattern
ns_plain Int
n Context
c = Code -> Code -> Pattern -> Pattern
wrapTokens Code
BeginScalar Code
EndScalar
(Pattern -> Pattern) -> Pattern -> Pattern
forall a b. (a -> b) -> a -> b
$ Pattern -> Pattern
forall match result. Match match result => match -> Pattern
text (case Context
c of
Context
FlowOut -> Int -> Context -> Pattern
ns_plain_multi_line Int
n Context
c
Context
FlowIn -> Int -> Context -> Pattern
ns_plain_multi_line Int
n Context
c
Context
BlockKey -> Context -> Pattern
ns_plain_one_line Context
c
Context
FlowKey -> Context -> Pattern
ns_plain_one_line Context
c
Context
_ -> String -> Pattern
forall a. HasCallStack => String -> a
error String
"unexpected node style pattern in ns_plain")
nb_ns_plain_in_line :: Context -> Pattern
nb_ns_plain_in_line Context
c = ( ( Pattern
s_white *) Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Context -> Pattern
ns_plain_char Context
c *)
ns_plain_one_line :: Context -> Pattern
ns_plain_one_line Context
c = Context -> Pattern
ns_plain_first Context
c Pattern -> Decision -> Pattern
forall match result.
Match match result =>
match -> Decision -> Pattern
! Decision
DeNode Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Context -> Pattern
nb_ns_plain_in_line Context
c
s_ns_plain_next_line :: Int -> Context -> Pattern
s_ns_plain_next_line Int
n Context
c = Int -> Pattern
s_flow_folded Int
n
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Context -> Pattern
ns_plain_char Context
c Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Context -> Pattern
nb_ns_plain_in_line Context
c
ns_plain_multi_line :: Int -> Context -> Pattern
ns_plain_multi_line Int
n Context
c = Context -> Pattern
ns_plain_one_line Context
c
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Int -> Context -> Pattern
s_ns_plain_next_line Int
n Context
c *)
in_flow :: Context -> Context
in_flow Context
c = case Context
c of
Context
FlowOut -> Context
FlowIn
Context
FlowIn -> Context
FlowIn
Context
BlockKey -> Context
FlowKey
Context
FlowKey -> Context
FlowKey
Context
_ -> String -> Context
forall a. HasCallStack => String -> a
error String
"unexpected node style pattern in in_flow"
c_flow_sequence :: Int -> Context -> Pattern
c_flow_sequence Int
n Context
c = Code -> Code -> Pattern -> Pattern
wrapTokens Code
BeginSequence Code
EndSequence
(Pattern -> Pattern) -> Pattern -> Pattern
forall a b. (a -> b) -> a -> b
$ Pattern
c_sequence_start Pattern -> Decision -> Pattern
forall match result.
Match match result =>
match -> Decision -> Pattern
! Decision
DeNode Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Int -> Context -> Pattern
s_separate Int
n Context
c ?)
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Int -> Context -> Pattern
ns_s_flow_seq_entries Int
n (Context -> Context
in_flow Context
c) ?) Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Pattern
c_sequence_end
ns_s_flow_seq_entries :: Int -> Context -> Pattern
ns_s_flow_seq_entries Int
n Context
c = Int -> Context -> Pattern
ns_flow_seq_entry Int
n Context
c Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Int -> Context -> Pattern
s_separate Int
n Context
c ?)
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Pattern
c_collect_entry Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Int -> Context -> Pattern
s_separate Int
n Context
c ?)
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Int -> Context -> Pattern
ns_s_flow_seq_entries Int
n Context
c ?) ?)
ns_flow_seq_entry :: Int -> Context -> Pattern
ns_flow_seq_entry Int
n Context
c = Decision
DePair Decision -> Pattern -> Pattern
forall match result.
Match match result =>
Decision -> match -> Parser result
^ ( Int -> Context -> Pattern
ns_flow_pair Int
n Context
c Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Decision
DeNode Decision -> Pattern -> Pattern
forall match result.
Match match result =>
Decision -> match -> Parser result
^ Int -> Context -> Pattern
ns_flow_node Int
n Context
c )
c_flow_mapping :: Int -> Context -> Pattern
c_flow_mapping Int
n Context
c = Code -> Code -> Pattern -> Pattern
wrapTokens Code
BeginMapping Code
EndMapping
(Pattern -> Pattern) -> Pattern -> Pattern
forall a b. (a -> b) -> a -> b
$ Pattern
c_mapping_start Pattern -> Decision -> Pattern
forall match result.
Match match result =>
match -> Decision -> Pattern
! Decision
DeNode Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Int -> Context -> Pattern
s_separate Int
n Context
c ?)
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Int -> Context -> Pattern
ns_s_flow_map_entries Int
n (Context -> Context
in_flow Context
c) ?) Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Pattern
c_mapping_end
ns_s_flow_map_entries :: Int -> Context -> Pattern
ns_s_flow_map_entries Int
n Context
c = Int -> Context -> Pattern
ns_flow_map_entry Int
n Context
c Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Int -> Context -> Pattern
s_separate Int
n Context
c ?)
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Pattern
c_collect_entry Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Int -> Context -> Pattern
s_separate Int
n Context
c ?)
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Int -> Context -> Pattern
ns_s_flow_map_entries Int
n Context
c ?) ?)
ns_flow_map_entry :: Int -> Context -> Pattern
ns_flow_map_entry Int
n Context
c = Code -> Code -> Pattern -> Pattern
wrapTokens Code
BeginPair Code
EndPair
(Pattern -> Pattern) -> Pattern -> Pattern
forall a b. (a -> b) -> a -> b
$ Decision
DeKey Decision -> Pattern -> Pattern
forall match result.
Match match result =>
Decision -> match -> Parser result
^ ( ( Pattern
c_mapping_key Pattern -> Decision -> Pattern
forall match result.
Match match result =>
match -> Decision -> Pattern
! Decision
DeKey Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Int -> Context -> Pattern
s_separate Int
n Context
c
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Int -> Context -> Pattern
ns_flow_map_explicit_entry Int
n Context
c )
Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Int -> Context -> Pattern
ns_flow_map_implicit_entry Int
n Context
c )
ns_flow_map_explicit_entry :: Int -> Context -> Pattern
ns_flow_map_explicit_entry Int
n Context
c = Int -> Context -> Pattern
ns_flow_map_implicit_entry Int
n Context
c
Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ ( Pattern
e_node
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Pattern
e_node )
ns_flow_map_implicit_entry :: Int -> Context -> Pattern
ns_flow_map_implicit_entry Int
n Context
c = Decision
DePair
Decision -> Pattern -> Pattern
forall match result.
Match match result =>
Decision -> match -> Parser result
^ ( Int -> Context -> Pattern
c_ns_flow_map_json_key_entry Int
n Context
c
Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Int -> Context -> Pattern
ns_flow_map_yaml_key_entry Int
n Context
c
Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Int -> Context -> Pattern
c_ns_flow_map_empty_key_entry Int
n Context
c )
ns_flow_map_yaml_key_entry :: Int -> Context -> Pattern
ns_flow_map_yaml_key_entry Int
n Context
c = ( Decision
DeNode Decision -> Pattern -> Pattern
forall match result.
Match match result =>
Decision -> match -> Parser result
^ Int -> Context -> Pattern
ns_flow_yaml_node Int
n Context
c ) Pattern -> Decision -> Pattern
forall match result.
Match match result =>
match -> Decision -> Pattern
! Decision
DePair
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( ( ( Int -> Context -> Pattern
s_separate Int
n Context
c ?)
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Int -> Context -> Pattern
c_ns_flow_map_separate_value Int
n Context
c )
Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
e_node )
c_ns_flow_map_empty_key_entry :: Int -> Context -> Pattern
c_ns_flow_map_empty_key_entry Int
n Context
c = Pattern
e_node
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Int -> Context -> Pattern
c_ns_flow_map_separate_value Int
n Context
c
c_ns_flow_map_separate_value :: Int -> Context -> Pattern
c_ns_flow_map_separate_value Int
n Context
c = Pattern
c_mapping_value Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( (Context -> Pattern
ns_plain_safe Context
c) >!) Pattern -> Decision -> Pattern
forall match result.
Match match result =>
match -> Decision -> Pattern
! Decision
DePair
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( ( Int -> Context -> Pattern
s_separate Int
n Context
c Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Int -> Context -> Pattern
ns_flow_node Int
n Context
c )
Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
e_node )
c_ns_flow_map_json_key_entry :: Int -> Context -> Pattern
c_ns_flow_map_json_key_entry Int
n Context
c = ( Decision
DeNode Decision -> Pattern -> Pattern
forall match result.
Match match result =>
Decision -> match -> Parser result
^ Int -> Context -> Pattern
c_flow_json_node Int
n Context
c ) Pattern -> Decision -> Pattern
forall match result.
Match match result =>
match -> Decision -> Pattern
! Decision
DePair
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( ( ( Int -> Context -> Pattern
s_separate Int
n Context
c ?)
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Int -> Context -> Pattern
c_ns_flow_map_adjacent_value Int
n Context
c )
Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
e_node )
c_ns_flow_map_adjacent_value :: Int -> Context -> Pattern
c_ns_flow_map_adjacent_value Int
n Context
c = Pattern
c_mapping_value Pattern -> Decision -> Pattern
forall match result.
Match match result =>
match -> Decision -> Pattern
! Decision
DePair
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( ( ( Int -> Context -> Pattern
s_separate Int
n Context
c ?)
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Int -> Context -> Pattern
ns_flow_node Int
n Context
c )
Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
e_node )
ns_flow_pair :: Int -> Context -> Pattern
ns_flow_pair Int
n Context
c = Code -> Code -> Pattern -> Pattern
wrapTokens Code
BeginMapping Code
EndMapping
(Pattern -> Pattern) -> Pattern -> Pattern
forall a b. (a -> b) -> a -> b
$ Code -> Code -> Pattern -> Pattern
wrapTokens Code
BeginPair Code
EndPair
(Pattern -> Pattern) -> Pattern -> Pattern
forall a b. (a -> b) -> a -> b
$ ( ( Pattern
c_mapping_key Pattern -> Decision -> Pattern
forall match result.
Match match result =>
match -> Decision -> Pattern
! Decision
DePair Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Int -> Context -> Pattern
s_separate Int
n Context
c
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Int -> Context -> Pattern
ns_flow_map_explicit_entry Int
n Context
c )
Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Int -> Context -> Pattern
ns_flow_pair_entry Int
n Context
c )
ns_flow_pair_entry :: Int -> Context -> Pattern
ns_flow_pair_entry Int
n Context
c = ( Int -> Context -> Pattern
ns_flow_pair_yaml_key_entry Int
n Context
c
Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Int -> Context -> Pattern
c_ns_flow_map_empty_key_entry Int
n Context
c
Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Int -> Context -> Pattern
c_ns_flow_pair_json_key_entry Int
n Context
c )
ns_flow_pair_yaml_key_entry :: Int -> Context -> Pattern
ns_flow_pair_yaml_key_entry Int
n Context
c = Context -> Pattern
ns_s_implicit_yaml_key Context
FlowKey
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Int -> Context -> Pattern
c_ns_flow_map_separate_value Int
n Context
c
c_ns_flow_pair_json_key_entry :: Int -> Context -> Pattern
c_ns_flow_pair_json_key_entry Int
n Context
c = Context -> Pattern
c_s_implicit_json_key Context
FlowKey
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Int -> Context -> Pattern
c_ns_flow_map_adjacent_value Int
n Context
c
ns_s_implicit_yaml_key :: Context -> Pattern
ns_s_implicit_yaml_key Context
c = ( Decision
DeNode Decision -> Pattern -> Pattern
forall match result.
Match match result =>
Decision -> match -> Parser result
^ ( Int -> Context -> Pattern
ns_flow_yaml_node Int
na Context
c ) Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Pattern
s_separate_in_line ?) )
Pattern -> Int -> Pattern
forall match result.
Match match result =>
match -> Int -> Parser result
`limitedTo` Int
1024
c_s_implicit_json_key :: Context -> Pattern
c_s_implicit_json_key Context
c = ( Decision
DeNode Decision -> Pattern -> Pattern
forall match result.
Match match result =>
Decision -> match -> Parser result
^ ( Int -> Context -> Pattern
c_flow_json_node Int
na Context
c ) Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Pattern
s_separate_in_line ?) )
Pattern -> Int -> Pattern
forall match result.
Match match result =>
match -> Int -> Parser result
`limitedTo` Int
1024
ns_flow_yaml_content :: Int -> Context -> Pattern
ns_flow_yaml_content Int
n Context
c = Int -> Context -> Pattern
ns_plain Int
n Context
c
c_flow_json_content :: Int -> Context -> Pattern
c_flow_json_content Int
n Context
c = Int -> Context -> Pattern
c_flow_sequence Int
n Context
c Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Int -> Context -> Pattern
c_flow_mapping Int
n Context
c
Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Int -> Context -> Pattern
c_single_quoted Int
n Context
c Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Int -> Context -> Pattern
c_double_quoted Int
n Context
c
ns_flow_content :: Int -> Context -> Pattern
ns_flow_content Int
n Context
c = Int -> Context -> Pattern
ns_flow_yaml_content Int
n Context
c Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Int -> Context -> Pattern
c_flow_json_content Int
n Context
c
ns_flow_yaml_node :: Int -> Context -> Pattern
ns_flow_yaml_node Int
n Context
c = Code -> Code -> Pattern -> Pattern
wrapTokens Code
BeginNode Code
EndNode
(Pattern -> Pattern) -> Pattern -> Pattern
forall a b. (a -> b) -> a -> b
$ Pattern
c_ns_alias_node
Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Int -> Context -> Pattern
ns_flow_yaml_content Int
n Context
c
Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ ( Int -> Context -> Pattern
c_ns_properties Int
n Context
c
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( ( Int -> Context -> Pattern
s_separate Int
n Context
c Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Int -> Context -> Pattern
ns_flow_yaml_content Int
n Context
c )
Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
e_scalar ) )
c_flow_json_node :: Int -> Context -> Pattern
c_flow_json_node Int
n Context
c = Code -> Code -> Pattern -> Pattern
wrapTokens Code
BeginNode Code
EndNode
(Pattern -> Pattern) -> Pattern -> Pattern
forall a b. (a -> b) -> a -> b
$ ( Int -> Context -> Pattern
c_ns_properties Int
n Context
c Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Int -> Context -> Pattern
s_separate Int
n Context
c ?)
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Int -> Context -> Pattern
c_flow_json_content Int
n Context
c
ns_flow_node :: Int -> Context -> Pattern
ns_flow_node Int
n Context
c = Code -> Code -> Pattern -> Pattern
wrapTokens Code
BeginNode Code
EndNode
(Pattern -> Pattern) -> Pattern -> Pattern
forall a b. (a -> b) -> a -> b
$ Pattern
c_ns_alias_node
Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Int -> Context -> Pattern
ns_flow_content Int
n Context
c
Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ ( Int -> Context -> Pattern
c_ns_properties Int
n Context
c
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( ( Int -> Context -> Pattern
s_separate Int
n Context
c Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Int -> Context -> Pattern
ns_flow_content Int
n Context
c )
Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
e_scalar ) )
Int
n = Decision
DeHeader
Decision -> Parser (Int, Chomp) -> Parser (Int, Chomp)
forall match result.
Match match result =>
Decision -> match -> Parser result
^ ( do Int
m <- Int -> Parser Int
c_indentation_indicator Int
n
Chomp
t <- Parser Chomp
c_chomping_indicator
( Pattern
s_white Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
b_char ) Pattern -> Decision -> Pattern
forall match result.
Match match result =>
match -> Decision -> Pattern
?! Decision
DeHeader
Pattern
s_b_comment
(Int, Chomp) -> Parser (Int, Chomp)
forall a. a -> Parser a
result (Int
m, Chomp
t)
Parser (Int, Chomp) -> Parser (Int, Chomp) -> Parser (Int, Chomp)
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ do Chomp
t <- Parser Chomp
c_chomping_indicator
Int
m <- Int -> Parser Int
c_indentation_indicator Int
n
Pattern
s_b_comment
(Int, Chomp) -> Parser (Int, Chomp)
forall a. a -> Parser a
result (Int
m, Chomp
t) )
c_indentation_indicator :: Int -> Parser Int
c_indentation_indicator Int
n = (Int -> Int) -> Parser Int -> Parser Int
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap Int -> Int
fixup (Pattern -> Pattern
forall match result. Match match result => match -> Pattern
indicator ( (Char, Char)
ns_dec_digit (Char, Char) -> Char -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result1
- Char
'0' ) Pattern -> Parser Int -> Parser Int
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Parser Int
asInteger)
Parser Int -> Parser Int -> Parser Int
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Int -> Parser Int
detect_scalar_indentation Int
n
where
fixup :: Int -> Int
fixup | Int
n Int -> Int -> Bool
forall a. Eq a => a -> a -> Bool
== -Int
1 = (Int -> Int -> Int
.+ Int
1)
| Bool
otherwise = Int -> Int
forall a. a -> a
id
detect_scalar_indentation :: Int -> Parser Int
detect_scalar_indentation Int
n = Parser Int -> Parser Int
forall parameter result.
Match parameter result =>
parameter -> Parser result
peek (Parser Int -> Parser Int) -> Parser Int -> Parser Int
forall a b. (a -> b) -> a -> b
$ ( Pattern
nb_char *)
Pattern -> Parser Int -> Parser Int
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Pattern
b_break Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( (Char
s_space *) Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Pattern
b_break *) ?)
Pattern -> Parser Int -> Parser Int
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Int -> Parser Int
count_spaces (-Int
n)
count_spaces :: Int -> Parser Int
count_spaces Int
n = (Char
s_space Char -> Parser Int -> Parser Int
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Int -> Parser Int
count_spaces (Int
n Int -> Int -> Int
.+ Int
1))
Parser Int -> Parser Int -> Parser Int
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Int -> Parser Int
forall a. a -> Parser a
result (Int -> Int -> Int
forall a. Ord a => a -> a -> a
max Int
1 Int
n)
c_chomping_indicator :: Parser Chomp
c_chomping_indicator = Char -> Pattern
forall match result. Match match result => match -> Pattern
indicator Char
'-' Pattern -> Parser Chomp -> Parser Chomp
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Chomp -> Parser Chomp
forall a. a -> Parser a
result Chomp
Strip
Parser Chomp -> Parser Chomp -> Parser Chomp
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Char -> Pattern
forall match result. Match match result => match -> Pattern
indicator Char
'+' Pattern -> Parser Chomp -> Parser Chomp
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Chomp -> Parser Chomp
forall a. a -> Parser a
result Chomp
Keep
Parser Chomp -> Parser Chomp -> Parser Chomp
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Chomp -> Parser Chomp
forall a. a -> Parser a
result Chomp
Clip
end_block_scalar :: Chomp -> Pattern
end_block_scalar Chomp
t = case Chomp
t of
Chomp
Strip -> Code -> Pattern
emptyToken Code
EndScalar
Chomp
Clip -> Code -> Pattern
emptyToken Code
EndScalar
Chomp
Keep -> Pattern
empty
b_chomped_last :: Chomp -> Pattern
b_chomped_last Chomp
t = case Chomp
t of
Chomp
Strip -> Code -> Pattern
emptyToken Code
EndScalar Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Pattern
b_non_content
Chomp
Clip -> Pattern
b_as_line_feed Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Code -> Pattern
emptyToken Code
EndScalar
Chomp
Keep -> Pattern
b_as_line_feed
l_chomped_empty :: Int -> Chomp -> Pattern
l_chomped_empty Int
n Chomp
t = case Chomp
t of
Chomp
Strip -> Int -> Pattern
l_strip_empty Int
n
Chomp
Clip -> Int -> Pattern
l_strip_empty Int
n
Chomp
Keep -> Int -> Pattern
l_keep_empty Int
n
l_strip_empty :: Int -> Pattern
l_strip_empty Int
n = ( Int -> Pattern
s_indent_le Int
n Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Pattern
b_non_content *)
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Int -> Pattern
l_trail_comments Int
n ?)
l_keep_empty :: Int -> Pattern
l_keep_empty Int
n = ( Int -> Context -> Pattern
l_empty Int
n Context
BlockIn *)
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Code -> Pattern
emptyToken Code
EndScalar
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Int -> Pattern
l_trail_comments Int
n ?)
Int
n = Int -> Pattern
s_indent_lt Int
n Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Pattern
c_nb_comment_text Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Pattern
b_comment
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Pattern -> Pattern
forall parameter result.
Match parameter result =>
parameter -> Parser result
nonEmpty Pattern
l_comment *)
c_l__literal :: Int -> Pattern
c_l__literal Int
n = do Code -> Pattern
emptyToken Code
BeginScalar
Pattern
c_literal Pattern -> Decision -> Pattern
forall match result.
Match match result =>
match -> Decision -> Pattern
! Decision
DeNode
(Int
m, Chomp
t) <- Int -> Parser (Int, Chomp)
c_b_block_header Int
n Parser (Int, Chomp) -> Pattern -> Parser (Int, Chomp)
forall match result.
Match match result =>
match -> Pattern -> Parser result
`prefixErrorWith` Code -> Pattern
emptyToken Code
EndScalar
Pattern -> Pattern
forall match result. Match match result => match -> Pattern
text ( Int -> Chomp -> Pattern
l_literal_content (Int
n Int -> Int -> Int
.+ Int
m) Chomp
t )
l_nb_literal_text :: Int -> Pattern
l_nb_literal_text Int
n = ( Int -> Context -> Pattern
l_empty Int
n Context
BlockIn *)
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Int -> Pattern
s_indent Int
n Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Pattern
nb_char +)
b_nb_literal_next :: Int -> Pattern
b_nb_literal_next Int
n = Pattern
b_as_line_feed
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Int -> Pattern
l_nb_literal_text Int
n
l_literal_content :: Int -> Chomp -> Pattern
l_literal_content Int
n Chomp
t = ( ( Int -> Pattern
l_nb_literal_text Int
n Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Int -> Pattern
b_nb_literal_next Int
n *) Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Chomp -> Pattern
b_chomped_last Chomp
t )
Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Chomp -> Pattern
end_block_scalar Chomp
t )
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Int -> Chomp -> Pattern
l_chomped_empty Int
n Chomp
t
c_l__folded :: Int -> Pattern
c_l__folded Int
n = do Code -> Pattern
emptyToken Code
BeginScalar
Pattern
c_folded Pattern -> Decision -> Pattern
forall match result.
Match match result =>
match -> Decision -> Pattern
! Decision
DeNode
(Int
m, Chomp
t) <- Int -> Parser (Int, Chomp)
c_b_block_header Int
n Parser (Int, Chomp) -> Pattern -> Parser (Int, Chomp)
forall match result.
Match match result =>
match -> Pattern -> Parser result
`prefixErrorWith` Code -> Pattern
emptyToken Code
EndScalar
Pattern -> Pattern
forall match result. Match match result => match -> Pattern
text ( Int -> Chomp -> Pattern
l_folded_content (Int
n Int -> Int -> Int
.+ Int
m) Chomp
t )
s_nb_folded_text :: Int -> Pattern
s_nb_folded_text Int
n = Int -> Pattern
s_indent Int
n Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Pattern
ns_char Pattern -> Decision -> Pattern
forall match result.
Match match result =>
match -> Decision -> Pattern
! Decision
DeFold Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Pattern
nb_char *)
l_nb_folded_lines :: Int -> Pattern
l_nb_folded_lines Int
n = Int -> Pattern
s_nb_folded_text Int
n
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Int -> Context -> Pattern
b_l_folded Int
n Context
BlockIn Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Int -> Pattern
s_nb_folded_text Int
n *)
s_nb_spaced_text :: Int -> Pattern
s_nb_spaced_text Int
n = Int -> Pattern
s_indent Int
n Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Pattern
s_white Pattern -> Decision -> Pattern
forall match result.
Match match result =>
match -> Decision -> Pattern
! Decision
DeFold Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Pattern
nb_char *)
b_l_spaced :: Int -> Pattern
b_l_spaced Int
n = Pattern
b_as_line_feed
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Int -> Context -> Pattern
l_empty Int
n Context
BlockIn *)
l_nb_spaced_lines :: Int -> Pattern
l_nb_spaced_lines Int
n = Int -> Pattern
s_nb_spaced_text Int
n
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Int -> Pattern
b_l_spaced Int
n Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Int -> Pattern
s_nb_spaced_text Int
n *)
l_nb_same_lines :: Int -> Pattern
l_nb_same_lines Int
n = ( Int -> Context -> Pattern
l_empty Int
n Context
BlockIn *)
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Decision
DeFold Decision -> Pattern -> Pattern
forall match result.
Match match result =>
Decision -> match -> Parser result
^ ( Int -> Pattern
l_nb_folded_lines Int
n Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Int -> Pattern
l_nb_spaced_lines Int
n )
l_nb_diff_lines :: Int -> Pattern
l_nb_diff_lines Int
n = Int -> Pattern
l_nb_same_lines Int
n
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Pattern
b_as_line_feed Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Int -> Pattern
l_nb_same_lines Int
n *)
l_folded_content :: Int -> Chomp -> Pattern
l_folded_content Int
n Chomp
t = ( ( Int -> Pattern
l_nb_diff_lines Int
n Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Chomp -> Pattern
b_chomped_last Chomp
t )
Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Chomp -> Pattern
end_block_scalar Chomp
t )
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Int -> Chomp -> Pattern
l_chomped_empty Int
n Chomp
t
detect_collection_indentation :: Int -> Parser Int
detect_collection_indentation Int
n = Parser Int -> Parser Int
forall parameter result.
Match parameter result =>
parameter -> Parser result
peek (Parser Int -> Parser Int) -> Parser Int -> Parser Int
forall a b. (a -> b) -> a -> b
$ ( Pattern -> Pattern
forall parameter result.
Match parameter result =>
parameter -> Parser result
nonEmpty Pattern
l_comment* ) Pattern -> Parser Int -> Parser Int
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Int -> Parser Int
count_spaces (-Int
n)
detect_inline_indentation :: Parser Int
detect_inline_indentation = Parser Int -> Parser Int
forall parameter result.
Match parameter result =>
parameter -> Parser result
peek (Parser Int -> Parser Int) -> Parser Int -> Parser Int
forall a b. (a -> b) -> a -> b
$ Int -> Parser Int
count_spaces Int
0
l__block_sequence :: Int -> Pattern
l__block_sequence Int
n = do Int
m <- Int -> Parser Int
detect_collection_indentation Int
n
Code -> Code -> Pattern -> Pattern
wrapTokens Code
BeginSequence Code
EndSequence (Pattern -> Pattern) -> Pattern -> Pattern
forall a b. (a -> b) -> a -> b
$ ( Int -> Pattern
s_indent (Int
n Int -> Int -> Int
.+ Int
m) Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Int -> Pattern
c_l_block_seq_entry (Int
n Int -> Int -> Int
.+ Int
m) +)
c_l_block_seq_entry :: Int -> Pattern
c_l_block_seq_entry Int
n = Pattern
c_sequence_entry Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Pattern
ns_char >!) Pattern -> Decision -> Pattern
forall match result.
Match match result =>
match -> Decision -> Pattern
! Decision
DeNode
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Int -> Context -> Pattern
s_l__block_indented Int
n Context
BlockIn
s_l__block_indented :: Int -> Context -> Pattern
s_l__block_indented Int
n Context
c = do Int
m <- Parser Int
detect_inline_indentation
Decision
DeNode Decision -> Pattern -> Pattern
forall match result.
Match match result =>
Decision -> match -> Parser result
^ ( ( Int -> Pattern
s_indent Int
m
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Int -> Pattern
ns_l_in_line_sequence (Int
n Int -> Int -> Int
.+ Int
1 Int -> Int -> Int
.+ Int
m)
Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Int -> Pattern
ns_l_in_line_mapping (Int
n Int -> Int -> Int
.+ Int
1 Int -> Int -> Int
.+ Int
m) ) )
Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Int -> Context -> Pattern
s_l__block_node Int
n Context
c
Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ ( Pattern
e_node Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Pattern
s_l_comments ?) Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Int -> Pattern
unparsed (Int
n Int -> Int -> Int
.+ Int
1) ) ) Pattern -> Pattern -> Pattern
forall match1 result.
Match match1 result =>
match1 -> Parser result -> Parser result
`recovery` Int -> Pattern
unparsed (Int
n Int -> Int -> Int
.+ Int
1)
ns_l_in_line_sequence :: Int -> Pattern
ns_l_in_line_sequence Int
n = Code -> Code -> Pattern -> Pattern
wrapTokens Code
BeginNode Code
EndNode
(Pattern -> Pattern) -> Pattern -> Pattern
forall a b. (a -> b) -> a -> b
$ Code -> Code -> Pattern -> Pattern
wrapTokens Code
BeginSequence Code
EndSequence
(Pattern -> Pattern) -> Pattern -> Pattern
forall a b. (a -> b) -> a -> b
$ Int -> Pattern
c_l_block_seq_entry Int
n
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Int -> Pattern
s_indent Int
n Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Int -> Pattern
c_l_block_seq_entry Int
n *)
l__block_mapping :: Int -> Pattern
l__block_mapping Int
n = do Int
m <- Int -> Parser Int
detect_collection_indentation Int
n
Code -> Code -> Pattern -> Pattern
wrapTokens Code
BeginMapping Code
EndMapping (Pattern -> Pattern) -> Pattern -> Pattern
forall a b. (a -> b) -> a -> b
$ ( Int -> Pattern
s_indent (Int
n Int -> Int -> Int
.+ Int
m) Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Int -> Pattern
ns_l_block_map_entry (Int
n Int -> Int -> Int
.+ Int
m) +)
ns_l_block_map_entry :: Int -> Pattern
ns_l_block_map_entry Int
n = Code -> Code -> Pattern -> Pattern
wrapTokens Code
BeginPair Code
EndPair
(Pattern -> Pattern) -> Pattern -> Pattern
forall a b. (a -> b) -> a -> b
$ Int -> Pattern
c_l_block_map_explicit_entry Int
n
Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Int -> Pattern
ns_l_block_map_implicit_entry Int
n
c_l_block_map_explicit_entry :: Int -> Pattern
c_l_block_map_explicit_entry Int
n = Int -> Pattern
c_l_block_map_explicit_key Int
n
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Int -> Pattern
l_block_map_explicit_value Int
n
Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
e_node )
c_l_block_map_explicit_key :: Int -> Pattern
c_l_block_map_explicit_key Int
n = Pattern
c_mapping_key Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Pattern
ns_char >!) Pattern -> Decision -> Pattern
forall match result.
Match match result =>
match -> Decision -> Pattern
! Decision
DeNode Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Int -> Context -> Pattern
s_l__block_indented Int
n Context
BlockOut
l_block_map_explicit_value :: Int -> Pattern
l_block_map_explicit_value Int
n = Int -> Pattern
s_indent Int
n Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Pattern
c_mapping_value Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Int -> Context -> Pattern
s_l__block_indented Int
n Context
BlockOut
ns_l_block_map_implicit_entry :: Int -> Pattern
ns_l_block_map_implicit_entry Int
n = ( Pattern
ns_s_block_map_implicit_key
Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
e_node )
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Int -> Pattern
c_l_block_map_implicit_value Int
n
ns_s_block_map_implicit_key :: Pattern
ns_s_block_map_implicit_key = Context -> Pattern
c_s_implicit_json_key Context
BlockKey
Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Context -> Pattern
ns_s_implicit_yaml_key Context
BlockKey
c_l_block_map_implicit_value :: Int -> Pattern
c_l_block_map_implicit_value Int
n = Pattern
c_mapping_value Pattern -> Decision -> Pattern
forall match result.
Match match result =>
match -> Decision -> Pattern
! Decision
DeNode
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( ( Int -> Context -> Pattern
s_l__block_node Int
n Context
BlockOut
Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ ( Pattern
e_node Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Pattern
s_l_comments ?) Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Int -> Pattern
unparsed (Int
n Int -> Int -> Int
.+ Int
1) ) ) Pattern -> Pattern -> Pattern
forall match1 result.
Match match1 result =>
match1 -> Parser result -> Parser result
`recovery` Int -> Pattern
unparsed (Int
n Int -> Int -> Int
.+ Int
1) )
ns_l_in_line_mapping :: Int -> Pattern
ns_l_in_line_mapping Int
n = Code -> Code -> Pattern -> Pattern
wrapTokens Code
BeginNode Code
EndNode
(Pattern -> Pattern) -> Pattern -> Pattern
forall a b. (a -> b) -> a -> b
$ Code -> Code -> Pattern -> Pattern
wrapTokens Code
BeginMapping Code
EndMapping
(Pattern -> Pattern) -> Pattern -> Pattern
forall a b. (a -> b) -> a -> b
$ Int -> Pattern
ns_l_block_map_entry Int
n
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Int -> Pattern
s_indent Int
n Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Int -> Pattern
ns_l_block_map_entry Int
n *)
unparsed :: Int -> Pattern
unparsed Int
n = ( Pattern
sol Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
unparsed_text Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Pattern
unparsed_break )
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Pattern -> Pattern
forall parameter result.
Match parameter result =>
parameter -> Parser result
nonEmpty ( Int -> Pattern
unparsed_indent Int
n Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Pattern
unparsed_text Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Pattern
unparsed_break ) *)
unparsed_indent :: Int -> Pattern
unparsed_indent Int
n = Code -> Pattern -> Pattern
forall match result. Match match result => Code -> match -> Pattern
token Code
Unparsed ( Char
s_space Char -> Int -> Pattern
forall match result. Match match result => match -> Int -> Pattern
% Int
n )
unparsed_text :: Pattern
unparsed_text = Code -> Pattern -> Pattern
forall match result. Match match result => Code -> match -> Pattern
token Code
Unparsed ( Pattern -> Pattern
upto ( Pattern
eof Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
c_forbidden Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
b_break ) )
unparsed_break :: Pattern
unparsed_break = Pattern
eof Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern -> Pattern
forall parameter result.
Match parameter result =>
parameter -> Parser result
peek Pattern
c_forbidden Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Code -> Pattern -> Pattern
forall match result. Match match result => Code -> match -> Pattern
token Code
Unparsed Pattern
b_break Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
empty
s_l__block_node :: Int -> Context -> Pattern
s_l__block_node Int
n Context
c = Int -> Context -> Pattern
s_l__block_in_block Int
n Context
c Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Int -> Pattern
s_l__flow_in_block Int
n
s_l__flow_in_block :: Int -> Pattern
s_l__flow_in_block Int
n = Int -> Context -> Pattern
s_separate (Int
n Int -> Int -> Int
.+ Int
1) Context
FlowOut
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Int -> Context -> Pattern
ns_flow_node (Int
n Int -> Int -> Int
.+ Int
1) Context
FlowOut Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Pattern
s_l_comments
s_l__block_in_block :: Int -> Context -> Pattern
s_l__block_in_block Int
n Context
c = Code -> Code -> Pattern -> Pattern
wrapTokens Code
BeginNode Code
EndNode
(Pattern -> Pattern) -> Pattern -> Pattern
forall a b. (a -> b) -> a -> b
$ ( Int -> Context -> Pattern
s_l__block_scalar Int
n Context
c Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Int -> Context -> Pattern
s_l__block_collection Int
n Context
c )
s_l__block_scalar :: Int -> Context -> Pattern
s_l__block_scalar Int
n Context
c = Int -> Context -> Pattern
s_separate (Int
n Int -> Int -> Int
.+ Int
1) Context
c
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Int -> Context -> Pattern
c_ns_properties (Int
n Int -> Int -> Int
.+ Int
1) Context
c Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Int -> Context -> Pattern
s_separate (Int
n Int -> Int -> Int
.+ Int
1) Context
c ?)
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Int -> Pattern
c_l__literal Int
n Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Int -> Pattern
c_l__folded Int
n )
s_l__block_collection :: Int -> Context -> Pattern
s_l__block_collection Int
n Context
c = ( Int -> Context -> Pattern
s_separate (Int
n Int -> Int -> Int
.+ Int
1) Context
c Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Int -> Context -> Pattern
c_ns_properties (Int
n Int -> Int -> Int
.+ Int
1) Context
c Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Pattern
s_l_comments >?) ?)
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Pattern
s_l_comments
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Int -> Pattern
l__block_sequence (Int -> Context -> Int
seq_spaces Int
n Context
c)
Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Int -> Pattern
l__block_mapping Int
n )
seq_spaces :: Int -> Context -> Int
seq_spaces Int
n Context
c = case Context
c of
Context
BlockOut -> Int
n Int -> Int -> Int
.- Int
1
Context
BlockIn -> Int
n
Context
_ -> String -> Int
forall a. HasCallStack => String -> a
error String
"unexpected node style pattern in seq_spaces"
l_document_prefix :: Pattern
l_document_prefix = ( Pattern
c_byte_order_mark ?) Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Pattern -> Pattern
forall parameter result.
Match parameter result =>
parameter -> Parser result
nonEmpty Pattern
l_comment *)
c_directives_end :: Pattern
c_directives_end = Code -> String -> Pattern
forall match result. Match match result => Code -> match -> Pattern
token Code
DirectivesEnd [ Char
'-', Char
'-', Char
'-' ]
c_document_end :: Pattern
c_document_end = Code -> String -> Pattern
forall match result. Match match result => Code -> match -> Pattern
token Code
DocumentEnd [ Char
'.', Char
'.', Char
'.' ]
l_document_suffix :: Pattern
l_document_suffix = Pattern
c_document_end Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Pattern
s_l_comments
c_forbidden :: Pattern
c_forbidden = Pattern
sol
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Pattern
c_directives_end Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
c_document_end )
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Pattern
b_char Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
s_white Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
eof )
l_bare_document :: Pattern
l_bare_document = Decision
DeNode Decision -> Pattern -> Pattern
forall match result.
Match match result =>
Decision -> match -> Parser result
^ Int -> Context -> Pattern
s_l__block_node (-Int
1) Context
BlockIn
Pattern -> Pattern -> Pattern
forall match1 result.
Match match1 result =>
match1 -> Parser result -> Parser result
`forbidding` Pattern
c_forbidden
l_explicit_document :: Pattern
l_explicit_document = ( Pattern
c_directives_end Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Pattern
b_char Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
s_white Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
eof >?)) Pattern -> Decision -> Pattern
forall match result.
Match match result =>
match -> Decision -> Pattern
! Decision
DeDoc
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( ( Pattern
l_bare_document
Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
e_node Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Pattern
s_l_comments ?) Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Int -> Pattern
unparsed Int
0 ) Pattern -> Pattern -> Pattern
forall match1 result.
Match match1 result =>
match1 -> Parser result -> Parser result
`recovery` Int -> Pattern
unparsed Int
0 )
l_directives_document :: Pattern
l_directives_document = ( Pattern
l_directive +)
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Pattern
l_explicit_document
l_any_document :: Pattern
l_any_document = Code -> Code -> Pattern -> Pattern
wrapTokens Code
BeginDocument Code
EndDocument
(Pattern -> Pattern) -> Pattern -> Pattern
forall a b. (a -> b) -> a -> b
$ Decision
DeDoc Decision -> Pattern -> Pattern
forall match result.
Match match result =>
Decision -> match -> Parser result
^ ( Pattern
l_directives_document
Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
l_explicit_document
Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
l_bare_document ) Pattern -> Pattern -> Pattern
forall match1 result.
Match match1 result =>
match1 -> Parser result -> Parser result
`recovery` Int -> Pattern
unparsed Int
0
l_yaml_stream :: Pattern
l_yaml_stream = ( Pattern -> Pattern
forall parameter result.
Match parameter result =>
parameter -> Parser result
nonEmpty Pattern
l_document_prefix *)
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Pattern
eof Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ ( Pattern
c_document_end Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Pattern
b_char Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
s_white Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
eof ) >?) Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
l_any_document )
Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Pattern -> Pattern
forall parameter result.
Match parameter result =>
parameter -> Parser result
nonEmpty ( Decision
DeMore Decision -> Pattern -> Pattern
forall match result.
Match match result =>
Decision -> match -> Parser result
^ ( ( Pattern
l_document_suffix Pattern -> Decision -> Pattern
forall match result.
Match match result =>
match -> Decision -> Pattern
! Decision
DeMore +) Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Pattern -> Pattern
forall parameter result.
Match parameter result =>
parameter -> Parser result
nonEmpty Pattern
l_document_prefix *) Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( Pattern
eof Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ Pattern
l_any_document )
Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ ( Pattern -> Pattern
forall parameter result.
Match parameter result =>
parameter -> Parser result
nonEmpty Pattern
l_document_prefix *) Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Decision
DeDoc Decision -> Pattern -> Pattern
forall match result.
Match match result =>
Decision -> match -> Parser result
^ ( Code -> Code -> Pattern -> Pattern
wrapTokens Code
BeginDocument Code
EndDocument Pattern
l_explicit_document ?) ) ) *)