Lines Matching refs:token

737                                json_token_t *token);
877 static void json_set_token_error(json_token_t *token, json_parse_t *json, in json_set_token_error() argument
880 token->type = T_ERROR; in json_set_token_error()
881 token->index = json->ptr - json->data; in json_set_token_error()
882 token->value.string = errtype; in json_set_token_error()
885 static void json_next_string_token(json_parse_t *json, json_token_t *token) in json_next_string_token() argument
905 json_set_token_error(token, json, "unexpected end of string"); in json_next_string_token()
920 json_set_token_error(token, json, in json_next_string_token()
925 json_set_token_error(token, json, "invalid escape code"); in json_next_string_token()
941 token->type = T_STRING; in json_next_string_token()
942 token->value.string = strbuf_string(json->tmp, &token->string_len); in json_next_string_token()
996 static void json_next_number_token(json_parse_t *json, json_token_t *token) in json_next_number_token() argument
1000 token->type = T_NUMBER; in json_next_number_token()
1001 token->value.number = fpconv_strtod(json->ptr, &endptr); in json_next_number_token()
1003 json_set_token_error(token, json, "invalid number"); in json_next_number_token()
1014 static void json_next_token(json_parse_t *json, json_token_t *token) in json_next_token() argument
1022 token->type = ch2token[ch]; in json_next_token()
1023 if (token->type != T_WHITESPACE) in json_next_token()
1030 token->index = json->ptr - json->data; in json_next_token()
1033 if (token->type == T_ERROR) { in json_next_token()
1034 json_set_token_error(token, json, "invalid token"); in json_next_token()
1038 if (token->type == T_END) { in json_next_token()
1043 if (token->type != T_UNKNOWN) { in json_next_token()
1055 json_next_string_token(json, token); in json_next_token()
1059 json_set_token_error(token, json, "invalid number"); in json_next_token()
1062 json_next_number_token(json, token); in json_next_token()
1065 token->type = T_BOOLEAN; in json_next_token()
1066 token->value.boolean = 1; in json_next_token()
1070 token->type = T_BOOLEAN; in json_next_token()
1071 token->value.boolean = 0; in json_next_token()
1075 token->type = T_NULL; in json_next_token()
1085 json_next_number_token(json, token); in json_next_token()
1090 json_set_token_error(token, json, "invalid token"); in json_next_token()
1100 const char *exp, json_token_t *token) in json_throw_parse_error() argument
1106 if (token->type == T_ERROR) in json_throw_parse_error()
1107 found = token->value.string; in json_throw_parse_error()
1109 found = json_token_type_name[token->type]; in json_throw_parse_error()
1113 exp, found, token->index + 1); in json_throw_parse_error()
1137 json_token_t token; in json_parse_object_context() local
1145 json_next_token(json, &token); in json_parse_object_context()
1148 if (token.type == T_OBJ_END) { in json_parse_object_context()
1154 if (token.type != T_STRING) in json_parse_object_context()
1155 json_throw_parse_error(l, json, "object key string", &token); in json_parse_object_context()
1158 lua_pushlstring(l, token.value.string, token.string_len); in json_parse_object_context()
1160 json_next_token(json, &token); in json_parse_object_context()
1161 if (token.type != T_COLON) in json_parse_object_context()
1162 json_throw_parse_error(l, json, "colon", &token); in json_parse_object_context()
1165 json_next_token(json, &token); in json_parse_object_context()
1166 json_process_value(l, json, &token); in json_parse_object_context()
1171 json_next_token(json, &token); in json_parse_object_context()
1173 if (token.type == T_OBJ_END) { in json_parse_object_context()
1178 if (token.type != T_COMMA) in json_parse_object_context()
1179 json_throw_parse_error(l, json, "comma or object end", &token); in json_parse_object_context()
1181 json_next_token(json, &token); in json_parse_object_context()
1188 json_token_t token; in json_parse_array_context() local
1197 json_next_token(json, &token); in json_parse_array_context()
1200 if (token.type == T_ARR_END) { in json_parse_array_context()
1206 json_process_value(l, json, &token); in json_parse_array_context()
1209 json_next_token(json, &token); in json_parse_array_context()
1211 if (token.type == T_ARR_END) { in json_parse_array_context()
1216 if (token.type != T_COMMA) in json_parse_array_context()
1217 json_throw_parse_error(l, json, "comma or array end", &token); in json_parse_array_context()
1219 json_next_token(json, &token); in json_parse_array_context()
1225 json_token_t *token) in json_process_value() argument
1227 switch (token->type) { in json_process_value()
1229 lua_pushlstring(l, token->value.string, token->string_len); in json_process_value()
1232 lua_pushnumber(l, token->value.number); in json_process_value()
1235 lua_pushboolean(l, token->value.boolean); in json_process_value()
1249 json_throw_parse_error(l, json, "value", token); in json_process_value()
1256 json_token_t token; in json_decode() local
1279 json_next_token(&json, &token); in json_decode()
1280 json_process_value(l, &json, &token); in json_decode()
1283 json_next_token(&json, &token); in json_decode()
1285 if (token.type != T_END) in json_decode()
1286 json_throw_parse_error(l, &json, "the end", &token); in json_decode()