Replies: 1 comment 11 replies
-
It doesn't appear to be possible with the current API. The rust binding tree-sitter/lib/src/language.c Lines 113 to 130 in cbcb51b I'm sure there's plenty of hacky ways you could have these values available at compile time, but I imagine that would make changing to a different version of the grammar to be quite difficult and/or messy. In the past I tried looking at the generated code to have the node values known beforehand, but they didn't match up with the values returned at runtime. It was suggested to me in this issue to just use the |
Beta Was this translation helpful? Give feedback.
-
Well, as the title states.
Is there some way to get compile time values for the kind and field ids for my custom language? This would allow the Rust optimizer to make much more efficient branch jump tables for compilers using tree-sitter as a compiler frontend.
Currently I am using the second-best option, namely simply requesting all ids ahead of time and storing them in a static data structure: https://github.com/pc2/sus-compiler/blob/3a3a5c9dfe5c5eeb8fde6ec7f49823af60d37f49/src/parser.rs#L84-L230
Beta Was this translation helpful? Give feedback.
All reactions