From xemacs-m  Mon Mar 10 20:08:15 1997
Received: from greatdane.webnexus.com (greatdane.webnexus.com [165.227.96.3])
	by xemacs.org (8.8.5/8.8.5) with ESMTP id UAA04738
	for <xemacs-beta@xemacs.org>; Mon, 10 Mar 1997 20:08:13 -0600 (CST)
Received: from apprentice.silicon-sorcery.com (apprentice.silicon-sorcery.com [205.179.145.161])
	by greatdane.webnexus.com (8.8.5/8.8.5/WN-1.2) with ESMTP id SAA29310;
	Mon, 10 Mar 1997 18:08:09 -0800 (PST)
Received: from mage.silicon-sorcery.com (mage [128.0.0.100]) by apprentice.silicon-sorcery.com (8.7.5/8.7.3) with SMTP id SAA01972; Mon, 10 Mar 1997 18:05:38 -0800 (PST)
From: mac@silicon-sorcery.com
Received: by mage.silicon-sorcery.com (4.1/SMI-4.1)
	id AA20578; Mon, 10 Mar 97 18:06:22 PST
Date: Mon, 10 Mar 97 18:06:22 PST
Message-Id: <9703110206.AA20578@mage.silicon-sorcery.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
To: David Moore <dmoore@ucsd.edu>
Cc: XEmacs Beta Mailing List <xemacs-beta@xemacs.org>
Subject: Re: b98 FAILURE
In-Reply-To: <rvzpwb9sg9.fsf@sdnp5.ucsd.edu>
References: <199703101942.OAA08804@verve.canada.sun.com>
	<rvzpwb9sg9.fsf@sdnp5.ucsd.edu>
Reply-To: mac@silicon-sorcery.com


David Moore writes:
 > Georg Nikodym <georgn@Canada.Sun.COM> writes:
 > 
 > > Incidentally, were any of the recent regexp fixes supposed to fix the
 > > parsing of error messages in compile.el?  The above build took place
 > > in b97 and it spun for about 5 minutes before I could regain control
 > > parsing error messages just because I made the unfortunate mistake of
 > > passing my mouse over the compilation buffer (shoot me).
 > 
 > It's about twice as fast as it used to be.  However, the regexps are
 > totally out of control.  If you want it to go faster, I strongly
 > recommend manually changing the regexp to just have forms generated by
 > your compilers.  It's trying to match error messages from many different
 > systems, and a lot of those patterns take a long time to match.
 > 
 > This might be a nice customize option, to be able to click on/off items
 > from the current set of regexps, in addition to allowing them to add
 > their own or replace the whole thing.
 > 
 > I think I managed to get gcc & solaris cc output down to being another
 > 3-5 times faster than it is currently, by limiting the regexps to just
 > the ones which match those compilers.
 > 

In this vein (I too have been bored to tears waiting for parsing of
error messages to complete; usually when I'm trying to show so newbie
the wonderous ways of Xemacs... *sigh*) I contribute an adaptive
compilation-error-regexp-alist builder based on xemacs-19.15-b98,
included below.

