How do I debug the Eclipse CDT's Regex Error Parser? - regex

I've wrote up my regex for error parsing of an unsupported compiler. However, it seems to ignore me and I don't know how to debug it.
The error message looks like this:
"file.c", line 224: Error: #20: identifier "myvar" is undefined
I wrote up this regex for Error:
"(.*?)", line (\d+): Error: #(\d+): (.*)
File: $1, Line: $2, Desc: $4
Eclipse's Console and Problems tabs seems to ignore it. What am I missing here?
Eclipse for Windows 3.7.1, CDT 8.0.0

Edited: while I use an online Javascript-based regex tester,
to debug CDT regular expressions I prefer to click into the console and use the regular search dialog box.

This might help someone. I was trying to get a custom parser working but I could never get it to match. It was a setup problem. You have to setup the match in Window > Preferences > c/c++ > Build > Settings > Error Parsers. To get it to USE it you have to check it in > Properties > c/c++ build > settings > error parsers.

Looks like my regex wasn't matching the error message.
The following regex solved the issue:
"(.*?)", line (\d+): Error:(\s*)#(.*): (.*)
File: $1, Line: $2, Desc: $5
Hope this helps someone with the same issue.

It did help me, actually. In response to your question about how to debug the error parser, I did my regex pattern testing with Python against strings captured from a compiler run. Once I got that working I just pasted the regexes into the error parser form in CDT.
Obviously, there are many different ways to play with regex, notably Perl.

Related

Eclipse RegExp Console Parsing Errors into Problems Window

Eclipse expert help needed! I have set up a makefile project to compile and link HCS12 code using the free codewarrior tools. It all seems to work well, but the only error/warning/information output I can get is to the console, with nothing being scanned from the console into the Problems window. I set up a regular expression error parser(Window -> Preferences -> C/C++ -> Build -> Settings -> Error Parsers) to scan the console for the appropriate information. If I search the console output (click in output and F) using find/replace with "regular expressions" checked, I find the warnings and errors--they just never get to the Problems tab.
I have enabled the error parser in (Project->Properties->C/C++ Build->Settings->ErrorParsers).
Somewhere I read that I need to enable this in C/C++ Makfile settings--but I cannot fine any settings which include the name "Makefile"; did I set up my project wrong??
Any suggestions or ideas on how to get my parsed errors into the problems window?
Eclipse Luna, Windows 7 professional.
It seems that the Regex parser for Eclipse (at least the older version I am currently using) assumes you start at the beginning of a line of text and end at the end of a line of text. My compiler errors were spanning multiple lines; I found a switch in the compiler which allowed it to output the errors in "microsoft format", which was then on a single line.
the new warning line looks like
.\CODE\LIBCODE\CodeLibraries\Drivers\CI2C1.C(312): WARNING C1801: Implicit parameter declaration for 'CI2C1_OnMasterBlockSent'
regex that works is now
[^"\n]\([^"(])((\d+)): WARNING C(\d+):([^\n]*)
of particular note is the [^"\n]*\ at the beginning of the regex expression, which matches all characters from the beginning of the line until the last \ is found--this is the piece I was missing. Eclipse Kepler is rather unforgiving about the regex it requires.
and we have
File $1 (just the file name--eclipse adds the path mysteriously if the file is in a code directory of the project)
Line $2 (gathers the line number of the error)
Descrioption $4 ( I ignore WARNING and the warning number, and capture the description of the error to the end of the line)
I now have a useful and somewhat more modern IDE to work with ancient code which grew from the assembly code over many years and was never parsed out into libraries or restructured into modern levels of abstraction.

Commands given for cmake and doxygen in _vimrc give error on gvim start up?

I am a beginner to vim and just downloaded the c-support plugin (for C/C++ programming) from the following link: http://www.vim.org/scripts/script.php?script_id=213
As advised in the link, to enable cmake and doxygen, i added the following lines to my _vimrc:
let g:C_UseTool_cmake = 'yes'
let g:C_UseTool_doxygen = 'yes'
However, now when I start up gvim, I get the following error message dialog:
Could not load the tool "cmake" (Vim(let):E117: Unknown function: mmtoolbox#make#Interface)- occurred at C:\Users\Satyendra\Vim\vimfiles\autoload\mmtoolbox\cmake.vim, line 219
My OS is Windows 10. How do I resolve this error?
(Posted on behalf of the OP).
I opened an issue on C-Support's Github page, and the problem was solved.

the troubles of rebuild apk

I always use apktool to decompiler the apk file ,and ,you known,some resources's name looks very strange, just like this: <attr name="do" format="string" />. when it's been decompilered.
the question is: when rebuild the folder which contains this resource file ,and then ,error occurs,the error message likes this:"error: invalid symbol: 'do'" or error: invalid symbol: 'if'.
of cause,I have read the source code of apktool ,and I found that these error messages are not throw by apktool,but throws by aapt when executes code: OS.exec(cmd.toArray(new String[0])); in package brut.androlib.res in it's AndroidLibResources.java file. So, I think the google has forgotten to handle these exceptions,because the words "if" and "do" are also the keywords of most popular programming language, and is there anybody has meet the same trouble with me? hope your(s) help.
This is a bug in aapt, which is why you see the error on that line in apktool. Basically symbols like do and if have special meaning. aapt should ignore that and treat them literally, but the validation is a bit too strong.
You may follow the AOSP Bug Report here.

emacs flycheck syntax checher for cpp file

I am using Emacs 24.3.1 to edit a .cpp file and when I activate M-x flycheck-mode, it shows the state being (C++/l FlyC- Abbrev), where FlyC- means it did not find a suitable syntax checker.
I can't see anything looking like a C++ checher in the list I get from flycheck-select-checker:
Possible completions are:
bash coffee-coffeelint css-csslint
emacs-lisp emacs-lisp-checkdoc go-build
go-gofmt go-test haml
html-tidy javascript-jshint json-jsonlint
lua perl php
php-phpcs python-flake8 python-pyflakes
python-pylint rst ruby
rust-rustc sass scss
sh tex-chktex tex-lacheck
xml-xmlstarlet zsh
Any ideas what might be missing?
I have both c/c++-clang and c/c++-cppcheck when I run flycheck-select-checker. Perhaps you're using an out of date flycheck?

Can i go to the error after executing make in VIM?

Can i go to the line of error , while compiling a C or C++ project ? Usually by executing make , and parse the error string , and go to the specific file , and the line with errors.
Is there already an usable plugin ?
Yeah this is already buit into vim. After typing :make type :cwindow to bring up the error list. You can then navigate to the errors using this window.
You can as well after :mak or :make do :cope to open the window with compiler output and once you are done :clo to close it.
Use :cn and :cp for jumping to next and previous error or when you are in the window go to line that has the error with file name, line & column and press enter to jump there.
IIRC, this functionality is built into vim. A quick google search revealed this useful link. This describes vim's features for navigating the errors after a make.