486 #define CACHE(parser,length) \ 487 (parser->unread >= (length) \ 489 : yaml_parser_update_buffer(parser, (length))) 495 #define SKIP(parser) \ 496 (parser->mark.index ++, \ 497 parser->mark.column ++, \ 499 parser->buffer.pointer += WIDTH(parser->buffer)) 501 #define SKIP_LINE(parser) \ 502 (IS_CRLF(parser->buffer) ? \ 503 (parser->mark.index += 2, \ 504 parser->mark.column = 0, \ 505 parser->mark.line ++, \ 506 parser->unread -= 2, \ 507 parser->buffer.pointer += 2) : \ 508 IS_BREAK(parser->buffer) ? \ 509 (parser->mark.index ++, \ 510 parser->mark.column = 0, \ 511 parser->mark.line ++, \ 513 parser->buffer.pointer += WIDTH(parser->buffer)) : 0) 519 #define READ(parser,string) \ 520 (STRING_EXTEND(parser,string) ? \ 521 (COPY(string,parser->buffer), \ 522 parser->mark.index ++, \ 523 parser->mark.column ++, \ 531 #define READ_LINE(parser,string) \ 532 (STRING_EXTEND(parser,string) ? \ 533 (((CHECK_AT(parser->buffer,'\r',0) \ 534 && CHECK_AT(parser->buffer,'\n',1)) ? \ 535 (*((string).pointer++) = (yaml_char_t) '\n', \ 536 parser->buffer.pointer += 2, \ 537 parser->mark.index += 2, \ 538 parser->mark.column = 0, \ 539 parser->mark.line ++, \ 540 parser->unread -= 2) : \ 541 (CHECK_AT(parser->buffer,'\r',0) \ 542 || CHECK_AT(parser->buffer,'\n',0)) ? \ 543 (*((string).pointer++) = (yaml_char_t) '\n', \ 544 parser->buffer.pointer ++, \ 545 parser->mark.index ++, \ 546 parser->mark.column = 0, \ 547 parser->mark.line ++, \ 548 parser->unread --) : \ 549 (CHECK_AT(parser->buffer,'\xC2',0) \ 550 && CHECK_AT(parser->buffer,'\x85',1)) ? \ 551 (*((string).pointer++) = (yaml_char_t) '\n', \ 552 parser->buffer.pointer += 2, \ 553 parser->mark.index ++, \ 554 parser->mark.column = 0, \ 555 parser->mark.line ++, \ 556 parser->unread --) : \ 557 (CHECK_AT(parser->buffer,'\xE2',0) && \ 558 CHECK_AT(parser->buffer,'\x80',1) && \ 559 (CHECK_AT(parser->buffer,'\xA8',2) || \ 560 CHECK_AT(parser->buffer,'\xA9',2))) ? \ 561 (*((string).pointer++) = *(parser->buffer.pointer++), \ 562 *((string).pointer++) = *(parser->buffer.pointer++), \ 563 *((string).pointer++) = *(parser->buffer.pointer++), \ 564 parser->mark.index ++, \ 565 parser->mark.column = 0, \ 566 parser->mark.line ++, \ 567 parser->unread --) : 0), \ 582 yaml_parser_set_scanner_error(
yaml_parser_t *parser,
const char *context,
619 yaml_parser_roll_indent(
yaml_parser_t *parser, ptrdiff_t column,
623 yaml_parser_unroll_indent(
yaml_parser_t *parser, ptrdiff_t column);
643 yaml_parser_fetch_flow_collection_start(
yaml_parser_t *parser,
669 yaml_parser_fetch_block_scalar(
yaml_parser_t *parser,
int literal);
672 yaml_parser_fetch_flow_scalar(
yaml_parser_t *parser,
int single);
692 yaml_parser_scan_version_directive_value(
yaml_parser_t *parser,
696 yaml_parser_scan_version_directive_number(
yaml_parser_t *parser,
711 yaml_parser_scan_tag_handle(
yaml_parser_t *parser,
int directive,
715 yaml_parser_scan_tag_uri(
yaml_parser_t *parser,
int uri_char,
int directive,
719 yaml_parser_scan_uri_escapes(
yaml_parser_t *parser,
int directive,
754 if (parser->stream_end_produced || parser->error) {
760 if (!parser->token_available) {
767 *token =
DEQUEUE(parser, parser->tokens);
768 parser->token_available = 0;
769 parser->tokens_parsed ++;
772 parser->stream_end_produced = 1;
783 yaml_parser_set_scanner_error(
yaml_parser_t *parser,
const char *context,
803 int need_more_tokens;
813 need_more_tokens = 0;
819 need_more_tokens = 1;
827 if (!yaml_parser_stale_simple_keys(parser))
834 need_more_tokens = 1;
842 if (!need_more_tokens)
847 if (!yaml_parser_fetch_next_token(parser))
865 if (!
CACHE(parser, 1))
871 return yaml_parser_fetch_stream_start(parser);
875 if (!yaml_parser_scan_to_next_token(parser))
880 if (!yaml_parser_stale_simple_keys(parser))
885 if (!yaml_parser_unroll_indent(parser, parser->
mark.
column))
893 if (!
CACHE(parser, 4))
899 return yaml_parser_fetch_stream_end(parser);
904 return yaml_parser_fetch_directive(parser);
913 return yaml_parser_fetch_document_indicator(parser,
923 return yaml_parser_fetch_document_indicator(parser,
929 return yaml_parser_fetch_flow_collection_start(parser,
935 return yaml_parser_fetch_flow_collection_start(parser,
941 return yaml_parser_fetch_flow_collection_end(parser,
947 return yaml_parser_fetch_flow_collection_end(parser,
953 return yaml_parser_fetch_flow_entry(parser);
958 return yaml_parser_fetch_block_entry(parser);
964 return yaml_parser_fetch_key(parser);
970 return yaml_parser_fetch_value(parser);
985 return yaml_parser_fetch_tag(parser);
990 return yaml_parser_fetch_block_scalar(parser, 1);
995 return yaml_parser_fetch_block_scalar(parser, 0);
1000 return yaml_parser_fetch_flow_scalar(parser, 1);
1005 return yaml_parser_fetch_flow_scalar(parser, 0);
1040 return yaml_parser_fetch_plain_scalar(parser);
1046 return yaml_parser_set_scanner_error(parser,
1047 "while scanning for the next token", parser->
mark,
1048 "found character that cannot start any token");
1080 return yaml_parser_set_scanner_error(parser,
1081 "while scanning a simple key", simple_key->
mark,
1082 "could not find expected ':'");
1122 if (!yaml_parser_remove_simple_key(parser))
return 0;
1144 return yaml_parser_set_scanner_error(parser,
1145 "while scanning a simple key", simple_key->
mark,
1146 "could not find expected ':'");
1206 yaml_parser_roll_indent(
yaml_parser_t *parser, ptrdiff_t column,
1216 if (parser->
indent < column)
1226 if (column > INT_MAX) {
1259 yaml_parser_unroll_indent(
yaml_parser_t *parser, ptrdiff_t column)
1270 while (parser->
indent > column)
1343 if (!yaml_parser_unroll_indent(parser, -1))
1348 if (!yaml_parser_remove_simple_key(parser))
1374 if (!yaml_parser_unroll_indent(parser, -1))
1379 if (!yaml_parser_remove_simple_key(parser))
1386 if (!yaml_parser_scan_directive(parser, &token))
1412 if (!yaml_parser_unroll_indent(parser, -1))
1417 if (!yaml_parser_remove_simple_key(parser))
1424 start_mark = parser->
mark;
1430 end_mark = parser->
mark;
1434 TOKEN_INIT(token, type, start_mark, end_mark);
1449 yaml_parser_fetch_flow_collection_start(
yaml_parser_t *parser,
1457 if (!yaml_parser_save_simple_key(parser))
1462 if (!yaml_parser_increase_flow_level(parser))
1471 start_mark = parser->
mark;
1473 end_mark = parser->
mark;
1477 TOKEN_INIT(token, type, start_mark, end_mark);
1492 yaml_parser_fetch_flow_collection_end(
yaml_parser_t *parser,
1500 if (!yaml_parser_remove_simple_key(parser))
1505 if (!yaml_parser_decrease_flow_level(parser))
1514 start_mark = parser->
mark;
1516 end_mark = parser->
mark;
1520 TOKEN_INIT(token, type, start_mark, end_mark);
1542 if (!yaml_parser_remove_simple_key(parser))
1551 start_mark = parser->
mark;
1553 end_mark = parser->
mark;
1582 return yaml_parser_set_scanner_error(parser, NULL, parser->
mark,
1583 "block sequence entries are not allowed in this context");
1588 if (!yaml_parser_roll_indent(parser, parser->
mark.
column, -1,
1603 if (!yaml_parser_remove_simple_key(parser))
1612 start_mark = parser->
mark;
1614 end_mark = parser->
mark;
1643 return yaml_parser_set_scanner_error(parser, NULL, parser->
mark,
1644 "mapping keys are not allowed in this context");
1649 if (!yaml_parser_roll_indent(parser, parser->
mark.
column, -1,
1656 if (!yaml_parser_remove_simple_key(parser))
1665 start_mark = parser->
mark;
1667 end_mark = parser->
mark;
1705 if (!yaml_parser_roll_indent(parser, simple_key->
mark.
column,
1729 return yaml_parser_set_scanner_error(parser, NULL, parser->
mark,
1730 "mapping values are not allowed in this context");
1735 if (!yaml_parser_roll_indent(parser, parser->
mark.
column, -1,
1747 start_mark = parser->
mark;
1749 end_mark = parser->
mark;
1772 if (!yaml_parser_save_simple_key(parser))
1781 if (!yaml_parser_scan_anchor(parser, &token, type))
1802 if (!yaml_parser_save_simple_key(parser))
1811 if (!yaml_parser_scan_tag(parser, &token))
1827 yaml_parser_fetch_block_scalar(
yaml_parser_t *parser,
int literal)
1833 if (!yaml_parser_remove_simple_key(parser))
1842 if (!yaml_parser_scan_block_scalar(parser, &token, literal))
1858 yaml_parser_fetch_flow_scalar(
yaml_parser_t *parser,
int single)
1864 if (!yaml_parser_save_simple_key(parser))
1873 if (!yaml_parser_scan_flow_scalar(parser, &token, single))
1895 if (!yaml_parser_save_simple_key(parser))
1904 if (!yaml_parser_scan_plain_scalar(parser, &token))
1928 if (!
CACHE(parser, 1))
return 0;
1943 if (!
CACHE(parser, 1))
return 0;
1949 if (!
CACHE(parser, 1))
return 0;
1957 if (!
CACHE(parser, 1))
return 0;
1965 if (!
CACHE(parser, 2))
return 0;
2005 start_mark = parser->
mark;
2011 if (!yaml_parser_scan_directive_name(parser, start_mark, &name))
2016 if (strcmp((
char *)name,
"YAML") == 0)
2020 if (!yaml_parser_scan_version_directive_value(parser, start_mark,
2024 end_mark = parser->
mark;
2029 start_mark, end_mark);
2034 else if (strcmp((
char *)name,
"TAG") == 0)
2038 if (!yaml_parser_scan_tag_directive_value(parser, start_mark,
2042 end_mark = parser->
mark;
2047 start_mark, end_mark);
2054 yaml_parser_set_scanner_error(parser,
"while scanning a directive",
2055 start_mark,
"found unknown directive name");
2061 if (!
CACHE(parser, 1))
goto error;
2065 if (!
CACHE(parser, 1))
goto error;
2071 if (!
CACHE(parser, 1))
goto error;
2078 yaml_parser_set_scanner_error(parser,
"while scanning a directive",
2079 start_mark,
"did not find expected comment or line break");
2086 if (!
CACHE(parser, 2))
goto error;
2121 if (!
CACHE(parser, 1))
goto error;
2125 if (!
READ(parser,
string))
goto error;
2126 if (!
CACHE(parser, 1))
goto error;
2131 if (
string.start ==
string.pointer) {
2132 yaml_parser_set_scanner_error(parser,
"while scanning a directive",
2133 start_mark,
"could not find expected directive name");
2140 yaml_parser_set_scanner_error(parser,
"while scanning a directive",
2141 start_mark,
"found unexpected non-alphabetical character");
2145 *name =
string.start;
2163 yaml_parser_scan_version_directive_value(
yaml_parser_t *parser,
2168 if (!
CACHE(parser, 1))
return 0;
2172 if (!
CACHE(parser, 1))
return 0;
2177 if (!yaml_parser_scan_version_directive_number(parser, start_mark, major))
2183 return yaml_parser_set_scanner_error(parser,
"while scanning a %YAML directive",
2184 start_mark,
"did not find expected digit or '.' character");
2191 if (!yaml_parser_scan_version_directive_number(parser, start_mark, minor))
2197 #define MAX_NUMBER_LENGTH 9 2210 yaml_parser_scan_version_directive_number(
yaml_parser_t *parser,
2218 if (!
CACHE(parser, 1))
return 0;
2225 return yaml_parser_set_scanner_error(parser,
"while scanning a %YAML directive",
2226 start_mark,
"found extremely long version number");
2233 if (!
CACHE(parser, 1))
return 0;
2239 return yaml_parser_set_scanner_error(parser,
"while scanning a %YAML directive",
2240 start_mark,
"did not find expected version number");
2265 if (!
CACHE(parser, 1))
goto error;
2269 if (!
CACHE(parser, 1))
goto error;
2274 if (!yaml_parser_scan_tag_handle(parser, 1, start_mark, &handle_value))
2279 if (!
CACHE(parser, 1))
goto error;
2282 yaml_parser_set_scanner_error(parser,
"while scanning a %TAG directive",
2283 start_mark,
"did not find expected whitespace");
2291 if (!
CACHE(parser, 1))
goto error;
2296 if (!yaml_parser_scan_tag_uri(parser, 1, 1, NULL, start_mark, &prefix_value))
2301 if (!
CACHE(parser, 1))
goto error;
2304 yaml_parser_set_scanner_error(parser,
"while scanning a %TAG directive",
2305 start_mark,
"did not find expected whitespace or line break");
2309 *handle = handle_value;
2310 *prefix = prefix_value;
2332 start_mark = parser->
mark;
2338 if (!
CACHE(parser, 1))
goto error;
2341 if (!
READ(parser,
string))
goto error;
2342 if (!
CACHE(parser, 1))
goto error;
2346 end_mark = parser->
mark;
2361 "while scanning an anchor" :
"while scanning an alias", start_mark,
2362 "did not find expected alphabetic or numeric character");
2393 start_mark = parser->
mark;
2397 if (!
CACHE(parser, 2))
goto error;
2404 if (!handle)
goto error;
2414 if (!yaml_parser_scan_tag_uri(parser, 1, 0, NULL, start_mark, &suffix))
2420 yaml_parser_set_scanner_error(parser,
"while scanning a tag",
2421 start_mark,
"did not find the expected '>'");
2433 if (!yaml_parser_scan_tag_handle(parser, 0, start_mark, &handle))
2438 if (handle[0] ==
'!' && handle[1] !=
'\0' && handle[strlen((
char *)handle)-1] ==
'!')
2442 if (!yaml_parser_scan_tag_uri(parser, 0, 0, NULL, start_mark, &suffix))
2449 if (!yaml_parser_scan_tag_uri(parser, 0, 0, handle, start_mark, &suffix))
2456 if (!handle)
goto error;
2465 if (suffix[0] ==
'\0') {
2475 if (!
CACHE(parser, 1))
goto error;
2479 yaml_parser_set_scanner_error(parser,
"while scanning a tag",
2480 start_mark,
"did not find expected whitespace or line break");
2485 end_mark = parser->
mark;
2504 yaml_parser_scan_tag_handle(
yaml_parser_t *parser,
int directive,
2513 if (!
CACHE(parser, 1))
goto error;
2516 yaml_parser_set_scanner_error(parser, directive ?
2517 "while scanning a tag directive" :
"while scanning a tag",
2518 start_mark,
"did not find expected '!'");
2524 if (!
READ(parser,
string))
goto error;
2528 if (!
CACHE(parser, 1))
goto error;
2532 if (!
READ(parser,
string))
goto error;
2533 if (!
CACHE(parser, 1))
goto error;
2540 if (!
READ(parser,
string))
goto error;
2550 if (directive && !(
string.start[0] ==
'!' &&
string.start[1] ==
'\0')) {
2551 yaml_parser_set_scanner_error(parser,
"while parsing a tag directive",
2552 start_mark,
"did not find expected '!'");
2557 *handle =
string.start;
2571 yaml_parser_scan_tag_uri(
yaml_parser_t *parser,
int uri_char,
int directive,
2574 size_t length = head ? strlen((
char *)head) : 0;
2581 while ((
size_t)(
string.end -
string.start) <= length) {
2595 memcpy(
string.start, head+1, length-1);
2596 string.pointer += length-1;
2601 if (!
CACHE(parser, 1))
goto error;
2635 if (!yaml_parser_scan_uri_escapes(parser,
2636 directive, start_mark, &
string))
goto error;
2639 if (!
READ(parser,
string))
goto error;
2643 if (!
CACHE(parser, 1))
goto error;
2652 yaml_parser_set_scanner_error(parser, directive ?
2653 "while parsing a %TAG directive" :
"while parsing a tag",
2654 start_mark,
"did not find expected tag URI");
2658 *uri =
string.start;
2672 yaml_parser_scan_uri_escapes(
yaml_parser_t *parser,
int directive,
2681 unsigned char octet = 0;
2685 if (!
CACHE(parser, 3))
return 0;
2690 return yaml_parser_set_scanner_error(parser, directive ?
2691 "while parsing a %TAG directive" :
"while parsing a tag",
2692 start_mark,
"did not find URI escaped octet");
2703 width = (octet & 0x80) == 0x00 ? 1 :
2704 (octet & 0xE0) == 0xC0 ? 2 :
2705 (octet & 0xF0) == 0xE0 ? 3 :
2706 (octet & 0xF8) == 0xF0 ? 4 : 0;
2708 return yaml_parser_set_scanner_error(parser, directive ?
2709 "while parsing a %TAG directive" :
"while parsing a tag",
2710 start_mark,
"found an incorrect leading UTF-8 octet");
2717 if ((octet & 0xC0) != 0x80) {
2718 return yaml_parser_set_scanner_error(parser, directive ?
2719 "while parsing a %TAG directive" :
"while parsing a tag",
2720 start_mark,
"found an incorrect trailing UTF-8 octet");
2726 *(
string->pointer++) = octet;
2752 int leading_blank = 0;
2753 int trailing_blank = 0;
2761 start_mark = parser->
mark;
2767 if (!
CACHE(parser, 1))
goto error;
2781 if (!
CACHE(parser, 1))
goto error;
2788 yaml_parser_set_scanner_error(parser,
"while scanning a block scalar",
2789 start_mark,
"found an indentation indicator equal to 0");
2806 yaml_parser_set_scanner_error(parser,
"while scanning a block scalar",
2807 start_mark,
"found an indentation indicator equal to 0");
2815 if (!
CACHE(parser, 1))
goto error;
2826 if (!
CACHE(parser, 1))
goto error;
2830 if (!
CACHE(parser, 1))
goto error;
2836 if (!
CACHE(parser, 1))
goto error;
2843 yaml_parser_set_scanner_error(parser,
"while scanning a block scalar",
2844 start_mark,
"did not find expected comment or line break");
2851 if (!
CACHE(parser, 2))
goto error;
2855 end_mark = parser->
mark;
2860 indent = parser->
indent >= 0 ? parser->
indent+increment : increment;
2865 if (!yaml_parser_scan_block_scalar_breaks(parser, &indent, &trailing_breaks,
2866 start_mark, &end_mark))
goto error;
2870 if (!
CACHE(parser, 1))
goto error;
2884 if (!literal && (*leading_break.
start ==
'\n')
2885 && !leading_blank && !trailing_blank)
2889 if (*trailing_breaks.
start ==
'\0') {
2891 *(
string.pointer ++) =
' ';
2894 CLEAR(parser, leading_break);
2897 if (!
JOIN(parser,
string, leading_break))
goto error;
2898 CLEAR(parser, leading_break);
2903 if (!
JOIN(parser,
string, trailing_breaks))
goto error;
2904 CLEAR(parser, trailing_breaks);
2913 if (!
READ(parser,
string))
goto error;
2914 if (!
CACHE(parser, 1))
goto error;
2919 if (!
CACHE(parser, 2))
goto error;
2921 if (!
READ_LINE(parser, leading_break))
goto error;
2925 if (!yaml_parser_scan_block_scalar_breaks(parser,
2926 &indent, &trailing_breaks, start_mark, &end_mark))
goto error;
2931 if (chomping != -1) {
2932 if (!
JOIN(parser,
string, leading_break))
goto error;
2934 if (chomping == 1) {
2935 if (!
JOIN(parser,
string, trailing_breaks))
goto error;
2942 start_mark, end_mark);
2969 *end_mark = parser->
mark;
2977 if (!
CACHE(parser, 1))
return 0;
2979 while ((!*indent || (
int)parser->
mark.
column < *indent)
2982 if (!
CACHE(parser, 1))
return 0;
2990 if ((!*indent || (
int)parser->
mark.
column < *indent)
2992 return yaml_parser_set_scanner_error(parser,
"while scanning a block scalar",
2993 start_mark,
"found a tab character where an indentation space is expected");
3002 if (!
CACHE(parser, 2))
return 0;
3003 if (!
READ_LINE(parser, *breaks))
return 0;
3004 *end_mark = parser->
mark;
3010 *indent = max_indent;
3011 if (*indent < parser->indent + 1)
3012 *indent = parser->
indent + 1;
3043 start_mark = parser->
mark;
3053 if (!
CACHE(parser, 4))
goto error;
3064 yaml_parser_set_scanner_error(parser,
"while scanning a quoted scalar",
3065 start_mark,
"found unexpected document indicator");
3072 yaml_parser_set_scanner_error(parser,
"while scanning a quoted scalar",
3073 start_mark,
"found unexpected end of stream");
3079 if (!
CACHE(parser, 2))
goto error;
3091 *(
string.pointer++) =
'\'';
3098 else if (
CHECK(parser->
buffer, single ?
'\'' :
'"'))
3108 if (!
CACHE(parser, 3))
goto error;
3119 size_t code_length = 0;
3128 *(
string.pointer++) =
'\0';
3132 *(
string.pointer++) =
'\x07';
3136 *(
string.pointer++) =
'\x08';
3141 *(
string.pointer++) =
'\x09';
3145 *(
string.pointer++) =
'\x0A';
3149 *(
string.pointer++) =
'\x0B';
3153 *(
string.pointer++) =
'\x0C';
3157 *(
string.pointer++) =
'\x0D';
3161 *(
string.pointer++) =
'\x1B';
3165 *(
string.pointer++) =
'\x20';
3169 *(
string.pointer++) =
'"';
3173 *(
string.pointer++) =
'/';
3177 *(
string.pointer++) =
'\\';
3181 *(
string.pointer++) =
'\xC2';
3182 *(
string.pointer++) =
'\x85';
3186 *(
string.pointer++) =
'\xC2';
3187 *(
string.pointer++) =
'\xA0';
3191 *(
string.pointer++) =
'\xE2';
3192 *(
string.pointer++) =
'\x80';
3193 *(
string.pointer++) =
'\xA8';
3197 *(
string.pointer++) =
'\xE2';
3198 *(
string.pointer++) =
'\x80';
3199 *(
string.pointer++) =
'\xA9';
3215 yaml_parser_set_scanner_error(parser,
"while parsing a quoted scalar",
3216 start_mark,
"found unknown escape character");
3227 unsigned int value = 0;
3232 if (!
CACHE(parser, code_length))
goto error;
3234 for (k = 0; k < code_length; k ++) {
3236 yaml_parser_set_scanner_error(parser,
"while parsing a quoted scalar",
3237 start_mark,
"did not find expected hexdecimal number");
3245 if ((value >= 0xD800 && value <= 0xDFFF) || value > 0x10FFFF) {
3246 yaml_parser_set_scanner_error(parser,
"while parsing a quoted scalar",
3247 start_mark,
"found invalid Unicode character escape code");
3251 if (value <= 0x7F) {
3252 *(
string.pointer++) = value;
3254 else if (value <= 0x7FF) {
3255 *(
string.pointer++) = 0xC0 + (value >> 6);
3256 *(
string.pointer++) = 0x80 + (value & 0x3F);
3258 else if (value <= 0xFFFF) {
3259 *(
string.pointer++) = 0xE0 + (value >> 12);
3260 *(
string.pointer++) = 0x80 + ((value >> 6) & 0x3F);
3261 *(
string.pointer++) = 0x80 + (value & 0x3F);
3264 *(
string.pointer++) = 0xF0 + (value >> 18);
3265 *(
string.pointer++) = 0x80 + ((value >> 12) & 0x3F);
3266 *(
string.pointer++) = 0x80 + ((value >> 6) & 0x3F);
3267 *(
string.pointer++) = 0x80 + (value & 0x3F);
3272 for (k = 0; k < code_length; k ++) {
3282 if (!
READ(parser,
string))
goto error;
3285 if (!
CACHE(parser, 2))
goto error;
3294 if (!
CACHE(parser, 1))
goto error;
3300 if (!
CACHE(parser, 1))
goto error;
3308 if (!leading_blanks) {
3309 if (!
READ(parser, whitespaces))
goto error;
3317 if (!
CACHE(parser, 2))
goto error;
3321 if (!leading_blanks)
3323 CLEAR(parser, whitespaces);
3324 if (!
READ_LINE(parser, leading_break))
goto error;
3329 if (!
READ_LINE(parser, trailing_breaks))
goto error;
3332 if (!
CACHE(parser, 1))
goto error;
3341 if (leading_break.
start[0] ==
'\n') {
3342 if (trailing_breaks.
start[0] ==
'\0') {
3344 *(
string.pointer++) =
' ';
3347 if (!
JOIN(parser,
string, trailing_breaks))
goto error;
3348 CLEAR(parser, trailing_breaks);
3350 CLEAR(parser, leading_break);
3353 if (!
JOIN(parser,
string, leading_break))
goto error;
3354 if (!
JOIN(parser,
string, trailing_breaks))
goto error;
3355 CLEAR(parser, leading_break);
3356 CLEAR(parser, trailing_breaks);
3361 if (!
JOIN(parser,
string, whitespaces))
goto error;
3362 CLEAR(parser, whitespaces);
3370 end_mark = parser->
mark;
3376 start_mark, end_mark);
3406 int leading_blanks = 0;
3407 int indent = parser->
indent+1;
3414 start_mark = end_mark = parser->
mark;
3422 if (!
CACHE(parser, 4))
goto error;
3458 yaml_parser_set_scanner_error(parser,
"while scanning a plain scalar",
3459 start_mark,
"found unexpected ':'");
3475 if (leading_blanks || whitespaces.
start != whitespaces.
pointer)
3481 if (leading_break.
start[0] ==
'\n') {
3482 if (trailing_breaks.
start[0] ==
'\0') {
3484 *(
string.pointer++) =
' ';
3487 if (!
JOIN(parser,
string, trailing_breaks))
goto error;
3488 CLEAR(parser, trailing_breaks);
3490 CLEAR(parser, leading_break);
3493 if (!
JOIN(parser,
string, leading_break))
goto error;
3494 if (!
JOIN(parser,
string, trailing_breaks))
goto error;
3495 CLEAR(parser, leading_break);
3496 CLEAR(parser, trailing_breaks);
3503 if (!
JOIN(parser,
string, whitespaces))
goto error;
3504 CLEAR(parser, whitespaces);
3510 if (!
READ(parser,
string))
goto error;
3512 end_mark = parser->
mark;
3514 if (!
CACHE(parser, 2))
goto error;
3524 if (!
CACHE(parser, 1))
goto error;
3532 if (leading_blanks && (
int)parser->
mark.
column < indent
3534 yaml_parser_set_scanner_error(parser,
"while scanning a plain scalar",
3535 start_mark,
"found a tab character that violates indentation");
3541 if (!leading_blanks) {
3542 if (!
READ(parser, whitespaces))
goto error;
3550 if (!
CACHE(parser, 2))
goto error;
3554 if (!leading_blanks)
3556 CLEAR(parser, whitespaces);
3557 if (!
READ_LINE(parser, leading_break))
goto error;
3562 if (!
READ_LINE(parser, trailing_breaks))
goto error;
3565 if (!
CACHE(parser, 1))
goto error;
3581 if (leading_blanks) {
The double-quoted scalar style.
#define READ(parser, string)
A BLOCK-SEQUENCE-START token.
yaml_token_t * tail
The tail of the tokens queue.
A FLOW-SEQUENCE-START token.
Cannot allocate or reallocate a block of memory.
#define ALIAS_TOKEN_INIT(token, token_value, start_mark, end_mark)
int stream_start_produced
Have we started to scan the input stream?
yaml_encoding_t encoding
The input encoding.
A BLOCK-MAPPING-START token.
struct yaml_parser_s::@37 tokens
The tokens queue.
unsigned char yaml_char_t
The character type (UTF-8 octet).
const unsigned char * start
The string start pointer.
const char * context
The error context.
yaml_mark_t mark
The position mark.
#define IS_BREAK_AT(string, offset)
int indent
The current indentation level.
#define TAG_DIRECTIVE_TOKEN_INIT(token, token_handle, token_prefix, start_mark, end_mark)
#define PUSH(context, stack, value)
yaml_char_t * pointer
The current position of the buffer.
yaml_mark_t mark
The mark of the current position.
#define IS_HEX_AT(string, offset)
#define DEQUEUE(context, queue)
A FLOW-SEQUENCE-END token.
int token_available
Does the tokens queue contain a token ready for dequeueing.
#define INITIAL_STRING_SIZE
#define STRING_DEL(context, string)
#define AS_HEX_AT(string, offset)
int * top
The top of the stack.
#define QUEUE_INSERT(context, queue, index, value)
int required
Is a simple key required?
int simple_key_allowed
May a simple key occur at the current position?
#define IS_BREAKZ(string)
yaml_string_extend(yaml_char_t **start, yaml_char_t **pointer, yaml_char_t **end)
#define CHECK(string, octet)
yaml_parser_fetch_more_tokens(yaml_parser_t *parser)
yaml_token_delete(yaml_token_t *token)
Free any memory allocated for a token object.
#define TOKEN_INIT(token, token_type, token_start_mark, token_end_mark)
#define YAML_DECLARE(type)
The public API declaration.
A FLOW-MAPPING-START token.
#define TAG_TOKEN_INIT(token, token_handle, token_suffix, start_mark, end_mark)
#define IS_BLANK_AT(string, offset)
struct yaml_parser_s::@39 simple_keys
The stack of simple keys.
yaml_error_type_t error
Error type.
struct yaml_parser_s::@35 buffer
The working buffer.
#define STREAM_START_TOKEN_INIT(token, token_encoding, start_mark, end_mark)
#define CHECK_AT(string, octet, offset)
size_t token_number
The number of the token.
#define CACHE(parser, length)
#define MAX_NUMBER_LENGTH
enum yaml_token_type_e yaml_token_type_t
Token types.
yaml_token_t * head
The head of the tokens queue.
#define ENQUEUE(context, queue, value)
#define JOIN(context, string_a, string_b)
#define ANCHOR_TOKEN_INIT(token, token_value, start_mark, end_mark)
#define SCALAR_TOKEN_INIT(token, token_value, token_length, token_style, start_mark, end_mark)
yaml_mark_t context_mark
The context position.
#define READ_LINE(parser, string)
A FLOW-MAPPING-END token.
yaml_mark_t problem_mark
The problem position.
size_t tokens_parsed
The number of tokens fetched from the queue.
#define STRING_EXTEND(context, string)
#define IS_BLANKZ_AT(string, offset)
#define YAML_MALLOC(size)
#define STRING_INIT(context, string, size)
#define STREAM_END_TOKEN_INIT(token, start_mark, end_mark)
This structure holds information about a potential simple key.
The literal scalar style.
size_t line
The position line.
#define POP(context, stack)
#define SKIP_LINE(parser)
Cannot scan the input stream.
size_t index
The position index.
#define IS_BLANKZ(string)
yaml_parser_scan(yaml_parser_t *parser, yaml_token_t *token)
Scan the input stream and produce the next token.
const char * problem
Error description.
int possible
Is a simple key possible?
#define VERSION_DIRECTIVE_TOKEN_INIT(token, token_major, token_minor, start_mark, end_mark)
size_t column
The position column.
struct yaml_parser_s::@38 indents
The indentation levels stack.
int flow_level
The number of unclosed '[' and '{' indicators.
#define CLEAR(context, string)
The single-quoted scalar style.