MCPcopy Index your code
hub / github.com/clips/pattern / _scan_once

Function _scan_once

pattern/web/json/scanner.py:32–67  ·  view source on GitHub ↗
(string, idx)

Source from the content-addressed store, hash-verified

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

Callers 1

scan_onceFunction · 0.85

Calls 1

parse_stringFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…