Commit 99f72de
committed
refactor(syntax): Group SyntaxKind and unify token/terminal kinds under LexemeKind.
SyntaxKind's flat token/terminal/missing variants are grouped into nested enums. A terminal node and the token that backs it share one lexical identity, so both reuse a single `LexemeKind` instead of duplicated `TokenKind`/`TerminalKind` lists; trivia tokens (whitespace, newlines, comments, skipped) move to `TriviaKind`, and enum missing-variants to `MissingKind`:
enum SyntaxKind {
Token(LexemeKind),
TriviaToken(TriviaKind),
Terminal(LexemeKind),
Missing(MissingKind),
// ...other node kinds stay flat
}
The parser/lexer layer now operates on `LexemeKind` directly (LexerTerminal, peek().kind, Terminal::KIND, MissingToken, operator-precedence and skip predicates), reserving SyntaxKind for green-tree node kinds. Debug/Display preserve the historical flat names (TerminalIdentifier, TokenWhitespace, ExprMissing) so diagnostics and golden tests are unaffected by the grouping; the lone visible change is the friendlier "Missing token Identifier." (was "TerminalIdentifier"), since kind_to_string now renders a LexemeKind.
colored_printer::set_color matches exhaustively over LexemeKind/TriviaKind, removing its panicking catch-all. All kind enums are generated from the spec via a single classifier, so the duplication can't drift.1 parent d6062f7 commit 99f72de
25 files changed
Lines changed: 4066 additions & 3554 deletions
File tree
- crates
- cairo-lang-doc/src
- tests
- cairo-lang-formatter/src
- cairo-lang-parser/src
- parser_test_data/diagnostics
- cairo-lang-sierra-generator/src/debug_info
- cairo-lang-syntax-codegen/src
- cairo-lang-syntax/src/node
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| |||
256 | 256 | | |
257 | 257 | | |
258 | 258 | | |
259 | | - | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
260 | 262 | | |
261 | 263 | | |
262 | 264 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
| 15 | + | |
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| |||
106 | 106 | | |
107 | 107 | | |
108 | 108 | | |
109 | | - | |
| 109 | + | |
110 | 110 | | |
111 | 111 | | |
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
115 | 115 | | |
116 | | - | |
| 116 | + | |
117 | 117 | | |
118 | 118 | | |
119 | 119 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
24 | 24 | | |
25 | 25 | | |
26 | 26 | | |
27 | | - | |
| 27 | + | |
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
19 | | - | |
| 19 | + | |
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
| |||
1145 | 1145 | | |
1146 | 1146 | | |
1147 | 1147 | | |
1148 | | - | |
1149 | | - | |
| 1148 | + | |
| 1149 | + | |
| 1150 | + | |
1150 | 1151 | | |
1151 | 1152 | | |
1152 | 1153 | | |
| |||
1262 | 1263 | | |
1263 | 1264 | | |
1264 | 1265 | | |
1265 | | - | |
| 1266 | + | |
1266 | 1267 | | |
1267 | 1268 | | |
1268 | 1269 | | |
| |||
0 commit comments