Commit 93a2336
committed
Support non-ASCII Unicode in grammar rule names
The grammar currently supports only ASCII rule names. We want to
support non-ASCII Unicode symbols such as `⊥` (bottom) since we plan
to add that rule.
In this commit, we add `is_name_start` and `is_name_continue`
predicates that centralize the decision of what can appear in a rule
name. `is_name_start` accepts alphabetic characters, underscores,
and non-ASCII characters; `is_name_continue` accepts alphanumeric
characters, underscores, and non-ASCII characters.
We use `is_name_start` in the `parse_expr1` condition that routes to
`parse_nonterminal`. The previous condition (`is_alphanumeric`) was
slightly misaligned with what `parse_name` actually accepts -- it
included digits (which `parse_name` rejects) and excluded underscores
(which `parse_name` accepts). Using `is_name_start` makes the
dispatch condition match `parse_name` exactly.
The `NAMES_RE` regex in `mdbook-spec` encodes the same name-matching
logic as a regex pattern, so let's add a comment tying it
to the predicates.1 parent 2dfed35 commit 93a2336
2 files changed
Lines changed: 28 additions & 12 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
41 | 59 | | |
42 | 60 | | |
43 | 61 | | |
| |||
152 | 170 | | |
153 | 171 | | |
154 | 172 | | |
155 | | - | |
156 | | - | |
157 | 173 | | |
158 | | - | |
| 174 | + | |
159 | 175 | | |
160 | 176 | | |
161 | | - | |
162 | | - | |
163 | | - | |
164 | | - | |
165 | | - | |
166 | | - | |
| 177 | + | |
167 | 178 | | |
168 | 179 | | |
169 | 180 | | |
| |||
231 | 242 | | |
232 | 243 | | |
233 | 244 | | |
234 | | - | |
| 245 | + | |
235 | 246 | | |
236 | 247 | | |
237 | 248 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
14 | | - | |
15 | | - | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
16 | 21 | | |
17 | 22 | | |
18 | 23 | | |
| |||
0 commit comments