tree-sitter-perl icon indicating copy to clipboard operation
tree-sitter-perl copied to clipboard

Looks like this breaks the parser

Open willt opened this issue 3 years ago • 16 comments

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 avatar Oct 11 '21 22:10 willt

@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.

ganezdragon avatar Oct 12 '21 10:10 ganezdragon

awesome. I will look forward to the fix.

On Tue, Oct 12, 2021 at 3:58 AM Ganesan @.***> wrote:

@willt https://github.com/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.

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ganezdragon/tree-sitter-perl/issues/10#issuecomment-940899158, or unsubscribe https://github.com/notifications/unsubscribe-auth/AACTAMCCM7U3RK524HYAKITUGQIFLANCNFSM5FZES2MA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

willt avatar Oct 12 '21 14:10 willt

Any news on this? Is it fixed?

Similar issue when my code contains something like:

print("${key}");

print("$key") looks ok.

DavidEGx avatar Dec 13 '21 14:12 DavidEGx

@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!

ganezdragon avatar Dec 14 '21 14:12 ganezdragon

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 avatar Jan 10 '22 16:01 marcelarie

@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

ganezdragon avatar Jan 10 '22 17:01 ganezdragon

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

ganezdragon avatar Jan 23 '22 19:01 ganezdragon

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

marcelarie avatar Jan 23 '22 19:01 marcelarie

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).

DavidEGx avatar Jan 25 '22 15:01 DavidEGx

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.

ganezdragon avatar Jan 25 '22 17:01 ganezdragon

Weird.

Code

DavidEGx avatar Jan 26 '22 09:01 DavidEGx

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?

DavidEGx avatar Jan 26 '22 10:01 DavidEGx

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

ganezdragon avatar Jan 26 '22 14:01 ganezdragon

@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 avatar Feb 12 '22 07:02 ganezdragon

@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.

DavidEGx avatar Feb 12 '22 07:02 DavidEGx

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

Noino avatar Aug 29 '23 11:08 Noino