MCPcopy Create free account
hub / github.com/0xShug0/audio.cpp / yaml_parser_scan_anchor

Function yaml_parser_scan_anchor

external/libyaml/src/scanner.c:2338–2398  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2336}
2337
2338static int
2339yaml_parser_scan_anchor(yaml_parser_t *parser, yaml_token_t *token,
2340 yaml_token_type_t type)
2341{
2342 int length = 0;
2343 yaml_mark_t start_mark, end_mark;
2344 yaml_string_t string = NULL_STRING;
2345
2346 if (!STRING_INIT(parser, string, INITIAL_STRING_SIZE)) goto error;
2347
2348 /* Eat the indicator character. */
2349
2350 start_mark = parser->mark;
2351
2352 SKIP(parser);
2353
2354 /* Consume the value. */
2355
2356 if (!CACHE(parser, 1)) goto error;
2357
2358 while (IS_ALPHA(parser->buffer)) {
2359 if (!READ(parser, string)) goto error;
2360 if (!CACHE(parser, 1)) goto error;
2361 length ++;
2362 }
2363
2364 end_mark = parser->mark;
2365
2366 /*
2367 * Check if length of the anchor is greater than 0 and it is followed by
2368 * a whitespace character or one of the indicators:
2369 *
2370 * '?', ':', ',', ']', '}', '%', '@', '`'.
2371 */
2372
2373 if (!length || !(IS_BLANKZ(parser->buffer) || CHECK(parser->buffer, '?')
2374 || CHECK(parser->buffer, ':') || CHECK(parser->buffer, ',')
2375 || CHECK(parser->buffer, ']') || CHECK(parser->buffer, '}')
2376 || CHECK(parser->buffer, '%') || CHECK(parser->buffer, '@')
2377 || CHECK(parser->buffer, '`'))) {
2378 yaml_parser_set_scanner_error(parser, type == YAML_ANCHOR_TOKEN ?
2379 "while scanning an anchor" : "while scanning an alias", start_mark,
2380 "did not find expected alphabetic or numeric character");
2381 goto error;
2382 }
2383
2384 /* Create a token. */
2385
2386 if (type == YAML_ANCHOR_TOKEN) {
2387 ANCHOR_TOKEN_INIT(*token, string.start, start_mark, end_mark);
2388 }
2389 else {
2390 ALIAS_TOKEN_INIT(*token, string.start, start_mark, end_mark);
2391 }
2392
2393 return 1;
2394
2395error:

Callers 1

yaml_parser_fetch_anchorFunction · 0.85

Calls 1

Tested by

no test coverage detected