yaml_parser_unfold_comments walks through the comments queue and joins all comments behind the position of the provided token into the respective top-level comment slices in the parser.
(parser *yaml_parser_t, token *yaml_token_t)
| 78 | // comments behind the position of the provided token into the respective |
| 79 | // top-level comment slices in the parser. |
| 80 | func yaml_parser_unfold_comments(parser *yaml_parser_t, token *yaml_token_t) { |
| 81 | for parser.comments_head < len(parser.comments) && token.start_mark.index >= parser.comments[parser.comments_head].token_mark.index { |
| 82 | comment := &parser.comments[parser.comments_head] |
| 83 | if len(comment.head) > 0 { |
| 84 | if token.typ == yaml_BLOCK_END_TOKEN { |
| 85 | // No heads on ends, so keep comment.head for a follow up token. |
| 86 | break |
| 87 | } |
| 88 | if len(parser.head_comment) > 0 { |
| 89 | parser.head_comment = append(parser.head_comment, '\n') |
| 90 | } |
| 91 | parser.head_comment = append(parser.head_comment, comment.head...) |
| 92 | } |
| 93 | if len(comment.foot) > 0 { |
| 94 | if len(parser.foot_comment) > 0 { |
| 95 | parser.foot_comment = append(parser.foot_comment, '\n') |
| 96 | } |
| 97 | parser.foot_comment = append(parser.foot_comment, comment.foot...) |
| 98 | } |
| 99 | if len(comment.line) > 0 { |
| 100 | if len(parser.line_comment) > 0 { |
| 101 | parser.line_comment = append(parser.line_comment, '\n') |
| 102 | } |
| 103 | parser.line_comment = append(parser.line_comment, comment.line...) |
| 104 | } |
| 105 | *comment = yaml_comment_t{} |
| 106 | parser.comments_head++ |
| 107 | } |
| 108 | } |
| 109 | |
| 110 | // Remove the next token from the queue (must be called after peek_token). |
| 111 | func skip_token(parser *yaml_parser_t) { |