(string, idx)
| 27 | memo = context.memo |
| 28 | |
| 29 | def _scan_once(string, idx): |
| 30 | try: |
| 31 | nextchar = string[idx] |
| 32 | except IndexError: |
| 33 | raise StopIteration(idx) from None |
| 34 | |
| 35 | if nextchar == '"': |
| 36 | return parse_string(string, idx + 1, strict) |
| 37 | elif nextchar == '{': |
| 38 | return parse_object((string, idx + 1), strict, |
| 39 | _scan_once, object_hook, object_pairs_hook, memo) |
| 40 | elif nextchar == '[': |
| 41 | return parse_array((string, idx + 1), _scan_once, array_hook) |
| 42 | elif nextchar == 'n' and string[idx:idx + 4] == 'null': |
| 43 | return None, idx + 4 |
| 44 | elif nextchar == 't' and string[idx:idx + 4] == 'true': |
| 45 | return True, idx + 4 |
| 46 | elif nextchar == 'f' and string[idx:idx + 5] == 'false': |
| 47 | return False, idx + 5 |
| 48 | |
| 49 | m = match_number(string, idx) |
| 50 | if m is not None: |
| 51 | integer, frac, exp = m.groups() |
| 52 | if frac or exp: |
| 53 | res = parse_float(integer + (frac or '') + (exp or '')) |
| 54 | else: |
| 55 | res = parse_int(integer) |
| 56 | return res, m.end() |
| 57 | elif nextchar == 'N' and string[idx:idx + 3] == 'NaN': |
| 58 | return parse_constant('NaN'), idx + 3 |
| 59 | elif nextchar == 'I' and string[idx:idx + 8] == 'Infinity': |
| 60 | return parse_constant('Infinity'), idx + 8 |
| 61 | elif nextchar == '-' and string[idx:idx + 9] == '-Infinity': |
| 62 | return parse_constant('-Infinity'), idx + 9 |
| 63 | else: |
| 64 | raise StopIteration(idx) |
| 65 | |
| 66 | def scan_once(string, idx): |
| 67 | try: |
no test coverage detected
searching dependent graphs…