You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+17Lines changed: 17 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -122,6 +122,23 @@ e.g. to take the existing 1kb JSON paramters, but also support 124-byte keys, us
122
122
123
123
If you are deriving a key to look up in-circuit and you do not know the maximum length of the key, all query methods have a version with a `_var` suffix (e.g. `JSON::get_string_var`), which accepts the key as a `BoundedVec`
124
124
125
+
# Architecture
126
+
### Overview
127
+
The JSON parser uses 5 steps to efficiently parse and index JSON data:
128
+
129
+
1.**build_transcript** - Convert raw bytes to token transcript
The JSON parser uses lookup tables to avoid branching logic and reduce gate count. These tables are generated from `src/_table_generation/make_tables.nr`.
5
+
6
+
## Generation Process
7
+
Tables are generated by simulating all possible input combinations from basic hardcoded tables and recording the expected outputs.
8
+
9
+
## TOKEN_FLAGS_TABLE
10
+
Maps (token, context) pairs to parsing flags:
11
+
-`create_json_entry`: Whether to create a JSON entry for this token
12
+
-`is_end_of_object_or_array`: Whether token ends an object/array
13
+
-`is_start_of_object_or_array`: Whether token starts an object/array
14
+
-`new_context`: What context to switch to
15
+
-`is_key_token`: Whether token is a key
16
+
-`is_value_token`: Whether token is a value
17
+
-`preserve_num_entries`: Whether to preserve entry count
18
+
19
+
## JSON_CAPTURE_TABLE
20
+
Maps (escape_flag, scan_mode, ascii) to scanning actions:
21
+
-`scan_token`: Next scan mode
22
+
-`push_transcript`: Whether to add token to transcript
23
+
-`increase_length`: Whether to extend current token
24
+
-`is_potential_escape_sequence`: Whether this could be escape sequence
0 commit comments