22 May 2008

Emacs regex to grok csc compilation errors

People have asked about this.  This is the regular expression I use to allow emacs' next-error function to handle csc error messages.  It is included in the emacs.el that I published previously.  Here it is excerpted for convenience.

;; to allow next-error to work with csc.exe: 
(setq compilation-scroll-output t)
(setq-default compilation-error-regexp-alist
;       (append 
 '(
 ; Microsoft VJC:
 ;sample.java(6,1) : error J0020: Expected 'class' or 'interface'
 ("\\(\\([a-zA-Z]:\\)?[^:(\t\n]+\\)(\\([0-9]+\\)[,]\\([0-9]+\\)): \\(error\\|warning\\) VJS[0-9]+:" 1 3 4)

 ;; dinoch - Wed, 04 Aug 2004  09:29
 ;; handle whitespace at beginning of line (for nant output)
 ;; 
 ;C# Compiler
 ;t.cs(6,18): error SC1006: Name of constructor must match name of class
 ;
 ("[ \t]*\\(\\([_a-zA-Z:\]:\\)?[^:(\t\n]+\\)(\\([0-9]+\\)[,]\\([0-9]+\\)): \\(error\\|warning\\) CS[0-9]+:" 1 3 4)

 ; Microsoft C/C++:
 ;  keyboard.c(537) : warning C4005: 'min' : macro redefinition
 ;  d:\tmp\test.c(23) : error C2143: syntax error : missing ';' before 'if'
 ;VC EEi
 ;e:\projects\myce40\tok.h(85) : error C2236: unexpected 'class' '$S1'
 ;myc.cpp(14) : error C3149: 'class System::String' : illegal use of managed type 'String'; did you forget a '*'?
    ("\\(\\([a-zA-Z]:\\)?[^:(\t\n]+\\)(\\([0-9]+\\)) \
: \\(error\\|warning\\) C[0-9]+:" 1 3)
 )
;;  compilation-error-regexp-alist)
)

 

Filed under: ,
 

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

# Alex Ott said:

Had you send it to emacs-devel list? i think, that it will useful for other users of emacs ;-)

23 May 08 at 7:00 AM
# DotNetInterop said:

I didn't know there was an emacs-devel list?  I'll look for it.

23 May 08 at 5:07 PM
# mschaef said:

This is slick, but when I run msbuild on a solution, it recursively invokes build on each nested project with the recursive invocations in the directory containing the project file.  The net result is that the compiler output doesn't contain the full path from the root of the solution, and next-error can't find the files in the error message. Any thoughts on how to fix this?

Thanks,

Mike

19 January 09 at 8:15 PM
# DotNetInterop said:

Hmmmmmmm, no I don't.  Maybe there is an MSBuild option to NOT recurse, or to emit full paths, or something.  

09 February 09 at 7:42 PM

Leave a Comment

Comment Policy: No HTML allowed. URIs and line breaks are converted automatically. Your e–mail address will not show up on any public page.

(required) 
(optional)
(required) 

  
Enter Code Here: Required
Page view tracker