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

Function yaml_parser_scan_line_comment

scannerc.go:2834–2883  ·  view source on GitHub ↗
(parser *yaml_parser_t, token_mark yaml_mark_t)

Source from the content-addressed store, hash-verified

2832}
2833
2834func yaml_parser_scan_line_comment(parser *yaml_parser_t, token_mark yaml_mark_t) bool {
2835 if parser.newlines > 0 {
2836 return true
2837 }
2838
2839 var start_mark yaml_mark_t
2840 var text []byte
2841
2842 for peek := 0; peek < 512; peek++ {
2843 if parser.unread < peek+1 && !yaml_parser_update_buffer(parser, peek+1) {
2844 break
2845 }
2846 if is_blank(parser.buffer, parser.buffer_pos+peek) {
2847 continue
2848 }
2849 if parser.buffer[parser.buffer_pos+peek] == '#' {
2850 seen := parser.mark.index+peek
2851 for {
2852 if parser.unread < 1 && !yaml_parser_update_buffer(parser, 1) {
2853 return false
2854 }
2855 if is_breakz(parser.buffer, parser.buffer_pos) {
2856 if parser.mark.index >= seen {
2857 break
2858 }
2859 if parser.unread < 2 && !yaml_parser_update_buffer(parser, 2) {
2860 return false
2861 }
2862 skip_line(parser)
2863 } else if parser.mark.index >= seen {
2864 if len(text) == 0 {
2865 start_mark = parser.mark
2866 }
2867 text = read(parser, text)
2868 } else {
2869 skip(parser)
2870 }
2871 }
2872 }
2873 break
2874 }
2875 if len(text) > 0 {
2876 parser.comments = append(parser.comments, yaml_comment_t{
2877 token_mark: token_mark,
2878 start_mark: start_mark,
2879 line: text,
2880 })
2881 }
2882 return true
2883}
2884
2885func yaml_parser_scan_comments(parser *yaml_parser_t, scan_mark yaml_mark_t) bool {
2886 token := parser.tokens[len(parser.tokens)-1]

Callers 2

Calls 6

is_blankFunction · 0.85
is_breakzFunction · 0.85
skip_lineFunction · 0.85
readFunction · 0.85
skipFunction · 0.85

Tested by

no test coverage detected