pub unsafe fn yaml_parser_parse(
    parser: *mut yaml_parser_t,
    event: *mut yaml_event_t
) -> Success
Expand description

Parse the input stream and produce the next parsing event.

Call the function subsequently to produce a sequence of events corresponding to the input stream. The initial event has the type YAML_STREAM_START_EVENT while the ending event has the type YAML_STREAM_END_EVENT.

An application is responsible for freeing any buffers associated with the produced event object using the yaml_event_delete() function.

An application must not alternate the calls of yaml_parser_parse() with the calls of yaml_parser_scan() or yaml_parser_load(). Doing this will break the parser.

Examples found in repository?
src/loader.rs (line 53)
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
pub unsafe fn yaml_parser_load(
    mut parser: *mut yaml_parser_t,
    document: *mut yaml_document_t,
) -> Success {
    let current_block: u64;
    let mut event = MaybeUninit::<yaml_event_t>::uninit();
    let event = event.as_mut_ptr();
    __assert!(!parser.is_null());
    __assert!(!document.is_null());
    memset(
        document as *mut libc::c_void,
        0,
        size_of::<yaml_document_t>() as libc::c_ulong,
    );
    STACK_INIT!((*document).nodes, yaml_node_t);
    if !(*parser).stream_start_produced {
        if yaml_parser_parse(parser, event).fail {
            current_block = 6234624449317607669;
        } else {
            __assert!((*event).type_ == YAML_STREAM_START_EVENT);
            current_block = 7815301370352969686;
        }
    } else {
        current_block = 7815301370352969686;
    }
    if current_block != 6234624449317607669 {
        if (*parser).stream_end_produced {
            return OK;
        }
        if yaml_parser_parse(parser, event).ok {
            if (*event).type_ == YAML_STREAM_END_EVENT {
                return OK;
            }
            STACK_INIT!((*parser).aliases, yaml_alias_data_t);
            let fresh6 = addr_of_mut!((*parser).document);
            *fresh6 = document;
            if yaml_parser_load_document(parser, event).ok {
                yaml_parser_delete_aliases(parser);
                let fresh7 = addr_of_mut!((*parser).document);
                *fresh7 = ptr::null_mut::<yaml_document_t>();
                return OK;
            }
        }
    }
    yaml_parser_delete_aliases(parser);
    yaml_document_delete(document);
    let fresh8 = addr_of_mut!((*parser).document);
    *fresh8 = ptr::null_mut::<yaml_document_t>();
    FAIL
}

unsafe fn yaml_parser_set_composer_error(
    mut parser: *mut yaml_parser_t,
    problem: *const libc::c_char,
    problem_mark: yaml_mark_t,
) -> Success {
    (*parser).error = YAML_COMPOSER_ERROR;
    let fresh9 = addr_of_mut!((*parser).problem);
    *fresh9 = problem;
    (*parser).problem_mark = problem_mark;
    FAIL
}

unsafe fn yaml_parser_set_composer_error_context(
    mut parser: *mut yaml_parser_t,
    context: *const libc::c_char,
    context_mark: yaml_mark_t,
    problem: *const libc::c_char,
    problem_mark: yaml_mark_t,
) -> Success {
    (*parser).error = YAML_COMPOSER_ERROR;
    let fresh10 = addr_of_mut!((*parser).context);
    *fresh10 = context;
    (*parser).context_mark = context_mark;
    let fresh11 = addr_of_mut!((*parser).problem);
    *fresh11 = problem;
    (*parser).problem_mark = problem_mark;
    FAIL
}

unsafe fn yaml_parser_delete_aliases(parser: *mut yaml_parser_t) {
    while !STACK_EMPTY!((*parser).aliases) {
        yaml_free(POP!((*parser).aliases).anchor as *mut libc::c_void);
    }
    STACK_DEL!((*parser).aliases);
}

unsafe fn yaml_parser_load_document(
    mut parser: *mut yaml_parser_t,
    event: *mut yaml_event_t,
) -> Success {
    let mut ctx = loader_ctx {
        start: ptr::null_mut::<libc::c_int>(),
        end: ptr::null_mut::<libc::c_int>(),
        top: ptr::null_mut::<libc::c_int>(),
    };
    __assert!((*event).type_ == YAML_DOCUMENT_START_EVENT);
    let fresh16 = addr_of_mut!((*(*parser).document).version_directive);
    *fresh16 = (*event).data.document_start.version_directive;
    let fresh17 = addr_of_mut!((*(*parser).document).tag_directives.start);
    *fresh17 = (*event).data.document_start.tag_directives.start;
    let fresh18 = addr_of_mut!((*(*parser).document).tag_directives.end);
    *fresh18 = (*event).data.document_start.tag_directives.end;
    (*(*parser).document).start_implicit = (*event).data.document_start.implicit;
    (*(*parser).document).start_mark = (*event).start_mark;
    STACK_INIT!(ctx, libc::c_int);
    if yaml_parser_load_nodes(parser, addr_of_mut!(ctx)).fail {
        STACK_DEL!(ctx);
        return FAIL;
    }
    STACK_DEL!(ctx);
    OK
}

unsafe fn yaml_parser_load_nodes(mut parser: *mut yaml_parser_t, ctx: *mut loader_ctx) -> Success {
    let mut event = MaybeUninit::<yaml_event_t>::uninit();
    let event = event.as_mut_ptr();
    loop {
        if yaml_parser_parse(parser, event).fail {
            return FAIL;
        }
        match (*event).type_ {
            YAML_ALIAS_EVENT => {
                if yaml_parser_load_alias(parser, event, ctx).fail {
                    return FAIL;
                }
            }
            YAML_SCALAR_EVENT => {
                if yaml_parser_load_scalar(parser, event, ctx).fail {
                    return FAIL;
                }
            }
            YAML_SEQUENCE_START_EVENT => {
                if yaml_parser_load_sequence(parser, event, ctx).fail {
                    return FAIL;
                }
            }
            YAML_SEQUENCE_END_EVENT => {
                if yaml_parser_load_sequence_end(parser, event, ctx).fail {
                    return FAIL;
                }
            }
            YAML_MAPPING_START_EVENT => {
                if yaml_parser_load_mapping(parser, event, ctx).fail {
                    return FAIL;
                }
            }
            YAML_MAPPING_END_EVENT => {
                if yaml_parser_load_mapping_end(parser, event, ctx).fail {
                    return FAIL;
                }
            }
            YAML_DOCUMENT_END_EVENT => {}
            _ => {
                __assert!(false);
            }
        }
        if (*event).type_ == YAML_DOCUMENT_END_EVENT {
            break;
        }
    }
    (*(*parser).document).end_implicit = (*event).data.document_end.implicit;
    (*(*parser).document).end_mark = (*event).end_mark;
    OK
}