{-# 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
record ^. :: record -> (record -> value) -> value
^. field :: 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 x :: Code
x = Code -> () -> ()
forall a b. a -> b -> b
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 :: Parser result -> State -> Reply result
applyParser (Parser p :: State -> Reply result
p) s :: State
s = State -> Reply result
p State
s
data Result result = Failed String
| Result result
| More (Parser result)
data Reply result = Reply {
Reply result -> Result result
rResult :: !(Result result),
Reply result -> DList Token
rTokens :: !(D.DList Token),
Reply result -> Maybe Decision
rCommit :: !(Maybe Decision),
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 input :: ByteString
input
= $WState :: Encoding
-> Decision
-> Int
-> Maybe Pattern
-> Bool
-> Bool
-> String
-> Int
-> Int
-> Int
-> Int
-> Int
-> Int
-> Int
-> Int
-> Code
-> Char
-> [(Int, Char)]
-> State
State { sEncoding :: Encoding
sEncoding = Encoding
encoding
, sDecision :: Decision
sDecision = Decision
DeNone
, sLimit :: Int
sLimit = -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 = -1
, sCharsCharOffset :: Int
sCharsCharOffset = -1
, sCharsLine :: Int
sCharsLine = -1
, sCharsLineChar :: Int
sCharsLineChar = -1
, sByteOffset :: Int
sByteOffset = 0
, sCharOffset :: Int
sCharOffset = 0
, sLine :: Int
sLine = 1
, sLineChar :: Int
sLineChar = 0
, sCode :: Code
sCode = Code
Unparsed
, sLast :: Char
sLast = ' '
, sInput :: [(Int, Char)]
sInput = [(Int, Char)]
decoded
}
where
(encoding :: Encoding
encoding, decoded :: [(Int, Char)]
decoded) = ByteString -> (Encoding, [(Int, Char)])
decode ByteString
input
setLimit :: Int -> State -> State
setLimit :: Int -> State -> State
setLimit limit :: Int
limit state :: State
state = State
state { sLimit :: Int
sLimit = Int
limit }
{-# INLINE setLimit #-}
setForbidden :: Maybe Pattern -> State -> State
setForbidden :: Maybe Pattern -> State -> State
setForbidden forbidden :: Maybe Pattern
forbidden state :: State
state = State
state { sForbidden :: Maybe Pattern
sForbidden = Maybe Pattern
forbidden }
{-# INLINE setForbidden #-}
setCode :: Code -> State -> State
setCode :: Code -> State -> State
setCode code :: Code
code state :: 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 code :: 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 (low :: Char
low, high :: Char
high) = (Char -> Bool) -> Pattern
nextIf ((Char -> Bool) -> Pattern) -> (Char -> Bool) -> Pattern
forall a b. (a -> b) -> a -> b
$ \ code :: 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 :: State -> result -> Reply result
returnReply state :: State
state result :: result
result = $WReply :: forall result.
Result result
-> DList Token -> Maybe Decision -> State -> Reply 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
state token :: Token
token = $WReply :: forall result.
Result result
-> DList Token -> Maybe Decision -> State -> Reply result
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 = -1,
sCharsCharOffset :: Int
sCharsCharOffset = -1,
sCharsLine :: Int
sCharsLine = -1,
sCharsLineChar :: Int
sCharsLineChar = -1,
sChars :: String
sChars = [] } }
failReply :: State -> String -> Reply result
failReply :: State -> String -> Reply result
failReply state :: State
state message :: String
message = $WReply :: forall result.
Result result
-> DList Token -> Maybe Decision -> State -> Reply result
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 :: State -> Reply result
unexpectedReply state :: State
state = case State
stateState -> (State -> [(Int, Char)]) -> [(Int, Char)]
forall record value. record -> (record -> value) -> value
^.State -> [(Int, Char)]
sInput of
((_, char :: Char
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
$ "Unexpected '" String -> ShowS
forall a. [a] -> [a] -> [a]
++ [Char
char] String -> ShowS
forall a. [a] -> [a] -> [a]
++ "'"
[] -> State -> String -> Reply result
forall result. State -> String -> Reply result
failReply State
state "Unexpected end of input"
instance Functor Parser where
fmap :: (a -> b) -> Parser a -> Parser b
fmap g :: a -> b
g f :: 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
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 message :: String
message -> Reply a
reply { rResult :: Result b
rResult = String -> Result b
forall result. String -> Result result
Failed String
message }
Result x :: 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 :: 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 :: a -> Parser a
pure result :: 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 -> State -> a -> Reply a
forall result. State -> result -> Reply result
returnReply State
state a
result
<*> :: 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
left :: Parser a
left *> :: Parser a -> Parser b -> Parser b
*> right :: 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
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 message :: String
message -> Reply a
reply { rResult :: Result b
rResult = String -> Result b
forall result. String -> Result result
Failed String
message }
Result _ -> Reply a
reply { rResult :: Result b
rResult = Parser b -> Result b
forall result. Parser result -> Result result
More Parser b
right }
More parser :: 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 :: a -> Parser a
return = a -> Parser a
forall (f :: * -> *) a. Applicative f => a -> f a
pure
left :: Parser a
left >>= :: Parser a -> (a -> Parser b) -> Parser b
>>= right :: 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
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 message :: String
message -> Reply a
reply { rResult :: Result b
rResult = String -> Result b
forall result. String -> Result result
Failed String
message }
Result value :: 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 :: 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 }
>> :: 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 :: String -> Parser a
pfail message :: 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 -> 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
parser :: match
parser % :: match -> Int -> Pattern
% n :: Int
n
| Int
n Int -> Int -> Bool
forall a. Ord a => a -> a -> Bool
<= 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
.- 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
parser :: match
parser <% :: match -> Int -> Pattern
<% n :: Int
n = case Int
n Int -> Int -> Ordering
forall a. Ord a => a -> a -> Ordering
`compare` 1 of
LT -> String -> Pattern
forall a. String -> Parser a
pfail "Fewer than 0 repetitions"
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
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
.- 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
decision ^ :: Decision -> match -> Parser result
^ parser :: 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
parser :: match
parser ! :: match -> Decision -> Pattern
! decision :: 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
parser :: match
parser ?! :: match -> Decision -> Pattern
?! decision :: 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
<? :: match -> Parser result
(<?) lookbehind :: match
lookbehind = match -> Parser result
forall parameter result.
Match parameter result =>
parameter -> Parser result
prev match
lookbehind
(>?) :: (Match match result) => match -> Parser result
>? :: match -> Parser result
(>?) lookahead :: match
lookahead = match -> Parser result
forall parameter result.
Match parameter result =>
parameter -> Parser result
peek match
lookahead
(>!) :: (Match match result) => match -> Pattern
>! :: match -> Pattern
(>!) lookahead :: 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
parser :: match1
parser - :: match1 -> match2 -> Parser result1
- rejected :: 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
before :: match1
before & :: match1 -> match2 -> Parser result2
& after :: 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
first :: match1
first / :: match1 -> match2 -> Parser result
/ second :: 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
? :: match -> Pattern
(?) optional :: 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
* :: match -> Pattern
(*) parser :: 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
+ :: match -> Pattern
(+) parser :: 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 match -> Pattern
forall match result. Match match result => match -> Pattern
*)
instance Alternative Parser where
empty :: Parser a
empty = String -> Parser a
forall a. String -> Parser a
pfail "empty"
left :: Parser a
left <|> :: Parser a -> Parser a -> Parser a
<|> right :: 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 -> 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 point :: State
point tokens :: DList Token
tokens left :: Parser result
left right :: Parser result
right state :: 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 _, _) -> $WReply :: forall result.
Result result
-> DList Token -> Maybe Decision -> State -> Reply result
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 _, _) -> Reply result
reply { rTokens :: DList Token
rTokens = DList Token
tokens' }
(More _, Just _) -> Reply result
reply { rTokens :: DList Token
rTokens = DList Token
tokens' }
(More left' :: Parser result
left', 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 :: Decision -> Parser result -> Parser result
choice decision :: Decision
decision parser :: 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
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 parentDecision :: Decision
parentDecision makingDecision :: Decision
makingDecision parser :: 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
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
Nothing -> Maybe Decision
forall a. Maybe a
Nothing
Just decision :: 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' :: 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' }
_ -> 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 :: match1 -> Parser result -> Parser result
recovery pattern :: match1
pattern recover :: 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
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 _ -> Reply result
reply
More 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 message :: 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
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 :: match -> Parser result
prev parser :: 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 ->
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 = (-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 point :: State
point parser :: Parser result
parser state :: 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 message :: String
message -> State -> String -> Reply result
forall result. State -> String -> Reply result
failReply State
point String
message
Result value :: result
value -> State -> result -> Reply result
forall result. State -> result -> Reply result
returnReply State
point result
value
More parser' :: 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 :: match -> Parser result
peek parser :: 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 ->
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 point :: State
point parser :: Parser result
parser state :: 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 message :: String
message -> State -> String -> Reply result
forall result. State -> String -> Reply result
failReply State
point String
message
Result value :: result
value -> State -> result -> Reply result
forall result. State -> result -> Reply result
returnReply State
point result
value
More parser' :: 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 :: match -> Maybe String -> Pattern
reject parser :: match
parser name :: 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 ->
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 point :: State
point name :: Maybe String
name parser :: Parser result
parser state :: 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 _message :: String
_message -> State -> () -> Reply ()
forall result. State -> result -> Reply result
returnReply State
point ()
Result _value :: result
_value -> case Maybe String
name of
Nothing -> State -> Reply ()
forall result. State -> Reply result
unexpectedReply State
point
Just text :: 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
$ "Unexpected " String -> ShowS
forall a. [a] -> [a] -> [a]
++ String
text
More parser' :: 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 parser :: Pattern
parser = ( ( Pattern
parser Pattern -> Pattern
forall match result. Match match result => match -> Pattern
>!) 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) Pattern -> Pattern
forall match result. Match match result => match -> Pattern
*)
nonEmpty :: (Match match result) => match -> Parser result
nonEmpty :: match -> Parser result
nonEmpty parser :: 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. 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 offset :: Int
offset parser :: 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
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 _message :: String
_message -> Reply result
reply
Result _value :: 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' "Matched empty pattern"
More parser' :: 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
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
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 "Expected start of line"
commit :: Decision -> Pattern
commit :: Decision -> Pattern
commit decision :: 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
state ->
$WReply :: forall result.
Result result
-> DList Token -> Maybe Decision -> State -> Reply result
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 ->
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
.+ 1,
sLineChar :: Int
sLineChar = 0 }
()
with :: (value -> State -> State) -> (State -> value) -> value -> Parser result -> Parser result
with :: (value -> State -> State)
-> (State -> value) -> value -> Parser result -> Parser result
with setField :: value -> State -> State
setField getField :: State -> value
getField value :: value
value parser :: 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
state ->
let value' :: value
value' = State -> value
getField State
state
Parser parser' :: State -> Reply result
parser' = value
value' value -> Parser result -> Parser result
forall a b. a -> b -> b
`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 parentValue :: value
parentValue parser :: 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
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 _ -> 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 _ -> 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' :: 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 :: match1 -> Parser result1 -> Parser result1
forbidding parser :: match1
parser forbidden :: 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 :: match -> Int -> Parser result
limitedTo parser :: match
parser limit :: 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 test :: 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
state ->
case State
stateState -> (State -> Maybe Pattern) -> Maybe Pattern
forall record value. record -> (record -> value) -> value
^.State -> Maybe Pattern
sForbidden of
Nothing -> State -> Reply ()
limitedNextIf State
state
Just parser :: 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 "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 _ -> Reply ()
reply
Result _ -> State -> Reply ()
limitedNextIf State
state
More _ -> String -> Reply ()
forall a. HasCallStack => String -> a
error "unexpected Result More _ pattern"
where
limitedNextIf :: State -> Reply ()
limitedNextIf state :: 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
0 -> State -> String -> Reply ()
forall result. State -> String -> Reply result
failReply State
state "Lookahead limit reached"
_limit :: 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
.- 1 }
consumeNextIf :: State -> Reply ()
consumeNextIf state :: State
state =
case State
stateState -> (State -> [(Int, Char)]) -> [(Int, Char)]
forall record value. record -> (record -> value) -> value
^.State -> [(Int, Char)]
sInput of
((offset :: Int
offset, char :: Char
char):rest :: [(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 p. Num p => (State -> p) -> (State -> p) -> p
charsOf State -> Int
sByteOffset State -> Int
sCharsByteOffset
char_offset :: Int
char_offset = (State -> Int) -> (State -> Int) -> Int
forall p. Num p => (State -> p) -> (State -> p) -> p
charsOf State -> Int
sCharOffset State -> Int
sCharsCharOffset
line :: Int
line = (State -> Int) -> (State -> Int) -> Int
forall p. Num p => (State -> p) -> (State -> p) -> p
charsOf State -> Int
sLine State -> Int
sCharsLine
line_char :: Int
line_char = (State -> Int) -> (State -> Int) -> Int
forall p. Num p => (State -> p) -> (State -> p) -> p
charsOf State -> Int
sLineChar State -> Int
sCharsLineChar
is_sol :: Bool
is_sol = Char
char Char -> Char -> Bool
forall a. Eq a => a -> a -> Bool
== '\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
.+ 1,
sLineChar :: Int
sLineChar = State
stateState -> (State -> Int) -> Int
forall record value. record -> (record -> value) -> value
^.State -> Int
sLineChar 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 -> p) -> (State -> p) -> p
charsOf field :: State -> p
field charsField :: State -> p
charsField
| State
stateState -> (State -> Bool) -> Bool
forall record value. record -> (record -> value) -> value
^.State -> Bool
sIsPeek = -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 -> p) -> p
forall record value. record -> (record -> value) -> value
^.State -> p
field
| Bool
otherwise = State
stateState -> (State -> p) -> p
forall record value. record -> (record -> value) -> value
^.State -> p
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
state ->
let state' :: State
state' = State
state { sChars :: String
sChars = [],
sCharsByteOffset :: Int
sCharsByteOffset = -1,
sCharsCharOffset :: Int
sCharsCharOffset = -1,
sCharsLine :: Int
sCharsLine = -1,
sCharsLineChar :: Int
sCharsLineChar = -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@(_:_) -> State -> Token -> Reply ()
tokenReply State
state' $WToken :: Int -> Int -> Int -> Int -> Code -> String -> Token
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 :: match -> Parser result
wrap parser :: 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 :: Code -> match -> Pattern
token code :: Code
code parser :: 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
code text :: 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
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 $WToken :: Int -> Int -> Int -> Int -> Code -> String -> Token
Token { tByteOffset :: Int
tByteOffset = State -> (State -> Int) -> (State -> Int) -> Int
forall p t. (Eq p, Num p) => t -> (t -> p) -> (t -> p) -> p
value State
state State -> Int
sByteOffset State -> Int
sCharsByteOffset,
tCharOffset :: Int
tCharOffset = State -> (State -> Int) -> (State -> Int) -> Int
forall p t. (Eq p, Num p) => t -> (t -> p) -> (t -> p) -> p
value State
state State -> Int
sCharOffset State -> Int
sCharsCharOffset,
tLine :: Int
tLine = State -> (State -> Int) -> (State -> Int) -> Int
forall p t. (Eq p, Num p) => t -> (t -> p) -> (t -> p) -> p
value State
state State -> Int
sLine State -> Int
sCharsLine,
tLineChar :: Int
tLineChar = State -> (State -> Int) -> (State -> Int) -> Int
forall p t. (Eq p, Num p) => t -> (t -> p) -> (t -> p) -> p
value State
state State -> Int
sLineChar State -> Int
sCharsLineChar,
tCode :: Code
tCode = Code
code,
tText :: String
tText = String
text }
where value :: t -> (t -> p) -> (t -> p) -> p
value state :: t
state field1 :: t -> p
field1 field2 :: t -> p
field2 =
if t -> p
field2 t
state p -> p -> Bool
forall a. Eq a => a -> a -> Bool
== -1
then t -> p
field1 t
state
else t -> p
field2 t
state
meta :: (Match match result) => match -> Pattern
meta :: match -> Pattern
meta parser :: 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 :: match -> Pattern
indicator parser :: 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 :: match -> Pattern
text parser :: 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
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
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
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 $WToken :: Int -> Int -> Int -> Int -> Code -> String -> Token
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 = "" }
wrapTokens :: Code -> Code -> Pattern -> Pattern
wrapTokens :: Code -> Code -> Pattern -> Pattern
wrapTokens beginCode :: Code
beginCode endCode :: Code
endCode pattern :: 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 :: match -> Pattern -> Parser result
prefixErrorWith pattern :: match
pattern prefix :: 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
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 _ -> Reply result
reply
More 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 message :: 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
pattern input :: ByteString
input withFollowing :: 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 :: Parser result
parser state :: 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 message :: String
message -> DList Token -> State -> String -> Bool -> DList Token
errorTokens DList Token
tokens State
state' String
message Bool
withFollowing
Result _ -> DList Token
tokens
More parser' :: 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 tokens :: DList Token
tokens state :: State
state message :: String
message withFollowing :: 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 $WToken :: Int -> Int -> Int -> Int -> Code -> String -> Token
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 $WToken :: Int -> Int -> Int -> Int -> Code -> String -> Token
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 :: Reply result -> DList Token
commitBugs reply :: 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
Nothing -> DList Token
tokens
Just commit :: 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 $WToken :: Int -> Int -> Int -> Int -> Code -> String -> Token
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 = "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]
++ " 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 :: match1 -> Pattern
bom code :: 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
state -> let text :: String
text = case State
stateState -> (State -> Encoding) -> Encoding
forall record value. record -> (record -> value) -> value
^.State -> Encoding
sEncoding of
UTF8 -> "TF-8"
UTF16LE -> "TF-16LE"
UTF16BE -> "TF-16BE"
UTF32LE -> "TF-32LE"
UTF32BE -> "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 "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 -> 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
.- 48
result :: result -> Parser result
result :: result -> Parser result
result = result -> Parser result
forall (m :: * -> *) a. Monad m => a -> m a
return
c_printable :: Pattern
c_printable = '\x9' Char -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ '\xA' Char -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ '\xD' Char -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ ('\x20', '\x7E')
(Char, Char) -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ '\x85' Char -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ ('\xA0', '\xD7FF') (Char, Char) -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ ('\xE000', '\xFFFD')
(Char, Char) -> (Char, Char) -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ ('\x10000', '\x10FFFF')
nb_json :: Pattern
nb_json = '\x9' Char -> (Char, Char) -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ ('\x20', '\x10FFFF')
c_byte_order_mark :: Pattern
c_byte_order_mark = Char -> Pattern
forall match result. Match match result => match -> Pattern
bom '\xFEFF'
c_sequence_entry :: Pattern
c_sequence_entry = Char -> Pattern
forall match result. Match match result => match -> Pattern
indicator '-'
c_mapping_key :: Pattern
c_mapping_key = Char -> Pattern
forall match result. Match match result => match -> Pattern
indicator '?'
c_mapping_value :: Pattern
c_mapping_value = Char -> Pattern
forall match result. Match match result => match -> Pattern
indicator ':'
c_collect_entry :: Pattern
c_collect_entry = Char -> Pattern
forall match result. Match match result => match -> Pattern
indicator ','
c_sequence_start :: Pattern
c_sequence_start = Char -> Pattern
forall match result. Match match result => match -> Pattern
indicator '['
c_sequence_end :: Pattern
c_sequence_end = Char -> Pattern
forall match result. Match match result => match -> Pattern
indicator ']'
c_mapping_start :: Pattern
c_mapping_start = Char -> Pattern
forall match result. Match match result => match -> Pattern
indicator '{'
c_mapping_end :: Pattern
c_mapping_end = Char -> Pattern
forall match result. Match match result => match -> Pattern
indicator '}'
= Char -> Pattern
forall match result. Match match result => match -> Pattern
indicator '#'
c_anchor :: Pattern
c_anchor = Char -> Pattern
forall match result. Match match result => match -> Pattern
indicator '&'
c_alias :: Pattern
c_alias = Char -> Pattern
forall match result. Match match result => match -> Pattern
indicator '*'
c_tag :: Pattern
c_tag = Char -> Pattern
forall match result. Match match result => match -> Pattern
indicator '!'
c_literal :: Pattern
c_literal = Char -> Pattern
forall match result. Match match result => match -> Pattern
indicator '|'
c_folded :: Pattern
c_folded = Char -> Pattern
forall match result. Match match result => match -> Pattern
indicator '>'
c_single_quote :: Pattern
c_single_quote = Char -> Pattern
forall match result. Match match result => match -> Pattern
indicator '\''
c_double_quote :: Pattern
c_double_quote = Char -> Pattern
forall match result. Match match result => match -> Pattern
indicator '"'
c_directive :: Pattern
c_directive = Char -> Pattern
forall match result. Match match result => match -> Pattern
indicator '%'
c_reserved :: Pattern
c_reserved = Pattern -> Pattern
forall match result. Match match result => match -> Pattern
indicator ( '@' Char -> Char -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ '`' )
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 = '\xA'
b_carriage_return :: Char
b_carriage_return = '\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 = '\x20'
s_tab :: Char
s_tab = '\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 = ('\x30', '\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
/ ('\x41', '\x46') (Char, Char) -> (Char, Char) -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ ('\x61', '\x66')
ns_ascii_letter :: Pattern
ns_ascii_letter = ('\x41', '\x5A') (Char, Char) -> (Char, Char) -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ ('\x61', '\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
/ '-'
ns_uri_char :: Pattern
ns_uri_char = Decision
DeEscape
Decision -> Pattern -> Pattern
forall match result.
Match match result =>
Decision -> match -> Parser result
^ ( '%' 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 -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ ';' Char -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ '/' Char -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ '?' Char -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ ':' Char -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ '@' Char -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ '&' Char -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ '=' Char -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ '+' Char -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ '$' Char -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ ','
Char -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ '_' Char -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ '.' Char -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ '!' Char -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ '~' Char -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ '*' Char -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ '\'' Char -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ '(' Char -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ ')' Char -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ '[' Char -> Char -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ ']' )
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 '\\'
ns_esc_null :: Pattern
ns_esc_null = Char -> Pattern
forall match result. Match match result => match -> Pattern
meta '0'
ns_esc_bell :: Pattern
ns_esc_bell = Char -> Pattern
forall match result. Match match result => match -> Pattern
meta 'a'
ns_esc_backspace :: Pattern
ns_esc_backspace = Char -> Pattern
forall match result. Match match result => match -> Pattern
meta 'b'
ns_esc_horizontal_tab :: Pattern
ns_esc_horizontal_tab = Pattern -> Pattern
forall match result. Match match result => match -> Pattern
meta ( 't' Char -> Char -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ '\x9' )
ns_esc_line_feed :: Pattern
ns_esc_line_feed = Char -> Pattern
forall match result. Match match result => match -> Pattern
meta 'n'
ns_esc_vertical_tab :: Pattern
ns_esc_vertical_tab = Char -> Pattern
forall match result. Match match result => match -> Pattern
meta 'v'
ns_esc_form_feed :: Pattern
ns_esc_form_feed = Char -> Pattern
forall match result. Match match result => match -> Pattern
meta 'f'
ns_esc_carriage_return :: Pattern
ns_esc_carriage_return = Char -> Pattern
forall match result. Match match result => match -> Pattern
meta 'r'
ns_esc_escape :: Pattern
ns_esc_escape = Char -> Pattern
forall match result. Match match result => match -> Pattern
meta 'e'
ns_esc_space :: Pattern
ns_esc_space = Char -> Pattern
forall match result. Match match result => match -> Pattern
meta '\x20'
ns_esc_double_quote :: Pattern
ns_esc_double_quote = Char -> Pattern
forall match result. Match match result => match -> Pattern
meta '"'
ns_esc_slash :: Pattern
ns_esc_slash = Char -> Pattern
forall match result. Match match result => match -> Pattern
meta '/'
ns_esc_backslash :: Pattern
ns_esc_backslash = Char -> Pattern
forall match result. Match match result => match -> Pattern
meta '\\'
ns_esc_next_line :: Pattern
ns_esc_next_line = Char -> Pattern
forall match result. Match match result => match -> Pattern
meta 'N'
ns_esc_non_breaking_space :: Pattern
ns_esc_non_breaking_space = Char -> Pattern
forall match result. Match match result => match -> Pattern
meta '_'
ns_esc_line_separator :: Pattern
ns_esc_line_separator = Char -> Pattern
forall match result. Match match result => match -> Pattern
meta 'L'
ns_esc_paragraph_separator :: Pattern
ns_esc_paragraph_separator = Char -> Pattern
forall match result. Match match result => match -> Pattern
meta 'P'
ns_esc_8_bit :: Pattern
ns_esc_8_bit = Char -> Pattern
forall match result. Match match result => match -> Pattern
indicator '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
% 2 )
ns_esc_16_bit :: Pattern
ns_esc_16_bit = Char -> Pattern
forall match result. Match match result => match -> Pattern
indicator '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
% 4 )
ns_esc_32_bit :: Pattern
ns_esc_32_bit = Char -> Pattern
forall match result. Match match result => match -> Pattern
indicator '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
% 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 n :: 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 n :: 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 n :: 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
.+ 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
forall match result. Match match result => match -> Pattern
+) 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 n :: Int
n c :: Context
c = case Context
c of
BlockOut -> Int -> Pattern
s_block_line_prefix Int
n
BlockIn -> Int -> Pattern
s_block_line_prefix Int
n
FlowOut -> Int -> Pattern
s_flow_line_prefix Int
n
FlowIn -> Int -> Pattern
s_flow_line_prefix Int
n
_ -> String -> Pattern
forall a. HasCallStack => String -> a
error "unexpected node style pattern in s_line_prefix"
s_block_line_prefix :: Int -> Pattern
s_block_line_prefix n :: Int
n = Int -> Pattern
s_indent Int
n
s_flow_line_prefix :: Int -> Pattern
s_flow_line_prefix n :: 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 Pattern -> Pattern
forall match result. Match match result => match -> Pattern
?)
l_empty :: Int -> Context -> Pattern
l_empty n :: Int
n c :: 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 n :: Int
n c :: 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 Pattern -> Pattern
forall match result. Match match result => match -> Pattern
+)
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 n :: Int
n c :: 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 n :: Int
n = ( Pattern
s_separate_in_line Pattern -> Pattern
forall match result. Match match result => match -> Pattern
?) 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 -> Pattern
forall match result. Match match result => match -> Pattern
*)
= 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
forall match result. Match match result => match -> Pattern
?) Pattern -> Pattern
forall match result. Match match result => match -> Pattern
?)
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
forall match result. Match match result => match -> Pattern
?) 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 Pattern -> Pattern
forall match result. Match match result => match -> Pattern
*)
s_separate :: Int -> Context -> Pattern
s_separate n :: Int
n c :: Context
c = case Context
c of
BlockOut -> Int -> Pattern
s_separate_lines Int
n
BlockIn -> Int -> Pattern
s_separate_lines Int
n
FlowOut -> Int -> Pattern
s_separate_lines Int
n
FlowIn -> Int -> Pattern
s_separate_lines Int
n
BlockKey -> Pattern
s_separate_in_line
FlowKey -> Pattern
s_separate_in_line
s_separate_lines :: Int -> Pattern
s_separate_lines n :: 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 Pattern -> Pattern
forall match result. Match match result => match -> Pattern
*)
ns_directive_name :: Pattern
ns_directive_name = Pattern -> Pattern
forall match result. Match match result => match -> Pattern
meta ( Pattern
ns_char Pattern -> Pattern
forall match result. Match match result => match -> Pattern
+)
ns_directive_parameter :: Pattern
ns_directive_parameter = Pattern -> Pattern
forall match result. Match match result => match -> Pattern
meta ( Pattern
ns_char Pattern -> Pattern
forall match result. Match match result => match -> Pattern
+)
ns_yaml_directive :: Pattern
ns_yaml_directive = String -> Pattern
forall match result. Match match result => match -> Pattern
meta [ 'Y', 'A', 'M', '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 (Char, Char) -> Pattern
forall match result. Match match result => match -> Pattern
+) Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& '.' Char -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& ( (Char, Char)
ns_dec_digit (Char, Char) -> Pattern
forall match result. Match match result => match -> Pattern
+) )
ns_tag_directive :: Pattern
ns_tag_directive = String -> Pattern
forall match result. Match match result => match -> Pattern
meta [ 'T', 'A', '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
forall match result. Match match result => match -> Pattern
+) 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 Pattern -> Pattern
forall match result. Match match result => match -> Pattern
*)
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 Pattern -> Pattern
forall match result. Match match result => match -> Pattern
*) )
c_ns_properties :: Int -> Context -> Pattern
c_ns_properties n :: Int
n c :: 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
forall match result. Match match result => match -> Pattern
?) )
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 Pattern -> Pattern
forall match result. Match match result => match -> Pattern
?) )
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 '<' 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
forall match result. Match match result => match -> Pattern
+) 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 '>'
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 Pattern -> Pattern
forall match result. Match match result => match -> Pattern
+)
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 Pattern -> Pattern
forall match result. Match match result => match -> Pattern
+)
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 n :: Int
n c :: 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 n :: Int
n c :: Context
c = case Context
c of
FlowOut -> Int -> Pattern
nb_double_multi_line Int
n
FlowIn -> Int -> Pattern
nb_double_multi_line Int
n
BlockKey -> Pattern
nb_double_one_line
FlowKey -> Pattern
nb_double_one_line
_ -> String -> Pattern
forall a. HasCallStack => String -> a
error "unexpected node style pattern in nb_double_text"
nb_double_one_line :: Pattern
nb_double_one_line = ( Pattern
nb_double_char Pattern -> Pattern
forall match result. Match match result => match -> Pattern
*)
s_double_escaped :: Int -> Pattern
s_double_escaped n :: Int
n = ( Pattern
s_white Pattern -> Pattern
forall match result. Match match result => match -> Pattern
*)
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
forall match result. Match match result => match -> Pattern
*)
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 n :: 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
forall match result. Match match result => match -> Pattern
*) Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Pattern
ns_double_char Pattern -> Pattern
forall match result. Match match result => match -> Pattern
*)
s_double_next_line :: Int -> Pattern
s_double_next_line n :: 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 Pattern -> Pattern
forall match result. Match match result => match -> Pattern
*) ) Pattern -> Pattern
forall match result. Match match result => match -> Pattern
?)
nb_double_multi_line :: Int -> Pattern
nb_double_multi_line n :: 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 Pattern -> Pattern
forall match result. Match match result => match -> Pattern
*) )
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 '\''
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 n :: Int
n c :: 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 n :: Int
n c :: Context
c = case Context
c of
FlowOut -> Int -> Pattern
nb_single_multi_line Int
n
FlowIn -> Int -> Pattern
nb_single_multi_line Int
n
BlockKey -> Pattern
nb_single_one_line
FlowKey -> Pattern
nb_single_one_line
_ -> String -> Pattern
forall a. HasCallStack => String -> a
error "unexpected node style pattern in nb_single_text"
nb_single_one_line :: Pattern
nb_single_one_line = ( Pattern
nb_single_char Pattern -> Pattern
forall match result. Match match result => match -> Pattern
*)
nb_ns_single_in_line :: Pattern
nb_ns_single_in_line = ( ( Pattern
s_white Pattern -> Pattern
forall match result. Match match result => match -> Pattern
*) Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Pattern
ns_single_char Pattern -> Pattern
forall match result. Match match result => match -> Pattern
*)
s_single_next_line :: Int -> Pattern
s_single_next_line n :: 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 Pattern -> Pattern
forall match result. Match match result => match -> Pattern
*) ) Pattern -> Pattern
forall match result. Match match result => match -> Pattern
?)
nb_single_multi_line :: Int -> Pattern
nb_single_multi_line n :: 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 Pattern -> Pattern
forall match result. Match match result => match -> Pattern
*) )
ns_plain_first :: Context -> Pattern
ns_plain_first _c :: 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 -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ '?' Char -> Char -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ '-' ) 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 -> Pattern
forall parameter result.
Match parameter result =>
parameter -> Parser result
>?)
ns_plain_safe :: Context -> Pattern
ns_plain_safe c :: Context
c = case Context
c of
FlowOut -> Pattern
ns_plain_safe_out
FlowIn -> Pattern
ns_plain_safe_in
BlockKey -> Pattern
ns_plain_safe_out
FlowKey -> Pattern
ns_plain_safe_in
_ -> String -> Pattern
forall a. HasCallStack => String -> a
error "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 c :: 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
- ':' Pattern -> Char -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result1
- '#'
Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ ( Pattern
ns_char Pattern -> Pattern
forall parameter result.
Match parameter result =>
parameter -> Parser result
<?) Pattern -> Char -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& '#'
Pattern -> Pattern -> Pattern
forall match1 result match2.
(Match match1 result, Match match2 result) =>
match1 -> match2 -> Parser result
/ ':' 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) Pattern -> Pattern
forall parameter result.
Match parameter result =>
parameter -> Parser result
>?)
ns_plain :: Int -> Context -> Pattern
ns_plain n :: Int
n c :: 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
FlowOut -> Int -> Context -> Pattern
ns_plain_multi_line Int
n Context
c
FlowIn -> Int -> Context -> Pattern
ns_plain_multi_line Int
n Context
c
BlockKey -> Context -> Pattern
ns_plain_one_line Context
c
FlowKey -> Context -> Pattern
ns_plain_one_line Context
c
_ -> String -> Pattern
forall a. HasCallStack => String -> a
error "unexpected node style pattern in ns_plain")
nb_ns_plain_in_line :: Context -> Pattern
nb_ns_plain_in_line c :: Context
c = ( ( Pattern
s_white Pattern -> Pattern
forall match result. Match match result => match -> Pattern
*) 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
forall match result. Match match result => match -> Pattern
*)
ns_plain_one_line :: Context -> Pattern
ns_plain_one_line c :: 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 n :: Int
n c :: 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 n :: Int
n c :: 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 Pattern -> Pattern
forall match result. Match match result => match -> Pattern
*)
in_flow :: Context -> Context
in_flow c :: Context
c = case Context
c of
FlowOut -> Context
FlowIn
FlowIn -> Context
FlowIn
BlockKey -> Context
FlowKey
FlowKey -> Context
FlowKey
_ -> String -> Context
forall a. HasCallStack => String -> a
error "unexpected node style pattern in in_flow"
c_flow_sequence :: Int -> Context -> Pattern
c_flow_sequence n :: Int
n c :: 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
forall match result. Match match result => match -> Pattern
?)
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
forall match result. Match match result => match -> Pattern
?) 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 n :: Int
n c :: 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
forall match result. Match match result => match -> Pattern
?)
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
forall match result. Match match result => match -> Pattern
?)
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 Pattern -> Pattern
forall match result. Match match result => match -> Pattern
?) Pattern -> Pattern
forall match result. Match match result => match -> Pattern
?)
ns_flow_seq_entry :: Int -> Context -> Pattern
ns_flow_seq_entry n :: Int
n c :: 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 n :: Int
n c :: 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
forall match result. Match match result => match -> Pattern
?)
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
forall match result. Match match result => match -> Pattern
?) 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 n :: Int
n c :: 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
forall match result. Match match result => match -> Pattern
?)
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
forall match result. Match match result => match -> Pattern
?)
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 Pattern -> Pattern
forall match result. Match match result => match -> Pattern
?) Pattern -> Pattern
forall match result. Match match result => match -> Pattern
?)
ns_flow_map_entry :: Int -> Context -> Pattern
ns_flow_map_entry n :: Int
n c :: 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 n :: Int
n c :: 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 n :: Int
n c :: 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 n :: Int
n c :: 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
forall match result. Match match result => match -> Pattern
?)
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 n :: Int
n c :: 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 n :: Int
n c :: 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 -> Pattern
forall match result. Match match result => match -> Pattern
>!) 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 n :: Int
n c :: 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
forall match result. Match match result => match -> Pattern
?)
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 n :: Int
n c :: 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
forall match result. Match match result => match -> Pattern
?)
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 n :: Int
n c :: 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 n :: Int
n c :: 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 n :: Int
n c :: 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 n :: Int
n c :: 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 c :: 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 -> Pattern
forall match result. Match match result => match -> Pattern
?) )
Pattern -> Int -> Pattern
forall match result.
Match match result =>
match -> Int -> Parser result
`limitedTo` 1024
c_s_implicit_json_key :: Context -> Pattern
c_s_implicit_json_key c :: 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 -> Pattern
forall match result. Match match result => match -> Pattern
?) )
Pattern -> Int -> Pattern
forall match result.
Match match result =>
match -> Int -> Parser result
`limitedTo` 1024
ns_flow_yaml_content :: Int -> Context -> Pattern
ns_flow_yaml_content n :: Int
n c :: Context
c = Int -> Context -> Pattern
ns_plain Int
n Context
c
c_flow_json_content :: Int -> Context -> Pattern
c_flow_json_content n :: Int
n c :: 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 n :: Int
n c :: 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 n :: Int
n c :: 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 n :: Int
n c :: 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
forall match result. Match match result => match -> Pattern
?)
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 n :: Int
n c :: 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 ) )
n :: 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 n :: 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
- '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
== -1 = (Int -> Int -> Int
.+ 1)
| Bool
otherwise = Int -> Int
forall a. a -> a
id
detect_scalar_indentation :: Int -> Parser Int
detect_scalar_indentation n :: 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 -> Pattern
forall match result. Match match result => match -> Pattern
*)
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 Char -> Pattern
forall match result. Match match result => match -> Pattern
*) Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Pattern
b_break Pattern -> Pattern
forall match result. Match match result => match -> Pattern
*) Pattern -> Pattern
forall match result. Match match result => match -> Pattern
?)
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 n :: 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
.+ 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 1 Int
n)
c_chomping_indicator :: Parser Chomp
c_chomping_indicator = Char -> Pattern
forall match result. Match match result => match -> Pattern
indicator '-' 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 '+' 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 t :: Chomp
t = case Chomp
t of
Strip -> Code -> Pattern
emptyToken Code
EndScalar
Clip -> Code -> Pattern
emptyToken Code
EndScalar
Keep -> Pattern
empty
b_chomped_last :: Chomp -> Pattern
b_chomped_last t :: Chomp
t = case Chomp
t of
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
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
Keep -> Pattern
b_as_line_feed
l_chomped_empty :: Int -> Chomp -> Pattern
l_chomped_empty n :: Int
n t :: Chomp
t = case Chomp
t of
Strip -> Int -> Pattern
l_strip_empty Int
n
Clip -> Int -> Pattern
l_strip_empty Int
n
Keep -> Int -> Pattern
l_keep_empty Int
n
l_strip_empty :: Int -> Pattern
l_strip_empty n :: 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
forall match result. Match match result => match -> Pattern
*)
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 Pattern -> Pattern
forall match result. Match match result => match -> Pattern
?)
l_keep_empty :: Int -> Pattern
l_keep_empty n :: Int
n = ( Int -> Context -> Pattern
l_empty Int
n Context
BlockIn Pattern -> Pattern
forall match result. Match match result => match -> Pattern
*)
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 Pattern -> Pattern
forall match result. Match match result => match -> Pattern
?)
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 Pattern -> Pattern
forall match result. Match match result => match -> Pattern
*)
c_l__literal :: Int -> Pattern
c_l__literal n :: 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
(m :: Int
m, t :: 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 n :: Int
n = ( Int -> Context -> Pattern
l_empty Int
n Context
BlockIn Pattern -> Pattern
forall match result. Match match result => match -> Pattern
*)
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 Pattern -> Pattern
forall match result. Match match result => match -> Pattern
+)
b_nb_literal_next :: Int -> Pattern
b_nb_literal_next n :: 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 n :: Int
n t :: 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
forall match result. Match match result => match -> Pattern
*) 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 n :: 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
(m :: Int
m, t :: 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 n :: 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 Pattern -> Pattern
forall match result. Match match result => match -> Pattern
*)
l_nb_folded_lines :: Int -> Pattern
l_nb_folded_lines n :: 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 Pattern -> Pattern
forall match result. Match match result => match -> Pattern
*)
s_nb_spaced_text :: Int -> Pattern
s_nb_spaced_text n :: 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 Pattern -> Pattern
forall match result. Match match result => match -> Pattern
*)
b_l_spaced :: Int -> Pattern
b_l_spaced n :: 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 Pattern -> Pattern
forall match result. Match match result => match -> Pattern
*)
l_nb_spaced_lines :: Int -> Pattern
l_nb_spaced_lines n :: 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 Pattern -> Pattern
forall match result. Match match result => match -> Pattern
*)
l_nb_same_lines :: Int -> Pattern
l_nb_same_lines n :: Int
n = ( Int -> Context -> Pattern
l_empty Int
n Context
BlockIn Pattern -> Pattern
forall match result. Match match result => match -> Pattern
*)
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 n :: 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 Pattern -> Pattern
forall match result. Match match result => match -> Pattern
*)
l_folded_content :: Int -> Chomp -> Pattern
l_folded_content n :: Int
n t :: 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 n :: 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_commentPattern -> Pattern
forall match result. Match match result => match -> Pattern
* ) 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 0
l__block_sequence :: Int -> Pattern
l__block_sequence n :: 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) Pattern -> Pattern
forall match result. Match match result => match -> Pattern
+)
c_l_block_seq_entry :: Int -> Pattern
c_l_block_seq_entry n :: 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 -> Pattern
forall match result. Match match result => match -> Pattern
>!) 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 n :: Int
n c :: 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
.+ 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
.+ 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
forall match result. Match match result => match -> Pattern
?) 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
.+ 1) ) ) Pattern -> Pattern -> Pattern
forall match1 result.
Match match1 result =>
match1 -> Parser result -> Parser result
`recovery` Int -> Pattern
unparsed (Int
n Int -> Int -> Int
.+ 1)
ns_l_in_line_sequence :: Int -> Pattern
ns_l_in_line_sequence n :: 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 Pattern -> Pattern
forall match result. Match match result => match -> Pattern
*)
l__block_mapping :: Int -> Pattern
l__block_mapping n :: 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) Pattern -> Pattern
forall match result. Match match result => match -> Pattern
+)
ns_l_block_map_entry :: Int -> Pattern
ns_l_block_map_entry n :: 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 n :: 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 n :: 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 -> Pattern
forall match result. Match match result => match -> Pattern
>!) 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 n :: 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 n :: 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 n :: 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
forall match result. Match match result => match -> Pattern
?) 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
.+ 1) ) ) Pattern -> Pattern -> Pattern
forall match1 result.
Match match1 result =>
match1 -> Parser result -> Parser result
`recovery` Int -> Pattern
unparsed (Int
n Int -> Int -> Int
.+ 1) )
ns_l_in_line_mapping :: Int -> Pattern
ns_l_in_line_mapping n :: 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 Pattern -> Pattern
forall match result. Match match result => match -> Pattern
*)
unparsed :: Int -> Pattern
unparsed n :: 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 ) Pattern -> Pattern
forall match result. Match match result => match -> Pattern
*)
unparsed_indent :: Int -> Pattern
unparsed_indent n :: 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 n :: Int
n c :: 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 n :: Int
n = Int -> Context -> Pattern
s_separate (Int
n 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
.+ 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 n :: Int
n c :: 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 n :: Int
n c :: Context
c = Int -> Context -> Pattern
s_separate (Int
n 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
.+ 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
.+ 1) Context
c Pattern -> Pattern
forall match result. Match match result => match -> Pattern
?)
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 n :: Int
n c :: Context
c = ( Int -> Context -> Pattern
s_separate (Int
n 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
.+ 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
forall parameter result.
Match parameter result =>
parameter -> Parser result
>?) Pattern -> Pattern
forall match result. Match match result => match -> Pattern
?)
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 n :: Int
n c :: Context
c = case Context
c of
BlockOut -> Int
n Int -> Int -> Int
.- 1
BlockIn -> Int
n
_ -> String -> Int
forall a. HasCallStack => String -> a
error "unexpected node style pattern in seq_spaces"
l_document_prefix :: Pattern
l_document_prefix = ( Pattern
c_byte_order_mark Pattern -> Pattern
forall match result. Match match result => match -> Pattern
?) 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 Pattern -> Pattern
forall match result. Match match result => match -> Pattern
*)
c_directives_end :: Pattern
c_directives_end = Code -> String -> Pattern
forall match result. Match match result => Code -> match -> Pattern
token Code
DirectivesEnd [ '-', '-', '-' ]
c_document_end :: Pattern
c_document_end = Code -> String -> Pattern
forall match result. Match match result => Code -> match -> Pattern
token Code
DocumentEnd [ '.', '.', '.' ]
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 (-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 -> Pattern
forall parameter result.
Match parameter result =>
parameter -> Parser result
>?)) 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
forall match result. Match match result => match -> Pattern
?) Pattern -> Pattern -> Pattern
forall match1 result1 match2 result2.
(Match match1 result1, Match match2 result2) =>
match1 -> match2 -> Parser result2
& Int -> Pattern
unparsed 0 ) Pattern -> Pattern -> Pattern
forall match1 result.
Match match1 result =>
match1 -> Parser result -> Parser result
`recovery` Int -> Pattern
unparsed 0 )
l_directives_document :: Pattern
l_directives_document = ( Pattern
l_directive Pattern -> Pattern
forall match result. Match match result => match -> Pattern
+)
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 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
forall match result. Match match result => match -> Pattern
*)
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
forall parameter result.
Match parameter result =>
parameter -> Parser result
>?) 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
forall match result. Match match result => match -> Pattern
+) 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
forall match result. Match match result => match -> Pattern
*) 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
forall match result. Match match result => match -> Pattern
*) 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 Pattern -> Pattern
forall match result. Match match result => match -> Pattern
?) ) ) Pattern -> Pattern
forall match result. Match match result => match -> Pattern
*)