Why my tool output matching does not work

General questions about using TextPad

Moderators: AmigoJack, bbadmin, helios, Bob Hansen, MudGuard

Post Reply
Tal Dayan

Why my tool output matching does not work

Post by Tal Dayan »

Hello,

I am trying to set CCSC PIC compiler as an external tool.

A typical error message looks like:

*** "D:\temp\test1\main.c" Line 113: Error #48: Expecting a (

My regular expression is

"\([^"]+\)"\ Line\ \([0-9]+\):

File = 1
Line = 2
Column = <none>

When I double click on the error line in the output window, Text Pad (version 4.3.1) gives the message "Cannot jump to item under the cursor".

Any idea what the problem is ?

Thanks,

Tal
Jens Hollmann

Re: Why my tool output matching does not work

Post by Jens Hollmann »

Hm, it seems that you have to match the beginning of a line in your regex. So something like

^.*"\([^"]+\)" Line \([0-9]+\):

works for me. Just add ^.* in front of your regex.

Mind that you have to close the output window when changing the regex. Just restarting the tool is not enough.

HTH

Jens
Stephan

Re: Why my tool output matching does not work

Post by Stephan »

Tal,

what I don't understand in your RegEx are the backslashes you put before the spaces.

Stephan
Tal Dayan

Re: Why my tool output matching does not work

Post by Tal Dayan »

Thank Jens.

It works great.

My regex was based on the IAR Assembler example in the help file. This example does not have the begining of line matching.

Tal
Tal Dayan

Re: Why my tool output matching does not work

Post by Tal Dayan »

Looks like it works both eays (with and without the '' before the spaces).

Tal
Andreas

Re: Why my tool output matching does not work

Post by Andreas »

As space is no special character, it is not necessary to escape it with a backslash.
But it does no harm as escaped characters are the same as unescaped characters as long as the characters are no special characters...
Jeff Epstein

Re: Why my tool output matching does not work

Post by Jeff Epstein »

My opinion is that if a character is not "special" it should never be escaped. Escaping characters that need not be, makes the Regular Expression more confusing, and really just takes advantage of the "generosity" of the language. That is, you really should be getting an error because it is invalidly formatted.

$.02


:' )
Jeffy
http://www.jeffyjeffy.com/textpad
Roy Beatty

Re: Why my tool output matching does not work

Post by Roy Beatty »

It ain't often that I disagree with Jeff...

I agree that preceding everything with backslash is hard on the eyes. When hardcoding regex in Python or Perl, please do keep it clean.

However, regex is usually "disposable". Few of us save regex strings unless we're just learning it and saving an example or if the regex string is long, robust and reusable. And TextPad discourages reusability by not automating regex capture. Disposability means that most of the time the only eye offended is our own.

Also, I like being able to escape whatever I need to. (Now *there's* a double entendre!) Within a program building regex on the fly, I might need to precede a few special characters with backslash . Rather than adding complicating logic to decide which characters get escaped, it might be simpler to escape them all, without the regex engine objecting. Besides, regex is so "greedy" -- should we complain when it is "generous"?

$.02+$.02,

Roy
Jeff Epstein

Re: Why my tool output matching does not work

Post by Jeff Epstein »

Roy,

If you were right, I would agree with you. :' )

:' )
Jeffy
http://www.jeffyjeffy.com/textpad
Roy Beatty

Re: Why my tool output matching does not work

Post by Roy Beatty »

I *knew* we'd agree on this!!!
Jeff Epstein

Re: Why my tool output matching does not work

Post by Jeff Epstein »

D'oh! That's not what I meant!

You got me.

:' )
Jeffy
http://www.jeffyjeffy.com/textpad
Post Reply