Lines Matching refs:parser
8 static jsmntok_t *jsmn_alloc_token(jsmn_parser *parser, in jsmn_alloc_token() argument
11 if (parser->toknext >= num_tokens) { in jsmn_alloc_token()
14 tok = &tokens[parser->toknext++]; in jsmn_alloc_token()
37 static jsmnerr_t jsmn_parse_primitive(jsmn_parser *parser, const char *js, in jsmn_parse_primitive() argument
42 start = parser->pos; in jsmn_parse_primitive()
44 for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) { in jsmn_parse_primitive()
45 switch (js[parser->pos]) { in jsmn_parse_primitive()
54 if (js[parser->pos] < 32 || js[parser->pos] >= 127) { in jsmn_parse_primitive()
55 parser->pos = start; in jsmn_parse_primitive()
61 parser->pos = start; in jsmn_parse_primitive()
67 parser->pos--; in jsmn_parse_primitive()
70 token = jsmn_alloc_token(parser, tokens, num_tokens); in jsmn_parse_primitive()
72 parser->pos = start; in jsmn_parse_primitive()
75 jsmn_fill_token(token, JSMN_PRIMITIVE, start, parser->pos); in jsmn_parse_primitive()
77 token->parent = parser->toksuper; in jsmn_parse_primitive()
79 parser->pos--; in jsmn_parse_primitive()
86 static jsmnerr_t jsmn_parse_string(jsmn_parser *parser, const char *js, in jsmn_parse_string() argument
90 int start = parser->pos; in jsmn_parse_string()
92 parser->pos++; in jsmn_parse_string()
95 for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) { in jsmn_parse_string()
96 char c = js[parser->pos]; in jsmn_parse_string()
103 token = jsmn_alloc_token(parser, tokens, num_tokens); in jsmn_parse_string()
105 parser->pos = start; in jsmn_parse_string()
108 jsmn_fill_token(token, JSMN_STRING, start+1, parser->pos); in jsmn_parse_string()
110 token->parent = parser->toksuper; in jsmn_parse_string()
117 parser->pos++; in jsmn_parse_string()
118 switch (js[parser->pos]) { in jsmn_parse_string()
125 parser->pos++; in jsmn_parse_string()
127 for(; i < 4 && js[parser->pos] != '\0'; i++) { in jsmn_parse_string()
129 if(!((js[parser->pos] >= 48 && js[parser->pos] <= 57) || /* 0-9 */ in jsmn_parse_string()
130 (js[parser->pos] >= 65 && js[parser->pos] <= 70) || /* A-F */ in jsmn_parse_string()
131 (js[parser->pos] >= 97 && js[parser->pos] <= 102))) { /* a-f */ in jsmn_parse_string()
132 parser->pos = start; in jsmn_parse_string()
135 parser->pos++; in jsmn_parse_string()
137 parser->pos--; in jsmn_parse_string()
141 parser->pos = start; in jsmn_parse_string()
146 parser->pos = start; in jsmn_parse_string()
153 jsmnerr_t jsmn_parse(jsmn_parser *parser, const char *js, size_t len, in jsmn_parse() argument
160 for (; parser->pos < len && js[parser->pos] != '\0'; parser->pos++) { in jsmn_parse()
164 c = js[parser->pos]; in jsmn_parse()
171 token = jsmn_alloc_token(parser, tokens, num_tokens); in jsmn_parse()
174 if (parser->toksuper != -1) { in jsmn_parse()
175 tokens[parser->toksuper].size++; in jsmn_parse()
177 token->parent = parser->toksuper; in jsmn_parse()
181 token->start = parser->pos; in jsmn_parse()
182 parser->toksuper = parser->toknext - 1; in jsmn_parse()
189 if (parser->toknext < 1) { in jsmn_parse()
192 token = &tokens[parser->toknext - 1]; in jsmn_parse()
198 token->end = parser->pos + 1; in jsmn_parse()
199 parser->toksuper = token->parent; in jsmn_parse()
208 for (i = parser->toknext - 1; i >= 0; i--) { in jsmn_parse()
214 parser->toksuper = -1; in jsmn_parse()
215 token->end = parser->pos + 1; in jsmn_parse()
224 parser->toksuper = i; in jsmn_parse()
231 r = jsmn_parse_string(parser, js, len, tokens, num_tokens); in jsmn_parse()
234 if (parser->toksuper != -1 && tokens != NULL) in jsmn_parse()
235 tokens[parser->toksuper].size++; in jsmn_parse()
248 r = jsmn_parse_primitive(parser, js, len, tokens, num_tokens); in jsmn_parse()
251 if (parser->toksuper != -1 && tokens != NULL) in jsmn_parse()
252 tokens[parser->toksuper].size++; in jsmn_parse()
263 for (i = parser->toknext - 1; i >= 0; i--) { in jsmn_parse()
277 void jsmn_init(jsmn_parser *parser) { in jsmn_init() argument
278 parser->pos = 0; in jsmn_init()
279 parser->toknext = 0; in jsmn_init()
280 parser->toksuper = -1; in jsmn_init()