Commit 391e4e6
feat(lexer): underscore-prefix idents
Extends `lower_ident_start` from a single `lower` to
`lower | ('_', alphanum)` — a lowercase letter, OR underscore followed
by at least one alphanum. This is the conventional Rust-idiom spelling
for "intentionally unused" bindings and parameters.
Bare `_` (the wildcard pattern) is preserved as the distinct
UNDERSCORE token: sedlex applies maximal munch, and the underscore
branch of `lower_ident_start` requires at least one trailing alphanum,
so `_` standalone falls through to the existing UNDERSCORE rule.
Updates `test/test_lexer.ml::test_identifiers` to assert the new
tokenisation — `_test` is now a single `LOWER_IDENT "_test"`, and the
test additionally asserts that bare `_` still emits `UNDERSCORE`.
327/327 tests pass.
Required by sustainabot hand-port (gitbot-fleet#148) — `GitHubApp.affine`
declares unused cache-stub bindings as `let _key = ...; let _value = ...;`.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>_key/_unused (Refs gitbot-fleet#148)1 parent 4b83c1a commit 391e4e6
2 files changed
Lines changed: 18 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
101 | | - | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
102 | 110 | | |
103 | 111 | | |
104 | 112 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
27 | 33 | | |
28 | 34 | | |
29 | | - | |
30 | | - | |
| 35 | + | |
| 36 | + | |
31 | 37 | | |
32 | 38 | | |
33 | 39 | | |
| |||
0 commit comments