typedef enum cYAML_handler_error (*yaml_token_handler)(yaml_token_t *token,
struct cYAML_tree_node *);
-static enum cYAML_handler_error yaml_parse_error(yaml_token_t *token,
+static enum cYAML_handler_error yaml_no_token(yaml_token_t *token,
struct cYAML_tree_node *tree);
static enum cYAML_handler_error yaml_stream_start(yaml_token_t *token,
struct cYAML_tree_node *tree);
/* dispatch table */
static yaml_token_handler dispatch_tbl[] = {
- [YAML_NO_TOKEN] = yaml_parse_error,
+ [YAML_NO_TOKEN] = yaml_no_token,
[YAML_STREAM_START_TOKEN] = yaml_stream_start,
[YAML_STREAM_END_TOKEN] = yaml_stream_end,
[YAML_VERSION_DIRECTIVE_TOKEN] = yaml_not_supported,
* else state = VALUE
*
*/
-static enum cYAML_handler_error yaml_parse_error(yaml_token_t *token,
- struct cYAML_tree_node *tree)
+
+static enum cYAML_handler_error yaml_no_token(yaml_token_t *token,
+ struct cYAML_tree_node *tree)
{
- return CYAML_ERROR_PARSE;
+ return CYAML_ERROR_NONE;
}
static enum cYAML_handler_error yaml_stream_start(yaml_token_t *token,
strdup((const char *)token->data.scalar.value);
tree->state = TREE_STATE_KEY_FILLED;
- } else if (tree->state == TREE_STATE_VALUE) {
+ } else if (tree->state == TREE_STATE_VALUE ||
+ tree->state == TREE_STATE_SEQ_START) {
if (assign_type_value(tree->cur,
(char *)token->data.scalar.value))
/* failed to assign a value */
rc = dispatch_tbl[token.type](&token, &tree);
if (rc != CYAML_ERROR_NONE) {
snprintf(err_str, sizeof(err_str),
- "Failed to handle token:%d "
+ "Failed to handle token:%d %s"
"[state=%d, rc=%d]",
- token.type, tree.state, rc);
+ token.type, token_type_string[token.type],
+ tree.state, rc);
cYAML_build_error(-1, -1, "yaml", "builder",
err_str,
err_rc);
}
/* Are we finished? */
done = (rc != CYAML_ERROR_NONE ||
- token.type == YAML_STREAM_END_TOKEN ||
- token.type == YAML_NO_TOKEN);
+ token.type == YAML_STREAM_END_TOKEN);
token_type = token.type;