Closed wldmr closed 2 weeks ago
I think this is a good change. If you change the generated sexp_name
s to _all_named
, _all_unnamed
, and _all_nodes
and submit a PR I'll merge.
I'm also fine with exposing more including NodeTypeMap
, parse_node_type_map
, and NodeType
. How do you want to use public NodeTypeMap
, and how do you imagine others would use it?
Nice :). I've opened a PR and put a usage example in the comments. Let me know what you think, esp. if you see any potential problems with this.
When iterating over a file I find myself missing a supertype that encompasses all grammar elements (or at least the named ones). An example would be a formatter, where you'll want to make sure you don't miss any nodes (especially on a moving target, like the wldmr/tree-sitter-ink grammar that I'm developing.
So I've done the smallest change that solves my problem here. It basically just wedges in the three new supertypes in the
NodeTypeMap::new()
function.I was thinking about maybe exposing an
insert()
method onNodeTypeMap
and makingparse_node_type_map()
public, so users then could postprocess it themselves before writing it out. But that would mean making all of the innards public as well, so I wanted to consult you first.My general question would be: Do you think this is something that you would want this library to offer, and if so, how?
I'm happy to implement this, if you're willing to help me along a bit (haven't fully grokked the code yet).
If not, do you think there's another/better way to get exhaustive (compile time) matching on all nodes?