Copyright | © Herbert Valerio Riedel 2015-2018 |
---|---|
License | GPL-2.0-or-later |
Safe Haskell | Safe |
Language | Haskell2010 |
Event-stream oriented YAML parsing API
Synopsis
- parseEvents :: ByteString -> EvStream
- type EvStream = [Either (Pos, String) Event]
- data Event
- = StreamStart
- | StreamEnd
- | DocumentStart !Bool
- | DocumentEnd !Bool
- | Alias !Anchor
- | Scalar !(Maybe Anchor) !Tag !Style !Text
- | SequenceStart !(Maybe Anchor) !Tag
- | SequenceEnd
- | MappingStart !(Maybe Anchor) !Tag
- | MappingEnd
- data Style
- data Tag
- untagged :: Tag
- isUntagged :: Tag -> Bool
- tagToText :: Tag -> Maybe Text
- mkTag :: String -> Tag
- type Anchor = Text
- data Pos = Pos {
- posByteOffset :: !Int
- posCharOffset :: !Int
- posLine :: !Int
- posColumn :: !Int
Documentation
parseEvents :: ByteString -> EvStream Source #
Parse YAML Event
s from a lazy ByteString
.
The input ByteString
is expected to have a YAML 1.2 stream
using the UTF-8, UTF-16 (LE or BE), or UTF-32 (LE or BE) encodings
(which will be auto-detected).
type EvStream = [Either (Pos, String) Event] Source #
Event stream produced by parseEvents
A Left
value denotes parsing errors. The event stream ends
immediately once a Left
value is returned.
YAML Event Types
The events correspond to the ones from LibYAML
The grammar below defines well-formed streams of Event
s:
stream ::=StreamStart
document*StreamEnd
document ::=DocumentStart
nodeDocumentEnd
node ::=Alias
|Scalar
| sequence | mapping sequence ::=SequenceStart
node*SequenceEnd
mapping ::=MappingStart
(node node)*MappingEnd
Position in parsed YAML source
Pos | |
|