Commit 1618dd6
authored
Add a code generator for enum boilerplate (#401)
Go does not have enums, but they are quite useful, so we emulate them
with int-kinded types and use switches and whatnot to convert them to
and from strings.
There are enough of these in the new compiler stack at this point that
maintaining all of these stringification functions is getting tedious
and error-prone, so this PR contains a very simple, 200-line
`//go:generate` helper for generating those functions.
I surveyed other existing packages of this kind, but unfortunately they
all want to put varying strong constraints on how we organize and name
our "enums", so I felt that we should just write the simplest possible
thing to fit our use-case.1 parent b04f563 commit 1618dd6
File tree
24 files changed
+1545
-675
lines changed- experimental
- ast
- predeclared
- internal/taxa
- token
- internal
- enum
- ext/slicesx
24 files changed
+1545
-675
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | 25 | | |
41 | 26 | | |
42 | 27 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
20 | 20 | | |
21 | 21 | | |
22 | 22 | | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | | - | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
34 | | - | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
40 | | - | |
41 | | - | |
42 | 23 | | |
43 | 24 | | |
44 | 25 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
92 | 92 | | |
93 | 93 | | |
94 | 94 | | |
| 95 | + | |
| 96 | + | |
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
0 commit comments