github.com/rochacon/deis@v1.0.2-0.20150903015341-6839b592a1ff/Godeps/_workspace/src/gopkg.in/yaml.v2/yamlh.go (about) 1 package yaml 2 3 import ( 4 "io" 5 ) 6 7 // The version directive data. 8 type yaml_version_directive_t struct { 9 major int8 // The major version number. 10 minor int8 // The minor version number. 11 } 12 13 // The tag directive data. 14 type yaml_tag_directive_t struct { 15 handle []byte // The tag handle. 16 prefix []byte // The tag prefix. 17 } 18 19 type yaml_encoding_t int 20 21 // The stream encoding. 22 const ( 23 // Let the parser choose the encoding. 24 yaml_ANY_ENCODING yaml_encoding_t = iota 25 26 yaml_UTF8_ENCODING // The default UTF-8 encoding. 27 yaml_UTF16LE_ENCODING // The UTF-16-LE encoding with BOM. 28 yaml_UTF16BE_ENCODING // The UTF-16-BE encoding with BOM. 29 ) 30 31 type yaml_break_t int 32 33 // Line break types. 34 const ( 35 // Let the parser choose the break type. 36 yaml_ANY_BREAK yaml_break_t = iota 37 38 yaml_CR_BREAK // Use CR for line breaks (Mac style). 39 yaml_LN_BREAK // Use LN for line breaks (Unix style). 40 yaml_CRLN_BREAK // Use CR LN for line breaks (DOS style). 41 ) 42 43 type yaml_error_type_t int 44 45 // Many bad things could happen with the parser and emitter. 46 const ( 47 // No error is produced. 48 yaml_NO_ERROR yaml_error_type_t = iota 49 50 yaml_MEMORY_ERROR // Cannot allocate or reallocate a block of memory. 51 yaml_READER_ERROR // Cannot read or decode the input stream. 52 yaml_SCANNER_ERROR // Cannot scan the input stream. 53 yaml_PARSER_ERROR // Cannot parse the input stream. 54 yaml_COMPOSER_ERROR // Cannot compose a YAML document. 55 yaml_WRITER_ERROR // Cannot write to the output stream. 56 yaml_EMITTER_ERROR // Cannot emit a YAML stream. 57 ) 58 59 // The pointer position. 60 type yaml_mark_t struct { 61 index int // The position index. 62 line int // The position line. 63 column int // The position column. 64 } 65 66 // Node Styles 67 68 type yaml_style_t int8 69 70 type yaml_scalar_style_t yaml_style_t 71 72 // Scalar styles. 73 const ( 74 // Let the emitter choose the style. 75 yaml_ANY_SCALAR_STYLE yaml_scalar_style_t = iota 76 77 yaml_PLAIN_SCALAR_STYLE // The plain scalar style. 78 yaml_SINGLE_QUOTED_SCALAR_STYLE // The single-quoted scalar style. 79 yaml_DOUBLE_QUOTED_SCALAR_STYLE // The double-quoted scalar style. 80 yaml_LITERAL_SCALAR_STYLE // The literal scalar style. 81 yaml_FOLDED_SCALAR_STYLE // The folded scalar style. 82 ) 83 84 type yaml_sequence_style_t yaml_style_t 85 86 // Sequence styles. 87 const ( 88 // Let the emitter choose the style. 89 yaml_ANY_SEQUENCE_STYLE yaml_sequence_style_t = iota 90 91 yaml_BLOCK_SEQUENCE_STYLE // The block sequence style. 92 yaml_FLOW_SEQUENCE_STYLE // The flow sequence style. 93 ) 94 95 type yaml_mapping_style_t yaml_style_t 96 97 // Mapping styles. 98 const ( 99 // Let the emitter choose the style. 100 yaml_ANY_MAPPING_STYLE yaml_mapping_style_t = iota 101 102 yaml_BLOCK_MAPPING_STYLE // The block mapping style. 103 yaml_FLOW_MAPPING_STYLE // The flow mapping style. 104 ) 105 106 // Tokens 107 108 type yaml_token_type_t int 109 110 // Token types. 111 const ( 112 // An empty token. 113 yaml_NO_TOKEN yaml_token_type_t = iota 114 115 yaml_STREAM_START_TOKEN // A STREAM-START token. 116 yaml_STREAM_END_TOKEN // A STREAM-END token. 117 118 yaml_VERSION_DIRECTIVE_TOKEN // A VERSION-DIRECTIVE token. 119 yaml_TAG_DIRECTIVE_TOKEN // A TAG-DIRECTIVE token. 120 yaml_DOCUMENT_START_TOKEN // A DOCUMENT-START token. 121 yaml_DOCUMENT_END_TOKEN // A DOCUMENT-END token. 122 123 yaml_BLOCK_SEQUENCE_START_TOKEN // A BLOCK-SEQUENCE-START token. 124 yaml_BLOCK_MAPPING_START_TOKEN // A BLOCK-SEQUENCE-END token. 125 yaml_BLOCK_END_TOKEN // A BLOCK-END token. 126 127 yaml_FLOW_SEQUENCE_START_TOKEN // A FLOW-SEQUENCE-START token. 128 yaml_FLOW_SEQUENCE_END_TOKEN // A FLOW-SEQUENCE-END token. 129 yaml_FLOW_MAPPING_START_TOKEN // A FLOW-MAPPING-START token. 130 yaml_FLOW_MAPPING_END_TOKEN // A FLOW-MAPPING-END token. 131 132 yaml_BLOCK_ENTRY_TOKEN // A BLOCK-ENTRY token. 133 yaml_FLOW_ENTRY_TOKEN // A FLOW-ENTRY token. 134 yaml_KEY_TOKEN // A KEY token. 135 yaml_VALUE_TOKEN // A VALUE token. 136 137 yaml_ALIAS_TOKEN // An ALIAS token. 138 yaml_ANCHOR_TOKEN // An ANCHOR token. 139 yaml_TAG_TOKEN // A TAG token. 140 yaml_SCALAR_TOKEN // A SCALAR token. 141 ) 142 143 func (tt yaml_token_type_t) String() string { 144 switch tt { 145 case yaml_NO_TOKEN: 146 return "yaml_NO_TOKEN" 147 case yaml_STREAM_START_TOKEN: 148 return "yaml_STREAM_START_TOKEN" 149 case yaml_STREAM_END_TOKEN: 150 return "yaml_STREAM_END_TOKEN" 151 case yaml_VERSION_DIRECTIVE_TOKEN: 152 return "yaml_VERSION_DIRECTIVE_TOKEN" 153 case yaml_TAG_DIRECTIVE_TOKEN: 154 return "yaml_TAG_DIRECTIVE_TOKEN" 155 case yaml_DOCUMENT_START_TOKEN: 156 return "yaml_DOCUMENT_START_TOKEN" 157 case yaml_DOCUMENT_END_TOKEN: 158 return "yaml_DOCUMENT_END_TOKEN" 159 case yaml_BLOCK_SEQUENCE_START_TOKEN: 160 return "yaml_BLOCK_SEQUENCE_START_TOKEN" 161 case yaml_BLOCK_MAPPING_START_TOKEN: 162 return "yaml_BLOCK_MAPPING_START_TOKEN" 163 case yaml_BLOCK_END_TOKEN: 164 return "yaml_BLOCK_END_TOKEN" 165 case yaml_FLOW_SEQUENCE_START_TOKEN: 166 return "yaml_FLOW_SEQUENCE_START_TOKEN" 167 case yaml_FLOW_SEQUENCE_END_TOKEN: 168 return "yaml_FLOW_SEQUENCE_END_TOKEN" 169 case yaml_FLOW_MAPPING_START_TOKEN: 170 return "yaml_FLOW_MAPPING_START_TOKEN" 171 case yaml_FLOW_MAPPING_END_TOKEN: 172 return "yaml_FLOW_MAPPING_END_TOKEN" 173 case yaml_BLOCK_ENTRY_TOKEN: 174 return "yaml_BLOCK_ENTRY_TOKEN" 175 case yaml_FLOW_ENTRY_TOKEN: 176 return "yaml_FLOW_ENTRY_TOKEN" 177 case yaml_KEY_TOKEN: 178 return "yaml_KEY_TOKEN" 179 case yaml_VALUE_TOKEN: 180 return "yaml_VALUE_TOKEN" 181 case yaml_ALIAS_TOKEN: 182 return "yaml_ALIAS_TOKEN" 183 case yaml_ANCHOR_TOKEN: 184 return "yaml_ANCHOR_TOKEN" 185 case yaml_TAG_TOKEN: 186 return "yaml_TAG_TOKEN" 187 case yaml_SCALAR_TOKEN: 188 return "yaml_SCALAR_TOKEN" 189 } 190 return "<unknown token>" 191 } 192 193 // The token structure. 194 type yaml_token_t struct { 195 // The token type. 196 typ yaml_token_type_t 197 198 // The start/end of the token. 199 start_mark, end_mark yaml_mark_t 200 201 // The stream encoding (for yaml_STREAM_START_TOKEN). 202 encoding yaml_encoding_t 203 204 // The alias/anchor/scalar value or tag/tag directive handle 205 // (for yaml_ALIAS_TOKEN, yaml_ANCHOR_TOKEN, yaml_SCALAR_TOKEN, yaml_TAG_TOKEN, yaml_TAG_DIRECTIVE_TOKEN). 206 value []byte 207 208 // The tag suffix (for yaml_TAG_TOKEN). 209 suffix []byte 210 211 // The tag directive prefix (for yaml_TAG_DIRECTIVE_TOKEN). 212 prefix []byte 213 214 // The scalar style (for yaml_SCALAR_TOKEN). 215 style yaml_scalar_style_t 216 217 // The version directive major/minor (for yaml_VERSION_DIRECTIVE_TOKEN). 218 major, minor int8 219 } 220 221 // Events 222 223 type yaml_event_type_t int8 224 225 // Event types. 226 const ( 227 // An empty event. 228 yaml_NO_EVENT yaml_event_type_t = iota 229 230 yaml_STREAM_START_EVENT // A STREAM-START event. 231 yaml_STREAM_END_EVENT // A STREAM-END event. 232 yaml_DOCUMENT_START_EVENT // A DOCUMENT-START event. 233 yaml_DOCUMENT_END_EVENT // A DOCUMENT-END event. 234 yaml_ALIAS_EVENT // An ALIAS event. 235 yaml_SCALAR_EVENT // A SCALAR event. 236 yaml_SEQUENCE_START_EVENT // A SEQUENCE-START event. 237 yaml_SEQUENCE_END_EVENT // A SEQUENCE-END event. 238 yaml_MAPPING_START_EVENT // A MAPPING-START event. 239 yaml_MAPPING_END_EVENT // A MAPPING-END event. 240 ) 241 242 // The event structure. 243 type yaml_event_t struct { 244 245 // The event type. 246 typ yaml_event_type_t 247 248 // The start and end of the event. 249 start_mark, end_mark yaml_mark_t 250 251 // The document encoding (for yaml_STREAM_START_EVENT). 252 encoding yaml_encoding_t 253 254 // The version directive (for yaml_DOCUMENT_START_EVENT). 255 version_directive *yaml_version_directive_t 256 257 // The list of tag directives (for yaml_DOCUMENT_START_EVENT). 258 tag_directives []yaml_tag_directive_t 259 260 // The anchor (for yaml_SCALAR_EVENT, yaml_SEQUENCE_START_EVENT, yaml_MAPPING_START_EVENT, yaml_ALIAS_EVENT). 261 anchor []byte 262 263 // The tag (for yaml_SCALAR_EVENT, yaml_SEQUENCE_START_EVENT, yaml_MAPPING_START_EVENT). 264 tag []byte 265 266 // The scalar value (for yaml_SCALAR_EVENT). 267 value []byte 268 269 // Is the document start/end indicator implicit, or the tag optional? 270 // (for yaml_DOCUMENT_START_EVENT, yaml_DOCUMENT_END_EVENT, yaml_SEQUENCE_START_EVENT, yaml_MAPPING_START_EVENT, yaml_SCALAR_EVENT). 271 implicit bool 272 273 // Is the tag optional for any non-plain style? (for yaml_SCALAR_EVENT). 274 quoted_implicit bool 275 276 // The style (for yaml_SCALAR_EVENT, yaml_SEQUENCE_START_EVENT, yaml_MAPPING_START_EVENT). 277 style yaml_style_t 278 } 279 280 func (e *yaml_event_t) scalar_style() yaml_scalar_style_t { return yaml_scalar_style_t(e.style) } 281 func (e *yaml_event_t) sequence_style() yaml_sequence_style_t { return yaml_sequence_style_t(e.style) } 282 func (e *yaml_event_t) mapping_style() yaml_mapping_style_t { return yaml_mapping_style_t(e.style) } 283 284 // Nodes 285 286 const ( 287 yaml_NULL_TAG = "tag:yaml.org,2002:null" // The tag !!null with the only possible value: null. 288 yaml_BOOL_TAG = "tag:yaml.org,2002:bool" // The tag !!bool with the values: true and false. 289 yaml_STR_TAG = "tag:yaml.org,2002:str" // The tag !!str for string values. 290 yaml_INT_TAG = "tag:yaml.org,2002:int" // The tag !!int for integer values. 291 yaml_FLOAT_TAG = "tag:yaml.org,2002:float" // The tag !!float for float values. 292 yaml_TIMESTAMP_TAG = "tag:yaml.org,2002:timestamp" // The tag !!timestamp for date and time values. 293 294 yaml_SEQ_TAG = "tag:yaml.org,2002:seq" // The tag !!seq is used to denote sequences. 295 yaml_MAP_TAG = "tag:yaml.org,2002:map" // The tag !!map is used to denote mapping. 296 297 // Not in original libyaml. 298 yaml_BINARY_TAG = "tag:yaml.org,2002:binary" 299 yaml_MERGE_TAG = "tag:yaml.org,2002:merge" 300 301 yaml_DEFAULT_SCALAR_TAG = yaml_STR_TAG // The default scalar tag is !!str. 302 yaml_DEFAULT_SEQUENCE_TAG = yaml_SEQ_TAG // The default sequence tag is !!seq. 303 yaml_DEFAULT_MAPPING_TAG = yaml_MAP_TAG // The default mapping tag is !!map. 304 ) 305 306 type yaml_node_type_t int 307 308 // Node types. 309 const ( 310 // An empty node. 311 yaml_NO_NODE yaml_node_type_t = iota 312 313 yaml_SCALAR_NODE // A scalar node. 314 yaml_SEQUENCE_NODE // A sequence node. 315 yaml_MAPPING_NODE // A mapping node. 316 ) 317 318 // An element of a sequence node. 319 type yaml_node_item_t int 320 321 // An element of a mapping node. 322 type yaml_node_pair_t struct { 323 key int // The key of the element. 324 value int // The value of the element. 325 } 326 327 // The node structure. 328 type yaml_node_t struct { 329 typ yaml_node_type_t // The node type. 330 tag []byte // The node tag. 331 332 // The node data. 333 334 // The scalar parameters (for yaml_SCALAR_NODE). 335 scalar struct { 336 value []byte // The scalar value. 337 length int // The length of the scalar value. 338 style yaml_scalar_style_t // The scalar style. 339 } 340 341 // The sequence parameters (for YAML_SEQUENCE_NODE). 342 sequence struct { 343 items_data []yaml_node_item_t // The stack of sequence items. 344 style yaml_sequence_style_t // The sequence style. 345 } 346 347 // The mapping parameters (for yaml_MAPPING_NODE). 348 mapping struct { 349 pairs_data []yaml_node_pair_t // The stack of mapping pairs (key, value). 350 pairs_start *yaml_node_pair_t // The beginning of the stack. 351 pairs_end *yaml_node_pair_t // The end of the stack. 352 pairs_top *yaml_node_pair_t // The top of the stack. 353 style yaml_mapping_style_t // The mapping style. 354 } 355 356 start_mark yaml_mark_t // The beginning of the node. 357 end_mark yaml_mark_t // The end of the node. 358 359 } 360 361 // The document structure. 362 type yaml_document_t struct { 363 364 // The document nodes. 365 nodes []yaml_node_t 366 367 // The version directive. 368 version_directive *yaml_version_directive_t 369 370 // The list of tag directives. 371 tag_directives_data []yaml_tag_directive_t 372 tag_directives_start int // The beginning of the tag directives list. 373 tag_directives_end int // The end of the tag directives list. 374 375 start_implicit int // Is the document start indicator implicit? 376 end_implicit int // Is the document end indicator implicit? 377 378 // The start/end of the document. 379 start_mark, end_mark yaml_mark_t 380 } 381 382 // The prototype of a read handler. 383 // 384 // The read handler is called when the parser needs to read more bytes from the 385 // source. The handler should write not more than size bytes to the buffer. 386 // The number of written bytes should be set to the size_read variable. 387 // 388 // [in,out] data A pointer to an application data specified by 389 // yaml_parser_set_input(). 390 // [out] buffer The buffer to write the data from the source. 391 // [in] size The size of the buffer. 392 // [out] size_read The actual number of bytes read from the source. 393 // 394 // On success, the handler should return 1. If the handler failed, 395 // the returned value should be 0. On EOF, the handler should set the 396 // size_read to 0 and return 1. 397 type yaml_read_handler_t func(parser *yaml_parser_t, buffer []byte) (n int, err error) 398 399 // This structure holds information about a potential simple key. 400 type yaml_simple_key_t struct { 401 possible bool // Is a simple key possible? 402 required bool // Is a simple key required? 403 token_number int // The number of the token. 404 mark yaml_mark_t // The position mark. 405 } 406 407 // The states of the parser. 408 type yaml_parser_state_t int 409 410 const ( 411 yaml_PARSE_STREAM_START_STATE yaml_parser_state_t = iota 412 413 yaml_PARSE_IMPLICIT_DOCUMENT_START_STATE // Expect the beginning of an implicit document. 414 yaml_PARSE_DOCUMENT_START_STATE // Expect DOCUMENT-START. 415 yaml_PARSE_DOCUMENT_CONTENT_STATE // Expect the content of a document. 416 yaml_PARSE_DOCUMENT_END_STATE // Expect DOCUMENT-END. 417 yaml_PARSE_BLOCK_NODE_STATE // Expect a block node. 418 yaml_PARSE_BLOCK_NODE_OR_INDENTLESS_SEQUENCE_STATE // Expect a block node or indentless sequence. 419 yaml_PARSE_FLOW_NODE_STATE // Expect a flow node. 420 yaml_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE // Expect the first entry of a block sequence. 421 yaml_PARSE_BLOCK_SEQUENCE_ENTRY_STATE // Expect an entry of a block sequence. 422 yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE // Expect an entry of an indentless sequence. 423 yaml_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE // Expect the first key of a block mapping. 424 yaml_PARSE_BLOCK_MAPPING_KEY_STATE // Expect a block mapping key. 425 yaml_PARSE_BLOCK_MAPPING_VALUE_STATE // Expect a block mapping value. 426 yaml_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE // Expect the first entry of a flow sequence. 427 yaml_PARSE_FLOW_SEQUENCE_ENTRY_STATE // Expect an entry of a flow sequence. 428 yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE // Expect a key of an ordered mapping. 429 yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE // Expect a value of an ordered mapping. 430 yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE // Expect the and of an ordered mapping entry. 431 yaml_PARSE_FLOW_MAPPING_FIRST_KEY_STATE // Expect the first key of a flow mapping. 432 yaml_PARSE_FLOW_MAPPING_KEY_STATE // Expect a key of a flow mapping. 433 yaml_PARSE_FLOW_MAPPING_VALUE_STATE // Expect a value of a flow mapping. 434 yaml_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE // Expect an empty value of a flow mapping. 435 yaml_PARSE_END_STATE // Expect nothing. 436 ) 437 438 func (ps yaml_parser_state_t) String() string { 439 switch ps { 440 case yaml_PARSE_STREAM_START_STATE: 441 return "yaml_PARSE_STREAM_START_STATE" 442 case yaml_PARSE_IMPLICIT_DOCUMENT_START_STATE: 443 return "yaml_PARSE_IMPLICIT_DOCUMENT_START_STATE" 444 case yaml_PARSE_DOCUMENT_START_STATE: 445 return "yaml_PARSE_DOCUMENT_START_STATE" 446 case yaml_PARSE_DOCUMENT_CONTENT_STATE: 447 return "yaml_PARSE_DOCUMENT_CONTENT_STATE" 448 case yaml_PARSE_DOCUMENT_END_STATE: 449 return "yaml_PARSE_DOCUMENT_END_STATE" 450 case yaml_PARSE_BLOCK_NODE_STATE: 451 return "yaml_PARSE_BLOCK_NODE_STATE" 452 case yaml_PARSE_BLOCK_NODE_OR_INDENTLESS_SEQUENCE_STATE: 453 return "yaml_PARSE_BLOCK_NODE_OR_INDENTLESS_SEQUENCE_STATE" 454 case yaml_PARSE_FLOW_NODE_STATE: 455 return "yaml_PARSE_FLOW_NODE_STATE" 456 case yaml_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE: 457 return "yaml_PARSE_BLOCK_SEQUENCE_FIRST_ENTRY_STATE" 458 case yaml_PARSE_BLOCK_SEQUENCE_ENTRY_STATE: 459 return "yaml_PARSE_BLOCK_SEQUENCE_ENTRY_STATE" 460 case yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE: 461 return "yaml_PARSE_INDENTLESS_SEQUENCE_ENTRY_STATE" 462 case yaml_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE: 463 return "yaml_PARSE_BLOCK_MAPPING_FIRST_KEY_STATE" 464 case yaml_PARSE_BLOCK_MAPPING_KEY_STATE: 465 return "yaml_PARSE_BLOCK_MAPPING_KEY_STATE" 466 case yaml_PARSE_BLOCK_MAPPING_VALUE_STATE: 467 return "yaml_PARSE_BLOCK_MAPPING_VALUE_STATE" 468 case yaml_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE: 469 return "yaml_PARSE_FLOW_SEQUENCE_FIRST_ENTRY_STATE" 470 case yaml_PARSE_FLOW_SEQUENCE_ENTRY_STATE: 471 return "yaml_PARSE_FLOW_SEQUENCE_ENTRY_STATE" 472 case yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE: 473 return "yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_KEY_STATE" 474 case yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE: 475 return "yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_VALUE_STATE" 476 case yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE: 477 return "yaml_PARSE_FLOW_SEQUENCE_ENTRY_MAPPING_END_STATE" 478 case yaml_PARSE_FLOW_MAPPING_FIRST_KEY_STATE: 479 return "yaml_PARSE_FLOW_MAPPING_FIRST_KEY_STATE" 480 case yaml_PARSE_FLOW_MAPPING_KEY_STATE: 481 return "yaml_PARSE_FLOW_MAPPING_KEY_STATE" 482 case yaml_PARSE_FLOW_MAPPING_VALUE_STATE: 483 return "yaml_PARSE_FLOW_MAPPING_VALUE_STATE" 484 case yaml_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE: 485 return "yaml_PARSE_FLOW_MAPPING_EMPTY_VALUE_STATE" 486 case yaml_PARSE_END_STATE: 487 return "yaml_PARSE_END_STATE" 488 } 489 return "<unknown parser state>" 490 } 491 492 // This structure holds aliases data. 493 type yaml_alias_data_t struct { 494 anchor []byte // The anchor. 495 index int // The node id. 496 mark yaml_mark_t // The anchor mark. 497 } 498 499 // The parser structure. 500 // 501 // All members are internal. Manage the structure using the 502 // yaml_parser_ family of functions. 503 type yaml_parser_t struct { 504 505 // Error handling 506 507 error yaml_error_type_t // Error type. 508 509 problem string // Error description. 510 511 // The byte about which the problem occured. 512 problem_offset int 513 problem_value int 514 problem_mark yaml_mark_t 515 516 // The error context. 517 context string 518 context_mark yaml_mark_t 519 520 // Reader stuff 521 522 read_handler yaml_read_handler_t // Read handler. 523 524 input_file io.Reader // File input data. 525 input []byte // String input data. 526 input_pos int 527 528 eof bool // EOF flag 529 530 buffer []byte // The working buffer. 531 buffer_pos int // The current position of the buffer. 532 533 unread int // The number of unread characters in the buffer. 534 535 raw_buffer []byte // The raw buffer. 536 raw_buffer_pos int // The current position of the buffer. 537 538 encoding yaml_encoding_t // The input encoding. 539 540 offset int // The offset of the current position (in bytes). 541 mark yaml_mark_t // The mark of the current position. 542 543 // Scanner stuff 544 545 stream_start_produced bool // Have we started to scan the input stream? 546 stream_end_produced bool // Have we reached the end of the input stream? 547 548 flow_level int // The number of unclosed '[' and '{' indicators. 549 550 tokens []yaml_token_t // The tokens queue. 551 tokens_head int // The head of the tokens queue. 552 tokens_parsed int // The number of tokens fetched from the queue. 553 token_available bool // Does the tokens queue contain a token ready for dequeueing. 554 555 indent int // The current indentation level. 556 indents []int // The indentation levels stack. 557 558 simple_key_allowed bool // May a simple key occur at the current position? 559 simple_keys []yaml_simple_key_t // The stack of simple keys. 560 561 // Parser stuff 562 563 state yaml_parser_state_t // The current parser state. 564 states []yaml_parser_state_t // The parser states stack. 565 marks []yaml_mark_t // The stack of marks. 566 tag_directives []yaml_tag_directive_t // The list of TAG directives. 567 568 // Dumper stuff 569 570 aliases []yaml_alias_data_t // The alias data. 571 572 document *yaml_document_t // The currently parsed document. 573 } 574 575 // Emitter Definitions 576 577 // The prototype of a write handler. 578 // 579 // The write handler is called when the emitter needs to flush the accumulated 580 // characters to the output. The handler should write @a size bytes of the 581 // @a buffer to the output. 582 // 583 // @param[in,out] data A pointer to an application data specified by 584 // yaml_emitter_set_output(). 585 // @param[in] buffer The buffer with bytes to be written. 586 // @param[in] size The size of the buffer. 587 // 588 // @returns On success, the handler should return @c 1. If the handler failed, 589 // the returned value should be @c 0. 590 // 591 type yaml_write_handler_t func(emitter *yaml_emitter_t, buffer []byte) error 592 593 type yaml_emitter_state_t int 594 595 // The emitter states. 596 const ( 597 // Expect STREAM-START. 598 yaml_EMIT_STREAM_START_STATE yaml_emitter_state_t = iota 599 600 yaml_EMIT_FIRST_DOCUMENT_START_STATE // Expect the first DOCUMENT-START or STREAM-END. 601 yaml_EMIT_DOCUMENT_START_STATE // Expect DOCUMENT-START or STREAM-END. 602 yaml_EMIT_DOCUMENT_CONTENT_STATE // Expect the content of a document. 603 yaml_EMIT_DOCUMENT_END_STATE // Expect DOCUMENT-END. 604 yaml_EMIT_FLOW_SEQUENCE_FIRST_ITEM_STATE // Expect the first item of a flow sequence. 605 yaml_EMIT_FLOW_SEQUENCE_ITEM_STATE // Expect an item of a flow sequence. 606 yaml_EMIT_FLOW_MAPPING_FIRST_KEY_STATE // Expect the first key of a flow mapping. 607 yaml_EMIT_FLOW_MAPPING_KEY_STATE // Expect a key of a flow mapping. 608 yaml_EMIT_FLOW_MAPPING_SIMPLE_VALUE_STATE // Expect a value for a simple key of a flow mapping. 609 yaml_EMIT_FLOW_MAPPING_VALUE_STATE // Expect a value of a flow mapping. 610 yaml_EMIT_BLOCK_SEQUENCE_FIRST_ITEM_STATE // Expect the first item of a block sequence. 611 yaml_EMIT_BLOCK_SEQUENCE_ITEM_STATE // Expect an item of a block sequence. 612 yaml_EMIT_BLOCK_MAPPING_FIRST_KEY_STATE // Expect the first key of a block mapping. 613 yaml_EMIT_BLOCK_MAPPING_KEY_STATE // Expect the key of a block mapping. 614 yaml_EMIT_BLOCK_MAPPING_SIMPLE_VALUE_STATE // Expect a value for a simple key of a block mapping. 615 yaml_EMIT_BLOCK_MAPPING_VALUE_STATE // Expect a value of a block mapping. 616 yaml_EMIT_END_STATE // Expect nothing. 617 ) 618 619 // The emitter structure. 620 // 621 // All members are internal. Manage the structure using the @c yaml_emitter_ 622 // family of functions. 623 type yaml_emitter_t struct { 624 625 // Error handling 626 627 error yaml_error_type_t // Error type. 628 problem string // Error description. 629 630 // Writer stuff 631 632 write_handler yaml_write_handler_t // Write handler. 633 634 output_buffer *[]byte // String output data. 635 output_file io.Writer // File output data. 636 637 buffer []byte // The working buffer. 638 buffer_pos int // The current position of the buffer. 639 640 raw_buffer []byte // The raw buffer. 641 raw_buffer_pos int // The current position of the buffer. 642 643 encoding yaml_encoding_t // The stream encoding. 644 645 // Emitter stuff 646 647 canonical bool // If the output is in the canonical style? 648 best_indent int // The number of indentation spaces. 649 best_width int // The preferred width of the output lines. 650 unicode bool // Allow unescaped non-ASCII characters? 651 line_break yaml_break_t // The preferred line break. 652 653 state yaml_emitter_state_t // The current emitter state. 654 states []yaml_emitter_state_t // The stack of states. 655 656 events []yaml_event_t // The event queue. 657 events_head int // The head of the event queue. 658 659 indents []int // The stack of indentation levels. 660 661 tag_directives []yaml_tag_directive_t // The list of tag directives. 662 663 indent int // The current indentation level. 664 665 flow_level int // The current flow level. 666 667 root_context bool // Is it the document root context? 668 sequence_context bool // Is it a sequence context? 669 mapping_context bool // Is it a mapping context? 670 simple_key_context bool // Is it a simple mapping key context? 671 672 line int // The current line. 673 column int // The current column. 674 whitespace bool // If the last character was a whitespace? 675 indention bool // If the last character was an indentation character (' ', '-', '?', ':')? 676 open_ended bool // If an explicit document end is required? 677 678 // Anchor analysis. 679 anchor_data struct { 680 anchor []byte // The anchor value. 681 alias bool // Is it an alias? 682 } 683 684 // Tag analysis. 685 tag_data struct { 686 handle []byte // The tag handle. 687 suffix []byte // The tag suffix. 688 } 689 690 // Scalar analysis. 691 scalar_data struct { 692 value []byte // The scalar value. 693 multiline bool // Does the scalar contain line breaks? 694 flow_plain_allowed bool // Can the scalar be expessed in the flow plain style? 695 block_plain_allowed bool // Can the scalar be expressed in the block plain style? 696 single_quoted_allowed bool // Can the scalar be expressed in the single quoted style? 697 block_allowed bool // Can the scalar be expressed in the literal or folded styles? 698 style yaml_scalar_style_t // The output style. 699 } 700 701 // Dumper stuff 702 703 opened bool // If the stream was already opened? 704 closed bool // If the stream was already closed? 705 706 // The information associated with the document nodes. 707 anchors *struct { 708 references int // The number of references. 709 anchor int // The anchor id. 710 serialized bool // If the node has been emitted? 711 } 712 713 last_anchor_id int // The last assigned anchor id. 714 715 document *yaml_document_t // The currently emitted document. 716 }