Tcl and Keyword Highlighting

Discuss syntax highlighting or submit new syntax files.
Post Reply
jgodfrey
Posts: 471
Joined: 19 Aug 2011 23:02
Location: Missouri, USA

Tcl and Keyword Highlighting

Post by jgodfrey »

I'm creating a Tcl/Tk syntax file and I've run into a highlight issue I don't understand. Here's an example:

First, I've defined the word "message" as a keyword, which generally works as expected. However, I've noticed that the string "message" is also colorized as a keyword in the string "-message". I've attached a small screenshot showing the issue. Notice that in the image, other random symbols in front of the "message" string disable the keyword highlighting - as I'd expect. So, it seems that the "-" character is somehow being treated differently in this case.

Originally, I thought it was because I had the "-" character in the Symbols definition - which according to the docs is "used to separate words". However, removing the "-" character from the symbols definition hasn't changed anything.

Thoughts?

Thanks,

Jef
Attachments
tcl_syntax.png
tcl_syntax.png (2.5 KiB) Viewed 9674 times
jgodfrey
Posts: 471
Joined: 19 Aug 2011 23:02
Location: Missouri, USA

Re: Tcl and Keyword Highlighting

Post by jgodfrey »

After fiddling with some syntax coloring, I realized that the offending dash character was being rendered in the color defined for numbers. So, it seems that TextEd's highlight parser is doing something like:

- Sees the "-", assumes it's at the beginning of a number, activates number colorization
- Sees the next character (the "m" in my above example) is not a number so turns off number colorization
- Recognizes the string "message" as a keyword and colorizes it accordingly

Obviously, the "-" is not part of a number in this case, though unless the colorization parser uses some kind of look-ahead, TextEd may not recognize that...

Is the above on the right track? Is there any way I can modify my syntax definition to avoid the issue?

Thanks,

Jeff

========== EDIT =============
In my example "-message" is actually an option to a command. It seems that the right way to fix this is to define an "Options" category in the language's Keywords list and explicitly define all of the command options. That'll be a big job, but probably worth it...
============================
Post Reply