MCPcopy Create free account
hub / github.com/Redot-Engine/redot-engine / _get_token

Method _get_token

core/io/json.cpp:184–403  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

182}
183
184Error JSON::_get_token(const char32_t *p_str, int &index, int p_len, Token &r_token, int &line, String &r_err_str) {
185 while (p_len > 0) {
186 switch (p_str[index]) {
187 case '\n': {
188 line++;
189 index++;
190 break;
191 }
192 case 0: {
193 r_token.type = TK_EOF;
194 return OK;
195 } break;
196 case '{': {
197 r_token.type = TK_CURLY_BRACKET_OPEN;
198 index++;
199 return OK;
200 }
201 case '}': {
202 r_token.type = TK_CURLY_BRACKET_CLOSE;
203 index++;
204 return OK;
205 }
206 case '[': {
207 r_token.type = TK_BRACKET_OPEN;
208 index++;
209 return OK;
210 }
211 case ']': {
212 r_token.type = TK_BRACKET_CLOSE;
213 index++;
214 return OK;
215 }
216 case ':': {
217 r_token.type = TK_COLON;
218 index++;
219 return OK;
220 }
221 case ',': {
222 r_token.type = TK_COMMA;
223 index++;
224 return OK;
225 }
226 case '"': {
227 index++;
228 String str;
229 while (true) {
230 if (p_str[index] == 0) {
231 r_err_str = "Unterminated string";
232 return ERR_PARSE_ERROR;
233 } else if (p_str[index] == '"') {
234 index++;
235 break;
236 } else if (p_str[index] == '\\') {
237 //escaped characters...
238 index++;
239 char32_t next = p_str[index];
240 if (next == 0) {
241 r_err_str = "Unterminated string";

Callers

nothing calls this directly

Calls 3

is_hex_digitFunction · 0.85
is_digitFunction · 0.85
is_ascii_alphabet_charFunction · 0.85

Tested by

no test coverage detected