GNOME Bugzilla – Bug 453638
Perl syntax file enhancement
Last modified: 2007-07-13 16:04:13 UTC
See below
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(-)
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(-)
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.
(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 ?
(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>(?<![$])#</start> the zero-width negative lookbehind (?<!foo) asserts that there's no foo before this place in the regexp.
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(-)
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(-)
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.)
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(-)