* %TAG !yaml! tag:yaml.org,2002:
* ---
*
- * The correspoding sequence of tokens:
+ * The corresponding sequence of tokens:
*
* STREAM-START(utf-8)
* VERSION-DIRECTIVE(1,1)
? 1 \
: yaml_parser_update_buffer(parser, (length)))
-/*
- * Check the octet at the specified position.
- */
-
-#define CHECK_AT(parser,octet,offset) \
- (parser->buffer.pointer[offset] == (yaml_char_t)(octet))
-
-/*
- * Check the current octet in the buffer.
- */
-
-#define CHECK(parser,octet) CHECK_AT(parser,(octet),0)
-
-/*
- * Check if the character at the specified position is an alphabetical
- * character, a digit, '_', or '-'.
- */
-
-#define IS_ALPHA_AT(parser,offset) \
- ((parser->buffer.pointer[offset] >= (yaml_char_t) '0' && \
- parser->buffer.pointer[offset] <= (yaml_char_t) '9') || \
- (parser->buffer.pointer[offset] >= (yaml_char_t) 'A' && \
- parser->buffer.pointer[offset] <= (yaml_char_t) 'Z') || \
- (parser->buffer.pointer[offset] >= (yaml_char_t) 'a' && \
- parser->buffer.pointer[offset] <= (yaml_char_t) 'z') || \
- parser->buffer.pointer[offset] == '_' || \
- parser->buffer.pointer[offset] == '-')
-
-#define IS_ALPHA(parser) IS_ALPHA_AT(parser,0)
-
-/*
- * Check if the character at the specified position is a digit.
- */
-
-#define IS_DIGIT_AT(parser,offset) \
- ((parser->buffer.pointer[offset] >= (yaml_char_t) '0' && \
- parser->buffer.pointer[offset] <= (yaml_char_t) '9'))
-
-#define IS_DIGIT(parser) IS_DIGIT_AT(parser,0)
-
-/*
- * Get the value of a digit.
- */
-
-#define AS_DIGIT_AT(parser,offset) \
- (parser->buffer.pointer[offset] - (yaml_char_t) '0')
-
-#define AS_DIGIT(parser) AS_DIGIT_AT(parser,0)
-
-/*
- * Check if the character at the specified position is a hex-digit.
- */
-
-#define IS_HEX_AT(parser,offset) \
- ((parser->buffer.pointer[offset] >= (yaml_char_t) '0' && \
- parser->buffer.pointer[offset] <= (yaml_char_t) '9') || \
- (parser->buffer.pointer[offset] >= (yaml_char_t) 'A' && \
- parser->buffer.pointer[offset] <= (yaml_char_t) 'F') || \
- (parser->buffer.pointer[offset] >= (yaml_char_t) 'a' && \
- parser->buffer.pointer[offset] <= (yaml_char_t) 'f'))
-
-#define IS_HEX(parser) IS_HEX_AT(parser,0)
-
-/*
- * Get the value of a hex-digit.
- */
-
-#define AS_HEX_AT(parser,offset) \
- ((parser->buffer.pointer[offset] >= (yaml_char_t) 'A' && \
- parser->buffer.pointer[offset] <= (yaml_char_t) 'F') ? \
- (parser->buffer.pointer[offset] - (yaml_char_t) 'A' + 10) : \
- (parser->buffer.pointer[offset] >= (yaml_char_t) 'a' && \
- parser->buffer.pointer[offset] <= (yaml_char_t) 'f') ? \
- (parser->buffer.pointer[offset] - (yaml_char_t) 'a' + 10) : \
- (parser->buffer.pointer[offset] - (yaml_char_t) '0'))
-
-#define AS_HEX(parser) AS_HEX_AT(parser,0)
-
-/*
- * Check if the character at the specified position is NUL.
- */
-
-#define IS_Z_AT(parser,offset) CHECK_AT(parser,'\0',(offset))
-
-#define IS_Z(parser) IS_Z_AT(parser,0)
-
-/*
- * Check if the character at the specified position is BOM.
- */
-
-#define IS_BOM_AT(parser,offset) \
- (CHECK_AT(parser,'\xEF',(offset)) \
- && CHECK_AT(parser,'\xBB',(offset)+1) \
- && CHECK_AT(parser,'\xBF',(offset)+1)) /* BOM (#xFEFF) */
-
-#define IS_BOM(parser) IS_BOM_AT(parser,0)
-
-/*
- * Check if the character at the specified position is space.
- */
-
-#define IS_SPACE_AT(parser,offset) CHECK_AT(parser,' ',(offset))
-
-#define IS_SPACE(parser) IS_SPACE_AT(parser,0)
-
-/*
- * Check if the character at the specified position is tab.
- */
-
-#define IS_TAB_AT(parser,offset) CHECK_AT(parser,'\t',(offset))
-
-#define IS_TAB(parser) IS_TAB_AT(parser,0)
-
-/*
- * Check if the character at the specified position is blank (space or tab).
- */
-
-#define IS_BLANK_AT(parser,offset) \
- (IS_SPACE_AT(parser,(offset)) || IS_TAB_AT(parser,(offset)))
-
-#define IS_BLANK(parser) IS_BLANK_AT(parser,0)
-
-/*
- * Check if the character at the specified position is a line break.
- */
-
-#define IS_BREAK_AT(parser,offset) \
- (CHECK_AT(parser,'\r',(offset)) /* CR (#xD)*/ \
- || CHECK_AT(parser,'\n',(offset)) /* LF (#xA) */ \
- || (CHECK_AT(parser,'\xC2',(offset)) \
- && CHECK_AT(parser,'\x85',(offset)+1)) /* NEL (#x85) */ \
- || (CHECK_AT(parser,'\xE2',(offset)) \
- && CHECK_AT(parser,'\x80',(offset)+1) \
- && CHECK_AT(parser,'\xA8',(offset)+2)) /* LS (#x2028) */ \
- || (CHECK_AT(parser,'\xE2',(offset)) \
- && CHECK_AT(parser,'\x80',(offset)+1) \
- && CHECK_AT(parser,'\xA9',(offset)+2))) /* PS (#x2029) */
-
-#define IS_BREAK(parser) IS_BREAK_AT(parser,0)
-
-#define IS_CRLF_AT(parser,offset) \
- (CHECK_AT(parser,'\r',(offset)) && CHECK_AT(parser,'\n',(offset)+1))
-
-#define IS_CRLF(parser) IS_CRLF_AT(parser,0)
-
-/*
- * Check if the character is a line break or NUL.
- */
-
-#define IS_BREAKZ_AT(parser,offset) \
- (IS_BREAK_AT(parser,(offset)) || IS_Z_AT(parser,(offset)))
-
-#define IS_BREAKZ(parser) IS_BREAKZ_AT(parser,0)
-
-/*
- * Check if the character is a line break, space, or NUL.
- */
-
-#define IS_SPACEZ_AT(parser,offset) \
- (IS_SPACE_AT(parser,(offset)) || IS_BREAKZ_AT(parser,(offset)))
-
-#define IS_SPACEZ(parser) IS_SPACEZ_AT(parser,0)
-
-/*
- * Check if the character is a line break, space, tab, or NUL.
- */
-
-#define IS_BLANKZ_AT(parser,offset) \
- (IS_BLANK_AT(parser,(offset)) || IS_BREAKZ_AT(parser,(offset)))
-
-#define IS_BLANKZ(parser) IS_BLANKZ_AT(parser,0)
-
-/*
- * Determine the width of the character.
- */
-
-#define WIDTH_AT(parser,offset) \
- ((parser->buffer.pointer[offset] & 0x80) == 0x00 ? 1 : \
- (parser->buffer.pointer[offset] & 0xE0) == 0xC0 ? 2 : \
- (parser->buffer.pointer[offset] & 0xF0) == 0xE0 ? 3 : \
- (parser->buffer.pointer[offset] & 0xF8) == 0xF0 ? 4 : 0)
-
-#define WIDTH(parser) WIDTH_AT(parser,0)
-
/*
* Advance the buffer pointer.
*/
(parser->mark.index ++, \
parser->mark.column ++, \
parser->unread --, \
- parser->buffer.pointer += WIDTH(parser))
+ parser->buffer.pointer += WIDTH(parser->buffer))
#define SKIP_LINE(parser) \
- (IS_CRLF(parser) ? \
+ (IS_CRLF(parser->buffer) ? \
(parser->mark.index += 2, \
parser->mark.column = 0, \
parser->mark.line ++, \
parser->unread -= 2, \
parser->buffer.pointer += 2) : \
- IS_BREAK(parser) ? \
+ IS_BREAK(parser->buffer) ? \
(parser->mark.index ++, \
parser->mark.column = 0, \
parser->mark.line ++, \
parser->unread --, \
- parser->buffer.pointer += WIDTH(parser)) : 0)
+ parser->buffer.pointer += WIDTH(parser->buffer)) : 0)
/*
* Copy a character to a string buffer and advance pointers.
#define READ(parser,string) \
(STRING_EXTEND(parser,string) ? \
- (((*parser->buffer.pointer & 0x80) == 0x00 ? \
- (*((string).pointer++) = *(parser->buffer.pointer++)) : \
- (*parser->buffer.pointer & 0xE0) == 0xC0 ? \
- (*((string).pointer++) = *(parser->buffer.pointer++), \
- *((string).pointer++) = *(parser->buffer.pointer++)) : \
- (*parser->buffer.pointer & 0xF0) == 0xE0 ? \
- (*((string).pointer++) = *(parser->buffer.pointer++), \
- *((string).pointer++) = *(parser->buffer.pointer++), \
- *((string).pointer++) = *(parser->buffer.pointer++)) : \
- (*parser->buffer.pointer & 0xF8) == 0xF0 ? \
- (*((string).pointer++) = *(parser->buffer.pointer++), \
- *((string).pointer++) = *(parser->buffer.pointer++), \
- *((string).pointer++) = *(parser->buffer.pointer++), \
- *((string).pointer++) = *(parser->buffer.pointer++)) : 0), \
+ (COPY(string,parser->buffer), \
parser->mark.index ++, \
parser->mark.column ++, \
parser->unread --, \
#define READ_LINE(parser,string) \
(STRING_EXTEND(parser,string) ? \
- (((CHECK_AT(parser,'\r',0) && CHECK_AT(parser,'\n',1)) ? /* CR LF -> LF */ \
+ (((CHECK_AT(parser->buffer,'\r',0) \
+ && CHECK_AT(parser->buffer,'\n',1)) ? /* CR LF -> LF */ \
(*((string).pointer++) = (yaml_char_t) '\n', \
parser->buffer.pointer += 2, \
parser->mark.index += 2, \
parser->mark.column = 0, \
parser->mark.line ++, \
parser->unread -= 2) : \
- (CHECK_AT(parser,'\r',0) || CHECK_AT(parser,'\n',0)) ? /* CR|LF -> LF */ \
+ (CHECK_AT(parser->buffer,'\r',0) \
+ || CHECK_AT(parser->buffer,'\n',0)) ? /* CR|LF -> LF */ \
(*((string).pointer++) = (yaml_char_t) '\n', \
parser->buffer.pointer ++, \
parser->mark.index ++, \
parser->mark.column = 0, \
parser->mark.line ++, \
parser->unread --) : \
- (CHECK_AT(parser,'\xC2',0) && CHECK_AT(parser,'\x85',1)) ? /* NEL -> LF */ \
+ (CHECK_AT(parser->buffer,'\xC2',0) \
+ && CHECK_AT(parser->buffer,'\x85',1)) ? /* NEL -> LF */ \
(*((string).pointer++) = (yaml_char_t) '\n', \
parser->buffer.pointer += 2, \
parser->mark.index ++, \
parser->mark.column = 0, \
parser->mark.line ++, \
parser->unread --) : \
- (CHECK_AT(parser,'\xE2',0) && \
- CHECK_AT(parser,'\x80',1) && \
- (CHECK_AT(parser,'\xA8',2) || \
- CHECK_AT(parser,'\xA9',2))) ? /* LS|PS -> LS|PS */ \
+ (CHECK_AT(parser->buffer,'\xE2',0) && \
+ CHECK_AT(parser->buffer,'\x80',1) && \
+ (CHECK_AT(parser->buffer,'\xA8',2) || \
+ CHECK_AT(parser->buffer,'\xA9',2))) ? /* LS|PS -> LS|PS */ \
(*((string).pointer++) = *(parser->buffer.pointer++), \
*((string).pointer++) = *(parser->buffer.pointer++), \
*((string).pointer++) = *(parser->buffer.pointer++), \
parser->unread --) : 0), \
1) : 0)
-/*
- * Token initializers.
- */
-
-#define TOKEN_INIT(token,token_type,token_start_mark,token_end_mark) \
- (memset(&(token), 0, sizeof(yaml_token_t)), \
- (token).type = (token_type), \
- (token).start_mark = (token_start_mark), \
- (token).end_mark = (token_end_mark))
-
-#define STREAM_START_TOKEN_INIT(token,token_encoding,start_mark,end_mark) \
- (TOKEN_INIT((token),YAML_STREAM_START_TOKEN,(start_mark),(end_mark)), \
- (token).data.stream_start.encoding = (token_encoding))
-
-#define STREAM_END_TOKEN_INIT(token,start_mark,end_mark) \
- (TOKEN_INIT((token),YAML_STREAM_END_TOKEN,(start_mark),(end_mark)))
-
-#define ALIAS_TOKEN_INIT(token,token_value,start_mark,end_mark) \
- (TOKEN_INIT((token),YAML_ALIAS_TOKEN,(start_mark),(end_mark)), \
- (token).data.alias.value = (token_value))
-
-#define ANCHOR_TOKEN_INIT(token,token_value,start_mark,end_mark) \
- (TOKEN_INIT((token),YAML_ANCHOR_TOKEN,(start_mark),(end_mark)), \
- (token).data.anchor.value = (token_value))
-
-#define TAG_TOKEN_INIT(token,token_handle,token_suffix,start_mark,end_mark) \
- (TOKEN_INIT((token),YAML_TAG_TOKEN,(start_mark),(end_mark)), \
- (token).data.tag.handle = (token_handle), \
- (token).data.tag.suffix = (token_suffix))
-
-#define SCALAR_TOKEN_INIT(token,token_value,token_length,token_style,start_mark,end_mark) \
- (TOKEN_INIT((token),YAML_SCALAR_TOKEN,(start_mark),(end_mark)), \
- (token).data.scalar.value = (token_value), \
- (token).data.scalar.length = (token_length), \
- (token).data.scalar.style = (token_style))
-
-#define VERSION_DIRECTIVE_TOKEN_INIT(token,token_major,token_minor,start_mark,end_mark) \
- (TOKEN_INIT((token),YAML_VERSION_DIRECTIVE_TOKEN,(start_mark),(end_mark)), \
- (token).data.version_directive.major = (token_major), \
- (token).data.version_directive.minor = (token_minor))
-
-#define TAG_DIRECTIVE_TOKEN_INIT(token,token_handle,token_prefix,start_mark,end_mark) \
- (TOKEN_INIT((token),YAML_TAG_DIRECTIVE_TOKEN,(start_mark),(end_mark)), \
- (token).data.tag_directive.handle = (token_handle), \
- (token).data.tag_directive.prefix = (token_prefix))
-
/*
* Public API declarations.
*/
*/
static int
-yaml_parser_roll_indent(yaml_parser_t *parser, int column,
- int number, yaml_token_type_t type, yaml_mark_t mark);
+yaml_parser_roll_indent(yaml_parser_t *parser, ptrdiff_t column,
+ ptrdiff_t number, yaml_token_type_t type, yaml_mark_t mark);
static int
-yaml_parser_unroll_indent(yaml_parser_t *parser, int column);
+yaml_parser_unroll_indent(yaml_parser_t *parser, ptrdiff_t column);
/*
* Token fetchers.
assert(parser); /* Non-NULL parser object is expected. */
assert(token); /* Non-NULL token object is expected. */
+ /* Erase the token object. */
+
+ memset(token, 0, sizeof(yaml_token_t));
+
/* No tokens after STREAM-END or error. */
if (parser->stream_end_produced || parser->error) {
- memset(token, 0, sizeof(yaml_token_t));
-
return 1;
}
}
/* Fetch the next token from the queue. */
-
+
*token = DEQUEUE(parser, parser->tokens);
parser->token_available = 0;
parser->tokens_parsed ++;
/* Is it the end of the stream? */
- if (IS_Z(parser))
+ if (IS_Z(parser->buffer))
return yaml_parser_fetch_stream_end(parser);
/* Is it a directive? */
- if (parser->mark.column == 0 && CHECK(parser, '%'))
+ if (parser->mark.column == 0 && CHECK(parser->buffer, '%'))
return yaml_parser_fetch_directive(parser);
/* Is it the document start indicator? */
if (parser->mark.column == 0
- && CHECK_AT(parser, '-', 0)
- && CHECK_AT(parser, '-', 1)
- && CHECK_AT(parser, '-', 2)
- && IS_BLANKZ_AT(parser, 3))
+ && CHECK_AT(parser->buffer, '-', 0)
+ && CHECK_AT(parser->buffer, '-', 1)
+ && CHECK_AT(parser->buffer, '-', 2)
+ && IS_BLANKZ_AT(parser->buffer, 3))
return yaml_parser_fetch_document_indicator(parser,
YAML_DOCUMENT_START_TOKEN);
/* Is it the document end indicator? */
if (parser->mark.column == 0
- && CHECK_AT(parser, '.', 0)
- && CHECK_AT(parser, '.', 1)
- && CHECK_AT(parser, '.', 2)
- && IS_BLANKZ_AT(parser, 3))
+ && CHECK_AT(parser->buffer, '.', 0)
+ && CHECK_AT(parser->buffer, '.', 1)
+ && CHECK_AT(parser->buffer, '.', 2)
+ && IS_BLANKZ_AT(parser->buffer, 3))
return yaml_parser_fetch_document_indicator(parser,
YAML_DOCUMENT_END_TOKEN);
/* Is it the flow sequence start indicator? */
- if (CHECK(parser, '['))
+ if (CHECK(parser->buffer, '['))
return yaml_parser_fetch_flow_collection_start(parser,
YAML_FLOW_SEQUENCE_START_TOKEN);
/* Is it the flow mapping start indicator? */
- if (CHECK(parser, '{'))
+ if (CHECK(parser->buffer, '{'))
return yaml_parser_fetch_flow_collection_start(parser,
YAML_FLOW_MAPPING_START_TOKEN);
/* Is it the flow sequence end indicator? */
- if (CHECK(parser, ']'))
+ if (CHECK(parser->buffer, ']'))
return yaml_parser_fetch_flow_collection_end(parser,
YAML_FLOW_SEQUENCE_END_TOKEN);
/* Is it the flow mapping end indicator? */
- if (CHECK(parser, '}'))
+ if (CHECK(parser->buffer, '}'))
return yaml_parser_fetch_flow_collection_end(parser,
YAML_FLOW_MAPPING_END_TOKEN);
/* Is it the flow entry indicator? */
- if (CHECK(parser, ','))
+ if (CHECK(parser->buffer, ','))
return yaml_parser_fetch_flow_entry(parser);
/* Is it the block entry indicator? */
- if (CHECK(parser, '-') && IS_BLANKZ_AT(parser, 1))
+ if (CHECK(parser->buffer, '-') && IS_BLANKZ_AT(parser->buffer, 1))
return yaml_parser_fetch_block_entry(parser);
/* Is it the key indicator? */
- if (CHECK(parser, '?') && (parser->flow_level || IS_BLANKZ_AT(parser, 1)))
+ if (CHECK(parser->buffer, '?')
+ && (parser->flow_level || IS_BLANKZ_AT(parser->buffer, 1)))
return yaml_parser_fetch_key(parser);
/* Is it the value indicator? */
- if (CHECK(parser, ':') && (parser->flow_level || IS_BLANKZ_AT(parser, 1)))
+ if (CHECK(parser->buffer, ':')
+ && (parser->flow_level || IS_BLANKZ_AT(parser->buffer, 1)))
return yaml_parser_fetch_value(parser);
/* Is it an alias? */
- if (CHECK(parser, '*'))
+ if (CHECK(parser->buffer, '*'))
return yaml_parser_fetch_anchor(parser, YAML_ALIAS_TOKEN);
/* Is it an anchor? */
- if (CHECK(parser, '&'))
+ if (CHECK(parser->buffer, '&'))
return yaml_parser_fetch_anchor(parser, YAML_ANCHOR_TOKEN);
/* Is it a tag? */
- if (CHECK(parser, '!'))
+ if (CHECK(parser->buffer, '!'))
return yaml_parser_fetch_tag(parser);
/* Is it a literal scalar? */
- if (CHECK(parser, '|') && !parser->flow_level)
+ if (CHECK(parser->buffer, '|') && !parser->flow_level)
return yaml_parser_fetch_block_scalar(parser, 1);
/* Is it a folded scalar? */
- if (CHECK(parser, '>') && !parser->flow_level)
+ if (CHECK(parser->buffer, '>') && !parser->flow_level)
return yaml_parser_fetch_block_scalar(parser, 0);
/* Is it a single-quoted scalar? */
- if (CHECK(parser, '\''))
+ if (CHECK(parser->buffer, '\''))
return yaml_parser_fetch_flow_scalar(parser, 1);
/* Is it a double-quoted scalar? */
- if (CHECK(parser, '"'))
+ if (CHECK(parser->buffer, '"'))
return yaml_parser_fetch_flow_scalar(parser, 0);
/*
* The last rule is more restrictive than the specification requires.
*/
- if (!(IS_BLANKZ(parser) || CHECK(parser, '-') || CHECK(parser, '?')
- || CHECK(parser, ':') || CHECK(parser, ',') || CHECK(parser, '[')
- || CHECK(parser, ']') || CHECK(parser, '{') || CHECK(parser, '}')
- || CHECK(parser, '#') || CHECK(parser, '&') || CHECK(parser, '*')
- || CHECK(parser, '!') || CHECK(parser, '|') || CHECK(parser, '>')
- || CHECK(parser, '\'') || CHECK(parser, '"') || CHECK(parser, '%')
- || CHECK(parser, '@') || CHECK(parser, '`')) ||
- (CHECK(parser, '-') && !IS_BLANK_AT(parser, 1)) ||
+ if (!(IS_BLANKZ(parser->buffer) || CHECK(parser->buffer, '-')
+ || CHECK(parser->buffer, '?') || CHECK(parser->buffer, ':')
+ || CHECK(parser->buffer, ',') || CHECK(parser->buffer, '[')
+ || CHECK(parser->buffer, ']') || CHECK(parser->buffer, '{')
+ || CHECK(parser->buffer, '}') || CHECK(parser->buffer, '#')
+ || CHECK(parser->buffer, '&') || CHECK(parser->buffer, '*')
+ || CHECK(parser->buffer, '!') || CHECK(parser->buffer, '|')
+ || CHECK(parser->buffer, '>') || CHECK(parser->buffer, '\'')
+ || CHECK(parser->buffer, '"') || CHECK(parser->buffer, '%')
+ || CHECK(parser->buffer, '@') || CHECK(parser->buffer, '`')) ||
+ (CHECK(parser->buffer, '-') && !IS_BLANK_AT(parser->buffer, 1)) ||
(!parser->flow_level &&
- (CHECK(parser, '?') || CHECK(parser, ':')) && !IS_BLANKZ_AT(parser, 1)))
+ (CHECK(parser->buffer, '?') || CHECK(parser->buffer, ':'))
+ && !IS_BLANKZ_AT(parser->buffer, 1)))
return yaml_parser_fetch_plain_scalar(parser);
/*
if (simple_key->required) {
return yaml_parser_set_scanner_error(parser,
"while scanning a simple key", simple_key->mark,
- "could not found expected ':'");
+ "could not find expected ':'");
}
simple_key->possible = 0;
*/
int required = (!parser->flow_level
- && parser->indent == parser->mark.column);
-
- /*
- * A simple key is required only when it is the first token in the current
- * line. Therefore it is always allowed. But we add a check anyway.
- */
-
- assert(parser->simple_key_allowed || !required); /* Impossible. */
+ && parser->indent == (ptrdiff_t)parser->mark.column);
/*
* If the current position may start a simple key, save it.
if (parser->simple_key_allowed)
{
- yaml_simple_key_t simple_key = { 1, required,
- parser->tokens_parsed + parser->tokens.tail - parser->tokens.head,
- parser->mark };
+ yaml_simple_key_t simple_key;
+ simple_key.possible = 1;
+ simple_key.required = required;
+ simple_key.token_number =
+ parser->tokens_parsed + (parser->tokens.tail - parser->tokens.head);
+ simple_key.mark = parser->mark;
if (!yaml_parser_remove_simple_key(parser)) return 0;
if (simple_key->required) {
return yaml_parser_set_scanner_error(parser,
"while scanning a simple key", simple_key->mark,
- "could not found expected ':'");
+ "could not find expected ':'");
}
}
/* Increase the flow level. */
+ if (parser->flow_level == INT_MAX) {
+ parser->error = YAML_MEMORY_ERROR;
+ return 0;
+ }
+
parser->flow_level++;
return 1;
static int
yaml_parser_decrease_flow_level(yaml_parser_t *parser)
{
+ yaml_simple_key_t dummy_key; /* Used to eliminate a compiler warning. */
+
if (parser->flow_level) {
parser->flow_level --;
- POP(parser, parser->simple_keys);
+ dummy_key = POP(parser, parser->simple_keys);
}
return 1;
* Push the current indentation level to the stack and set the new level
* the current column is greater than the indentation level. In this case,
* append or insert the specified token into the token queue.
- *
+ *
*/
static int
-yaml_parser_roll_indent(yaml_parser_t *parser, int column,
- int number, yaml_token_type_t type, yaml_mark_t mark)
+yaml_parser_roll_indent(yaml_parser_t *parser, ptrdiff_t column,
+ ptrdiff_t number, yaml_token_type_t type, yaml_mark_t mark)
{
yaml_token_t token;
if (!PUSH(parser, parser->indents, parser->indent))
return 0;
+ if (column > INT_MAX) {
+ parser->error = YAML_MEMORY_ERROR;
+ return 0;
+ }
+
parser->indent = column;
/* Create a token and insert it into the queue. */
/*
* Pop indentation levels from the indents stack until the current level
- * becomes less or equal to the column. For each intendation level, append
+ * becomes less or equal to the column. For each indentation level, append
* the BLOCK-END token.
*/
static int
-yaml_parser_unroll_indent(yaml_parser_t *parser, int column)
+yaml_parser_unroll_indent(yaml_parser_t *parser, ptrdiff_t column)
{
yaml_token_t token;
if (parser->flow_level)
return 1;
- /* Loop through the intendation levels in the stack. */
+ /* Loop through the indentation levels in the stack. */
while (parser->indent > column)
{
{
yaml_token_t token;
+ /* Force new line. */
+
+ if (parser->mark.column != 0) {
+ parser->mark.column = 0;
+ parser->mark.line ++;
+ }
+
/* Reset the indentation level. */
if (!yaml_parser_unroll_indent(parser, -1))
if (!CACHE(parser, 1)) return 0;
- if (parser->mark.column == 0 && IS_BOM(parser))
+ if (parser->mark.column == 0 && IS_BOM(parser->buffer))
SKIP(parser);
/*
*
* - in the flow context;
* - in the block context, but not at the beginning of the line or
- * after '-', '?', or ':' (complex value).
+ * after '-', '?', or ':' (complex value).
*/
if (!CACHE(parser, 1)) return 0;
- while (CHECK(parser,' ') ||
+ while (CHECK(parser->buffer,' ') ||
((parser->flow_level || !parser->simple_key_allowed) &&
- CHECK(parser, '\t'))) {
+ CHECK(parser->buffer, '\t'))) {
SKIP(parser);
if (!CACHE(parser, 1)) return 0;
}
/* Eat a comment until a line break. */
- if (CHECK(parser, '#')) {
- while (!IS_BREAKZ(parser)) {
+ if (CHECK(parser->buffer, '#')) {
+ while (!IS_BREAKZ(parser->buffer)) {
SKIP(parser);
if (!CACHE(parser, 1)) return 0;
}
/* If it is a line break, eat it. */
- if (IS_BREAK(parser))
+ if (IS_BREAK(parser->buffer))
{
if (!CACHE(parser, 2)) return 0;
SKIP_LINE(parser);
else
{
yaml_parser_set_scanner_error(parser, "while scanning a directive",
- start_mark, "found uknown directive name");
+ start_mark, "found unknown directive name");
goto error;
}
if (!CACHE(parser, 1)) goto error;
- while (IS_BLANK(parser)) {
+ while (IS_BLANK(parser->buffer)) {
SKIP(parser);
if (!CACHE(parser, 1)) goto error;
}
- if (CHECK(parser, '#')) {
- while (!IS_BREAKZ(parser)) {
+ if (CHECK(parser->buffer, '#')) {
+ while (!IS_BREAKZ(parser->buffer)) {
SKIP(parser);
if (!CACHE(parser, 1)) goto error;
}
/* Check if we are at the end of the line. */
- if (!IS_BREAKZ(parser)) {
+ if (!IS_BREAKZ(parser->buffer)) {
yaml_parser_set_scanner_error(parser, "while scanning a directive",
- start_mark, "did not found expected comment or line break");
+ start_mark, "did not find expected comment or line break");
goto error;
}
/* Eat a line break. */
- if (IS_BREAK(parser)) {
+ if (IS_BREAK(parser->buffer)) {
if (!CACHE(parser, 2)) goto error;
SKIP_LINE(parser);
}
if (!CACHE(parser, 1)) goto error;
- while (IS_ALPHA(parser))
+ while (IS_ALPHA(parser->buffer))
{
if (!READ(parser, string)) goto error;
if (!CACHE(parser, 1)) goto error;
if (string.start == string.pointer) {
yaml_parser_set_scanner_error(parser, "while scanning a directive",
- start_mark, "cannot found expected directive name");
+ start_mark, "could not find expected directive name");
goto error;
}
/* Check for an blank character after the name. */
- if (!IS_BLANKZ(parser)) {
+ if (!IS_BLANKZ(parser->buffer)) {
yaml_parser_set_scanner_error(parser, "while scanning a directive",
start_mark, "found unexpected non-alphabetical character");
goto error;
if (!CACHE(parser, 1)) return 0;
- while (IS_BLANK(parser)) {
+ while (IS_BLANK(parser->buffer)) {
SKIP(parser);
if (!CACHE(parser, 1)) return 0;
}
/* Eat '.'. */
- if (!CHECK(parser, '.')) {
+ if (!CHECK(parser->buffer, '.')) {
return yaml_parser_set_scanner_error(parser, "while scanning a %YAML directive",
start_mark, "did not find expected digit or '.' character");
}
if (!CACHE(parser, 1)) return 0;
- while (IS_DIGIT(parser))
+ while (IS_DIGIT(parser->buffer))
{
/* Check if the number is too long. */
start_mark, "found extremely long version number");
}
- value = value*10 + AS_DIGIT(parser);
+ value = value*10 + AS_DIGIT(parser->buffer);
SKIP(parser);
if (!CACHE(parser, 1)) goto error;
- while (IS_BLANK(parser)) {
+ while (IS_BLANK(parser->buffer)) {
SKIP(parser);
if (!CACHE(parser, 1)) goto error;
}
if (!CACHE(parser, 1)) goto error;
- if (!IS_BLANK(parser)) {
+ if (!IS_BLANK(parser->buffer)) {
yaml_parser_set_scanner_error(parser, "while scanning a %TAG directive",
start_mark, "did not find expected whitespace");
goto error;
/* Eat whitespaces. */
- while (IS_BLANK(parser)) {
+ while (IS_BLANK(parser->buffer)) {
SKIP(parser);
if (!CACHE(parser, 1)) goto error;
}
if (!CACHE(parser, 1)) goto error;
- if (!IS_BLANKZ(parser)) {
+ if (!IS_BLANKZ(parser->buffer)) {
yaml_parser_set_scanner_error(parser, "while scanning a %TAG directive",
start_mark, "did not find expected whitespace or line break");
goto error;
if (!CACHE(parser, 1)) goto error;
- while (IS_ALPHA(parser)) {
+ while (IS_ALPHA(parser->buffer)) {
if (!READ(parser, string)) goto error;
if (!CACHE(parser, 1)) goto error;
length ++;
* '?', ':', ',', ']', '}', '%', '@', '`'.
*/
- if (!length || !(IS_BLANKZ(parser) || CHECK(parser, '?') || CHECK(parser, ':') ||
- CHECK(parser, ',') || CHECK(parser, ']') || CHECK(parser, '}') ||
- CHECK(parser, '%') || CHECK(parser, '@') || CHECK(parser, '`'))) {
+ if (!length || !(IS_BLANKZ(parser->buffer) || CHECK(parser->buffer, '?')
+ || CHECK(parser->buffer, ':') || CHECK(parser->buffer, ',')
+ || CHECK(parser->buffer, ']') || CHECK(parser->buffer, '}')
+ || CHECK(parser->buffer, '%') || CHECK(parser->buffer, '@')
+ || CHECK(parser->buffer, '`'))) {
yaml_parser_set_scanner_error(parser, type == YAML_ANCHOR_TOKEN ?
"while scanning an anchor" : "while scanning an alias", start_mark,
"did not find expected alphabetic or numeric character");
if (!CACHE(parser, 2)) goto error;
- if (CHECK_AT(parser, '<', 1))
+ if (CHECK_AT(parser->buffer, '<', 1))
{
/* Set the handle to '' */
/* Check for '>' and eat it. */
- if (!CHECK(parser, '>')) {
+ if (!CHECK(parser->buffer, '>')) {
yaml_parser_set_scanner_error(parser, "while scanning a tag",
start_mark, "did not find the expected '>'");
goto error;
if (!CACHE(parser, 1)) goto error;
- if (!IS_BLANKZ(parser)) {
+ if (!IS_BLANKZ(parser->buffer)) {
yaml_parser_set_scanner_error(parser, "while scanning a tag",
- start_mark, "did not found expected whitespace or line break");
+ start_mark, "did not find expected whitespace or line break");
goto error;
}
if (!CACHE(parser, 1)) goto error;
- if (!CHECK(parser, '!')) {
+ if (!CHECK(parser->buffer, '!')) {
yaml_parser_set_scanner_error(parser, directive ?
"while scanning a tag directive" : "while scanning a tag",
start_mark, "did not find expected '!'");
if (!CACHE(parser, 1)) goto error;
- while (IS_ALPHA(parser))
+ while (IS_ALPHA(parser->buffer))
{
if (!READ(parser, string)) goto error;
if (!CACHE(parser, 1)) goto error;
/* Check if the trailing character is '!' and copy it. */
- if (CHECK(parser, '!'))
+ if (CHECK(parser->buffer, '!'))
{
if (!READ(parser, string)) goto error;
}
/* Resize the string to include the head. */
- while (string.end - string.start <= length) {
+ while ((size_t)(string.end - string.start) <= length) {
if (!yaml_string_extend(&string.start, &string.pointer, &string.end)) {
parser->error = YAML_MEMORY_ERROR;
goto error;
* '%'.
*/
- while (IS_ALPHA(parser) || CHECK(parser, ';') || CHECK(parser, '/') ||
- CHECK(parser, '?') || CHECK(parser, ':') || CHECK(parser, '@') ||
- CHECK(parser, '&') || CHECK(parser, '=') || CHECK(parser, '+') ||
- CHECK(parser, '$') || CHECK(parser, ',') || CHECK(parser, '.') ||
- CHECK(parser, '!') || CHECK(parser, '~') || CHECK(parser, '*') ||
- CHECK(parser, '\'') || CHECK(parser, '(') || CHECK(parser, ')') ||
- CHECK(parser, '[') || CHECK(parser, ']') || CHECK(parser, '%'))
+ while (IS_ALPHA(parser->buffer) || CHECK(parser->buffer, ';')
+ || CHECK(parser->buffer, '/') || CHECK(parser->buffer, '?')
+ || CHECK(parser->buffer, ':') || CHECK(parser->buffer, '@')
+ || CHECK(parser->buffer, '&') || CHECK(parser->buffer, '=')
+ || CHECK(parser->buffer, '+') || CHECK(parser->buffer, '$')
+ || CHECK(parser->buffer, ',') || CHECK(parser->buffer, '.')
+ || CHECK(parser->buffer, '!') || CHECK(parser->buffer, '~')
+ || CHECK(parser->buffer, '*') || CHECK(parser->buffer, '\'')
+ || CHECK(parser->buffer, '(') || CHECK(parser->buffer, ')')
+ || CHECK(parser->buffer, '[') || CHECK(parser->buffer, ']')
+ || CHECK(parser->buffer, '%'))
{
/* Check if it is a URI-escape sequence. */
- if (CHECK(parser, '%')) {
+ if (CHECK(parser->buffer, '%')) {
+ if (!STRING_EXTEND(parser, string))
+ goto error;
+
if (!yaml_parser_scan_uri_escapes(parser,
directive, start_mark, &string)) goto error;
}
if (!CACHE(parser, 3)) return 0;
- if (!(CHECK(parser, '%') && IS_HEX_AT(parser, 1) && IS_HEX_AT(parser, 2))) {
+ if (!(CHECK(parser->buffer, '%')
+ && IS_HEX_AT(parser->buffer, 1)
+ && IS_HEX_AT(parser->buffer, 2))) {
return yaml_parser_set_scanner_error(parser, directive ?
"while parsing a %TAG directive" : "while parsing a tag",
start_mark, "did not find URI escaped octet");
/* Get the octet. */
- octet = (AS_HEX_AT(parser, 1) << 4) + AS_HEX_AT(parser, 2);
+ octet = (AS_HEX_AT(parser->buffer, 1) << 4) + AS_HEX_AT(parser->buffer, 2);
/* If it is the leading octet, determine the length of the UTF-8 sequence. */
/* Check for a chomping indicator. */
- if (CHECK(parser, '+') || CHECK(parser, '-'))
+ if (CHECK(parser->buffer, '+') || CHECK(parser->buffer, '-'))
{
/* Set the chomping method and eat the indicator. */
- chomping = CHECK(parser, '+') ? +1 : -1;
+ chomping = CHECK(parser->buffer, '+') ? +1 : -1;
SKIP(parser);
if (!CACHE(parser, 1)) goto error;
- if (IS_DIGIT(parser))
+ if (IS_DIGIT(parser->buffer))
{
- /* Check that the intendation is greater than 0. */
+ /* Check that the indentation is greater than 0. */
- if (CHECK(parser, '0')) {
+ if (CHECK(parser->buffer, '0')) {
yaml_parser_set_scanner_error(parser, "while scanning a block scalar",
- start_mark, "found an intendation indicator equal to 0");
+ start_mark, "found an indentation indicator equal to 0");
goto error;
}
- /* Get the intendation level and eat the indicator. */
+ /* Get the indentation level and eat the indicator. */
- increment = AS_DIGIT(parser);
+ increment = AS_DIGIT(parser->buffer);
SKIP(parser);
}
/* Do the same as above, but in the opposite order. */
- else if (IS_DIGIT(parser))
+ else if (IS_DIGIT(parser->buffer))
{
- if (CHECK(parser, '0')) {
+ if (CHECK(parser->buffer, '0')) {
yaml_parser_set_scanner_error(parser, "while scanning a block scalar",
- start_mark, "found an intendation indicator equal to 0");
+ start_mark, "found an indentation indicator equal to 0");
goto error;
}
- increment = AS_DIGIT(parser);
+ increment = AS_DIGIT(parser->buffer);
SKIP(parser);
if (!CACHE(parser, 1)) goto error;
- if (CHECK(parser, '+') || CHECK(parser, '-')) {
- chomping = CHECK(parser, '+') ? +1 : -1;
+ if (CHECK(parser->buffer, '+') || CHECK(parser->buffer, '-')) {
+ chomping = CHECK(parser->buffer, '+') ? +1 : -1;
SKIP(parser);
}
if (!CACHE(parser, 1)) goto error;
- while (IS_BLANK(parser)) {
+ while (IS_BLANK(parser->buffer)) {
SKIP(parser);
if (!CACHE(parser, 1)) goto error;
}
- if (CHECK(parser, '#')) {
- while (!IS_BREAKZ(parser)) {
+ if (CHECK(parser->buffer, '#')) {
+ while (!IS_BREAKZ(parser->buffer)) {
SKIP(parser);
if (!CACHE(parser, 1)) goto error;
}
/* Check if we are at the end of the line. */
- if (!IS_BREAKZ(parser)) {
+ if (!IS_BREAKZ(parser->buffer)) {
yaml_parser_set_scanner_error(parser, "while scanning a block scalar",
- start_mark, "did not found expected comment or line break");
+ start_mark, "did not find expected comment or line break");
goto error;
}
/* Eat a line break. */
- if (IS_BREAK(parser)) {
+ if (IS_BREAK(parser->buffer)) {
if (!CACHE(parser, 2)) goto error;
SKIP_LINE(parser);
}
end_mark = parser->mark;
- /* Set the intendation level if it was specified. */
+ /* Set the indentation level if it was specified. */
if (increment) {
indent = parser->indent >= 0 ? parser->indent+increment : increment;
if (!CACHE(parser, 1)) goto error;
- while (parser->mark.column == indent && !IS_Z(parser))
+ while ((int)parser->mark.column == indent && !IS_Z(parser->buffer))
{
/*
* We are at the beginning of a non-empty line.
/* Is it a trailing whitespace? */
- trailing_blank = IS_BLANK(parser);
+ trailing_blank = IS_BLANK(parser->buffer);
/* Check if we need to fold the leading line break. */
/* Is it a leading whitespace? */
- leading_blank = IS_BLANK(parser);
+ leading_blank = IS_BLANK(parser->buffer);
/* Consume the current line. */
- while (!IS_BREAKZ(parser)) {
+ while (!IS_BREAKZ(parser->buffer)) {
if (!READ(parser, string)) goto error;
if (!CACHE(parser, 1)) goto error;
}
if (!READ_LINE(parser, leading_break)) goto error;
- /* Eat the following intendation spaces and line breaks. */
+ /* Eat the following indentation spaces and line breaks. */
if (!yaml_parser_scan_block_scalar_breaks(parser,
&indent, &trailing_breaks, start_mark, &end_mark)) goto error;
}
/*
- * Scan intendation spaces and line breaks for a block scalar. Determine the
- * intendation level if needed.
+ * Scan indentation spaces and line breaks for a block scalar. Determine the
+ * indentation level if needed.
*/
static int
*end_mark = parser->mark;
- /* Eat the intendation spaces and line breaks. */
+ /* Eat the indentation spaces and line breaks. */
while (1)
{
- /* Eat the intendation spaces. */
+ /* Eat the indentation spaces. */
if (!CACHE(parser, 1)) return 0;
- while ((!*indent || parser->mark.column < *indent) && IS_SPACE(parser)) {
+ while ((!*indent || (int)parser->mark.column < *indent)
+ && IS_SPACE(parser->buffer)) {
SKIP(parser);
if (!CACHE(parser, 1)) return 0;
}
- if (parser->mark.column > max_indent)
- max_indent = parser->mark.column;
+ if ((int)parser->mark.column > max_indent)
+ max_indent = (int)parser->mark.column;
- /* Check for a tab character messing the intendation. */
+ /* Check for a tab character messing the indentation. */
- if ((!*indent || parser->mark.column < *indent) && IS_TAB(parser)) {
+ if ((!*indent || (int)parser->mark.column < *indent)
+ && IS_TAB(parser->buffer)) {
return yaml_parser_set_scanner_error(parser, "while scanning a block scalar",
- start_mark, "found a tab character where an intendation space is expected");
+ start_mark, "found a tab character where an indentation space is expected");
}
/* Have we found a non-empty line? */
- if (!IS_BREAK(parser)) break;
+ if (!IS_BREAK(parser->buffer)) break;
/* Consume the line break. */
*indent = 1;
}
- return 1;
+ return 1;
}
/*
if (!CACHE(parser, 4)) goto error;
if (parser->mark.column == 0 &&
- ((CHECK_AT(parser, '-', 0) &&
- CHECK_AT(parser, '-', 1) &&
- CHECK_AT(parser, '-', 2)) ||
- (CHECK_AT(parser, '.', 0) &&
- CHECK_AT(parser, '.', 1) &&
- CHECK_AT(parser, '.', 2))) &&
- IS_BLANKZ_AT(parser, 3))
+ ((CHECK_AT(parser->buffer, '-', 0) &&
+ CHECK_AT(parser->buffer, '-', 1) &&
+ CHECK_AT(parser->buffer, '-', 2)) ||
+ (CHECK_AT(parser->buffer, '.', 0) &&
+ CHECK_AT(parser->buffer, '.', 1) &&
+ CHECK_AT(parser->buffer, '.', 2))) &&
+ IS_BLANKZ_AT(parser->buffer, 3))
{
yaml_parser_set_scanner_error(parser, "while scanning a quoted scalar",
start_mark, "found unexpected document indicator");
/* Check for EOF. */
- if (IS_Z(parser)) {
+ if (IS_Z(parser->buffer)) {
yaml_parser_set_scanner_error(parser, "while scanning a quoted scalar",
start_mark, "found unexpected end of stream");
goto error;
leading_blanks = 0;
- while (!IS_BLANKZ(parser))
+ while (!IS_BLANKZ(parser->buffer))
{
/* Check for an escaped single quote. */
- if (single && CHECK_AT(parser, '\'', 0) && CHECK_AT(parser, '\'', 1))
+ if (single && CHECK_AT(parser->buffer, '\'', 0)
+ && CHECK_AT(parser->buffer, '\'', 1))
{
if (!STRING_EXTEND(parser, string)) goto error;
*(string.pointer++) = '\'';
/* Check for the right quote. */
- else if (CHECK(parser, single ? '\'' : '"'))
+ else if (CHECK(parser->buffer, single ? '\'' : '"'))
{
break;
}
/* Check for an escaped line break. */
- else if (!single && CHECK(parser, '\\') && IS_BREAK_AT(parser, 1))
+ else if (!single && CHECK(parser->buffer, '\\')
+ && IS_BREAK_AT(parser->buffer, 1))
{
if (!CACHE(parser, 3)) goto error;
SKIP(parser);
/* Check for an escape sequence. */
- else if (!single && CHECK(parser, '\\'))
+ else if (!single && CHECK(parser->buffer, '\\'))
{
- int code_length = 0;
+ size_t code_length = 0;
if (!STRING_EXTEND(parser, string)) goto error;
*(string.pointer++) = '"';
break;
+ case '/':
+ *(string.pointer++) = '/';
+ break;
+
case '\'':
*(string.pointer++) = '\'';
break;
if (code_length)
{
unsigned int value = 0;
- int k;
+ size_t k;
/* Scan the character value. */
if (!CACHE(parser, code_length)) goto error;
for (k = 0; k < code_length; k ++) {
- if (!IS_HEX_AT(parser, k)) {
+ if (!IS_HEX_AT(parser->buffer, k)) {
yaml_parser_set_scanner_error(parser, "while parsing a quoted scalar",
start_mark, "did not find expected hexdecimal number");
goto error;
}
- value = (value << 4) + AS_HEX_AT(parser, k);
+ value = (value << 4) + AS_HEX_AT(parser->buffer, k);
}
/* Check the value and write the character. */
/* Check if we are at the end of the scalar. */
- if (CHECK(parser, single ? '\'' : '"'))
+ if (CHECK(parser->buffer, single ? '\'' : '"'))
break;
/* Consume blank characters. */
if (!CACHE(parser, 1)) goto error;
- while (IS_BLANK(parser) || IS_BREAK(parser))
+ while (IS_BLANK(parser->buffer) || IS_BREAK(parser->buffer))
{
- if (IS_BLANK(parser))
+ if (IS_BLANK(parser->buffer))
{
/* Consume a space or a tab character. */
if (!STRING_INIT(parser, trailing_breaks, INITIAL_STRING_SIZE)) goto error;
if (!STRING_INIT(parser, whitespaces, INITIAL_STRING_SIZE)) goto error;
- start_mark = parser->mark;
+ start_mark = end_mark = parser->mark;
/* Consume the content of the plain scalar. */
if (!CACHE(parser, 4)) goto error;
if (parser->mark.column == 0 &&
- ((CHECK_AT(parser, '-', 0) &&
- CHECK_AT(parser, '-', 1) &&
- CHECK_AT(parser, '-', 2)) ||
- (CHECK_AT(parser, '.', 0) &&
- CHECK_AT(parser, '.', 1) &&
- CHECK_AT(parser, '.', 2))) &&
- IS_BLANKZ_AT(parser, 3)) break;
+ ((CHECK_AT(parser->buffer, '-', 0) &&
+ CHECK_AT(parser->buffer, '-', 1) &&
+ CHECK_AT(parser->buffer, '-', 2)) ||
+ (CHECK_AT(parser->buffer, '.', 0) &&
+ CHECK_AT(parser->buffer, '.', 1) &&
+ CHECK_AT(parser->buffer, '.', 2))) &&
+ IS_BLANKZ_AT(parser->buffer, 3)) break;
/* Check for a comment. */
- if (CHECK(parser, '#'))
+ if (CHECK(parser->buffer, '#'))
break;
/* Consume non-blank characters. */
- while (!IS_BLANKZ(parser))
+ while (!IS_BLANKZ(parser->buffer))
{
/* Check for 'x:x' in the flow context. TODO: Fix the test "spec-08-13". */
- if (parser->flow_level && CHECK(parser, ':') && !IS_BLANKZ_AT(parser, 1)) {
+ if (parser->flow_level
+ && CHECK(parser->buffer, ':')
+ && !IS_BLANKZ_AT(parser->buffer, 1)) {
yaml_parser_set_scanner_error(parser, "while scanning a plain scalar",
start_mark, "found unexpected ':'");
goto error;
/* Check for indicators that may end a plain scalar. */
- if ((CHECK(parser, ':') && IS_BLANKZ_AT(parser, 1)) ||
- (parser->flow_level &&
- (CHECK(parser, ',') || CHECK(parser, ':') ||
- CHECK(parser, '?') || CHECK(parser, '[') ||
- CHECK(parser, ']') || CHECK(parser, '{') ||
- CHECK(parser, '}'))))
+ if ((CHECK(parser->buffer, ':') && IS_BLANKZ_AT(parser->buffer, 1))
+ || (parser->flow_level &&
+ (CHECK(parser->buffer, ',') || CHECK(parser->buffer, ':')
+ || CHECK(parser->buffer, '?') || CHECK(parser->buffer, '[')
+ || CHECK(parser->buffer, ']') || CHECK(parser->buffer, '{')
+ || CHECK(parser->buffer, '}'))))
break;
/* Check if we need to join whitespaces and breaks. */
/* Is it the end? */
- if (!(IS_BLANK(parser) || IS_BREAK(parser)))
+ if (!(IS_BLANK(parser->buffer) || IS_BREAK(parser->buffer)))
break;
/* Consume blank characters. */
if (!CACHE(parser, 1)) goto error;
- while (IS_BLANK(parser) || IS_BREAK(parser))
+ while (IS_BLANK(parser->buffer) || IS_BREAK(parser->buffer))
{
- if (IS_BLANK(parser))
+ if (IS_BLANK(parser->buffer))
{
- /* Check for tab character that abuse intendation. */
+ /* Check for tab character that abuse indentation. */
- if (leading_blanks && parser->mark.column < indent && IS_TAB(parser)) {
+ if (leading_blanks && (int)parser->mark.column < indent
+ && IS_TAB(parser->buffer)) {
yaml_parser_set_scanner_error(parser, "while scanning a plain scalar",
- start_mark, "found a tab character that violate intendation");
+ start_mark, "found a tab character that violate indentation");
goto error;
}
if (!CACHE(parser, 1)) goto error;
}
- /* Check intendation level. */
+ /* Check indentation level. */
- if (!parser->flow_level && parser->mark.column < indent)
+ if (!parser->flow_level && (int)parser->mark.column < indent)
break;
}
return 0;
}
-