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

Function yaml_parser_scan_to_next_token

xs/tools/yaml/scanner.c:1942–2006  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1940 */
1941
1942static int
1943yaml_parser_scan_to_next_token(yaml_parser_t *parser)
1944{
1945 /* Until the next token is not found. */
1946
1947 while (1)
1948 {
1949 /* Allow the BOM mark to start a line. */
1950
1951 if (!CACHE(parser, 1)) return 0;
1952
1953 if (parser->mark.column == 0 && IS_BOM(parser->buffer))
1954 SKIP(parser);
1955
1956 /*
1957 * Eat whitespaces.
1958 *
1959 * Tabs are allowed:
1960 *
1961 * - in the flow context;
1962 * - in the block context, but not at the beginning of the line or
1963 * after '-', '?', or ':' (complex value).
1964 */
1965
1966 if (!CACHE(parser, 1)) return 0;
1967
1968 while (CHECK(parser->buffer,' ') ||
1969 ((parser->flow_level || !parser->simple_key_allowed) &&
1970 CHECK(parser->buffer, '\t'))) {
1971 SKIP(parser);
1972 if (!CACHE(parser, 1)) return 0;
1973 }
1974
1975 /* Eat a comment until a line break. */
1976
1977 if (CHECK(parser->buffer, '#')) {
1978 while (!IS_BREAKZ(parser->buffer)) {
1979 SKIP(parser);
1980 if (!CACHE(parser, 1)) return 0;
1981 }
1982 }
1983
1984 /* If it is a line break, eat it. */
1985
1986 if (IS_BREAK(parser->buffer))
1987 {
1988 if (!CACHE(parser, 2)) return 0;
1989 SKIP_LINE(parser);
1990
1991 /* In the block context, a new line may start a simple key. */
1992
1993 if (!parser->flow_level) {
1994 parser->simple_key_allowed = 1;
1995 }
1996 }
1997 else
1998 {
1999 /* We have found a token. */

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected