David Abrahams wrote:
James Fowler <[EMAIL PROTECTED]> writes:
  
Not sure why it wants the _expression_ to start with "\\[inc..." instead 
of "\[inc...", 
    

This should answer your question:

  C:\Documents and Settings\dave>bjam -f -
  ECHO "\\[include[ ]*([^\]]+)\]" ;
  ^Z
  \[include[ ]*([^]]+)]

quotes don't prevent backslashes from acting like escapes.
OK, that makes sense - escapes must be doubled in a literal string to get through to the regex parser.   What tripped me up is that the rules for escaping a "literal" close bracket character in bjam aren't quite what I was used to (perl/python and the regex rules in my editor (CodeWright...)).  Here's an summary of the differences based on the actual string passed to the regex (i.e., after initial "string literal" escapes are processed):

pattern
description
bjam
CodeWright
python re
\[include[ ]*([^]]+)]
no charset close bracket escape, no final close bracket escape
works
fails
works
\[include[ ]*([^]]+)\] no charset close bracket escape, final close bracket escaped works
works
works
\[include[ ]*([^\]]+)] charset close bracket escaped, no final close bracket escape fails
works
works
\[include[ ]*([^\]]+)\] charset close bracket escaped, final close bracket escaped fails
works
works

bjam and python silently interpret an unmatched unescaped closing bracket as a literal, where it is an illegal _expression_ for CodeWright.  All three work if the final close bracket is escaped.   I think the part that really confused me is that bjam gets confused when the close bracket is escaped in a negated character set, i.e. "[^]]" works but "[^\]]" fails.  What I considered the "intuitive" pattern ( \[include[ ]*([^\]]+)\] ) failed with bjam.  Oh what fun...

- james

p.s. anyone have strong preferences/recommendations on an editor?  I've been using CodeWright for ages, but it's been finicky lately (really complex C++ code crashes CodeWright's source indexing logic).  Unfortunately Borland seems to be abandoning the product, so I'm thinking it's time to move on...

-- 
__________________________________________________________
 James Fowler, Open Sea Consulting
 http://www.OpenSeaConsulting.com, Marietta, Georgia, USA
 Do C++ Right.  http://www.OpenCpp.org, opening soon!

Reply via email to