Open Kha opened 1 year ago
I would propose to consistently prefix atoms when interpreted as kinds with token.
(or atom.
?), which in fact we already do in TSyntax
:
https://github.com/leanprover/lean4/blob/8de1c0786c5b2f77f94b19224f4b08a054f935d4/tests/lean/1275.lean.expected.out#L9
There will be a small cost in indexing overhead which we should measure but I expect to be insignificant.
@Kha For complete safety, we could instead make SyntaxNodeKind
and inductive (which we use to index the tables and parameterize TSyntax
). For example:
inductive SyntaxNodeKind
| missing
| ident
| atom (s : String)
| node (kind : Name)
When indexing the parser tables with the next token (ignoring extended identifier behavior for this issue), we do one of two things:
s
(i.e. a symbol or keyword), we uses
as the indexk
, we usek
as the indexThese two categories are reasonably disjoint in Lean code, but that is unfortunately not true for embedded languages!
Here the keyword
char
and the literal kindcharKind = `char
overlap