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

Function yaml_simple_key_is_valid

scannerc.go:883–907  ·  view source on GitHub ↗
(parser *yaml_parser_t, simple_key *yaml_simple_key_t)

Source from the content-addressed store, hash-verified

881}
882
883func yaml_simple_key_is_valid(parser *yaml_parser_t, simple_key *yaml_simple_key_t) (valid, ok bool) {
884 if !simple_key.possible {
885 return false, true
886 }
887
888 // The 1.2 specification says:
889 //
890 // "If the ? indicator is omitted, parsing needs to see past the
891 // implicit key to recognize it as such. To limit the amount of
892 // lookahead required, the “:” indicator must appear at most 1024
893 // Unicode characters beyond the start of the key. In addition, the key
894 // is restricted to a single line."
895 //
896 if simple_key.mark.line < parser.mark.line || simple_key.mark.index+1024 < parser.mark.index {
897 // Check if the potential simple key to be removed is required.
898 if simple_key.required {
899 return false, yaml_parser_set_scanner_error(parser,
900 "while scanning a simple key", simple_key.mark,
901 "could not find expected ':'")
902 }
903 simple_key.possible = false
904 return false, true
905 }
906 return true, true
907}
908
909// Check if a simple key may start at the current position and add it if
910// needed.

Callers 2

yaml_parser_fetch_valueFunction · 0.85

Calls 1

Tested by

no test coverage detected