1

For those who love code, there is nothing worse than looking at ugly code. My current syntax highlighting file scheme.vim for the editor vim on debian does not seem to recognize some character literals which are perfectly legal (at least in guile or indeed scm). For example the character literal #\x0000 which refers to the hexadecimal unicode point 0x0000 is recognized as such and properly displayed, but if I use an octal representation #\000 or a name representation #\nul, then vim gives me this bright orange (I am guessing the intent is to highlight an error condition). Does anyone have a suggestion helping me to fix this?

Sven Williamson
  • 1,094
  • 1
  • 10
  • 19
  • k fixing the name representation is easy once we know of a given name which is accepted (e.g. `#\newline`). Simply search for the relevant line, and duplicate it in the syntax file with the appropriate name. For octal representation, I have looked for the `schemeCharacter` line with a regex to parse hex representations, but adding a line with a regex for octal doesn't seem to work yet. – Sven Williamson Mar 29 '17 at 15:24
  • Ok got it, adding the line `syn match schemeCharacter "#\\[0-7]\+"` below or above the corresponding line for hex does it. I should have waited a bit before asking question. Apologies. – Sven Williamson Mar 29 '17 at 15:29
  • 1
    You can answer your own question and accept that answer. It's perfectly acceptable to do so. – Randy Morris Mar 29 '17 at 18:13

1 Answers1

1

This is a more polished version of what came out of the comments:

The existing syntax file scheme.vim probably recognizes some names for character literals, for example#\newline, and this gives us a starting point of where to search:

syn match schemeCharacter "#\\newline"

It is then just a matter of adding similar lines to the file with the new desired names...

syn match schemeCharacter "#\\linefeed"
...

Now we know that the existing file properly formats character literals where the unicode point is expressed in hexadecimal form. Searching for other occurences of schemeCharacter we find:

syn match schemeCharacter "#\\x[0-9a-fA-F]\+"

This really looks like a way of specifying a regex expression to match hex literals preceded by #\x. In order to add syntax recognition for character literals in octal format, we simply need to add another line of this type with the appropriate regex, this time allowing parsing of octal literals:

syn match schemeCharacter "#\\[0-7]\+"

Note: according to the GNU guile manual, R7RS uses the literal #\escape instead of #\esc (or as well as?). If you want both literals to be recognized by the syntax file, you cannot simply put the line relating to 'escape' first. Maybe replace the line for 'esc' by:

 syn match schemeCharacter "#\\esc[^a]"

which indicates you will match any #\esc provided it is not followed by a.

Sven Williamson
  • 1,094
  • 1
  • 10
  • 19