Home Download Buy Blog Forum Support

Perl Syntax: Single quote package delimiter not supported

Perl Syntax: Single quote package delimiter not supported

Postby eogas on Fri Aug 17, 2012 9:45 pm

I know it's not the preferred way of doing it anymore, and it's probably a hassle to parse, but Perl supports a single quote as a package delimiter which is being incorrectly identified as the start of a string in ST's syntax highlighting. This feature is mentioned specifically in the perl docs in the second paragraph here: http://perldoc.perl.org/perlmod.html#Packages

I figure this will end up being a "won't fix" issue, but I figured I'd mention it. My company has code with this delimiter in it all over the place, and it's a hassle looking at huge chunks of code that lack syntax highlighting because ST thinks it's all a string.
eogas
 
Posts: 4
Joined: Fri Aug 17, 2012 9:36 pm

Re: Perl Syntax: Single quote package delimiter not supported

Postby KES on Sat Aug 18, 2012 3:21 pm

There are also highlight problem with:

Code: Select all
   $nocache =  $nocache ? "?nocache=$nocache" : "" ;
KES
 
Posts: 41
Joined: Sun Aug 05, 2012 12:13 pm

Re: Perl Syntax: Single quote package delimiter not supported

Postby nick. on Sun Aug 19, 2012 3:24 pm

oof, this will be very difficult to parse out.

Not having syntax highlighting is miserable, so I'll give it a shot for ya.

Edit: Not as hard as I expected, as it turns out. See my github repo (link below).
nick.
 
Posts: 266
Joined: Wed Jan 18, 2012 3:45 am

Re: Perl Syntax: Single quote package delimiter not supported

Postby eogas on Mon Aug 20, 2012 3:12 pm

nick you are the man! That's so much better. There are still a few quirks though. It looks like it's only operating on scalars, whereas we have instances of arrays and hashes that are referenced in packages as well. So for instance:

Code: Select all
$myPackage'myScalar = 12;
@myPackage'myArray = ();
%myPackage'myHash = ();


The first instance will be detected properly, whereas the following two are not. So I extended your plain array handling regex to this:

Code: Select all
@[A-Za-z0-9_]+(('|::)[A-Za-z0-9_]+)*


Which seems to do the trick. I'm not comfortable submitting a pull request, or extending this to other cases (in braces, from scalar), because honestly I'm not a perl expert and I'm not familiar at all with ST's custom parsing functionality, but that should give you a decent idea of what's currently lacking if you want to improve it somewhat.
eogas
 
Posts: 4
Joined: Fri Aug 17, 2012 9:36 pm

Re: Perl Syntax: Single quote package delimiter not supported

Postby nick. on Mon Aug 20, 2012 4:55 pm

@eogas, I made a small change which adds support for using arrays and hashes as packages. Let me know if you come across any other bugs.
nick.
 
Posts: 266
Joined: Wed Jan 18, 2012 3:45 am

Re: Perl Syntax: Single quote package delimiter not supported

Postby eogas on Mon Aug 20, 2012 6:02 pm

Looks good. I do have a regular expression that's "leaking", but I pulled an old version (before the single quote changes), and confirmed that it's an existing issue. I'll see if I can identify what exactly is causing that expression to not be identified correctly, but as far as the single quote stuff, it all seems to be good.

On the regex issue, is it best to keep responding here, or should I just submit an issue on your repo?
eogas
 
Posts: 4
Joined: Fri Aug 17, 2012 9:36 pm

Re: Perl Syntax: Single quote package delimiter not supported

Postby nick. on Mon Aug 20, 2012 6:06 pm

I check these forum pretty frequently, but to keep things organized go ahead and open an issue in the repo. If you can provide the regex, that'd be best. I understand that may be private information, so no worries if you can't.
nick.
 
Posts: 266
Joined: Wed Jan 18, 2012 3:45 am

Re: Perl Syntax: Single quote package delimiter not supported

Postby eogas on Mon Aug 20, 2012 6:34 pm

Cool, I went ahead and submitted an issue.
eogas
 
Posts: 4
Joined: Fri Aug 17, 2012 9:36 pm


Return to Technical Support

Who is online

Users browsing this forum: Google [Bot] and 28 guests