Split stem comment from head comment. When a sequence or map is found under a sequence entry, the former head comment is assigned to the underlying sequence or map as a whole, not the individual sequence or map entry as would be expected otherwise. To handle this case the previous head comment is m
(parser *yaml_parser_t, stem_len int)
| 784 | // sequence or map entry as would be expected otherwise. To handle this case the |
| 785 | // previous head comment is moved aside as the stem comment. |
| 786 | func yaml_parser_split_stem_comment(parser *yaml_parser_t, stem_len int) { |
| 787 | if stem_len == 0 { |
| 788 | return |
| 789 | } |
| 790 | |
| 791 | token := peek_token(parser) |
| 792 | if token == nil || token.typ != yaml_BLOCK_SEQUENCE_START_TOKEN && token.typ != yaml_BLOCK_MAPPING_START_TOKEN { |
| 793 | return |
| 794 | } |
| 795 | |
| 796 | parser.stem_comment = parser.head_comment[:stem_len] |
| 797 | if len(parser.head_comment) == stem_len { |
| 798 | parser.head_comment = nil |
| 799 | } else { |
| 800 | // Copy suffix to prevent very strange bugs if someone ever appends |
| 801 | // further bytes to the prefix in the stem_comment slice above. |
| 802 | parser.head_comment = append([]byte(nil), parser.head_comment[stem_len+1:]...) |
| 803 | } |
| 804 | } |
| 805 | |
| 806 | // Parse the productions: |
| 807 | // block_mapping ::= BLOCK-MAPPING_START |
no test coverage detected