MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / yaml_parser_save_simple_key

Function yaml_parser_save_simple_key

xs/tools/yaml/scanner.c:1118–1149  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1116 */
1117
1118static int
1119yaml_parser_save_simple_key(yaml_parser_t *parser)
1120{
1121 /*
1122 * A simple key is required at the current position if the scanner is in
1123 * the block context and the current column coincides with the indentation
1124 * level.
1125 */
1126
1127 int required = (!parser->flow_level
1128 && parser->indent == (ptrdiff_t)parser->mark.column);
1129
1130 /*
1131 * If the current position may start a simple key, save it.
1132 */
1133
1134 if (parser->simple_key_allowed)
1135 {
1136 yaml_simple_key_t simple_key;
1137 simple_key.possible = 1;
1138 simple_key.required = required;
1139 simple_key.token_number =
1140 parser->tokens_parsed + (parser->tokens.tail - parser->tokens.head);
1141 simple_key.mark = parser->mark;
1142
1143 if (!yaml_parser_remove_simple_key(parser)) return 0;
1144
1145 *(parser->simple_keys.top-1) = simple_key;
1146 }
1147
1148 return 1;
1149}
1150
1151/*
1152 * Remove a potential simple key at the current flow level.

Calls 1

Tested by

no test coverage detected