Re: [BUG?] Syntax question regarding \%[

2006-09-06 Thread Tim Chase

  inte
  integ
  intege
  integer
  inter
  interv
  interva
  interval

is there any easy way to make these two commands work?

  syntax match Error /int\%[eger]/
  syntax match Error /int\%[erval]/

The second match begins taking priority as soon as the word is 'inte', and
prevents 'integer' from being matched correctly.


Your problem is that both patterns match int and inte, resulting in ambiguity.
I think solution is to separate 'int' and 'inte' as separate matches,
whcih results in unambiguous matching:

   syntax match Error /integ\%[er]/
   syntax match Error /inter\%[val]/
   syntax match Error /\int\%[e]\/

(untested)



I suspect, in testing ideas on this, I may have turned up a bug
in either the implementation of \%[] or its documentation needs a
remedy.

In theory, the following should work:

:match Error /int\%[\(eger\|erval\)]/

I base that assumption on a combination of these two pieces of
the help:

 From :help /\%[] one finds that this syntax matches a list of
optionally matched atoms. (note atoms, not ordinary atoms)

So what's an atom?  We jump over to :help atom where we read
that an atom is

 atom::=ordinary-atom   |/ordinary-atom|
or  \( pattern \)   |/\(|
or  \%( pattern \)  |/\%(|
or  \z( pattern \)  |/\z(|

and that a pattern is (according to :help pattern)

pattern ::= branch
or  branch \| branch
or  branch \| branch \| branch
etc.

Thus, my understanding of it is that one should be perfectly
allowed to use a \(...\|...\) atom within a \%[] expression.
If this is not the case, the help for \%[] may likely intend to
refer to ordinary atoms rather than atoms.

*However*, the above search/match expression returns an E369:
invalid item in \%[] error.

I get this both in vim6.3 and vim7.

-tim








Re: [BUG?] Syntax question regarding \%[

2006-09-06 Thread Bram Moolenaar

Tim Chase wrote:

 I suspect, in testing ideas on this, I may have turned up a bug
 in either the implementation of \%[] or its documentation needs a
 remedy.
 
 In theory, the following should work:
 
   :match Error /int\%[\(eger\|erval\)]/
 
 I base that assumption on a combination of these two pieces of
 the help:
 
   From :help /\%[] one finds that this syntax matches a list of
 optionally matched atoms. (note atoms, not ordinary atoms)
 
 So what's an atom?  We jump over to :help atom where we read
 that an atom is
 
   atom::= ordinary-atom   |/ordinary-atom|
   or  \( pattern \)   |/\(|
   or  \%( pattern \)  |/\%(|
   or  \z( pattern \)  |/\z(|
 
 and that a pattern is (according to :help pattern)
 
  pattern ::=  branch
   or  branch \| branch
   or  branch \| branch \| branch
   etc.
 
 Thus, my understanding of it is that one should be perfectly
 allowed to use a \(...\|...\) atom within a \%[] expression.
 If this is not the case, the help for \%[] may likely intend to
 refer to ordinary atoms rather than atoms.
 
 *However*, the above search/match expression returns an E369:
 invalid item in \%[] error.
 
 I get this both in vim6.3 and vim7.

The documentation omits to mention that \(\) things are not allowed
inside \%[].  It also doesn't nest.

-- 
MORTICIAN:Bring out your dead!
  [clang]
  Bring out your dead!
  [clang]
  Bring out your dead!
CUSTOMER: Here's one -- nine pence.
DEAD PERSON:  I'm not dead!
  The Quest for the Holy Grail (Monty Python)

 /// Bram Moolenaar -- [EMAIL PROTECTED] -- http://www.Moolenaar.net   \\\
///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\download, build and distribute -- http://www.A-A-P.org///
 \\\help me help AIDS victims -- http://ICCF-Holland.org///


Re: [BUG?] Syntax question regarding \%[

2006-09-06 Thread Tim Chase

If this is not the case, the help for \%[] may likely intend to
refer to ordinary atoms rather than atoms.

*However*, the above search/match expression returns an E369:
invalid item in \%[] error.

I get this both in vim6.3 and vim7.


The documentation omits to mention that \(\) things are not allowed
inside \%[].  It also doesn't nest.


So should the documentation for \%[] be updated to read ordinary 
atoms rather than atoms then?  Or are there additional items 
that can go in a \%[] that are some subset of atom but a 
superset of ordinary atoms?


-tim





Re: [BUG?] Syntax question regarding \%[

2006-09-06 Thread Bram Moolenaar

Tim Chase wrote:

  If this is not the case, the help for \%[] may likely intend to
  refer to ordinary atoms rather than atoms.
 
  *However*, the above search/match expression returns an E369:
  invalid item in \%[] error.
 
  I get this both in vim6.3 and vim7.
  
  The documentation omits to mention that \(\) things are not allowed
  inside \%[].  It also doesn't nest.
 
 So should the documentation for \%[] be updated to read ordinary 
 atoms rather than atoms then?  Or are there additional items 
 that can go in a \%[] that are some subset of atom but a 
 superset of ordinary atoms?

All atoms can be used except \(\), \%(\), \z(\) and \%[].  Basically
things that nest.

-- 
We do not stumble over mountains, but over molehills.
Confucius

 /// Bram Moolenaar -- [EMAIL PROTECTED] -- http://www.Moolenaar.net   \\\
///sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\download, build and distribute -- http://www.A-A-P.org///
 \\\help me help AIDS victims -- http://ICCF-Holland.org///