 webmailusr-msn
Member
|
Hi:
I need to customize some regex for output capture, I’d like to ask your help:
PHP:
Parse error: syntax error, unexpected T_STRING in Test.php on line 11
(No idea)
GCC:
Test.cpp:21: syntax error before `(‘ token
%f:%l:(%c:)?.* works for that but not when column is included:
Test.cpp:7:17: Mat.h: No such file or directory
|
 simon
Key Master
|
PHP:
Try this:
.*in %f on line %l
GCC:
PN actually has built-in support for GCC error parsing, but this is currently broken in 2.0.9 as I need to change the regexes for the new engine.
To use .9 currently, it’s easy enough to fix the regex. The one you reference above expands to this:
(?P<f>.+) ?P<l>[0-9]+) (?P<c>[0-9]+) ? .*
Note that the following expansions are done:
%f = (?P<f>.+)
%l = (?P<l>[0-9]+)
%c = (?P<c>[0-9]+)
Regular expressions are by default “greedy” which means they’ll take as many characters for each match as they can. Because the last match bit is optional, the first reference to [0-9]+: ends up using the last number and colon (so the line number field matches the column in the string). The filename then includes the line number.
Results from your example:
File: Test.cpp:7
Line: 17
Col:
If we make the filename match bit “non-greedy” then it will take as little of the string as it can. With Xpressive (the new regular expressions engine) we do this by adding a question mark to the filename bit:
(?P<f>.+?) ?P<l>[0-9]+) (?P<c>[0-9]+) ? .*
The results are now:
File: Test.cpp
Line: 7
Col: 17
|
 webmailusr-msn
Member
|
Yeah, the second one did work (for gcc), however for php:
Parse error: syntax error, unexpected T_STRING in Test.php on line 11
.*in %f on line %l
does work in the test area, but not in the output window (weird, isn’t it?)
anyway thanks for the gcc trick!
|