ganezdragon/tree-sitter-perl

Looks like this breaks the parser

Opened this issue ยท 16 comments

willt commented

I just installed tree-sitter and this tree-sitter-perl grammar file. I'm using latest neovim with the gurvbox colorscheme.
The image on the left is with tree-sitter highlighting on and the one on the right is with it off.
Looks like the parser breaks if qw/ /; contains a question mark.

image

@willt , this is a known issue.. the parser doesn't behave properly for all the quote like operators in perl with deliimiters other than, {, /, [, '

I'm currently fixing it since users are requesting. Expect it to be fixed by this week. Or you could use the delimiters I have mentioned above in the meantime.

willt commented

Any news on this? Is it fixed?

Similar issue when my code contains something like:

print("${key}");

print("$key") looks ok.

@DavidEGx , in recent commits, I have fixed it for qw as mentioned in the above example. And there were other quote based operators which were facing the issue, so fixed them too. But there is still s// and tr// syntax left. Should push them, and make a version upgrade. Very soon!

I got the same problem with =~ s!!!;
And some subroutines have different color.

with OceanicNext
ArcoLinux_2022-01-10_17-30-15
ArcoLinux_2022-01-10_17-30-27

with gruvbox-flat
ArcoLinux_2022-01-10_17-31-52
ArcoLinux_2022-01-10_17-32-30

@marcelarie , I'm still working on the s/// and tr// syntaxes with other identifiers. Currently it should work with s///.

And let me checkout why that subname is highlighted differently and get back

I have publish version 0.3.0 . This should parse all these syntax properly. Let me know otherwise. :)

Amazing, thanks @ganezdragon!! I will test it at work tomorrow.

Thanks for the work.

This one seems to break it currently:

my $x;
if ($x =~ m/^asf$/) {
}

Also this one:

my $x;
if ($x =~ //) {
}

As far as I know I'm using the last version (run :TSUpdateSync).

okay, I see the $ in the regex is causing the problem. It starts to expect a scalar variable. Let me fix that.

But the latter with just // works fine for me.

Weird.

Code

Another one:

use strict;
use warnings;

=head1 METHODS

=head2 test1

Test

=cut

sub test1 : Path('/') {
}

=head2 test2

Looks good. But now...

=cut

sub test2 : Path('/') Args(0) {
}

=head3 test3

Hmmm, this is looks odd now

=cut

sub test3 {
}

See:

code

BTW, shall I create separate separate github issues for any separate new problem I find?

yea we could create separate issues, as a fallout of 0.3.0 version maybe, to better keep on track.

@DavidEGx , I'm not sure if your last snippet is syntactically correct. When I compile the code I get the following,

Invalid CODE attribute: Path('/') at examples/test.pl line 13.
BEGIN failed--compilation aborted at examples/test.pl line 13.

@ganezdragon forgot to inherit from Catalyst::Controller in the example.

Fixed version:

use strict;
use warnings;
use base qw/Catalyst::Controller/;

=head1 METHODS

=head2 test1                      

Test

=cut

sub test1 : Path('/') {
}

=head2 test2

Looks good. But now...

=cut

sub test2 : Path('/') Args(0) {
}

=head3 test3

Hmmm, this is looks odd now

=cut

sub test3 {
}

1;

Same syntax highlighting issue.

Noino commented

also in the category of things that break the parser?
image