Author Topic: SE 23.0.2, perl heredoc color coding issue  (Read 296 times)

tuchman

  • Senior Community Member
  • Posts: 136
  • Hero Points: 7
SE 23.0.2, perl heredoc color coding issue
« on: June 13, 2019, 04:00:43 pm »
Escaped quote in perl heredoc breaks color-coding.
Same behavior on Windows10 and macOS.
Please see attached perl file and screenshots.
Thanks,
-ken



Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 4743
  • Hero Points: 383
Re: SE 23.0.2, perl heredoc color coding issue
« Reply #1 on: June 13, 2019, 07:43:55 pm »
Looks like a simple problem but its not. It's always possible to break any products color coding for Perl. Sad but true. That's because you need to be able to run the code to be certain how the code needs to be parsed. Almost all other languages do not have this issue.

Perl has a ton of multi-line constructs. Because SlickEdit is not sure of itself when it sees one, it doesn't always treat the construct as a multi-line construct or may not even assume it recognized the construct unless it's completed on one line. The most difficult is the / symbol since it could be a regex or just a divide symbol and this occurs frequently.

Whether a string quoted with ' ` or " is multi-line can be configured. The other constructs, like q{...}, are hard wired so you can't configure whether they are multi-line.

In this specific case, SlickEdit doesn't assume it recognized the q{ because it's span's multiple lines. It would be nice if there was a simple way to configure this but there isn't.

As a simple work around, you could configure the double quoted string not to span multiple lines.  Tools>Options>Languages>All Languages>Scripting Languages>Perl>Color Coding>Tokens, Select String ", change "Color to end across multiple lines" to "Color to end of line".

As a complicated work around, you can define a fairly complicated regex to match q{ ...} as a multi-line string.

* Tools>Options>Languages>All Languages>Scripting Languages>Perl>Color Coding>Tokens

* Click Add Other

* Set Type to String

* Set Start delimiter to:

   (#<=(^|[^$@%)}])[ \t]#|[^a-zA-Z_0-9$@% \t]|^)q\{

* Change Start "Plain text search" to "SlickEdit Regex". The above string is a SlickEdit Regex.

* Set End Delimited to }

* Set When end delimiter is not on same line to "Color to end across multiple lines"

* Set Escape char to \

See attached picture.

tuchman

  • Senior Community Member
  • Posts: 136
  • Hero Points: 7
Re: SE 23.0.2, perl heredoc color coding issue
« Reply #2 on: June 14, 2019, 08:27:56 am »
Thanks for the very detailed explanation!
I will try out your first work-around.