48 #define PEEK_TOKEN(parser) \
49 ((parser->token_available || yaml_parser_fetch_more_tokens(parser)) ? \
50 parser->tokens.head : NULL)
56 #define SKIP_TOKEN(parser) \
57 (parser->token_available = 0, \
58 parser->tokens_parsed ++, \
59 parser->stream_end_produced = \
60 (parser->tokens.head->type == YAML_STREAM_END_TOKEN), \
61 parser->tokens.head ++)
105 int block,
int indentless_sequence);
181 if (parser->stream_end_produced || parser->error ||
228 switch (parser->
state)
318 if (!token)
return 0;
322 "did not find expected <stream-start>", token->
start_mark);
353 if (!token)
return 0;
362 if (!token)
return 0;
390 &tag_directives.start, &tag_directives.end))
393 if (!token)
goto error;
396 "did not find expected <document start>", token->
start_mark);
404 tag_directives.start, tag_directives.end, 0,
405 start_mark, end_mark);
407 version_directive =
NULL;
408 tag_directives.start = tag_directives.end =
NULL;
424 while (tag_directives.start != tag_directives.end) {
425 yaml_free(tag_directives.end[-1].handle);
426 yaml_free(tag_directives.end[-1].prefix);
427 tag_directives.end --;
445 if (!token)
return 0;
477 if (!token)
return 0;
530 int block,
int indentless_sequence)
541 if (!token)
return 0;
563 if (!token)
goto error;
566 tag_handle = token->
data.
tag.handle;
567 tag_suffix = token->
data.
tag.suffix;
572 if (!token)
goto error;
577 tag_handle = token->
data.
tag.handle;
578 tag_suffix = token->
data.
tag.suffix;
583 if (!token)
goto error;
590 if (!token)
goto error;
598 tag_handle = tag_suffix =
NULL;
605 if (strcmp((
char *)tag_directive->
handle, (
char *)tag_handle) == 0) {
607 size_t suffix_len =
strlen((
char *)tag_suffix);
614 memcpy(tag+prefix_len, tag_suffix, suffix_len);
615 tag[prefix_len+suffix_len] =
'\0';
618 tag_handle = tag_suffix =
NULL;
624 "while parsing a node", start_mark,
625 "found undefined tag handle", tag_mark);
631 implicit = (!tag || !*tag);
641 int plain_implicit = 0;
642 int quoted_implicit = 0;
645 || (tag && strcmp((
char *)tag,
"!") == 0)) {
654 plain_implicit, quoted_implicit,
655 token->
data.
scalar.style, start_mark, end_mark);
687 else if (anchor || tag) {
697 start_mark, end_mark);
702 (block ?
"while parsing a block node"
703 :
"while parsing a flow node"), start_mark,
704 "did not find expected node content", token->
start_mark);
739 if (!token)
return 0;
746 if (!token)
return 0;
772 "while parsing a block collection",
POP(parser, parser->
marks),
773 "did not find expected '-' indicator", token->
start_mark);
790 if (!token)
return 0;
797 if (!token)
return 0;
847 if (!token)
return 0;
854 if (!token)
return 0;
881 "while parsing a block mapping",
POP(parser, parser->
marks),
882 "did not find expected key", token->
start_mark);
905 if (!token)
return 0;
912 if (!token)
return 0;
962 if (!token)
return 0;
970 if (!token)
return 0;
974 "while parsing a flow sequence",
POP(parser, parser->
marks),
975 "did not find expected ',' or ']'", token->
start_mark);
1016 if (!token)
return 0;
1046 if (!token)
return 0;
1051 if (!token)
return 0;
1077 if (!token)
return 0;
1113 if (!token)
return 0;
1121 if (!token)
return 0;
1125 "while parsing a flow mapping",
POP(parser, parser->
marks),
1126 "did not find expected ',' or '}'", token->
start_mark);
1133 if (!token)
return 0;
1176 if (!token)
return 0;
1187 if (!token)
return 0;
1245 } tag_directives = {
NULL,
NULL, NULL };
1252 if (!token)
goto error;
1258 if (version_directive) {
1260 "found duplicate %YAML directive", token->
start_mark);
1266 "found incompatible YAML document", token->
start_mark);
1270 if (!version_directive) {
1286 if (!
PUSH(parser, tag_directives, value))
1292 if (!token)
goto error;
1295 for (default_tag_directive = default_tag_directives;
1296 default_tag_directive->
handle; default_tag_directive++) {
1302 if (version_directive_ref) {
1303 *version_directive_ref = version_directive;
1305 if (tag_directives_start_ref) {
1307 *tag_directives_start_ref = *tag_directives_end_ref =
NULL;
1311 *tag_directives_start_ref = tag_directives.start;
1312 *tag_directives_end_ref = tag_directives.top;
1345 if (strcmp((
char *)value.
handle, (
char *)tag_directive->
handle) == 0) {
1346 if (allow_duplicates)
1349 "found duplicate %TAG directive", mark);
yaml_strdup(const yaml_char_t *str)
Expect an entry of a flow sequence.
int register char * block
A BLOCK-SEQUENCE-START token.
yaml_parser_parse(yaml_parser_t *parser, yaml_event_t *event)
Parse the input stream and produce the next parsing event.
#define STREAM_END_EVENT_INIT(event, start_mark, end_mark)
size_t strlen(const char *)
#define SCALAR_EVENT_INIT(event, event_anchor, event_tag, event_value, event_length,event_plain_implicit, event_quoted_implicit, event_style, start_mark, end_mark)
struct yaml_token_s::@44::@47 anchor
The anchor (for YAML_ANCHOR_TOKEN).
A FLOW-SEQUENCE-START token.
Expect the first key of a block mapping.
Cannot allocate or reallocate a block of memory.
yaml_mark_t end_mark
The end of the token.
static int yaml_parser_parse_flow_mapping_value(yaml_parser_t *parser, yaml_event_t *event, int empty)
static int yaml_parser_parse_flow_sequence_entry_mapping_value(yaml_parser_t *parser, yaml_event_t *event)
A BLOCK-SEQUENCE-END token.
static int yaml_parser_parse_flow_sequence_entry_mapping_key(yaml_parser_t *parser, yaml_event_t *event)
#define STREAM_START_EVENT_INIT(event, event_encoding, start_mark, end_mark)
yaml_parser_state_t state
The current parser state.
#define PEEK_TOKEN(parser)
#define SEQUENCE_START_EVENT_INIT(event, event_anchor, event_tag,event_implicit, event_style, start_mark, end_mark)
#define INITIAL_STACK_SIZE
unsigned char yaml_char_t
The character type (UTF-8 octet).
const unsigned char * start
The string start pointer.
The version directive data.
const char * context
The error context.
static int yaml_parser_append_tag_directive(yaml_parser_t *parser, yaml_tag_directive_t value, int allow_duplicates, yaml_mark_t mark)
Expect a key of an ordered mapping.
yaml_char_t * prefix
The tag prefix.
static int yaml_parser_parse_stream_start(yaml_parser_t *parser, yaml_event_t *event)
#define MAPPING_START_EVENT_INIT(event, event_anchor, event_tag,event_implicit, event_style, start_mark, end_mark)
#define SEQUENCE_END_EVENT_INIT(event, start_mark, end_mark)
Expect the beginning of an implicit document.
A FLOW-SEQUENCE-END token.
#define STACK_EMPTY(context, stack)
Expect the content of a document.
static int yaml_parser_process_empty_scalar(yaml_parser_t *parser, yaml_event_t *event, yaml_mark_t mark)
static int yaml_parser_parse_flow_sequence_entry_mapping_end(yaml_parser_t *parser, yaml_event_t *event)
memset(y->frac+ix+1, 0,(y->Prec-(ix+1))*sizeof(BDIGIT))
static int yaml_parser_parse_block_sequence_entry(yaml_parser_t *parser, yaml_event_t *event, int first)
int * top
The top of the stack.
struct yaml_parser_s::@75 states
The parser states stack.
struct yaml_parser_s::@77 tag_directives
The list of TAG directives.
A VERSION-DIRECTIVE token.
static int yaml_parser_parse_document_end(yaml_parser_t *parser, yaml_event_t *event)
int major
The major version number.
Expect an entry of a block sequence.
static int yaml_parser_process_directives(yaml_parser_t *parser, yaml_version_directive_t **version_directive_ref, yaml_tag_directive_t **tag_directives_start_ref, yaml_tag_directive_t **tag_directives_end_ref)
#define ALIAS_EVENT_INIT(event, event_anchor, start_mark, end_mark)
static int yaml_parser_parse_document_start(yaml_parser_t *parser, yaml_event_t *event, int implicit)
struct yaml_token_s::@44::@48 tag
The tag (for YAML_TAG_TOKEN).
#define YAML_DECLARE(type)
The public API declaration.
A FLOW-MAPPING-START token.
#define STACK_DEL(context, stack)
yaml_error_type_t error
Error type.
#define DOCUMENT_END_EVENT_INIT(event, event_implicit, start_mark, end_mark)
#define MAPPING_END_EVENT_INIT(event, start_mark, end_mark)
static int yaml_parser_set_parser_error(yaml_parser_t *parser, const char *problem, yaml_mark_t problem_mark)
yaml_char_t * handle
The tag handle.
static int yaml_parser_parse_indentless_sequence_entry(yaml_parser_t *parser, yaml_event_t *event)
Expect a block mapping value.
static int yaml_parser_parse_node(yaml_parser_t *parser, yaml_event_t *event, int block, int indentless_sequence)
struct yaml_parser_s::@76 marks
The stack of marks.
yaml_token_type_t type
The token type.
Cannot parse the input stream.
Expect an empty value of a flow mapping.
yaml_mark_t context_mark
The context position.
struct yaml_token_s::@44::@49 scalar
The scalar value (for YAML_SCALAR_TOKEN).
static int yaml_parser_set_parser_error_context(yaml_parser_t *parser, const char *context, yaml_mark_t context_mark, const char *problem, yaml_mark_t problem_mark)
A FLOW-MAPPING-END token.
static int yaml_parser_parse_block_mapping_value(yaml_parser_t *parser, yaml_event_t *event)
yaml_mark_t problem_mark
The problem position.
static int yaml_parser_state_machine(yaml_parser_t *parser, yaml_event_t *event)
#define DOCUMENT_START_EVENT_INIT(event, event_version_directive,event_tag_directives_start, event_tag_directives_end, event_implicit, start_mark, end_mark)
Expect the and of an ordered mapping entry.
static int yaml_parser_parse_flow_mapping_key(yaml_parser_t *parser, yaml_event_t *event, int first)
Expect an entry of an indentless sequence.
Expect a block node or indentless sequence.
int minor
The minor version number.
struct yaml_token_s::@44::@51 tag_directive
The tag directive (for YAML_TAG_DIRECTIVE_TOKEN).
Expect the first entry of a flow sequence.
#define POP(context, stack)
Expect the first entry of a block sequence.
static VALUE mark(VALUE self)
Expect a value of a flow mapping.
struct parser_params * parser
Expect a key of a flow mapping.
#define assert(condition)
Expect the first key of a flow mapping.
const char * problem
Error description.
#define SKIP_TOKEN(parser)
#define STACK_INIT(context, stack, size)
Expect a value of an ordered mapping.
struct yaml_token_s::@44::@45 stream_start
The stream start (for YAML_STREAM_START_TOKEN).
struct yaml_token_s::@44::@46 alias
The alias (for YAML_ALIAS_TOKEN).
Expect a block mapping key.
static int yaml_parser_parse_block_mapping_key(yaml_parser_t *parser, yaml_event_t *event, int first)
struct yaml_token_s::@44::@50 version_directive
The version directive (for YAML_VERSION_DIRECTIVE_TOKEN).
union yaml_token_s::@44 data
The token data.
static int yaml_parser_parse_document_content(yaml_parser_t *parser, yaml_event_t *event)
The block sequence style.
static int yaml_parser_parse_flow_sequence_entry(yaml_parser_t *parser, yaml_event_t *event, int first)
yaml_mark_t start_mark
The beginning of the token.