Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Handle shorthand syntax in explanations
When performing a performance test on https://github.com/kddnewton/syntax_tree/blob/50f9fc1b815156bdde53f13d4f250d9522f15e64/test/syntax_tree_test.rb I noticed a strange output. The explain syntax indicated that it was missing a bracket when I had only deleted an `end`: ``` $ time DEAD_END_TIMEOUT=10 ./exe/dead_end spec/fixtures/syntax_tree.rb.txt --> /Users/rschneeman/Documents/projects/dead_end/spec/fixtures/syntax_tree.rb.txt Unmatched `]', missing `[' ? Unmatched keyword, missing `end' ? 6 class SyntaxTree < Ripper 170 def self.parse(source) 174 end 176 private ❯ 754 def on_args_add(arguments, argument) ❯ 776 class ArgsAddBlock ❯ 810 end 9233 end DEAD_END_TIMEOUT=10 ./exe/dead_end spec/fixtures/syntax_tree.rb.txt 1.63s user 0.07s system 99% cpu 1.703 total ``` The cause was this line: ``` node.is_a?(Op) && %w[| ||].include?(node.value) && ``` With the `%w[]` syntax the lexer tokenizes `%w[` which *since it doesn't match `[`) is not counted. This commit corrects that logic by explicitly looking for the last character of these events.
- Loading branch information