Interpret precedence the way tree-sitter does, kinda

This allows most of our precedence to be re-used. There are some cases
still where tree-sitter gets confused (and we don't), see the
corresponding change to grammar.py. I wish I knew how to fix this but
I don't. :(
This commit is contained in:
John Doty 2024-09-01 07:37:54 -07:00
parent 0354fbf4a4
commit a99b3ecb70
2 changed files with 27 additions and 10 deletions

View file

@ -290,15 +290,11 @@ class FineGrammar(Grammar):
@rule("Pattern")
def pattern(self) -> Rule:
return (
seq(self.variable_binding, self._pattern_core, self._pattern_predicate)
seq(self.variable_binding, self._pattern_core, self.AND, self.expression)
| seq(self.variable_binding, self._pattern_core)
| self._pattern_core
)
@rule
def _pattern_predicate(self) -> Rule:
return seq(self.AND, self.expression)
@rule
def _pattern_core(self) -> Rule:
return self.type_expression | self.wildcard_pattern