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

Function yaml_parser_fetch_key

scannerc.go:1331–1367  ·  view source on GitHub ↗

Produce the KEY token.

(parser *yaml_parser_t)

Source from the content-addressed store, hash-verified

1329
1330// Produce the KEY token.
1331func yaml_parser_fetch_key(parser *yaml_parser_t) bool {
1332
1333 // In the block context, additional checks are required.
1334 if parser.flow_level == 0 {
1335 // Check if we are allowed to start a new key (not nessesary simple).
1336 if !parser.simple_key_allowed {
1337 return yaml_parser_set_scanner_error(parser, "", parser.mark,
1338 "mapping keys are not allowed in this context")
1339 }
1340 // Add the BLOCK-MAPPING-START token if needed.
1341 if !yaml_parser_roll_indent(parser, parser.mark.column, -1, yaml_BLOCK_MAPPING_START_TOKEN, parser.mark) {
1342 return false
1343 }
1344 }
1345
1346 // Reset any potential simple keys on the current flow level.
1347 if !yaml_parser_remove_simple_key(parser) {
1348 return false
1349 }
1350
1351 // Simple keys are allowed after '?' in the block context.
1352 parser.simple_key_allowed = parser.flow_level == 0
1353
1354 // Consume the token.
1355 start_mark := parser.mark
1356 skip(parser)
1357 end_mark := parser.mark
1358
1359 // Create the KEY token and append it to the queue.
1360 token := yaml_token_t{
1361 typ: yaml_KEY_TOKEN,
1362 start_mark: start_mark,
1363 end_mark: end_mark,
1364 }
1365 yaml_insert_token(parser, -1, &token)
1366 return true
1367}
1368
1369// Produce the VALUE token.
1370func yaml_parser_fetch_value(parser *yaml_parser_t) bool {

Callers 1

Calls 5

yaml_parser_roll_indentFunction · 0.85
skipFunction · 0.85
yaml_insert_tokenFunction · 0.85

Tested by

no test coverage detected