Skip to content

Commit c51ca3a

Browse files
committed
remove unused function
1 parent c29d179 commit c51ca3a

File tree

2 files changed

+44
-22
lines changed

2 files changed

+44
-22
lines changed

src/_table_generation/make_tables.nr

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -46,28 +46,6 @@ global CAPTURE_ERROR_FLAG: [[bool; 128]; 4] = [
4646
LITERAL_CAPTURE_ERROR_FLAG,
4747
];
4848

49-
unconstrained fn make_capture_table_full() -> [[Field; 128]; 4] {
50-
let mut result: [[Field; 128]; 4] = [[0; 128]; 4];
51-
for i in 0..4 {
52-
for j in 0..128 {
53-
let table = CAPTURE_TABLE[i][j];
54-
let token = CAPTURE_TOKEN[i][j];
55-
let push_transcript = CAPTURE_PUSH_TRANSCRIPT[i][j] as Field;
56-
let increase_length = CAPTURE_INCREASE_LENGTH[i][j] as Field;
57-
let error = CAPTURE_ERROR_FLAG[i][j] as Field;
58-
59-
let full = table
60-
+ token as Field * 0x100
61-
+ push_transcript * 0x10000
62-
+ increase_length * 0x1000000
63-
+ error * 0x100000000;
64-
result[i][j] = full;
65-
}
66-
}
67-
68-
result
69-
}
70-
7149
unconstrained fn make_ascii_to_token_table() -> [Field; 1024] {
7250
let mut result: [Field; 256 * 4] = [0; 256 * 4];
7351
for i in 0..4 {

src/_table_generation/table_generation.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,47 @@ Maps (escape_flag, scan_mode, ascii) to scanning actions:
2323
- `push_transcript`: Whether to add token to transcript: in grammar mode: true for all structual elements[,{,comma,},],:. In string_capture, true for ", which signals string end. In numeric/literal_capture, true for space, \t, \n, \r, ", and comma. Note the first scan will not pick up numerics or literals because we don't know when they end, so we need to rely on capture_missing_tokens function.
2424
- `increase_length`: Whether to extend current token, always false for grammar_capture, true for 0-9 in numeric capture, all characters except for " in string_capture, all letters in true, false, null in literal_capture
2525
- `is_potential_escape_sequence`: true if current token is / in string_capture mode
26+
27+
## Other tables
28+
While TOKEN_FLAGS_TABLE and JSON_CAPTURE_TABLE are the more important tables, they are built from foundational hardcoded tables in make_tables_subtables.nr:
29+
30+
GRAMMAR_CAPTURE_TABLE: State transition table for grammar scan mode. Each entry specifies the next scan mode (GRAMMAR_CAPTURE, STRING_CAPTURE, NUMERIC_CAPTURE, LITERAL_CAPTURE, or ERROR_CAPTURE) based on the encountered ASCII character. For example, "f" is mapped to LITEAL_CAPTURE because it indicates we began to scan the literal false.
31+
STRING_CAPTURE_TABLE
32+
NUMERIC_CAPTURE_TABLE
33+
LITERAL_CAPTURE_TABLE
34+
35+
GRAMMAR_CAPTURE_TOKEN: Maps characters in grammar mode to token types. Converts ASCII characters into the appropriate JSON token types for structural elements, values, and literals.
36+
Structural characters ({, }, [, ], ,, :) → their respective structural tokens
37+
- Quote (") → STRING_TOKEN (start of string)
38+
- Digits (0-9) → NUMERIC_TOKEN (start of number)
39+
- Literal starters (f, t, n) → LITERAL_TOKEN (start of true/false/null)
40+
- Invalid characters → NO_TOKEN or error handling
41+
STRING_CAPTURE_TOKEN
42+
NUMERIC_CAPTURE_TOKEN
43+
LITERAL_CAPTURE_TOKEN
44+
45+
STRING_CAPTURE_PUSH_TRANSCRIPT: Determines when to add tokens to the transcript while scanning inside a string. Only true for the closing quote ("). This signals the end of the string and triggers token creation. All other characters within the string (letters, numbers, punctuation, spaces) are false because they extend the current string token rather than creating new tokens.
46+
47+
GRAMMAR_CAPTURE_PUSH_TRANSCRIPT: Determines when to add tokens to the transcript while scanning in grammar mode. True for the following characters:
48+
- Comma (,) → true (value separator)
49+
- Colon (:) → true (key-value separator)
50+
- All other characters → false (including digits, quotes, and literal starters)
51+
52+
NUMERIC_CAPTURE_PUSH_TRANSCRIPT: Determines when to add the current numeric token to the transcript while scanning a number. True for the following characters:
53+
- Whitespace (space, tab, newline, carriage return) → true (end number)
54+
- Quote (") → true (end number, followed by string)
55+
- Comma (,) → true (end number, followed by next value)
56+
- All other characters → false (extend current number or error)
57+
58+
LITERAL_CAPTURE_PUSH_TRANSCRIPT: Determines when to add the current literal token (true/false/null) to the transcript while scanning a literal. True for any grammar character: , [ ] { } " space tab newline (This is only used in the first scan, in the second step capture_missing_tokens, we will be able to separate the literal and value separator)
59+
60+
GRAMMAR_CAPTURE_INCREASE_LENGTH: Determines when to extend the current token length while scanning in grammar mode. True for Digits (0-9) -> starting numeric scan, Letters for literals (f, t, n, r, u, e, a, l, s) -> starting literal scan. For structural tokens, we don't count its length (is just 1). For string tokens, we are expecting to see a " first before seeing letters.
61+
62+
STRING_CAPTURE_INCREASE_LENGTH: Determines when to extend the current string token while scanning inside a string. True for all printable characters except for Quote (ends the string)
63+
NUMERIC_CAPTURE_INCREASE_LENGTH: True for 0-9
64+
LITERAL_CAPTURE_INCREASE_LENGTH: True for t,r,u,e,f,a,l,s,n
65+
66+
GRAMMAR_CAPTURE_ERROR_FLAG
67+
STRING_CAPTURE_ERROR_FLAG
68+
NUMERIC_CAPTURE_ERROR_FLAG
69+
LITERAL_CAPTURE_ERROR_FLAG

0 commit comments

Comments
 (0)