The dispatcher for token fetchers.
(parser *yaml_parser_t)
| 685 | |
| 686 | // The dispatcher for token fetchers. |
| 687 | func yaml_parser_fetch_next_token(parser *yaml_parser_t) (ok bool) { |
| 688 | // Ensure that the buffer is initialized. |
| 689 | if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) { |
| 690 | return false |
| 691 | } |
| 692 | |
| 693 | // Check if we just started scanning. Fetch STREAM-START then. |
| 694 | if !parser.stream_start_produced { |
| 695 | return yaml_parser_fetch_stream_start(parser) |
| 696 | } |
| 697 | |
| 698 | scan_mark := parser.mark |
| 699 | |
| 700 | // Eat whitespaces and comments until we reach the next token. |
| 701 | if !yaml_parser_scan_to_next_token(parser) { |
| 702 | return false |
| 703 | } |
| 704 | |
| 705 | // [Go] While unrolling indents, transform the head comments of prior |
| 706 | // indentation levels observed after scan_start into foot comments at |
| 707 | // the respective indexes. |
| 708 | |
| 709 | // Check the indentation level against the current column. |
| 710 | if !yaml_parser_unroll_indent(parser, parser.mark.column, scan_mark) { |
| 711 | return false |
| 712 | } |
| 713 | |
| 714 | // Ensure that the buffer contains at least 4 characters. 4 is the length |
| 715 | // of the longest indicators ('--- ' and '... '). |
| 716 | if parser.unread < 4 && !yaml_parser_update_buffer(parser, 4) { |
| 717 | return false |
| 718 | } |
| 719 | |
| 720 | // Is it the end of the stream? |
| 721 | if is_z(parser.buffer, parser.buffer_pos) { |
| 722 | return yaml_parser_fetch_stream_end(parser) |
| 723 | } |
| 724 | |
| 725 | // Is it a directive? |
| 726 | if parser.mark.column == 0 && parser.buffer[parser.buffer_pos] == '%' { |
| 727 | return yaml_parser_fetch_directive(parser) |
| 728 | } |
| 729 | |
| 730 | buf := parser.buffer |
| 731 | pos := parser.buffer_pos |
| 732 | |
| 733 | // Is it the document start indicator? |
| 734 | if parser.mark.column == 0 && buf[pos] == '-' && buf[pos+1] == '-' && buf[pos+2] == '-' && is_blankz(buf, pos+3) { |
| 735 | return yaml_parser_fetch_document_indicator(parser, yaml_DOCUMENT_START_TOKEN) |
| 736 | } |
| 737 | |
| 738 | // Is it the document end indicator? |
| 739 | if parser.mark.column == 0 && buf[pos] == '.' && buf[pos+1] == '.' && buf[pos+2] == '.' && is_blankz(buf, pos+3) { |
| 740 | return yaml_parser_fetch_document_indicator(parser, yaml_DOCUMENT_END_TOKEN) |
| 741 | } |
| 742 | |
| 743 | comment_mark := parser.mark |
| 744 | if len(parser.tokens) > 0 && (parser.flow_level == 0 && buf[pos] == ':' || parser.flow_level > 0 && buf[pos] == ',') { |
no test coverage detected