| 1590 | */ |
| 1591 | |
| 1592 | static int |
| 1593 | yaml_parser_fetch_block_entry(yaml_parser_t *parser) |
| 1594 | { |
| 1595 | yaml_mark_t start_mark, end_mark; |
| 1596 | yaml_token_t token; |
| 1597 | |
| 1598 | /* Check if the scanner is in the block context. */ |
| 1599 | |
| 1600 | if (!parser->flow_level) |
| 1601 | { |
| 1602 | /* Check if we are allowed to start a new entry. */ |
| 1603 | |
| 1604 | if (!parser->simple_key_allowed) { |
| 1605 | return yaml_parser_set_scanner_error(parser, NULL, parser->mark, |
| 1606 | "block sequence entries are not allowed in this context"); |
| 1607 | } |
| 1608 | |
| 1609 | /* Add the BLOCK-SEQUENCE-START token if needed. */ |
| 1610 | |
| 1611 | if (!yaml_parser_roll_indent(parser, parser->mark.column, -1, |
| 1612 | YAML_BLOCK_SEQUENCE_START_TOKEN, parser->mark)) |
| 1613 | return 0; |
| 1614 | } |
| 1615 | else |
| 1616 | { |
| 1617 | /* |
| 1618 | * It is an error for the '-' indicator to occur in the flow context, |
| 1619 | * but we let the Parser detect and report about it because the Parser |
| 1620 | * is able to point to the context. |
| 1621 | */ |
| 1622 | } |
| 1623 | |
| 1624 | /* Reset any potential simple keys on the current flow level. */ |
| 1625 | |
| 1626 | if (!yaml_parser_remove_simple_key(parser)) |
| 1627 | return 0; |
| 1628 | |
| 1629 | /* Simple keys are allowed after '-'. */ |
| 1630 | |
| 1631 | parser->simple_key_allowed = 1; |
| 1632 | |
| 1633 | /* Consume the token. */ |
| 1634 | |
| 1635 | start_mark = parser->mark; |
| 1636 | SKIP(parser); |
| 1637 | end_mark = parser->mark; |
| 1638 | |
| 1639 | /* Create the BLOCK-ENTRY token and append it to the queue. */ |
| 1640 | |
| 1641 | TOKEN_INIT(token, YAML_BLOCK_ENTRY_TOKEN, start_mark, end_mark); |
| 1642 | |
| 1643 | if (!ENQUEUE(parser, parser->tokens, token)) |
| 1644 | return 0; |
| 1645 | |
| 1646 | return 1; |
| 1647 | } |
| 1648 | |
| 1649 | /* |
no test coverage detected