One of the powers that be needs to decide where (or if!) to
incorporate this, and how.  Basically, I just set the list of 
error generators (-: I use, and byte compile & load this.  

[ Note also that I've added a line to recognize bison's output.]

(defun set-compile-env ()
  "Set up compile regexp based on tools actually in use; based on:

Alist that specifies how to match errors in compiler output.
Each elt has the form (REGEXP FILE-IDX LINE-IDX [COLUMN-IDX FILE-FORMAT...])
If REGEXP matches constrained to the beginning of the line, the
FILE-IDX'th subexpression gives the file name, and the LINE-IDX'th
subexpression gives the line number.  If COLUMN-IDX is given, the
COLUMN-IDX'th subexpression gives the column number on that line.  If
any FILE-FORMAT is given, each is a format string to produce a file name
to try; %s in the string is replaced by the text matching the
FILE-IDX'th subexpression.  Note previously REGEXP was not constrained
to the beginning of the line, so old patterns without leading `^' or `\\n'
may now require a leading `.*'."
  (interactive)
  (let (
	(a nil)				; accumulator

	(gnu     t)			; but of course
	(lcc     nil)			; Lucid compilers
	(ada     nil)			; Ada compilers
	(of      nil)			; Using tool that says line xx of foo.c
	(comma   nil)			; Using tool that says "foo.c", line 12
	(4bsd    nil)			; Using 4bsd
	(msft    nil)			; Using microsoft
	(borland nil)			; Using Borland
	(mips    nil)			; Using Mips
	(sgi     nil)			; Using SGI
	(cray    nil)			; Using cray
	(ibm     nil)			; IBM C compilers
	(aix     nil)			; the operating system
	(ultrix  nil)			; the operating system
	)
    
	;; NOTE!  See also grep-regexp-alist, below.
	(if 4bsd 
	    (setq a (append '(
			      ;; 4.3BSD grep, cc, lint pass 1:
			      ;; 	/usr/src/foo/foo.c(8): warning: w may be used before set
			      ;; or GNU utilities:
			      ;; 	foo.c:8: error message
			      ;; or HP-UX 7.0 fc:
			      ;; 	foo.f          :16    some horrible error message
			      ;; or GNU utilities with column (GNAT 1.82):
			      ;;   foo.adb:2:1: Unit name does not match file name
			      ;; 
			      ;; We'll insist that the number be followed by a colon or closing
			      ;; paren, because otherwise this matches just about anything
			      ;; containing a number with spaces around it.
			      ("\
\\([a-zA-Z]?:?[^:( \t\n]+\\)[:(][ \t]*\\([0-9]+\\)\\([) \t]\\|\
:\\([^0-9\n]\\|\\([0-9]+:\\)\\)\\)" 1 2 5)
			      ;; 4.3BSD lint pass 2
			      ;; 	strcmp: variable # of args. llib-lc(359)  ::  /usr/src/foo/foo.c(8)
			      ("[^\n]*[ \t:]\\([a-zA-Z]?:?[^:( \t\n]+\\)[:(](+[ \t]*\\([0-9]+\\))[:) \t]*$" 1 2)
			      ;; 4.3BSD lint pass 3
			      ;; 	bloofle defined( /users/wolfgang/foo.c(4) ), but never used
			      ;; This used to be
			      ;; ("[ \t(]+\\([a-zA-Z]?:?[^:( \t\n]+\\)[:( \t]+\\([0-9]+\\)[:) \t]+" 1 2)
			      ;; which is regexp Impressionism - it matches almost anything!
			      ("[^\n]*([ \t]*\\([a-zA-Z]?:?[^:( \t\n]+\\)[:(][ \t]*\\([0-9]+\\))" 1 2)
			      ) a)))
	(if msft
	    ;; Microsoft C/C++:
	    ;;  keyboard.c(537) : warning C4005: 'min' : macro redefinition
	    ;;  d:\tmp\test.c(23) : error C2143: syntax error : missing ';' before 'if'
	    (setq a (cons '("\\(\\([a-zA-Z]:\\)?[^:( \t\n-]+\\)[:(][ \t]*\\([0-9]+\\)[:) \t]" 1 3) a))
	  )

	(if borland
	    ;; Borland C++:
	    ;;  Error ping.c 15: Unable to open include file 'sys/types.h'
	    ;;  Warning ping.c 68: Call to function 'func' with no prototype
	    (setq a (cons '("\\(Error\\|Warning\\) \\([a-zA-Z]?:?[^:( \t\n]+\\)\
 \\([0-9]+\\)\\([) \t]\\|:[^0-9\n]\\)" 2 3) a)))
	(if mips
	    (setq a 
		  (append 
		   '(
		     ;; MIPS lint pass<n>; looks good for SunPro lint also
		     ;;  TrimMask (255) in solomon.c may be indistinguishable from TrimMasks (93) in solomon.c due to truncation
		     ("[^ \n]+ (\\([0-9]+\\)) in \\([^ \n]+\\)" 2 1)
		     ;;  name defined but never used: LinInt in cmap_calc.c(199)
		     ("[^\n]*in \\([^(\n]+\\)(\\([0-9]+\\))$" 1 2)) a)))
	(if (or sgi ultrix)
	    ;; Ultrix 3.0 f77:
	    ;;  fort: Severe: addstf.f, line 82: Missing operator or delimiter symbol
	    ;; Some SGI cc version:
	    ;;  cfe: Warning 835: foo.c, line 2: something
	    (setq a (cons '("\\(cfe\\|fort\\): [^:\n]*: \\([^ \n]*\\), line \\([0-9]+\\):" 2 3) a)))
	(if of
	    ;;  Error on line 3 of t.f: Execution error unclassifiable statement    
	    ;; Unknown who does this:
	    ;;  Line 45 of "foo.c": bloofle undefined
	    ;; Absoft FORTRAN 77 Compiler 3.1.3
	    ;;  error on line 19 of fplot.f: spelling error?
	    ;;  warning on line 17 of fplot.f: data type is undefined for variable d
	    (setq a (cons '("\\(\\|[^\n]* on \\)[Ll]ine[ \t]+\\([0-9]+\\)[ \t]+\
of[ \t]+\"?\\([a-zA-Z]?:?[^\":\n]+\\)\"?:" 3 2) a)))
	(if comma
	    ;; Apollo cc, 4.3BSD fc:
	    ;;	"foo.f", line 3: Error: syntax error near end of statement
	    ;; IBM RS6000:
	    ;;  "vvouch.c", line 19.5: 1506-046 (S) Syntax error.
	    ;; Unknown compiler:
	    ;;  File "foobar.ml", lines 5-8, characters 20-155: blah blah
	    ;; Microtec mcc68k:
	    ;;  "foo.c", line 32 pos 1; (E) syntax error; unexpected symbol: "lossage"
	    ;; GNAT (as of July 94): 
	    ;;  "foo.adb", line 2(11): warning: file name does not match ...
	    ;; IBM AIX xlc compiler:
	    ;;  "src/swapping.c", line 30.34: 1506-342 (W) "/*" detected in comment.
	    (setq a (cons '("[^\n]*\"\\([^,\" \n\t]+\\)\", lines? \
\\([0-9]+\\)\\([\(.]\\([0-9]+\\)\)?\\)?[:., (-]" 1 2 4) a)))
	(if (or mips ultrix)
	    ;; MIPS RISC CC - the one distributed with Ultrix:
	    ;;	ccom: Error: foo.c, line 2: syntax error
	    ;; DEC AXP OSF/1 cc
	    ;;  /usr/lib/cmplrs/cc/cfe: Error: foo.c: 1: blah blah 
	    (setq a (cons '("[^\n]*rror: \\([^,\" \n\t]+\\)[,:] \\(line \\)?\\([0-9]+\\):" 1 3) a)))
	(if aix
	    ;; IBM AIX PS/2 C version 1.1:
	    ;;	****** Error number 140 in line 8 of file errors.c ******
	    ;; IBM AIX lint is too painful to do right this way.  File name
	    ;; prefixes entire sections rather than being on each line.
	    (setq a (cons '("[^\n]*in line \\([0-9]+\\) of file \\([^ \n]+[^. \n]\\)\\.? " 2 1) a)))
	(if lcc
	    ;; Lucid Compiler, lcc 3.x
	    ;; E, file.cc(35,52) Illegal operation on pointers
	    (setq a (cons '("[EW], \\([^(\n]*\\)(\\([0-9]+\\),[ \t]*\\([0-9]+\\)" 1 2 3) a)))
	(if gnu
	    (setq a 
		  (append 
		   '(
		     ;; GNU messages with program name and optional column number.
		     ("[a-zA-Z]?:?[^0-9 \n\t:]+:[ \t]*\\([^ \n\t:]+\\):\
\\([0-9]+\\):\\(\\([0-9]+\\)[: \t]\\)?" 1 2 4)
		     ;; ("grammar.y", line 2162) error: symbol input_identfiers is used, but is not defined as a token and has no rules
		     ("\n\(\"\\([^\"]+\\)\", line \\([0-9]+\\)\) error:" 1 2)

		     ;; GNU messages with program name and optional column number
		     ;; and a severity letter after that.  nsgmls makes them.
		     ("[^0-9 \n\t:]+:[ \t]*\\([^ \n\t:]+\\):\
\\([0-9]+\\):\\(\\([0-9]+\\):\\)?[A-Za-z]:" 1 2 4)) a)))
	(if sgi
	    (setq a 
		  (append 
		   '(
		     ;; jwz:
		     ;; IRIX 5.2
		     ;; cfe: Warning 712: foo.c, line 2: illegal combination of pointer and ...
		     ("[^\n]* \\([^ \n,\"]+\\), line \\([0-9]+\\):" 1 2)
		     ;; IRIX 5.2
		     ;; cfe: Warning 600: xfe.c: 170: Not in a conditional directive while ...
		     ("[^\n]*: \\([^ \n,\"]+\\): \\([0-9]+\\):" 1 2))a)))
	(if cray
	    ;; Cray C compiler error messages
	    (setq a (cons '("\\(cc\\| cft\\)-[0-9]+ c\\(c\\|f77\\): ERROR \\([^,\n]+, \\)* File = \\([^,\n]+\\), Line = \\([0-9]+\\)" 4 5) a)))

	(if ibm
	    ;; IBM C/C++ Tools 2.01:
	    ;;  foo.c(2:0) : informational EDC0804: Function foo is not referenced.
	    ;;  foo.c(3:8) : warning EDC0833: Implicit return statement encountered.
	    ;;  foo.c(5:5) : error EDC0350: Syntax error.
	    (setq a (cons '("\\([^( \n\t]+\\)(\\([0-9]+\\):\\([0-9]+\\)) : " 1 2 3) a)))
	(if ada
	    ;; Sun ada (VADS, Solaris):
	    ;;  /home3/xdhar/rcds_rc/main.a, line 361, char 6:syntax error: "," inserted
	    (setq a (cons '("\\([^, \n\t]+\\), line \\([0-9]+\\), char \\([0-9]+\\)[:., \(-]" 1 2 3) a)))
	(setq compilation-error-regexp-alist a)
	)
  )

