Lines Matching refs:tok
26 static bool lexer_consume(struct json_lexer *lex, struct json_token *tok, in lexer_consume() argument
29 if (lex->tok.type == empty_token) { in lexer_consume()
33 *tok = lex->tok; in lexer_consume()
34 lex->tok.type = empty_token; in lexer_consume()
39 static bool lexer_next(struct json_lexer *lex, struct json_token *tok) in lexer_next() argument
42 if (lexer_consume(lex, tok, JSON_TOK_NONE)) { in lexer_next()
49 return lexer_consume(lex, tok, JSON_TOK_EOF); in lexer_next()
56 lex->tok.type = token; in emit()
57 lex->tok.start = lex->start; in emit()
58 lex->tok.end = lex->pos; in emit()
267 lex->tok.type = JSON_TOK_NONE; in lexer_init()
272 struct json_token tok; in obj_init() local
276 if (!lexer_next(&json->lex, &tok)) { in obj_init()
280 if (tok.type != JSON_TOK_OBJECT_START) { in obj_init()
289 struct json_token tok; in arr_init() local
293 if (!lexer_next(&json->lex, &tok)) { in arr_init()
297 if (tok.type != JSON_TOK_ARRAY_START) { in arr_init()
325 struct json_token tok; in obj_next() local
327 if (!lexer_next(&json->lex, &tok)) { in obj_next()
332 switch (tok.type) { in obj_next()
336 kv->value = tok; in obj_next()
340 if (!lexer_next(&json->lex, &tok)) { in obj_next()
344 if (tok.type != JSON_TOK_STRING) { in obj_next()
350 kv->key = tok.start; in obj_next()
351 kv->key_len = (size_t)(tok.end - tok.start); in obj_next()
358 if (!lexer_next(&json->lex, &tok)) { in obj_next()
362 if (tok.type != JSON_TOK_COLON) { in obj_next()
588 struct json_token tok; in arr_parse() local
601 while (!arr_next(obj, &tok)) { in arr_parse()
602 if (tok.type == JSON_TOK_ARRAY_END) { in arr_parse()
617 if (decode_value(obj, elem_descr, &tok, field, value) < 0) { in arr_parse()
651 obj->lex.tok.end = obj->lex.pos; in arr_data_parse()
652 obj->lex.tok.start = val->start; in arr_data_parse()
653 obj->lex.tok.type = JSON_TOK_NONE; in arr_data_parse()
766 struct json_token tok; in json_arr_separate_parse_object() local
768 if (!lexer_next(&json->lex, &tok)) { in json_arr_separate_parse_object()
772 if (tok.type == JSON_TOK_ARRAY_END) { in json_arr_separate_parse_object()
774 } else if (tok.type == JSON_TOK_COMMA) { in json_arr_separate_parse_object()
775 if (!lexer_next(&json->lex, &tok)) { in json_arr_separate_parse_object()
780 if (tok.type != JSON_TOK_OBJECT_START) { in json_arr_separate_parse_object()