admin管理员组文章数量:1125614
I'm currently implementing a custom grammar for a personal project using tree-sitter. Mostly everything is going alright, but I've run into a problem that I cannot wrap my head around.
Here's a simplified version of the situation that produces the same problem.
rule: $ => /[ab]+/
rule: $ => repeat1(choice("a","b"))
Now I must admit I'm not particularly well versed in the mathematics of grammars. I've gotten by mostly on intuition.
My intuition tells me these two statements are the same, though I must be missing something because tree-sitter says otherwise. The first implementation of rule with the regex passes with no complaints, but the second implementation produces the following error:
Unresolved conflict for symbol sequence:
rule_repeat1 • 'a' …
Possible interpretations:
1: (rule rule_repeat1) • 'a' …
2: (rule_repeat1 rule_repeat1 • rule_repeat1)
Possible resolutions:
1: Specify a left or right associativity in `rule`
2: Add a conflict for these rules: `rule`
Any help or explanation on what I've misunderstood would be greatly appreciated.
本文标签: neovimConfused on the difference between two treesitter grammar implementationsStack Overflow
版权声明:本文标题:neovim - Confused on the difference between two tree-sitter grammar implementations - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736627054a1945696.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论