Skip to content

Commit 556df6b

Browse files
committed
Rewrite how keywords are listed
This changes the keyword listings so that they are just lists instead of lexer rules. We never used the named rules, and I don't foresee us ever doing that. Also, the `IDENTIFIER_OR_KEYWORD` rule meant that we never needed to explicitly identify these keywords as lexer tokens. This helps avoid problems when building the grammar graph for missing connections.
1 parent 35c098a commit 556df6b

File tree

1 file changed

+59
-66
lines changed

1 file changed

+59
-66
lines changed

src/keywords.md

Lines changed: 59 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -24,50 +24,50 @@ be used as the names of:
2424
* [Crates]
2525

2626
r[lex.keywords.strict.list]
27-
> **<sup>Lexer:<sup>**\
28-
> KW_AS : `as`\
29-
> KW_BREAK : `break`\
30-
> KW_CONST : `const`\
31-
> KW_CONTINUE : `continue`\
32-
> KW_CRATE : `crate`\
33-
> KW_ELSE : `else`\
34-
> KW_ENUM : `enum`\
35-
> KW_EXTERN : `extern`\
36-
> KW_FALSE : `false`\
37-
> KW_FN : `fn`\
38-
> KW_FOR : `for`\
39-
> KW_IF : `if`\
40-
> KW_IMPL : `impl`\
41-
> KW_IN : `in`\
42-
> KW_LET : `let`\
43-
> KW_LOOP : `loop`\
44-
> KW_MATCH : `match`\
45-
> KW_MOD : `mod`\
46-
> KW_MOVE : `move`\
47-
> KW_MUT : `mut`\
48-
> KW_PUB : `pub`\
49-
> KW_REF : `ref`\
50-
> KW_RETURN : `return`\
51-
> KW_SELFVALUE : `self`\
52-
> KW_SELFTYPE : `Self`\
53-
> KW_STATIC : `static`\
54-
> KW_STRUCT : `struct`\
55-
> KW_SUPER : `super`\
56-
> KW_TRAIT : `trait`\
57-
> KW_TRUE : `true`\
58-
> KW_TYPE : `type`\
59-
> KW_UNSAFE : `unsafe`\
60-
> KW_USE : `use`\
61-
> KW_WHERE : `where`\
62-
> KW_WHILE : `while`
27+
The following keywords are in all editions:
28+
29+
- `as`
30+
- `break`
31+
- `const`
32+
- `continue`
33+
- `crate`
34+
- `else`
35+
- `enum`
36+
- `extern`
37+
- `false`
38+
- `fn`
39+
- `for`
40+
- `if`
41+
- `impl`
42+
- `in`
43+
- `let`
44+
- `loop`
45+
- `match`
46+
- `mod`
47+
- `move`
48+
- `mut`
49+
- `pub`
50+
- `ref`
51+
- `return`
52+
- `self`
53+
- `Self`
54+
- `static`
55+
- `struct`
56+
- `super`
57+
- `trait`
58+
- `true`
59+
- `type`
60+
- `unsafe`
61+
- `use`
62+
- `where`
63+
- `while`
6364

6465
r[lex.keywords.strict.edition2018]
6566
The following keywords were added beginning in the 2018 edition.
6667

67-
> **<sup>Lexer 2018+</sup>**\
68-
> KW_ASYNC : `async`\
69-
> KW_AWAIT : `await`\
70-
> KW_DYN : `dyn`
68+
- `async`
69+
- `await`
70+
- `dyn`
7171

7272
r[lex.keywords.reserved]
7373
## Reserved keywords
@@ -79,31 +79,28 @@ current programs forward compatible with future versions of Rust by forbidding
7979
them to use these keywords.
8080

8181
r[lex.keywords.reserved.list]
82-
> **<sup>Lexer</sup>**\
83-
> KW_ABSTRACT : `abstract`\
84-
> KW_BECOME : `become`\
85-
> KW_BOX : `box`\
86-
> KW_DO : `do`\
87-
> KW_FINAL : `final`\
88-
> KW_MACRO : `macro`\
89-
> KW_OVERRIDE : `override`\
90-
> KW_PRIV : `priv`\
91-
> KW_TYPEOF : `typeof`\
92-
> KW_UNSIZED : `unsized`\
93-
> KW_VIRTUAL : `virtual`\
94-
> KW_YIELD : `yield`
82+
- `abstract`
83+
- `become`
84+
- `box`
85+
- `do`
86+
- `final`
87+
- `macro`
88+
- `override`
89+
- `priv`
90+
- `typeof`
91+
- `unsized`
92+
- `virtual`
93+
- `yield`
9594

9695
r[lex.keywords.reserved.edition2018]
9796
The following keywords are reserved beginning in the 2018 edition.
9897

99-
> **<sup>Lexer 2018+</sup>**\
100-
> KW_TRY : `try`
98+
- `try`
10199

102100
r[lex.keywords.reserved.edition2024]
103101
The following keywords are reserved beginning in the 2024 edition.
104102

105-
> **<sup>Lexer 2024+</sup>**\
106-
> KW_GEN : `gen`
103+
- `gen`
107104

108105
r[lex.keywords.weak]
109106
## Weak keywords
@@ -112,15 +109,11 @@ r[lex.keywords.weak.intro]
112109
These keywords have special meaning only in certain contexts. For example, it
113110
is possible to declare a variable or method with the name `union`.
114111

115-
> **<sup>Lexer</sup>**\
116-
> KW_MACRO_RULES : `macro_rules`\
117-
> KW_UNION : `union`\
118-
> KW_STATICLIFETIME : `'static`\
119-
> KW_SAFE : `safe`\
120-
> KW_RAW : `raw`
121-
>
122-
> **<sup>Lexer 2015</sup>**\
123-
> KW_DYN : `dyn`
112+
- `'static`
113+
- `macro_rules`
114+
- `raw`
115+
- `safe`
116+
- `union`
124117

125118
r[lex.keywords.weak.macro_rules]
126119
* `macro_rules` is used to create custom [macros].

0 commit comments

Comments
 (0)