MCPcopy
hub / github.com/go-yaml/yaml / yaml_parser_split_stem_comment

Function yaml_parser_split_stem_comment

parserc.go:786–804  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
786func 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

Calls 1

peek_tokenFunction · 0.85

Tested by

no test coverage detected