tree-sitter / haskell-tree-sitter

Haskell bindings for tree-sitter
152 stars 45 forks source link

Add reserved names #290

Closed 314eter closed 4 years ago

314eter commented 4 years ago

I added some reserved names that should be avoided as haskell identifier. I took the list from https://wiki.haskell.org/Keywords. The space character was missing from the list of special characters.

The field names class and default, and the anonymous node " " currently occur in tree-sitter-ocaml.

Another problem that I encountered is that some supertypes (e.g. _sequence_expression) are too similar to other nodes (sequence_expression) and result in the same identifier. I don't think this can be solved by haskell-tree-sitter in a backwards compatible way, so this should probably be forbidden by tree-sitter (and documented).

patrickt commented 4 years ago

@314eter This is great! I think that the problem with supertypes can be fixed on the Haskell end; we can introspect whether a given rule has a _ prefix and prepend its identifier with Internal or Private or whatever. Would you mind filing a bug about this issue?

patrickt commented 4 years ago

Good to go once @aymannadeem gives the final OK.

314eter commented 4 years ago

We can introspect whether a given rule has a _ prefix and prepend its identifier with Internal or Private or whatever.

That was my idea, but that would change some identifiers that are already in use. I forgot that the haskell typechecker solves that problem.