...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 package yaml
24
25 import (
26 "fmt"
27 "io"
28 )
29
30
31 type yaml_version_directive_t struct {
32 major int8
33 minor int8
34 }
35
36
37 type yaml_tag_directive_t struct {
38 handle []byte
39 prefix []byte
40 }
41
42 type yaml_encoding_t int
43
44
45 const (
46
47 yaml_ANY_ENCODING yaml_encoding_t = iota
48
49 yaml_UTF8_ENCODING
50 yaml_UTF16LE_ENCODING
51 yaml_UTF16BE_ENCODING
52 )
53
54 type yaml_break_t int
55
56
57 const (
58
59 yaml_ANY_BREAK yaml_break_t = iota
60
61 yaml_CR_BREAK
62 yaml_LN_BREAK
63 yaml_CRLN_BREAK
64 )
65
66 type yaml_error_type_t int
67
68
69 const (
70
71 yaml_NO_ERROR yaml_error_type_t = iota
72
73 yaml_MEMORY_ERROR
74 yaml_READER_ERROR
75 yaml_SCANNER_ERROR
76 yaml_PARSER_ERROR
77 yaml_COMPOSER_ERROR
78 yaml_WRITER_ERROR
79 yaml_EMITTER_ERROR
80 )
81
82
83 type yaml_mark_t struct {
84 index int
85 line int
86 column int
87 }
88
89
90
91 type yaml_style_t int8
92
93 type yaml_scalar_style_t yaml_style_t
94
95
96 const (
97
98 yaml_ANY_SCALAR_STYLE yaml_scalar_style_t = 0
99
100 yaml_PLAIN_SCALAR_STYLE yaml_scalar_style_t = 1 << iota
101 yaml_SINGLE_QUOTED_SCALAR_STYLE
102 yaml_DOUBLE_QUOTED_SCALAR_STYLE
103 yaml_LITERAL_SCALAR_STYLE
104 yaml_FOLDED_SCALAR_STYLE
105 )
106
107 type yaml_sequence_style_t yaml_style_t
108
109
110 const (
111
112 yaml_ANY_SEQUENCE_STYLE yaml_sequence_style_t = iota
113
114 yaml_BLOCK_SEQUENCE_STYLE
115 yaml_FLOW_SEQUENCE_STYLE
116 )
117
118 type yaml_mapping_style_t yaml_style_t
119
120
121 const (
122
123 yaml_ANY_MAPPING_STYLE yaml_mapping_style_t = iota
124
125 yaml_BLOCK_MAPPING_STYLE
126 yaml_FLOW_MAPPING_STYLE
127 )
128
129
130
131 type yaml_token_type_t int
132
133
134 const (
135
136 yaml_NO_TOKEN yaml_token_type_t = iota
137
138 yaml_STREAM_START_TOKEN
139 yaml_STREAM_END_TOKEN
140
141 yaml_VERSION_DIRECTIVE_TOKEN
142 yaml_TAG_DIRECTIVE_TOKEN
143 yaml_DOCUMENT_START_TOKEN
144 yaml_DOCUMENT_END_TOKEN
145
146 yaml_BLOCK_SEQUENCE_START_TOKEN
147 yaml_BLOCK_MAPPING_START_TOKEN
148 yaml_BLOCK_END_TOKEN
149
150 yaml_FLOW_SEQUENCE_START_TOKEN
151 yaml_FLOW_SEQUENCE_END_TOKEN
152 yaml_FLOW_MAPPING_START_TOKEN
153 yaml_FLOW_MAPPING_END_TOKEN
154
155 yaml_BLOCK_ENTRY_TOKEN
156 yaml_FLOW_ENTRY_TOKEN
157 yaml_KEY_TOKEN
158 yaml_VALUE_TOKEN
159
160 yaml_ALIAS_TOKEN
161 yaml_ANCHOR_TOKEN
162 yaml_TAG_TOKEN
163 yaml_SCALAR_TOKEN
164 )
165
166 func (tt yaml_token_type_t) String() string {
167 switch tt {
168 case yaml_NO_TOKEN:
169 return "yaml_NO_TOKEN"
170 case yaml_STREAM_START_TOKEN:
171 return "yaml_STREAM_START_TOKEN"
172 case yaml_STREAM_END_TOKEN:
173 return "yaml_STREAM_END_TOKEN"
174 case yaml_VERSION_DIRECTIVE_TOKEN:
175 return "yaml_VERSION_DIRECTIVE_TOKEN"
176 case yaml_TAG_DIRECTIVE_TOKEN:
177 return "yaml_TAG_DIRECTIVE_TOKEN"
178 case yaml_DOCUMENT_START_TOKEN:
179 return "yaml_DOCUMENT_START_TOKEN"
180 case yaml_DOCUMENT_END_TOKEN:
181 return "yaml_DOCUMENT_END_TOKEN"
182 case yaml_BLOCK_SEQUENCE_START_TOKEN:
183 return "yaml_BLOCK_SEQUENCE_START_TOKEN"
184 case yaml_BLOCK_MAPPING_START_TOKEN:
185 return "yaml_BLOCK_MAPPING_START_TOKEN"
186 case yaml_BLOCK_END_TOKEN:
187 return "yaml_BLOCK_END_TOKEN"
188 case yaml_FLOW_SEQUENCE_START_TOKEN:
189 return "yaml_FLOW_SEQUENCE_START_TOKEN"
190 case yaml_FLOW_SEQUENCE_END_TOKEN:
191 return "yaml_FLOW_SEQUENCE_END_TOKEN"
192 case yaml_FLOW_MAPPING_START_TOKEN:
193 return "yaml_FLOW_MAPPING_START_TOKEN"
194 case yaml_FLOW_MAPPING_END_TOKEN:
195 return "yaml_FLOW_MAPPING_END_TOKEN"
196 case yaml_BLOCK_ENTRY_TOKEN:
197 return "yaml_BLOCK_ENTRY_TOKEN"
198 case yaml_FLOW_ENTRY_TOKEN:
199 return "yaml_FLOW_ENTRY_TOKEN"
200 case yaml_KEY_TOKEN:
201 return "yaml_KEY_TOKEN"
202 case yaml_VALUE_TOKEN:
203 return "yaml_VALUE_TOKEN"
204 case yaml_ALIAS_TOKEN:
205 return "yaml_ALIAS_TOKEN"
206 case yaml_ANCHOR_TOKEN:
207 return "yaml_ANCHOR_TOKEN"
208 case yaml_TAG_TOKEN:
209 return "yaml_TAG_TOKEN"
210 case yaml_SCALAR_TOKEN:
211 return "yaml_SCALAR_TOKEN"
212 }
213 return "<unknown token>"
214 }
215
216
217 type yaml_token_t struct {
218
219 typ yaml_token_type_t
220
221
222 start_mark, end_mark yaml_mark_t
223
224
225 encoding yaml_encoding_t
226
227
228
229 value []byte
230
231
232 suffix []byte
233
234
235 prefix []byte
236
237
238 style yaml_scalar_style_t
239
240
241 major, minor int8
242 }
243
244
245
246 type yaml_event_type_t int8
247
248
249 const (
250
251 yaml_NO_EVENT yaml_event_type_t = iota
252
253 yaml_STREAM_START_EVENT
254 yaml_STREAM_END_EVENT
255 yaml_DOCUMENT_START_EVENT
256 yaml_DOCUMENT_END_EVENT
257 yaml_ALIAS_EVENT
258 yaml_SCALAR_EVENT
259 yaml_SEQUENCE_START_EVENT
260 yaml_SEQUENCE_END_EVENT
261 yaml_MAPPING_START_EVENT
262 yaml_MAPPING_END_EVENT
263 yaml_TAIL_COMMENT_EVENT
264 )
265
266 var eventStrings = []string{
267 yaml_NO_EVENT: "none",
268 yaml_STREAM_START_EVENT: "stream start",
269 yaml_STREAM_END_EVENT: "stream end",
270 yaml_DOCUMENT_START_EVENT: "document start",
271 yaml_DOCUMENT_END_EVENT: "document end",
272 yaml_ALIAS_EVENT: "alias",
273 yaml_SCALAR_EVENT: "scalar",
274 yaml_SEQUENCE_START_EVENT: "sequence start",
275 yaml_SEQUENCE_END_EVENT: "sequence end",
276 yaml_MAPPING_START_EVENT: "mapping start",
277 yaml_MAPPING_END_EVENT: "mapping end",
278 yaml_TAIL_COMMENT_EVENT: "tail comment",
279 }
280
281 func (e yaml_event_type_t) String() string {
282 if e < 0 || int(e) >= len(eventStrings) {
283 return fmt.Sprintf("unknown event %d", e)
284 }
285 return eventStrings[e]
286 }
287
288
289 type yaml_event_t struct {
290
291
292 typ yaml_event_type_t
293
294
295 start_mark, end_mark yaml_mark_t
296
297
298 encoding yaml_encoding_t
299
300
301 version_directive *yaml_version_directive_t
302
303
304 tag_directives []yaml_tag_directive_t
305
306
307 head_comment []byte
308 line_comment []byte
309 foot_comment []byte
310 tail_comment []byte
311
312
313 anchor []byte
314
315
316 tag []byte
317
318
319 value []byte
320
321
322
323 implicit bool
324
325
326 quoted_implicit bool
327
328
329 style yaml_style_t
330 }
331
332 func (e *yaml_event_t) scalar_style() yaml_scalar_style_t { return yaml_scalar_style_t(e.style) }
333 func (e *yaml_event_t) sequence_style() yaml_sequence_style_t { return yaml_sequence_style_t(e.style) }
334 func (e *yaml_event_t) mapping_style() yaml_mapping_style_t { return yaml_mapping_style_t(e.style) }
335
336
337
338 const (
339 yaml_NULL_TAG = "tag:yaml.org,2002:null"
340 yaml_BOOL_TAG = "tag:yaml.org,2002:bool"
341 yaml_STR_TAG = "tag:yaml.org,2002:str"
342 yaml_INT_TAG = "tag:yaml.org,2002:int"
343 yaml_FLOAT_TAG = "tag:yaml.org,2002:float"
344 yaml_TIMESTAMP_TAG = "tag:yaml.org,2002:timestamp"
345
346 yaml_SEQ_TAG = "tag:yaml.org,2002:seq"
347 yaml_MAP_TAG = "tag:yaml.org,2002:map"
348
349
350 yaml_BINARY_TAG = "tag:yaml.org,2002:binary"
351 yaml_MERGE_TAG = "tag:yaml.org,2002:merge"
352
353 yaml_DEFAULT_SCALAR_TAG = yaml_STR_TAG
354 yaml_DEFAULT_SEQUENCE_TAG = yaml_SEQ_TAG
355 yaml_DEFAULT_MAPPING_TAG = yaml_MAP_TAG
356 )
357
358 type yaml_node_type_t int
359
360
361 const (
362
363 yaml_NO_NODE yaml_node_type_t = iota
364
365 yaml_SCALAR_NODE
366 yaml_SEQUENCE_NODE
367 yaml_MAPPING_NODE
368 )
369
370
371 type yaml_node_item_t int
372
373
374 type yaml_node_pair_t struct {
375 key int
376 value int
377 }
378
379
380 type yaml_node_t struct {
381 typ yaml_node_type_t
382 tag []byte
383
384
385
386
387 scalar struct {
388 value []byte
389 length int
390 style yaml_scalar_style_t
391 }
392
393
394 sequence struct {
395 items_data []yaml_node_item_t
396 style yaml_sequence_style_t
397 }
398
399
400 mapping struct {
401 pairs_data []yaml_node_pair_t
402 pairs_start *yaml_node_pair_t
403 pairs_end *yaml_node_pair_t
404 pairs_top *yaml_node_pair_t
405 style yaml_mapping_style_t
406 }
407
408 start_mark yaml_mark_t
409 end_mark yaml_mark_t
410
411 }
412
413
414 type yaml_document_t struct {
415
416
417 nodes []yaml_node_t
418
419
420 version_directive *yaml_version_directive_t
421
422
423 tag_directives_data []yaml_tag_directive_t
424 tag_directives_start int
425 tag_directives_end int
426
427 start_implicit int
428 end_implicit int
429
430
431 start_mark, end_mark yaml_mark_t
432 }
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449 type yaml_read_handler_t func(parser *yaml_parser_t, buffer []byte) (n int, err error)
450
451
452 type yaml_simple_key_t struct {
453 possible bool
454 required bool
455 token_number int
456 mark yaml_mark_t
457 }
458
459
460 type yaml_parser_state_t int
461
462 const (
463 yaml_PARSE_STREAM_START_STATE yaml_parser_state_t = iota
464
465 yaml_PARSE_IMPLICIT_DOCUMENT_START_STATE
466 yaml_PARSE_DOCUMENT_START_STATE
467 yaml_PARSE_DOCUMENT_CONTENT_STATE
468 yaml_PARSE_DOCUMENT_END_STATE
469 yaml_PARSE_BLOCK_NODE_STATE
470 yaml_PARSE_BLOCK_NODE_OR_INDENTLESS_SEQUENCE_STATE
471 yaml_PARSE_FLOW_NODE_STATE
472 yaml_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE
473 yaml_PARSE_BLOCK_SEQUENCE_ENTRY_STATE
474 yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE
475 yaml_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE
476 yaml_PARSE_BLOCK_MAPPING_KEY_STATE
477 yaml_PARSE_BLOCK_MAPPING_VALUE_STATE
478 yaml_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE
479 yaml_PARSE_FLOW_SEQUENCE_ENTRY_STATE
480 yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE
481 yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE
482 yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE
483 yaml_PARSE_FLOW_MAPPING_FIRST_KEY_STATE
484 yaml_PARSE_FLOW_MAPPING_KEY_STATE
485 yaml_PARSE_FLOW_MAPPING_VALUE_STATE
486 yaml_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE
487 yaml_PARSE_END_STATE
488 )
489
490 func (ps yaml_parser_state_t) String() string {
491 switch ps {
492 case yaml_PARSE_STREAM_START_STATE:
493 return "yaml_PARSE_STREAM_START_STATE"
494 case yaml_PARSE_IMPLICIT_DOCUMENT_START_STATE:
495 return "yaml_PARSE_IMPLICIT_DOCUMENT_START_STATE"
496 case yaml_PARSE_DOCUMENT_START_STATE:
497 return "yaml_PARSE_DOCUMENT_START_STATE"
498 case yaml_PARSE_DOCUMENT_CONTENT_STATE:
499 return "yaml_PARSE_DOCUMENT_CONTENT_STATE"
500 case yaml_PARSE_DOCUMENT_END_STATE:
501 return "yaml_PARSE_DOCUMENT_END_STATE"
502 case yaml_PARSE_BLOCK_NODE_STATE:
503 return "yaml_PARSE_BLOCK_NODE_STATE"
504 case yaml_PARSE_BLOCK_NODE_OR_INDENTLESS_SEQUENCE_STATE:
505 return "yaml_PARSE_BLOCK_NODE_OR_INDENTLESS_SEQUENCE_STATE"
506 case yaml_PARSE_FLOW_NODE_STATE:
507 return "yaml_PARSE_FLOW_NODE_STATE"
508 case yaml_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE:
509 return "yaml_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE"
510 case yaml_PARSE_BLOCK_SEQUENCE_ENTRY_STATE:
511 return "yaml_PARSE_BLOCK_SEQUENCE_ENTRY_STATE"
512 case yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE:
513 return "yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE"
514 case yaml_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE:
515 return "yaml_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE"
516 case yaml_PARSE_BLOCK_MAPPING_KEY_STATE:
517 return "yaml_PARSE_BLOCK_MAPPING_KEY_STATE"
518 case yaml_PARSE_BLOCK_MAPPING_VALUE_STATE:
519 return "yaml_PARSE_BLOCK_MAPPING_VALUE_STATE"
520 case yaml_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE:
521 return "yaml_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE"
522 case yaml_PARSE_FLOW_SEQUENCE_ENTRY_STATE:
523 return "yaml_PARSE_FLOW_SEQUENCE_ENTRY_STATE"
524 case yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE:
525 return "yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE"
526 case yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE:
527 return "yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE"
528 case yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE:
529 return "yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE"
530 case yaml_PARSE_FLOW_MAPPING_FIRST_KEY_STATE:
531 return "yaml_PARSE_FLOW_MAPPING_FIRST_KEY_STATE"
532 case yaml_PARSE_FLOW_MAPPING_KEY_STATE:
533 return "yaml_PARSE_FLOW_MAPPING_KEY_STATE"
534 case yaml_PARSE_FLOW_MAPPING_VALUE_STATE:
535 return "yaml_PARSE_FLOW_MAPPING_VALUE_STATE"
536 case yaml_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE:
537 return "yaml_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE"
538 case yaml_PARSE_END_STATE:
539 return "yaml_PARSE_END_STATE"
540 }
541 return "<unknown parser state>"
542 }
543
544
545 type yaml_alias_data_t struct {
546 anchor []byte
547 index int
548 mark yaml_mark_t
549 }
550
551
552
553
554
555 type yaml_parser_t struct {
556
557
558
559 error yaml_error_type_t
560
561 problem string
562
563
564 problem_offset int
565 problem_value int
566 problem_mark yaml_mark_t
567
568
569 context string
570 context_mark yaml_mark_t
571
572
573
574 read_handler yaml_read_handler_t
575
576 input_reader io.Reader
577 input []byte
578 input_pos int
579
580 eof bool
581
582 buffer []byte
583 buffer_pos int
584
585 unread int
586
587 newlines int
588
589 raw_buffer []byte
590 raw_buffer_pos int
591
592 encoding yaml_encoding_t
593
594 offset int
595 mark yaml_mark_t
596
597
598
599 head_comment []byte
600 line_comment []byte
601 foot_comment []byte
602 tail_comment []byte
603 stem_comment []byte
604
605 comments []yaml_comment_t
606 comments_head int
607
608
609
610 stream_start_produced bool
611 stream_end_produced bool
612
613 flow_level int
614
615 tokens []yaml_token_t
616 tokens_head int
617 tokens_parsed int
618 token_available bool
619
620 indent int
621 indents []int
622
623 simple_key_allowed bool
624 simple_keys []yaml_simple_key_t
625 simple_keys_by_tok map[int]int
626
627
628
629 state yaml_parser_state_t
630 states []yaml_parser_state_t
631 marks []yaml_mark_t
632 tag_directives []yaml_tag_directive_t
633
634
635
636 aliases []yaml_alias_data_t
637
638 document *yaml_document_t
639 }
640
641 type yaml_comment_t struct {
642
643 scan_mark yaml_mark_t
644 token_mark yaml_mark_t
645 start_mark yaml_mark_t
646 end_mark yaml_mark_t
647
648 head []byte
649 line []byte
650 foot []byte
651 }
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669 type yaml_write_handler_t func(emitter *yaml_emitter_t, buffer []byte) error
670
671 type yaml_emitter_state_t int
672
673
674 const (
675
676 yaml_EMIT_STREAM_START_STATE yaml_emitter_state_t = iota
677
678 yaml_EMIT_FIRST_DOCUMENT_START_STATE
679 yaml_EMIT_DOCUMENT_START_STATE
680 yaml_EMIT_DOCUMENT_CONTENT_STATE
681 yaml_EMIT_DOCUMENT_END_STATE
682 yaml_EMIT_FLOW_SEQUENCE_FIRST_ITEM_STATE
683 yaml_EMIT_FLOW_SEQUENCE_TRAIL_ITEM_STATE
684 yaml_EMIT_FLOW_SEQUENCE_ITEM_STATE
685 yaml_EMIT_FLOW_MAPPING_FIRST_KEY_STATE
686 yaml_EMIT_FLOW_MAPPING_TRAIL_KEY_STATE
687 yaml_EMIT_FLOW_MAPPING_KEY_STATE
688 yaml_EMIT_FLOW_MAPPING_SIMPLE_VALUE_STATE
689 yaml_EMIT_FLOW_MAPPING_VALUE_STATE
690 yaml_EMIT_BLOCK_SEQUENCE_FIRST_ITEM_STATE
691 yaml_EMIT_BLOCK_SEQUENCE_ITEM_STATE
692 yaml_EMIT_BLOCK_MAPPING_FIRST_KEY_STATE
693 yaml_EMIT_BLOCK_MAPPING_KEY_STATE
694 yaml_EMIT_BLOCK_MAPPING_SIMPLE_VALUE_STATE
695 yaml_EMIT_BLOCK_MAPPING_VALUE_STATE
696 yaml_EMIT_END_STATE
697 )
698
699
700
701
702
703 type yaml_emitter_t struct {
704
705
706
707 error yaml_error_type_t
708 problem string
709
710
711
712 write_handler yaml_write_handler_t
713
714 output_buffer *[]byte
715 output_writer io.Writer
716
717 buffer []byte
718 buffer_pos int
719
720 raw_buffer []byte
721 raw_buffer_pos int
722
723 encoding yaml_encoding_t
724
725
726
727 canonical bool
728 best_indent int
729 best_width int
730 unicode bool
731 line_break yaml_break_t
732
733 state yaml_emitter_state_t
734 states []yaml_emitter_state_t
735
736 events []yaml_event_t
737 events_head int
738
739 indents []int
740
741 tag_directives []yaml_tag_directive_t
742
743 indent int
744
745 flow_level int
746
747 root_context bool
748 sequence_context bool
749 mapping_context bool
750 simple_key_context bool
751
752 line int
753 column int
754 whitespace bool
755 indention bool
756 open_ended bool
757
758 space_above bool
759 foot_indent int
760
761
762 anchor_data struct {
763 anchor []byte
764 alias bool
765 }
766
767
768 tag_data struct {
769 handle []byte
770 suffix []byte
771 }
772
773
774 scalar_data struct {
775 value []byte
776 multiline bool
777 flow_plain_allowed bool
778 block_plain_allowed bool
779 single_quoted_allowed bool
780 block_allowed bool
781 style yaml_scalar_style_t
782 }
783
784
785 head_comment []byte
786 line_comment []byte
787 foot_comment []byte
788 tail_comment []byte
789
790 key_line_comment []byte
791
792
793
794 opened bool
795 closed bool
796
797
798 anchors *struct {
799 references int
800 anchor int
801 serialized bool
802 }
803
804 last_anchor_id int
805
806 document *yaml_document_t
807 }
808
View as plain text