tree-sitter / tree-sitter-ruby

Ruby grammar for tree-sitter
MIT License
176 stars 58 forks source link

Parser improvements: `!=` operator and `key: [line_break]` #220

Closed aibaars closed 2 years ago

aibaars commented 2 years ago

This pull request implements two fixes to the parser:

The first problem is addressed by letting the scanner handle identifiers that end with !, so it can do a negative lookahead test for a = character.

The second problem is addressed by adding a fake "no_line_break" token in the grammar right after the : symbol in a pair and change the scanner so it won't produce "line_break" symbols if a "no_line_break" symbol is expected. This solution feels a bit "hacky" to me, but it could not think of a better way. @maxbrunsfeld any ideas?

Checklist: