1 namespace {
2 const char *ex2_1 =
3     "- Mark McGwire\n"
4     "- Sammy Sosa\n"
5     "- Ken Griffey";
6 
7 const char *ex2_2 =
8     "hr:  65    # Home runs\n"
9     "avg: 0.278 # Batting average\n"
10     "rbi: 147   # Runs Batted In";
11 
12 const char *ex2_3 =
13     "american:\n"
14     "- Boston Red Sox\n"
15     "- Detroit Tigers\n"
16     "- New York Yankees\n"
17     "national:\n"
18     "- New York Mets\n"
19     "- Chicago Cubs\n"
20     "- Atlanta Braves";
21 
22 const char *ex2_4 =
23     "-\n"
24     "  name: Mark McGwire\n"
25     "  hr:   65\n"
26     "  avg:  0.278\n"
27     "-\n"
28     "  name: Sammy Sosa\n"
29     "  hr:   63\n"
30     "  avg:  0.288";
31 
32 const char *ex2_5 =
33     "- [name        , hr, avg  ]\n"
34     "- [Mark McGwire, 65, 0.278]\n"
35     "- [Sammy Sosa  , 63, 0.288]";
36 
37 const char *ex2_6 =
38     "Mark McGwire: {hr: 65, avg: 0.278}\n"
39     "Sammy Sosa: {\n"
40     "    hr: 63,\n"
41     "    avg: 0.288\n"
42     "  }";
43 
44 const char *ex2_7 =
45     "# Ranking of 1998 home runs\n"
46     "---\n"
47     "- Mark McGwire\n"
48     "- Sammy Sosa\n"
49     "- Ken Griffey\n"
50     "\n"
51     "# Team ranking\n"
52     "---\n"
53     "- Chicago Cubs\n"
54     "- St Louis Cardinals";
55 
56 const char *ex2_8 =
57     "---\n"
58     "time: 20:03:20\n"
59     "player: Sammy Sosa\n"
60     "action: strike (miss)\n"
61     "...\n"
62     "---\n"
63     "time: 20:03:47\n"
64     "player: Sammy Sosa\n"
65     "action: grand slam\n"
66     "...";
67 
68 const char *ex2_9 =
69     "---\n"
70     "hr: # 1998 hr ranking\n"
71     "  - Mark McGwire\n"
72     "  - Sammy Sosa\n"
73     "rbi:\n"
74     "  # 1998 rbi ranking\n"
75     "  - Sammy Sosa\n"
76     "  - Ken Griffey";
77 
78 const char *ex2_10 =
79     "---\n"
80     "hr:\n"
81     "  - Mark McGwire\n"
82     "  # Following node labeled SS\n"
83     "  - &SS Sammy Sosa\n"
84     "rbi:\n"
85     "  - *SS # Subsequent occurrence\n"
86     "  - Ken Griffey";
87 
88 const char *ex2_11 =
89     "? - Detroit Tigers\n"
90     "  - Chicago cubs\n"
91     ":\n"
92     "  - 2001-07-23\n"
93     "\n"
94     "? [ New York Yankees,\n"
95     "    Atlanta Braves ]\n"
96     ": [ 2001-07-02, 2001-08-12,\n"
97     "    2001-08-14 ]";
98 
99 const char *ex2_12 =
100     "---\n"
101     "# Products purchased\n"
102     "- item    : Super Hoop\n"
103     "  quantity: 1\n"
104     "- item    : Basketball\n"
105     "  quantity: 4\n"
106     "- item    : Big Shoes\n"
107     "  quantity: 1";
108 
109 const char *ex2_13 =
110     "# ASCII Art\n"
111     "--- |\n"
112     "  \\//||\\/||\n"
113     "  // ||  ||__";
114 
115 const char *ex2_14 =
116     "--- >\n"
117     "  Mark McGwire's\n"
118     "  year was crippled\n"
119     "  by a knee injury.";
120 
121 const char *ex2_15 =
122     ">\n"
123     " Sammy Sosa completed another\n"
124     " fine season with great stats.\n"
125     " \n"
126     "   63 Home Runs\n"
127     "   0.288 Batting Average\n"
128     " \n"
129     " What a year!";
130 
131 const char *ex2_16 =
132     "name: Mark McGwire\n"
133     "accomplishment: >\n"
134     "  Mark set a major league\n"
135     "  home run record in 1998.\n"
136     "stats: |\n"
137     "  65 Home Runs\n"
138     "  0.278 Batting Average\n";
139 
140 const char *ex2_17 =
141     "unicode: \"Sosa did fine.\\u263A\"\n"
142     "control: \"\\b1998\\t1999\\t2000\\n\"\n"
143     "hex esc: \"\\x0d\\x0a is \\r\\n\"\n"
144     "\n"
145     "single: '\"Howdy!\" he cried.'\n"
146     "quoted: ' # Not a ''comment''.'\n"
147     "tie-fighter: '|\\-*-/|'";
148 
149 const char *ex2_18 =
150     "plain:\n"
151     "  This unquoted scalar\n"
152     "  spans many lines.\n"
153     "\n"
154     "quoted: \"So does this\n"
155     "  quoted scalar.\\n\"";
156 
157 // TODO: 2.19 - 2.22 schema tags
158 
159 const char *ex2_23 =
160     "---\n"
161     "not-date: !!str 2002-04-28\n"
162     "\n"
163     "picture: !!binary |\n"
164     " R0lGODlhDAAMAIQAAP//9/X\n"
165     " 17unp5WZmZgAAAOfn515eXv\n"
166     " Pz7Y6OjuDg4J+fn5OTk6enp\n"
167     " 56enmleECcgggoBADs=\n"
168     "\n"
169     "application specific tag: !something |\n"
170     " The semantics of the tag\n"
171     " above may be different for\n"
172     " different documents.";
173 
174 const char *ex2_24 =
175     "%TAG ! tag:clarkevans.com,2002:\n"
176     "--- !shape\n"
177     "  # Use the ! handle for presenting\n"
178     "  # tag:clarkevans.com,2002:circle\n"
179     "- !circle\n"
180     "  center: &ORIGIN {x: 73, y: 129}\n"
181     "  radius: 7\n"
182     "- !line\n"
183     "  start: *ORIGIN\n"
184     "  finish: { x: 89, y: 102 }\n"
185     "- !label\n"
186     "  start: *ORIGIN\n"
187     "  color: 0xFFEEBB\n"
188     "  text: Pretty vector drawing.";
189 
190 const char *ex2_25 =
191     "# Sets are represented as a\n"
192     "# Mapping where each key is\n"
193     "# associated with a null value\n"
194     "--- !!set\n"
195     "? Mark McGwire\n"
196     "? Sammy Sosa\n"
197     "? Ken Griffey";
198 
199 const char *ex2_26 =
200     "# Ordered maps are represented as\n"
201     "# A sequence of mappings, with\n"
202     "# each mapping having one key\n"
203     "--- !!omap\n"
204     "- Mark McGwire: 65\n"
205     "- Sammy Sosa: 63\n"
206     "- Ken Griffey: 58";
207 
208 const char *ex2_27 =
209     "--- !<tag:clarkevans.com,2002:invoice>\n"
210     "invoice: 34843\n"
211     "date   : 2001-01-23\n"
212     "bill-to: &id001\n"
213     "    given  : Chris\n"
214     "    family : Dumars\n"
215     "    address:\n"
216     "        lines: |\n"
217     "            458 Walkman Dr.\n"
218     "            Suite #292\n"
219     "        city    : Royal Oak\n"
220     "        state   : MI\n"
221     "        postal  : 48046\n"
222     "ship-to: *id001\n"
223     "product:\n"
224     "    - sku         : BL394D\n"
225     "      quantity    : 4\n"
226     "      description : Basketball\n"
227     "      price       : 450.00\n"
228     "    - sku         : BL4438H\n"
229     "      quantity    : 1\n"
230     "      description : Super Hoop\n"
231     "      price       : 2392.00\n"
232     "tax  : 251.42\n"
233     "total: 4443.52\n"
234     "comments:\n"
235     "    Late afternoon is best.\n"
236     "    Backup contact is Nancy\n"
237     "    Billsmer @ 338-4338.";
238 
239 const char *ex2_28 =
240     "---\n"
241     "Time: 2001-11-23 15:01:42 -5\n"
242     "User: ed\n"
243     "Warning:\n"
244     "  This is an error message\n"
245     "  for the log file\n"
246     "---\n"
247     "Time: 2001-11-23 15:02:31 -5\n"
248     "User: ed\n"
249     "Warning:\n"
250     "  A slightly different error\n"
251     "  message.\n"
252     "---\n"
253     "Date: 2001-11-23 15:03:17 -5\n"
254     "User: ed\n"
255     "Fatal:\n"
256     "  Unknown variable \"bar\"\n"
257     "Stack:\n"
258     "  - file: TopClass.py\n"
259     "    line: 23\n"
260     "    code: |\n"
261     "      x = MoreObject(\"345\\n\")\n"
262     "  - file: MoreClass.py\n"
263     "    line: 58\n"
264     "    code: |-\n"
265     "      foo = bar";
266 
267 // TODO: 5.1 - 5.2 BOM
268 
269 const char *ex5_3 =
270     "sequence:\n"
271     "- one\n"
272     "- two\n"
273     "mapping:\n"
274     "  ? sky\n"
275     "  : blue\n"
276     "  sea : green";
277 
278 const char *ex5_4 =
279     "sequence: [ one, two, ]\n"
280     "mapping: { sky: blue, sea: green }";
281 
282 const char *ex5_5 = "# Comment only.";
283 
284 const char *ex5_6 =
285     "anchored: !local &anchor value\n"
286     "alias: *anchor";
287 
288 const char *ex5_7 =
289     "literal: |\n"
290     "  some\n"
291     "  text\n"
292     "folded: >\n"
293     "  some\n"
294     "  text\n";
295 
296 const char *ex5_8 =
297     "single: 'text'\n"
298     "double: \"text\"";
299 
300 // TODO: 5.9 directive
301 // TODO: 5.10 reserved indicator
302 
303 const char *ex5_11 =
304     "|\n"
305     "  Line break (no glyph)\n"
306     "  Line break (glyphed)\n";
307 
308 const char *ex5_12 =
309     "# Tabs and spaces\n"
310     "quoted: \"Quoted\t\"\n"
311     "block:	|\n"
312     "  void main() {\n"
313     "  \tprintf(\"Hello, world!\\n\");\n"
314     "  }";
315 
316 const char *ex5_13 =
317     "\"Fun with \\\\\n"
318     "\\\" \\a \\b \\e \\f \\\n"
319     "\\n \\r \\t \\v \\0 \\\n"
320     "\\  \\_ \\N \\L \\P \\\n"
321     "\\x41 \\u0041 \\U00000041\"";
322 
323 const char *ex5_14 =
324     "Bad escapes:\n"
325     "  \"\\c\n"
326     "  \\xq-\"";
327 
328 const char *ex6_1 =
329     "  # Leading comment line spaces are\n"
330     "   # neither content nor indentation.\n"
331     "    \n"
332     "Not indented:\n"
333     " By one space: |\n"
334     "    By four\n"
335     "      spaces\n"
336     " Flow style: [    # Leading spaces\n"
337     "   By two,        # in flow style\n"
338     "  Also by two,    # are neither\n"
339     "  \tStill by two   # content nor\n"
340     "    ]             # indentation.";
341 
342 const char *ex6_2 =
343     "? a\n"
344     ": -\tb\n"
345     "  -  -\tc\n"
346     "     - d";
347 
348 const char *ex6_3 =
349     "- foo:\t bar\n"
350     "- - baz\n"
351     "  -\tbaz";
352 
353 const char *ex6_4 =
354     "plain: text\n"
355     "  lines\n"
356     "quoted: \"text\n"
357     "  \tlines\"\n"
358     "block: |\n"
359     "  text\n"
360     "   \tlines\n";
361 
362 const char *ex6_5 =
363     "Folding:\n"
364     "  \"Empty line\n"
365     "   \t\n"
366     "  as a line feed\"\n"
367     "Chomping: |\n"
368     "  Clipped empty lines\n"
369     " ";
370 
371 const char *ex6_6 =
372     ">-\n"
373     "  trimmed\n"
374     "  \n"
375     " \n"
376     "\n"
377     "  as\n"
378     "  space";
379 
380 const char *ex6_7 =
381     ">\n"
382     "  foo \n"
383     " \n"
384     "  \t bar\n"
385     "\n"
386     "  baz\n";
387 
388 const char *ex6_8 =
389     "\"\n"
390     "  foo \n"
391     " \n"
392     "  \t bar\n"
393     "\n"
394     "  baz\n"
395     "\"";
396 
397 const char *ex6_9 =
398     "key:    # Comment\n"
399     "  value";
400 
401 const char *ex6_10 =
402     "  # Comment\n"
403     "   \n"
404     "\n";
405 
406 const char *ex6_11 =
407     "key:    # Comment\n"
408     "        # lines\n"
409     "  value\n"
410     "\n";
411 
412 const char *ex6_12 =
413     "{ first: Sammy, last: Sosa }:\n"
414     "# Statistics:\n"
415     "  hr:  # Home runs\n"
416     "     65\n"
417     "  avg: # Average\n"
418     "   0.278";
419 
420 const char *ex6_13 =
421     "%FOO  bar baz # Should be ignored\n"
422     "               # with a warning.\n"
423     "--- \"foo\"";
424 
425 const char *ex6_14 =
426     "%YAML 1.3 # Attempt parsing\n"
427     "           # with a warning\n"
428     "---\n"
429     "\"foo\"";
430 
431 const char *ex6_15 =
432     "%YAML 1.2\n"
433     "%YAML 1.1\n"
434     "foo";
435 
436 const char *ex6_16 =
437     "%TAG !yaml! tag:yaml.org,2002:\n"
438     "---\n"
439     "!yaml!str \"foo\"";
440 
441 const char *ex6_17 =
442     "%TAG ! !foo\n"
443     "%TAG ! !foo\n"
444     "bar";
445 
446 const char *ex6_18 =
447     "# Private\n"
448     "!foo \"bar\"\n"
449     "...\n"
450     "# Global\n"
451     "%TAG ! tag:example.com,2000:app/\n"
452     "---\n"
453     "!foo \"bar\"";
454 
455 const char *ex6_19 =
456     "%TAG !! tag:example.com,2000:app/\n"
457     "---\n"
458     "!!int 1 - 3 # Interval, not integer";
459 
460 const char *ex6_20 =
461     "%TAG !e! tag:example.com,2000:app/\n"
462     "---\n"
463     "!e!foo \"bar\"";
464 
465 const char *ex6_21 =
466     "%TAG !m! !my-\n"
467     "--- # Bulb here\n"
468     "!m!light fluorescent\n"
469     "...\n"
470     "%TAG !m! !my-\n"
471     "--- # Color here\n"
472     "!m!light green";
473 
474 const char *ex6_22 =
475     "%TAG !e! tag:example.com,2000:app/\n"
476     "---\n"
477     "- !e!foo \"bar\"";
478 
479 const char *ex6_23 =
480     "!!str &a1 \"foo\":\n"
481     "  !!str bar\n"
482     "&a2 baz : *a1";
483 
484 const char *ex6_24 =
485     "!<tag:yaml.org,2002:str> foo :\n"
486     "  !<!bar> baz";
487 
488 const char *ex6_25 =
489     "- !<!> foo\n"
490     "- !<$:?> bar\n";
491 
492 const char *ex6_26 =
493     "%TAG !e! tag:example.com,2000:app/\n"
494     "---\n"
495     "- !local foo\n"
496     "- !!str bar\n"
497     "- !e!tag%21 baz\n";
498 
499 const char *ex6_27a =
500     "%TAG !e! tag:example,2000:app/\n"
501     "---\n"
502     "- !e! foo";
503 
504 const char *ex6_27b =
505     "%TAG !e! tag:example,2000:app/\n"
506     "---\n"
507     "- !h!bar baz";
508 
509 const char *ex6_28 =
510     "# Assuming conventional resolution:\n"
511     "- \"12\"\n"
512     "- 12\n"
513     "- ! 12";
514 
515 const char *ex6_29 =
516     "First occurrence: &anchor Value\n"
517     "Second occurrence: *anchor";
518 
519 const char *ex7_1 =
520     "First occurrence: &anchor Foo\n"
521     "Second occurrence: *anchor\n"
522     "Override anchor: &anchor Bar\n"
523     "Reuse anchor: *anchor";
524 
525 const char *ex7_2 =
526     "{\n"
527     "  foo : !!str,\n"
528     "  !!str : bar,\n"
529     "}";
530 
531 const char *ex7_3 =
532     "{\n"
533     "  ? foo :,\n"
534     "  : bar,\n"
535     "}\n";
536 
537 const char *ex7_4 =
538     "\"implicit block key\" : [\n"
539     "  \"implicit flow key\" : value,\n"
540     " ]";
541 
542 const char *ex7_5 =
543     "\"folded \n"
544     "to a space,\t\n"
545     " \n"
546     "to a line feed, or \t\\\n"
547     " \\ \tnon-content\"";
548 
549 const char *ex7_6 =
550     "\" 1st non-empty\n"
551     "\n"
552     " 2nd non-empty \n"
553     "\t3rd non-empty \"";
554 
555 const char *ex7_7 = " 'here''s to \"quotes\"'";
556 
557 const char *ex7_8 =
558     "'implicit block key' : [\n"
559     "  'implicit flow key' : value,\n"
560     " ]";
561 
562 const char *ex7_9 =
563     "' 1st non-empty\n"
564     "\n"
565     " 2nd non-empty \n"
566     "\t3rd non-empty '";
567 
568 const char *ex7_10 =
569     "# Outside flow collection:\n"
570     "- ::vector\n"
571     "- \": - ()\"\n"
572     "- Up, up, and away!\n"
573     "- -123\n"
574     "- http://example.com/foo#bar\n"
575     "# Inside flow collection:\n"
576     "- [ ::vector,\n"
577     "  \": - ()\",\n"
578     "  \"Up, up, and away!\",\n"
579     "  -123,\n"
580     "  http://example.com/foo#bar ]";
581 
582 const char *ex7_11 =
583     "implicit block key : [\n"
584     "  implicit flow key : value,\n"
585     " ]";
586 
587 const char *ex7_12 =
588     "1st non-empty\n"
589     "\n"
590     " 2nd non-empty \n"
591     "\t3rd non-empty";
592 
593 const char *ex7_13 =
594     "- [ one, two, ]\n"
595     "- [three ,four]";
596 
597 const char *ex7_14 =
598     "[\n"
599     "\"double\n"
600     " quoted\", 'single\n"
601     "           quoted',\n"
602     "plain\n"
603     " text, [ nested ],\n"
604     "single: pair,\n"
605     "]";
606 
607 const char *ex7_15 =
608     "- { one : two , three: four , }\n"
609     "- {five: six,seven : eight}";
610 
611 const char *ex7_16 =
612     "{\n"
613     "? explicit: entry,\n"
614     "implicit: entry,\n"
615     "?\n"
616     "}";
617 
618 const char *ex7_17 =
619     "{\n"
620     "unquoted : \"separate\",\n"
621     "http://foo.com,\n"
622     "omitted value:,\n"
623     ": omitted key,\n"
624     "}";
625 
626 const char *ex7_18 =
627     "{\n"
628     "\"adjacent\":value,\n"
629     "\"readable\":value,\n"
630     "\"empty\":\n"
631     "}";
632 
633 const char *ex7_19 =
634     "[\n"
635     "foo: bar\n"
636     "]";
637 
638 const char *ex7_20 =
639     "[\n"
640     "? foo\n"
641     " bar : baz\n"
642     "]";
643 
644 const char *ex7_21 =
645     "- [ YAML : separate ]\n"
646     "- [ : empty key entry ]\n"
647     "- [ {JSON: like}:adjacent ]";
648 
649 const char *ex7_22 =
650     "[ foo\n"
651     " bar: invalid,";  // Note: we don't check (on purpose) the >1K chars for an
652                        // implicit key
653 
654 const char *ex7_23 =
655     "- [ a, b ]\n"
656     "- { a: b }\n"
657     "- \"a\"\n"
658     "- 'b'\n"
659     "- c";
660 
661 const char *ex7_24 =
662     "- !!str \"a\"\n"
663     "- 'b'\n"
664     "- &anchor \"c\"\n"
665     "- *anchor\n"
666     "- !!str";
667 
668 const char *ex8_1 =
669     "- | # Empty header\n"
670     " literal\n"
671     "- >1 # Indentation indicator\n"
672     "  folded\n"
673     "- |+ # Chomping indicator\n"
674     " keep\n"
675     "\n"
676     "- >1- # Both indicators\n"
677     "  strip\n";
678 
679 const char *ex8_2 =
680     "- |\n"
681     " detected\n"
682     "- >\n"
683     " \n"
684     "  \n"
685     "  # detected\n"
686     "- |1\n"
687     "  explicit\n"
688     "- >\n"
689     " \t\n"
690     " detected\n";
691 
692 const char *ex8_3a =
693     "- |\n"
694     "  \n"
695     " text";
696 
697 const char *ex8_3b =
698     "- >\n"
699     "  text\n"
700     " text";
701 
702 const char *ex8_3c =
703     "- |2\n"
704     " text";
705 
706 const char *ex8_4 =
707     "strip: |-\n"
708     "  text\n"
709     "clip: |\n"
710     "  text\n"
711     "keep: |+\n"
712     "  text\n";
713 
714 const char *ex8_5 =
715     " # Strip\n"
716     "  # Comments:\n"
717     "strip: |-\n"
718     "  # text\n"
719     "  \n"
720     " # Clip\n"
721     "  # comments:\n"
722     "\n"
723     "clip: |\n"
724     "  # text\n"
725     " \n"
726     " # Keep\n"
727     "  # comments:\n"
728     "\n"
729     "keep: |+\n"
730     "  # text\n"
731     "\n"
732     " # Trail\n"
733     "  # Comments\n";
734 
735 const char *ex8_6 =
736     "strip: >-\n"
737     "\n"
738     "clip: >\n"
739     "\n"
740     "keep: |+\n"
741     "\n";
742 
743 const char *ex8_7 =
744     "|\n"
745     " literal\n"
746     " \ttext\n"
747     "\n";
748 
749 const char *ex8_8 =
750     "|\n"
751     " \n"
752     "  \n"
753     "  literal\n"
754     "   \n"
755     "  \n"
756     "  text\n"
757     "\n"
758     " # Comment\n";
759 
760 const char *ex8_9 =
761     ">\n"
762     " folded\n"
763     " text\n"
764     "\n";
765 
766 const char *ex8_10 =
767     ">\n"
768     "\n"
769     " folded\n"
770     " line\n"
771     "\n"
772     " next\n"
773     " line\n"
774     "   * bullet\n"
775     "\n"
776     "   * list\n"
777     "   * lines\n"
778     "\n"
779     " last\n"
780     " line\n"
781     "\n"
782     "# Comment\n";
783 
784 const char *ex8_11 = ex8_10;
785 const char *ex8_12 = ex8_10;
786 const char *ex8_13 = ex8_10;
787 
788 const char *ex8_14 =
789     "block sequence:\n"
790     "  - one\n"
791     "  - two : three\n";
792 
793 const char *ex8_15 =
794     "- # Empty\n"
795     "- |\n"
796     " block node\n"
797     "- - one # Compact\n"
798     "  - two # sequence\n"
799     "- one: two # Compact mapping\n";
800 
801 const char *ex8_16 =
802     "block mapping:\n"
803     " key: value\n";
804 
805 const char *ex8_17 =
806     "? explicit key # Empty value\n"
807     "? |\n"
808     "  block key\n"
809     ": - one # Explicit compact\n"
810     "  - two # block value\n";
811 
812 const char *ex8_18 =
813     "plain key: in-line value\n"
814     ":  # Both empty\n"
815     "\"quoted key\":\n"
816     "- entry\n";
817 
818 const char *ex8_19 =
819     "- sun: yellow\n"
820     "- ? earth: blue\n"
821     "  : moon: white\n";
822 
823 const char *ex8_20 =
824     "-\n"
825     "  \"flow in block\"\n"
826     "- >\n"
827     " Block scalar\n"
828     "- !!map # Block collection\n"
829     "  foo : bar\n";
830 
831 const char *ex8_21 =
832     "literal: |2\n"
833     "  value\n"
834     "folded:\n"
835     "   !foo\n"
836     "  >1\n"
837     " value\n";
838 
839 const char *ex8_22 =
840     "sequence: !!seq\n"
841     "- entry\n"
842     "- !!seq\n"
843     " - nested\n"
844     "mapping: !!map\n"
845     " foo: bar\n";
846 }
847