After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 453638 - Perl syntax file enhancement
Perl syntax file enhancement
Status: RESOLVED FIXED
Product: gtksourceview
Classification: Platform
Component: Syntax files
git master
Other Linux
: Normal normal
: ---
Assigned To: GTK Sourceview maintainers
GTK Sourceview maintainers
Depends on:
Blocks:
 
 
Reported: 2007-07-04 10:17 UTC by Steve Frécinaux
Modified: 2007-07-13 16:04 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
[PATCH] Enhance perl markup (11.29 KB, patch)
2007-07-04 10:17 UTC, Steve Frécinaux
none Details | Review
[PATCH] Enhance perl markup (11.83 KB, patch)
2007-07-04 10:35 UTC, Steve Frécinaux
none Details | Review
[PATCH] Perl enhancement II (21.47 KB, patch)
2007-07-06 00:06 UTC, Steve Frécinaux
none Details | Review
[PATCH] Perl enhancement III (15.77 KB, patch)
2007-07-06 10:27 UTC, Steve Frécinaux
none Details | Review
perl enhancements v2 (29.29 KB, patch)
2007-07-11 20:45 UTC, Steve Frécinaux
committed Details | Review

Description Steve Frécinaux 2007-07-04 10:17:16 UTC
See below
Comment 1 Steve Frécinaux 2007-07-04 10:17:54 UTC
Created attachment 91168 [details] [review]
[PATCH] Enhance perl markup


- Add HereDoc support, able to highlight that correctly (bug #323998):
	$var = <<FOO if TRUE;
	blah
	FOO
- Split 'keywords' into several classes (keyword, builtin-function,
  control, file-descriptor)
- Highlight special use flags
- Add $var highlighting in double-quoted strings and backtick-quoted
  strings (bug #141698)
- Remove 'other' style, rename other styles
---
 gtksourceview/language-specs/perl.lang |  175 +++++++++++++++++++++++++-------
 1 files changed, 136 insertions(+), 39 deletions(-)
Comment 2 Steve Frécinaux 2007-07-04 10:35:15 UTC
Created attachment 91171 [details] [review]
[PATCH] Enhance perl markup


- Add HereDoc support, able to highlight the following code correctly,
  and to handle separately var-expansion and no-var-expansion (bug
  #323998):
	$var = <<FOO if TRUE;
	blah
	FOO
- Split 'keywords' into several classes (keyword, builtin-function,
  control, file-descriptor)
- Highlight special use flags
- Add $var highlighting in double-quoted strings and backtick-quoted
  strings (bug #141698)
- Remove 'other' style, rename other styles
---
 gtksourceview/language-specs/perl.lang |  196 +++++++++++++++++++++++++------
 1 files changed, 158 insertions(+), 38 deletions(-)
Comment 3 thelema 2007-07-04 18:28:38 UTC
Looks good to me.  This patch seems to lose the code for highlighting method calls (->method) and function calls &function(args), but maybe it's not so important to highlight those. 
On variable highlighting, maybe the regex could be changed to start with [$@%][$]* instead [$@%][$]?, because one could have many levels of $-dereferencing to work through.
Comment handling could use an assertion so it doesn't mark $#answers as a comment.  
Comment 4 Steve Frécinaux 2007-07-04 22:26:03 UTC
(In reply to comment #3)
> Looks good to me.  This patch seems to lose the code for highlighting method
> calls (->method) and function calls &function(args), but maybe it's not so
> important to highlight those. 

I removed them because I estimated it was not important, linked to the "other" colour, and inconsistent with other languages like python that don't highlight stuff like methods. I know methods are unusual in perl but still ;-)

> On variable highlighting, maybe the regex could be changed to start with
> [$@%][$]* instead [$@%][$]?, because one could have many levels of
> $-dereferencing to work through.

This is fixed in a second patch I have here, but I wait till I have a basic support for regexp (the last big bug in perl highlighting) before submitting it here.

> Comment handling could use an assertion so it doesn't mark $#answers as a
> comment.  

I don't use an assertion but it works ok. What is an assertion in .lang files context ?
Comment 5 thelema 2007-07-04 23:52:55 UTC
(In reply to comment #4)
> (In reply to comment #3)
> > Comment handling could use an assertion so it doesn't mark $#answers as a
> > comment.  
> 
> I don't use an assertion but it works ok. What is an assertion in .lang files
> context ?
> 

<start>(?&lt;![$])#</start>
the zero-width negative lookbehind (?<!foo) asserts that there's no foo before this place in the regexp.
Comment 6 Steve Frécinaux 2007-07-06 00:06:10 UTC
Created attachment 91283 [details] [review]
[PATCH] Perl enhancement II


- inline regexp support
- variables
---
 gtksourceview/language-specs/perl.lang |  501 +++++++++++++++++++++++++++++---
 1 files changed, 455 insertions(+), 46 deletions(-)
Comment 7 Steve Frécinaux 2007-07-06 10:27:57 UTC
Created attachment 91294 [details] [review]
[PATCH] Perl enhancement III


- fixed ${foo}
- fixed bracket nesting in regexes
- fixed variable interpolation in m''
- fixed s, tr and y with chars other than /
---
 gtksourceview/language-specs/perl.lang |  229 ++++++++++++++++++++++++--------
 1 files changed, 172 insertions(+), 57 deletions(-)
Comment 8 thelema 2007-07-09 23:49:25 UTC
In order to highlight # comments in extended regexes (and only regexes), we cannot use <start><end>-based contexts.  The reason for this is that once we match the <start> of a context, that context is entered, and the <start> for both regular and extended regexes are identical.  (Although I guess we could put in a massive assertion that looks ahead to the end of the /regex/ and checks for the x, but somehow that seems ugly/unsatisfying/impossible in the general case where you need to count matching braces.)
Comment 9 Steve Frécinaux 2007-07-11 20:45:47 UTC
Created attachment 91650 [details] [review]
perl enhancements v2

- much better pattern handling, + q, qq, qw, qx, etc.
- operators are now highlighted
- fix a few bugs

 gtksourceview/language-specs/perl.lang |  704 +++++++++++++++++++++++++++-----
 1 files changed, 608 insertions(+), 96 deletions(-)