I've recently started a job with a perl backed custom language, and I'm
spending a little time to enhance the syntax. I start by "runtime!
syntax/perl.vim". This is my first time working with syntax highlighting.

I've got a couple of questions; one about syntax operation, one about
performance. Any tips or hints appreciated. Thanks for your time.

In this language "int" is a type, not a function. I tried
  syn keyword simt4Type           int
this didn't work. I tried putting it before the inclusion of perl.vim, still
didn't work. I ended up doing
  syn clear perlStatementNumeric
  syn keyword perlStatementNumeric    abs atan2 cos exp hex log oct rand 
sin sqrt srand
which works, but this is pretty ugly. Is there a better way?

In the following, the "ms" and "milliseconds" should highlight as type
and the 200 highlight as numbers.
  cycle 200 ms;
  cycle 200ms;

  cycle 200 milliseconds;
  cycle 200milliseconds;
with the rules
  syn keyword simt4Units          ms milliSeconds
  syn match simt4Units            "\(\<\d\+\)\@<=\(ms\|milliSeconds\)\>"
It works for all the "ms" and "milliseconds", but with 200ms the 200 is not
highlighted like a number. BTW, I tried the "\zs" as in:
  syn match simt4Units            "\<\d\+\zs\(ms\|milliSeconds\)\>"
But this didn't work. Is there a way to get the \zs to work?

The 200ms case is pretty common, so I thought I could catch it with
  syn match simt4Number           "\<\d\+ms\>"me=e-2
But this didn't work, but then I moved it *before* the other rules and it
started working. I was surprised, but its probably in the docs somewhere.
But this last rule isn't very nice with the "me=e-2" in there. So
  syn match simt4Number           "\<\d\+\(ms\>\|milliseconds\>\)[EMAIL 
PROTECTED]"
and this work. Now all the 200ms, with or without a space, highlight ok.

BTW, using the rule without the "me=e-2" and I can change the order of
statements and it still works.

I've got something that works, but I'm wondering about the performance 
of the
"[EMAIL PROTECTED]" and "\@<=" in two otherwise identical patterns. Is there a 
better 
way to
do this?


--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_dev" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Raspunde prin e-mail lui