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()
327 struct json_token tok; in obj_next() local
329 if (!lexer_next(&json->lex, &tok)) { in obj_next()
334 switch (tok.type) { in obj_next()
338 kv->value = tok; in obj_next()
342 if (!lexer_next(&json->lex, &tok)) { in obj_next()
346 if (tok.type != JSON_TOK_STRING) { in obj_next()
352 kv->key = tok.start; in obj_next()
353 kv->key_len = (size_t)(tok.end - tok.start); in obj_next()
360 if (!lexer_next(&json->lex, &tok)) { in obj_next()
364 if (tok.type != JSON_TOK_COLON) { in obj_next()
660 struct json_token tok; in arr_parse() local
673 while (!arr_next(obj, &tok)) { in arr_parse()
674 if (tok.type == JSON_TOK_ARRAY_END) { in arr_parse()
689 if (decode_value(obj, elem_descr, &tok, field, value) < 0) { in arr_parse()
723 obj->lex.tok.end = obj->lex.pos; in arr_data_parse()
724 obj->lex.tok.start = val->start; in arr_data_parse()
725 obj->lex.tok.type = JSON_TOK_NONE; in arr_data_parse()
838 struct json_token tok; in json_arr_separate_parse_object() local
840 if (!lexer_next(&json->lex, &tok)) { in json_arr_separate_parse_object()
844 if (tok.type == JSON_TOK_ARRAY_END) { in json_arr_separate_parse_object()
846 } else if (tok.type == JSON_TOK_COMMA) { in json_arr_separate_parse_object()
847 if (!lexer_next(&json->lex, &tok)) { in json_arr_separate_parse_object()
852 if (tok.type != JSON_TOK_OBJECT_START) { in json_arr_separate_parse_object()