Lines Matching refs:parser

402 typedef ssize_t (*ucl_msgpack_parse_function)(struct ucl_parser *parser,
406 static ssize_t ucl_msgpack_parse_map (struct ucl_parser *parser,
409 static ssize_t ucl_msgpack_parse_array (struct ucl_parser *parser,
412 static ssize_t ucl_msgpack_parse_string (struct ucl_parser *parser,
415 static ssize_t ucl_msgpack_parse_int (struct ucl_parser *parser,
418 static ssize_t ucl_msgpack_parse_float (struct ucl_parser *parser,
421 static ssize_t ucl_msgpack_parse_bool (struct ucl_parser *parser,
424 static ssize_t ucl_msgpack_parse_null (struct ucl_parser *parser,
427 static ssize_t ucl_msgpack_parse_ignore (struct ucl_parser *parser,
762 ucl_msgpack_get_container (struct ucl_parser *parser, in ucl_msgpack_get_container() argument
773 if (parser->stack == NULL) { in ucl_msgpack_get_container()
774 parser->stack = calloc (1, sizeof (struct ucl_stack)); in ucl_msgpack_get_container()
776 if (parser->stack == NULL) { in ucl_msgpack_get_container()
777 ucl_create_err (&parser->err, "no memory"); in ucl_msgpack_get_container()
781 parser->stack->chunk = parser->chunks; in ucl_msgpack_get_container()
787 ucl_create_err (&parser->err, "no memory"); in ucl_msgpack_get_container()
791 stack->chunk = parser->chunks; in ucl_msgpack_get_container()
792 stack->next = parser->stack; in ucl_msgpack_get_container()
793 parser->stack = stack; in ucl_msgpack_get_container()
796 parser->stack->e.len = len; in ucl_msgpack_get_container()
799 stack = parser->stack; in ucl_msgpack_get_container()
812 if (parser->stack) { in ucl_msgpack_get_container()
813 return parser->stack; in ucl_msgpack_get_container()
816 ucl_create_err (&parser->err, "bad top level object for msgpack"); in ucl_msgpack_get_container()
821 return parser->stack; in ucl_msgpack_get_container()
838 ucl_msgpack_insert_object (struct ucl_parser *parser, in ucl_msgpack_insert_object() argument
844 container = parser->stack; in ucl_msgpack_insert_object()
855 ucl_create_err (&parser->err, "cannot insert object with no key"); in ucl_msgpack_insert_object()
862 if (!(parser->flags & UCL_PARSER_ZEROCOPY)) { in ucl_msgpack_insert_object()
866 ucl_parser_process_object_element (parser, obj); in ucl_msgpack_insert_object()
869 ucl_create_err (&parser->err, "bad container type"); in ucl_msgpack_insert_object()
879 ucl_msgpack_get_next_container (struct ucl_parser *parser) in ucl_msgpack_get_next_container() argument
884 cur = parser->stack; in ucl_msgpack_get_next_container()
894 parser->stack = cur->next; in ucl_msgpack_get_next_container()
895 parser->cur_obj = cur->obj; in ucl_msgpack_get_next_container()
899 cur = parser->stack; in ucl_msgpack_get_next_container()
904 …fprintf(stderr, "-%s -> %d\n", parser->cur_obj->type == UCL_OBJECT ? "object" : "array", (int)pars… in ucl_msgpack_get_next_container()
907 return ucl_msgpack_get_next_container (parser); in ucl_msgpack_get_next_container()
928 ucl_create_err (&parser->err, \
937 container = ucl_msgpack_get_next_container (parser); \
939 ucl_create_err (&parser->err, \
948 ucl_msgpack_consume (struct ucl_parser *parser) in ucl_msgpack_consume() argument
971 p = parser->chunks->begin; in ucl_msgpack_consume()
972 remain = parser->chunks->remain; in ucl_msgpack_consume()
985 ucl_create_err (&parser->err, "unknown msgpack format: %x", in ucl_msgpack_consume()
998 ucl_create_err (&parser->err, "not enough data remain to " in ucl_msgpack_consume()
1025 ucl_create_err (&parser->err, "not enough data remain to " in ucl_msgpack_consume()
1048 ucl_create_err (&parser->err, "invalid length of the length field: %u", in ucl_msgpack_consume()
1071 parser->cur_obj = ucl_object_new_full (UCL_OBJECT, in ucl_msgpack_consume()
1072 parser->chunks->priority); in ucl_msgpack_consume()
1074 if (parser->stack && !ucl_msgpack_insert_object (parser, in ucl_msgpack_consume()
1075 key, keylen, parser->cur_obj)) { in ucl_msgpack_consume()
1079 container = ucl_msgpack_get_container (parser, obj_parser, len); in ucl_msgpack_consume()
1085 ret = obj_parser->func (parser, container, len, obj_parser->fmt, in ucl_msgpack_consume()
1102 parser->cur_obj = ucl_object_new_full (UCL_ARRAY, in ucl_msgpack_consume()
1103 parser->chunks->priority); in ucl_msgpack_consume()
1105 if (parser->stack && !ucl_msgpack_insert_object (parser, in ucl_msgpack_consume()
1106 key, keylen, parser->cur_obj)) { in ucl_msgpack_consume()
1110 container = ucl_msgpack_get_container (parser, obj_parser, len); in ucl_msgpack_consume()
1116 ret = obj_parser->func (parser, container, len, obj_parser->fmt, in ucl_msgpack_consume()
1135 container = parser->stack; in ucl_msgpack_consume()
1137 if (parser->stack == NULL) { in ucl_msgpack_consume()
1138 ucl_create_err (&parser->err, in ucl_msgpack_consume()
1143 ret = obj_parser->func (parser, container, len, obj_parser->fmt, in ucl_msgpack_consume()
1149 if (!ucl_msgpack_insert_object (parser, NULL, 0, in ucl_msgpack_consume()
1150 parser->cur_obj)) { in ucl_msgpack_consume()
1170 ucl_create_err (&parser->err, "bad type for key: %u, expected " in ucl_msgpack_consume()
1180 ucl_create_err (&parser->err, "too long or empty key"); in ucl_msgpack_consume()
1196 container = parser->stack; in ucl_msgpack_consume()
1199 ucl_create_err (&parser->err, in ucl_msgpack_consume()
1204 ret = obj_parser->func (parser, container, len, obj_parser->fmt, in ucl_msgpack_consume()
1210 if (!ucl_msgpack_insert_object (parser, key, keylen, in ucl_msgpack_consume()
1211 parser->cur_obj)) { in ucl_msgpack_consume()
1236 ucl_create_err (&parser->err, "invalid state machine state"); in ucl_msgpack_consume()
1248 ucl_create_err (&parser->err, in ucl_msgpack_consume()
1255 parser->cur_obj = ucl_object_new_full ( in ucl_msgpack_consume()
1257 parser->chunks->priority); in ucl_msgpack_consume()
1259 if (parser->stack == NULL) { in ucl_msgpack_consume()
1260 ucl_create_err (&parser->err, in ucl_msgpack_consume()
1265 if (!ucl_msgpack_insert_object (parser, in ucl_msgpack_consume()
1266 key, keylen, parser->cur_obj)) { in ucl_msgpack_consume()
1270 container = ucl_msgpack_get_container (parser, obj_parser, len); in ucl_msgpack_consume()
1276 ret = obj_parser->func (parser, container, len, obj_parser->fmt, in ucl_msgpack_consume()
1283 ucl_create_err (&parser->err, "unfinished value at the end"); in ucl_msgpack_consume()
1288 container = parser->stack; in ucl_msgpack_consume()
1290 if (parser->stack == NULL) { in ucl_msgpack_consume()
1291 ucl_create_err (&parser->err, in ucl_msgpack_consume()
1296 ret = obj_parser->func (parser, container, len, obj_parser->fmt, in ucl_msgpack_consume()
1302 if (!ucl_msgpack_insert_object (parser, NULL, 0, in ucl_msgpack_consume()
1303 parser->cur_obj)) { in ucl_msgpack_consume()
1314 ucl_create_err (&parser->err, "invalid state machine finishing state: %d", in ucl_msgpack_consume()
1321 ucl_msgpack_get_next_container (parser); in ucl_msgpack_consume()
1323 if (parser->stack != NULL) { in ucl_msgpack_consume()
1324 ucl_create_err (&parser->err, "incomplete container"); in ucl_msgpack_consume()
1333 ucl_parse_msgpack (struct ucl_parser *parser) in ucl_parse_msgpack() argument
1339 assert (parser != NULL); in ucl_parse_msgpack()
1340 assert (parser->chunks != NULL); in ucl_parse_msgpack()
1341 assert (parser->chunks->begin != NULL); in ucl_parse_msgpack()
1342 assert (parser->chunks->remain != 0); in ucl_parse_msgpack()
1344 p = parser->chunks->begin; in ucl_parse_msgpack()
1346 if (parser->stack) { in ucl_parse_msgpack()
1347 container = parser->stack->obj; in ucl_parse_msgpack()
1357 ucl_create_err (&parser->err, "bad top level object for msgpack"); in ucl_parse_msgpack()
1362 ret = ucl_msgpack_consume (parser); in ucl_parse_msgpack()
1364 if (ret && parser->top_obj == NULL) { in ucl_parse_msgpack()
1365 parser->top_obj = parser->cur_obj; in ucl_parse_msgpack()
1372 ucl_msgpack_parse_map (struct ucl_parser *parser, in ucl_msgpack_parse_map() argument
1376 container->obj = parser->cur_obj; in ucl_msgpack_parse_map()
1382 ucl_msgpack_parse_array (struct ucl_parser *parser, in ucl_msgpack_parse_array() argument
1386 container->obj = parser->cur_obj; in ucl_msgpack_parse_array()
1392 ucl_msgpack_parse_string (struct ucl_parser *parser, in ucl_msgpack_parse_string() argument
1402 obj = ucl_object_new_full (UCL_STRING, parser->chunks->priority); in ucl_msgpack_parse_string()
1410 if (!(parser->flags & UCL_PARSER_ZEROCOPY)) { in ucl_msgpack_parse_string()
1423 parser->cur_obj = obj; in ucl_msgpack_parse_string()
1429 ucl_msgpack_parse_int (struct ucl_parser *parser, in ucl_msgpack_parse_int() argument
1447 obj = ucl_object_new_full (UCL_INT, parser->chunks->priority); in ucl_msgpack_parse_int()
1508 parser->cur_obj = obj; in ucl_msgpack_parse_int()
1514 ucl_msgpack_parse_float (struct ucl_parser *parser, in ucl_msgpack_parse_float() argument
1529 obj = ucl_object_new_full (UCL_FLOAT, parser->chunks->priority); in ucl_msgpack_parse_float()
1550 parser->cur_obj = obj; in ucl_msgpack_parse_float()
1556 ucl_msgpack_parse_bool (struct ucl_parser *parser, in ucl_msgpack_parse_bool() argument
1566 obj = ucl_object_new_full (UCL_BOOLEAN, parser->chunks->priority); in ucl_msgpack_parse_bool()
1580 parser->cur_obj = obj; in ucl_msgpack_parse_bool()
1586 ucl_msgpack_parse_null (struct ucl_parser *parser, in ucl_msgpack_parse_null() argument
1596 obj = ucl_object_new_full (UCL_NULL, parser->chunks->priority); in ucl_msgpack_parse_null()
1597 parser->cur_obj = obj; in ucl_msgpack_parse_null()
1603 ucl_msgpack_parse_ignore (struct ucl_parser *parser, in ucl_msgpack_parse_ignore() argument
1633 ucl_create_err (&parser->err, "bad type: %x", (unsigned)fmt); in ucl_msgpack_parse_ignore()