Discussion:
Tcl Syntax Highlighting
Offer Kaye
2010-06-22 14:21:23 UTC
Permalink
Hi,
Does anyone know how to modify the Tcl syntax highlighting patterns so
that code like:

regexp {^\s*#} $line

Will be highlighted correctly? Currently It is highlighted as a
comment starting from the "#" character, which is wrong.

I've tried to understand the current patterns and how they work but
either I don't understand how NEdit is setup or the default Tcl
language mode is just wrong - it uses a single quote as the start/end
delimiter for single-quoted strings which as far as I know is wrong,
"{" and "}" are the correct characters for single quoted strings.

Best regards,
--
Offer Kaye
--
NEdit Discuss mailing list - Discuss-***@public.gmane.org
http://www.nedit.org/mailman/listinfo/discuss
Tony Balinski
2010-06-22 21:54:53 UTC
Permalink
Post by Offer Kaye
Hi,
Does anyone know how to modify the Tcl syntax highlighting patterns so
regexp {^\s*#} $line
Will be highlighted correctly? Currently It is highlighted as a
comment starting from the "#" character, which is wrong.
I've tried to understand the current patterns and how they work but
either I don't understand how NEdit is setup or the default Tcl
language mode is just wrong - it uses a single quote as the start/end
delimiter for single-quoted strings which as far as I know is wrong,
"{" and "}" are the correct characters for single quoted strings.
If you want {...} to pick up a string, then set up a "braced string"
recognition pattern, probably best with start and end REs. eg start: \{
end: \} matching error: \n say. A # between the braces then becomes a
character in the string. Make sure you move the pattern to a position just
after the Single Quote String pattern. But then you'll have two other
problems: nested braces (are such things valid in TCL string?) or highlighting
within a brace-string, and braces when used for other reasons (are there any?)
where you'll have to give REs that provide a bit of context. It can get
tricky!

Tony
--
NEdit Discuss mailing list - Discuss-***@public.gmane.org
http://www.nedit.org/mailman/listinfo/discuss
Offer Kaye
2010-06-23 10:32:16 UTC
Permalink
Post by Tony Balinski
But then you'll have two other
problems: nested braces (are such things valid in TCL string?)
Sure, since strings in Tcl are just lists and nested lists are a legal
construct:
set my_list {1 2 {3 4}}
Post by Tony Balinski
or highlighting
within a brace-string, and braces when used for other reasons (are there any?)
Alas, yes.
if {conditional} { body }

For example in this case the braces do not act as SQ-Delimiters so the
conditional and body do undergo variable interpolation.
Post by Tony Balinski
where you'll have to give REs that provide a bit of context. It can get
tricky!
That's why I need the help :)

Also I still think (until someone says differently) that the use of
single-quotes in the default NEdit Tcl language recognition pattern as
a SQ-Delimiter is just plain wrong. I wonder if any NEdit developer
who knows Tcl reads this mailing list? :)

Thanks anyway Tony.

Regards,
--
Offer Kaye
--
NEdit Discuss mailing list - Discuss-***@public.gmane.org
http://www.nedit.org/mailman/listinfo/discuss
Aldric L'Hernault
2010-06-23 11:13:15 UTC
Permalink
Hello,
Post by Offer Kaye
Does anyone know how to modify the Tcl syntax highlighting patterns so
regexp {^\s*#} $line
Will be highlighted correctly? Currently It is highlighted as a
comment starting from the "#" character, which is wrong.
I have changed default settings to better match Tcl behaviour:
comments start after pound-sign (#) if first non-blanck char on a line,
or first non blank char after a semi-column.
comments stop at end of line unless continued with backslash (\) as very
last char before linefeed.

Starting RE:
(^|;)\s*#

Ending RE:
[^\\]$

Hope this helps,
Aldric

Sorry to copy you, but due to my uncommon email address, I'm unsure the
mail will get to the list anyway...
--
NEdit Discuss mailing list - Discuss-***@public.gmane.org
http://www.nedit.org/mailman/listinfo/discuss
Offer Kaye
2010-06-23 19:22:09 UTC
Permalink
comments start after pound-sign (#) if first non-blanck char on a line, or
first non blank char after a semi-column.
comments stop at end of line unless continued with backslash (\) as very
last char before linefeed.
That's fantastic, exactly what I wanted! Thanks Aldric!
Sorry to copy you, but due to my uncommon email address, I'm unsure the mail
will get to the list anyway...
No problem, thanks to Gmail I see a single email. Gmail rocks :)

Cheers,
--
Offer Kaye
--
NEdit Discuss mailing list - Discuss-***@public.gmane.org
http://www.nedit.org/mailman/listinfo/discuss
Continue reading on narkive:
Loading...