Skip to content
Tina Müller (tinita) edited this page Jan 2, 2018 · 7 revisions

Example

Here is an example of a YAML file and its parsing events:

# YAML
---
key a: 1
key b: 
- item 1
- item 2
1. stream-start
2. document-start
3. mapping-start
4. scalar 'key a'
5. scalar '1'
6. scalar 'key b'
7. sequence-start
8. scalar 'item 1'
9. scalar 'item 2'
10. sequence-end
11. mapping-end
12. document-end
13. stream-end

These are the events in test suite format:

+STR
+DOC
+MAP
=VAL :key a
=VAL :1
=VAL :key b
+SEQ
=VAL :item 1
=VAL :item 2
-SEQ
-MAP
-DOC
-STR

Events

+STR StreamStartEvent

Beginning of the YAML Stream

+STR

+DOC DocumentStartEvent

Beginning of a document

  • implicit: true/false

  • DocumentStartEvent(implicit=true)

  • +DOC

  • DocumentStartEvent(implicit=false)

  • +DOC ---

+SEQ SequenceStartEvent

Beginning of a Sequence

  • style: flow/block (collection style is not yet represented in the test.events)
  • anchor: string
  • tag: string
YAML:
sequence: &myalias !!seq [a, b]
  • SequenceStartEvent(style=flow, anchor=myalias, tag=!<tag:yaml.org,2002:seq>)
  • +SEQ &myalias !<tag:yaml.org,2002:seq>
YAML:
sequence: &myalias
  - a
  - b
  • SequenceStartEvent(anchor=myalias)
  • +SEQ &myalias
Clone this wiki locally