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

Function yaml_parser_save_simple_key

scannerc.go:911–936  ·  view source on GitHub ↗

Check if a simple key may start at the current position and add it if needed.

(parser *yaml_parser_t)

Source from the content-addressed store, hash-verified

909// Check if a simple key may start at the current position and add it if
910// needed.
911func yaml_parser_save_simple_key(parser *yaml_parser_t) bool {
912 // A simple key is required at the current position if the scanner is in
913 // the block context and the current column coincides with the indentation
914 // level.
915
916 required := parser.flow_level == 0 && parser.indent == parser.mark.column
917
918 //
919 // If the current position may start a simple key, save it.
920 //
921 if parser.simple_key_allowed {
922 simple_key := yaml_simple_key_t{
923 possible: true,
924 required: required,
925 token_number: parser.tokens_parsed + (len(parser.tokens) - parser.tokens_head),
926 mark: parser.mark,
927 }
928
929 if !yaml_parser_remove_simple_key(parser) {
930 return false
931 }
932 parser.simple_keys[len(parser.simple_keys)-1] = simple_key
933 parser.simple_keys_by_tok[simple_key.token_number] = len(parser.simple_keys) - 1
934 }
935 return true
936}
937
938// Remove a potential simple key at the current flow level.
939func yaml_parser_remove_simple_key(parser *yaml_parser_t) bool {

Calls 1

Tested by

no test coverage detected