Hello,

--- "A.J.Mechelynck" <[EMAIL PROTECTED]> wrote:

> 
> So, it matches a part-word. Try adding an end-of-word pattern atom \> 
> before the ending slash (but after the ending bracket) on each line. You 
> wouldn't want "session.cookie_nomatch" to be matched as far as 
> "session.cookie_" would you?
> 

Sorry, it isn't that simple.  I want to match as much as possible regardless of
what comes next.  What I am trying to do is:

  <?php
  ini_get('session.gc_maxlifetime');

There are only 150 or so possibilities for the argument to ini_get(), I am
trying to highlight them.  If I make a spelling mistake or put in the wrong
item, then I would want to highlight the error:

  <?php
  // should only highlight 'session.gc_' as correct
  // 'axlifetime' highlights as Error
  ini_get('session.gc_axlifetime');
  // the whole 'not.a_real_option' string should be higlighted as an error
  // (except for the quotes)
  ini_get('not.a_real_option');

So I use the following commands to set it all up:

  " find the ini_get function
  syntax keyword phpFunctions ini_get contained nextgroup=phpIniParents
  syntax region phpIniParents contained matchgroup=Delimiter start=/(/ end=/)/
keepend
        \ contains=phpIniError

  " highlight a string inside ini_get() as an Error
  syntax match phpIniError contained /(\@<="\%(\\.\|[^"]\)*"\=/
[EMAIL PROTECTED]
  syntax match phpIniError contained /(\@<='\%(\\.\|[^']\)*'\=/
