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

Function yaml_parser_scan_directive

xs/tools/yaml/scanner.c:2018–2122  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2016 */
2017
2018int
2019yaml_parser_scan_directive(yaml_parser_t *parser, yaml_token_t *token)
2020{
2021 yaml_mark_t start_mark, end_mark;
2022 yaml_char_t *name = NULL;
2023 int major, minor;
2024 yaml_char_t *handle = NULL, *prefix = NULL;
2025
2026 /* Eat '%'. */
2027
2028 start_mark = parser->mark;
2029
2030 SKIP(parser);
2031
2032 /* Scan the directive name. */
2033
2034 if (!yaml_parser_scan_directive_name(parser, start_mark, &name))
2035 goto error;
2036
2037 /* Is it a YAML directive? */
2038
2039 if (strcmp((char *)name, "YAML") == 0)
2040 {
2041 /* Scan the VERSION directive value. */
2042
2043 if (!yaml_parser_scan_version_directive_value(parser, start_mark,
2044 &major, &minor))
2045 goto error;
2046
2047 end_mark = parser->mark;
2048
2049 /* Create a VERSION-DIRECTIVE token. */
2050
2051 VERSION_DIRECTIVE_TOKEN_INIT(*token, major, minor,
2052 start_mark, end_mark);
2053 }
2054
2055 /* Is it a TAG directive? */
2056
2057 else if (strcmp((char *)name, "TAG") == 0)
2058 {
2059 /* Scan the TAG directive value. */
2060
2061 if (!yaml_parser_scan_tag_directive_value(parser, start_mark,
2062 &handle, &prefix))
2063 goto error;
2064
2065 end_mark = parser->mark;
2066
2067 /* Create a TAG-DIRECTIVE token. */
2068
2069 TAG_DIRECTIVE_TOKEN_INIT(*token, handle, prefix,
2070 start_mark, end_mark);
2071 }
2072
2073 /* Unknown directive. */
2074
2075 else

Callers 1

Tested by

no test coverage detected