Question about syntax coloring

Get help with the installation and running of the Zeus IDE. Please do not post bug reports or feature requests here. When in doubt post your question here.
Post Reply
pwdiener
Posts: 134
Joined: Wed Jul 11, 2007 3:45 pm

Question about syntax coloring

Post by pwdiener »

I'm trying to put together a syntax coloring scheme for the M4 macro language. Keywords are easy, as are comments and a couple other items that user defined words accommodate. Where I'm running it to some issues is the strings. M4 uses (by default, at least) the ` character (back quote?) as the leading quoting character, and the ' characters (quote) as the trailing quoting character. It also permits effectively infinite nesting of strings, across multiple lines. What would be absolutely ideal is to be able to see the full quoted string with the nested sub-strings somehow also indicated, but that strikes me as somewhat difficult. Failing that, it would be useful to be able to highlight the open quote and close quote by color, perhaps using different colors. What I tried was to define the open quote as a user-defined 1 word, and close quote as a user-defined 2 word, with nothing entered for the string or literal settings. This works well for the open quote, but only sporadically for the close quote. Is there an alternative way?

Another possibility would be to use BraceMatching, but I don't see any way to tell it about open and close quoting.

I'm considering developing a macro that highlights the string on request - am I correct that the only means I have of highlighting is to mark the text?

Bill Diener
jussij
Site Admin
Posts: 2650
Joined: Fri Aug 13, 2004 5:10 pm

Post by jussij »

It also permits effectively infinite nesting of strings, across multiple lines.
Any syntax highlighting that uses information from multiple lines can only be catered for by special code built into to the syntax highlighter and generally these options can not be user configured.

For multi-line syntax highlighting the currently available options are the two block comments and the Python triple quotes options.
Is there an alternative way?
When it comes to string quotes the logic is also hard coded into the syntax highlighter. There rules for strings are fairly simple:
  1. Is the current character any of the characters defined as a string?
  2. If the answer is no then we are done.
  3. If the answer is yes then search for the next character that matches the current character ignoring any characters that are delimited.
NOTE: A delimited character is any character preceded by the Literal character defined in the Keywords section of the document type.
Another possibility would be to use BraceMatching, but I don't see any way to tell it about open and close quoting.
The brace matching characters are defined in the Templates section of the document type.
I'm considering developing a macro that highlights the string on request - am I correct that the only means I have of highlighting is to mark the text?
I'm not sure if there is a lot you can do via the scripting layer :?

Cheers Jussi
jussij
Site Admin
Posts: 2650
Joined: Fri Aug 13, 2004 5:10 pm

Post by jussij »

Is there an alternative way?
Based on the code you posted in your bug report:

Code: Select all

define(`procdivarglist', `ifelse(`$#', `0', , `$#', `1', ``$1'', ``$1' 
procdivarglist(shift($@))')')dnl

I would say the only other option is to define a keyword pattern that looks like this: `*'

But you would also need to remove the `$#' characters as delimiters.

Cheers Jussi
Post Reply