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

Function yaml_parser_fetch_block_entry

scannerc.go:1289–1328  ·  view source on GitHub ↗

Produce the BLOCK-ENTRY token.

(parser *yaml_parser_t)

Source from the content-addressed store, hash-verified

1287
1288// Produce the BLOCK-ENTRY token.
1289func yaml_parser_fetch_block_entry(parser *yaml_parser_t) bool {
1290 // Check if the scanner is in the block context.
1291 if parser.flow_level == 0 {
1292 // Check if we are allowed to start a new entry.
1293 if !parser.simple_key_allowed {
1294 return yaml_parser_set_scanner_error(parser, "", parser.mark,
1295 "block sequence entries are not allowed in this context")
1296 }
1297 // Add the BLOCK-SEQUENCE-START token if needed.
1298 if !yaml_parser_roll_indent(parser, parser.mark.column, -1, yaml_BLOCK_SEQUENCE_START_TOKEN, parser.mark) {
1299 return false
1300 }
1301 } else {
1302 // It is an error for the '-' indicator to occur in the flow context,
1303 // but we let the Parser detect and report about it because the Parser
1304 // is able to point to the context.
1305 }
1306
1307 // Reset any potential simple keys on the current flow level.
1308 if !yaml_parser_remove_simple_key(parser) {
1309 return false
1310 }
1311
1312 // Simple keys are allowed after '-'.
1313 parser.simple_key_allowed = true
1314
1315 // Consume the token.
1316 start_mark := parser.mark
1317 skip(parser)
1318 end_mark := parser.mark
1319
1320 // Create the BLOCK-ENTRY token and append it to the queue.
1321 token := yaml_token_t{
1322 typ: yaml_BLOCK_ENTRY_TOKEN,
1323 start_mark: start_mark,
1324 end_mark: end_mark,
1325 }
1326 yaml_insert_token(parser, -1, &token)
1327 return true
1328}
1329
1330// Produce the KEY token.
1331func yaml_parser_fetch_key(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