[EMAIL PROTECTED]
  hi link phpIniError Error

  " highlight string quotes inside ini_get() as a normal color
  syntax cluster phpIniInside add=phpIniQuotes
  syntax match phpIniQuotes contained /['"]/ containedin=phpIniError
  hi link phpIniQuotes Define

  " highlight settings and partial settings inside the string:
  " - phpIniKey is a correct keyword
  " - phpIniKeyPartial matches part of a keyword
  syntax cluster phpIniInside add=phpIniKey,phpIniKeyPartial
  syntax match phpIniKeyPartial contained /['"]\@<=S\%[MT]/
  syntax match phpIniKey        contained /['"]\@<=SMTP/
  syntax match phpIniKeyPartial contained
/['"]\@<=a\%[llow_call_time_pass_referenc]/
  syntax match phpIniKey        contained
/['"]\@<=allow_call_time_pass_reference/
  syntax match phpIniKeyPartial contained /['"]\@<=allow_u\%[rl_fope]/
  syntax match phpIniKey        contained /['"]\@<=allow_url_fopen/
  syntax match phpIniKeyPartial contained /['"]\@<=allow_url_i\%[nclud]/
  syntax match phpIniKey        contained /['"]\@<=allow_url_include/
  syntax match phpIniKeyPartial contained
/['"]\@<=alw\%[ays_populate_raw_post_dat]/
  syntax match phpIniKey        contained
/['"]\@<=always_populate_raw_post_data/
  syntax match phpIniKeyPartial contained /['"]\@<=ar\%[g_separator\.inpu]/
  syntax match phpIniKey        contained /['"]\@<=arg_separator\.input/
  syntax match phpIniKeyPartial contained /['"]\@<=arg_separator\.o\%[utpu]/
  syntax match phpIniKey        contained /['"]\@<=arg_separator\.output/
  syntax match phpIniKeyPartial contained /['"]\@<=as\%[p_tag]/
  syntax match phpIniKey        contained /['"]\@<=asp_tags/
  syntax match phpIniKeyPartial contained /['"]\@<=ass\%[ert\.activ]/
  syntax match phpIniKey        contained /['"]\@<=assert\.active/
  syntax match phpIniKeyPartial contained /['"]\@<=assert\.b\%[ai]/
  syntax match phpIniKey        contained /['"]\@<=assert\.bail/
  syntax match phpIniKeyPartial contained /['"]\@<=assert\.c\%[allbac]/
  syntax match phpIniKey        contained /['"]\@<=assert\.callback/
  syntax match phpIniKeyPartial contained /['"]\@<=assert\.q\%[uiet_eva]/
  syntax match phpIniKey        contained /['"]\@<=assert\.quiet_eval/
  syntax match phpIniKeyPartial contained /['"]\@<=assert\.w\%[arnin]/
  syntax match phpIniKey        contained /['"]\@<=assert\.warning/
  syntax match phpIniKeyPartial contained /['"]\@<=au\%[to_append_fil]/
  syntax match phpIniKey        contained /['"]\@<=auto_append_file/
  syntax match phpIniKeyPartial contained /['"]\@<=auto_d\%[etect_line_ending]/
  syntax match phpIniKey        contained /['"]\@<=auto_detect_line_endings/
  syntax match phpIniKeyPartial contained /['"]\@<=auto_g\%[lobals_ji]/
  syntax match phpIniKey        contained /['"]\@<=auto_globals_jit/
  syntax match phpIniKeyPartial contained /['"]\@<=auto_p\%[repend_fil]/
  syntax match phpIniKey        contained /['"]\@<=auto_prepend_file/
  syntax match phpIniKeyPartial contained /['"]\@<=b\%[rowsca]/
  syntax match phpIniKey        contained /['"]\@<=browscap/
  syntax match phpIniKeyPartial contained /['"]\@<=d\%[ate\.default_latitud]/
  syntax match phpIniKey        contained /['"]\@<=date\.default_latitude/
  syntax match phpIniKeyPartial contained /['"]\@<=date\.default_lo\%[ngitud]/
  syntax match phpIniKey        contained /['"]\@<=date\.default_longitude/
  syntax match phpIniKeyPartial contained /['"]\@<=date\.s\%[unrise_zenit]/
  syntax match phpIniKey        contained /['"]\@<=date\.sunrise_zenith/
  syntax match phpIniKeyPartial contained /['"]\@<=date\.suns\%[et_zenit]/
  syntax match phpIniKey        contained /['"]\@<=date\.sunset_zenith/
  syntax match phpIniKeyPartial contained /['"]\@<=date\.t\%[imezon]/
  syntax match phpIniKey        contained /['"]\@<=date\.timezone/
  syntax match phpIniKeyPartial contained /['"]\@<=de\%[fault_charse]/
  syntax match phpIniKey        contained /['"]\@<=default_charset/
  syntax match phpIniKeyPartial contained /['"]\@<=default_m\%[imetyp]/
  syntax match phpIniKey        contained /['"]\@<=default_mimetype/
  syntax match phpIniKeyPartial contained /['"]\@<=default_s\%[ocket_timeou]/
  syntax match phpIniKey        contained /['"]\@<=default_socket_timeout/
  syntax match phpIniKeyPartial contained /['"]\@<=defi\%[ne_syslog_variable]/
  syntax match phpIniKey        contained /['"]\@<=define_syslog_variables/
  syntax match phpIniKeyPartial contained /['"]\@<=di\%[sable_classe]/
  syntax match phpIniKey        contained /['"]\@<=disable_classes/
  [...]
  hi link phpIniKey Define
  hi link phpIniKeyPartial Todo

This all works correctly, and the following examples all work correctlly (where
d = Define, E = Error, t = Todo):

  ini_get('register_globalss'); // extra 's' at end
           ddddddddddddddddE

  ini_get('session.gc_axlifetime'); // letter missing after 'gc_'
           tttttttttttEEEEEEEEEE 

  ini_get('not.a_real_option'); // probably only first two letters are valid
           ttEEEEEEEEEEEEEEE

I was just hoping there would be a simpler way to accomplish the same thing.

regards,
Peter



                
____________________________________________________ 
Do you Yahoo!? 
Take part in Total GirlÂ’s Ultimate Slumber Party and help break a world record 
http://www.totalgirl.com.au

Reply via email to