[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-source-highlight] Re: Backreferences in source-highlight 2.7

From: Lorenzo Bettini
Subject: Re: [Help-source-highlight] Re: Backreferences in source-highlight 2.7
Date: Mon, 11 Jun 2007 10:00:53 +0200
User-agent: Mozilla-Thunderbird (X11/20070601)

gnombat wrote:
Lorenzo Bettini wrote:
gnombat wrote:
I'm having trouble with backreferences in source-highlight 2.7.  If I
create a language definition file named foo.lang:

keyword = `a(.)\1`

And then I create a test file

aaa abb acc a** a@@

And then I run source-highlight:

source-highlight --lang-def=foo.lang

Then "aaa", "abb" and "acc" are highlighted, but "a**" and "a@@" are
not.  Shouldn't the dot match any character?

yes you're right, so this must be a bug...

I'll try to work on it tomorrow

thanks for the feedback!

I think I figured out what is going on: is_to_isolate from regexpstatebuilder.cpp is treating the regular expression as an alphanumerical string because `a(.)\1` starts and ends with a letter or number.

 * An expression is isolated basically if it is an alphanumerical
 * string
 * TODO check whether this is actually correct in principle
 * @param s
 * @return
bool is_to_isolate(const string &s) {
  if (s.size()) {
if ((isalnum(s[0]) || s[0] == '_') && (isalnum(s[s.size()-1]) || s[s.size()-1] == '_'))
      return true;

  return false;

Then the whole regular expression gets surrounded with word boundary characters. This causes the match to fail with "a**" and "a@@".

Yes you're right!

I'll have to fix the code calling is_to_isolate (in the case of a ` ` is_to_isolate probably should not be called at all)

hope to have a fix soon
thanks again

Lorenzo Bettini, PhD in Computer Science, DSI, Univ. di Firenze
ICQ# lbetto, 16080134     (GNU/Linux User # 158233)

reply via email to

[Prev in Thread] Current Thread [Next in Thread]