home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 5 Edit / 05-Edit.zip / vim45os2.zip / vim-4.5 / tools / efm_filt.er next >
INI File  |  1996-10-07  |  2KB  |  72 lines

  1. [adopted from a message that Ives posted in the Vim mailing list]
  2.  
  3. Some compilers produce an error message that cannot be handled with
  4. 'errorformat' in Vim.  Following is an example of a Perl script that
  5. translates one error message into something that Vim understands.
  6.  
  7.  
  8. The compiler that generates this kind of error messages (4 lines):
  9.  
  10. "/tmp_mnt/cm/src/apertos/MoU/MetaCore/MetaCore/common/src/MetaCoreImp_M.cc",
  11. line 50: error(3114):
  12.            identifier "PRIMITIVE_M" is undefined
  13.          return(ExecuteCore(PRIMITIVE_M,
  14.  
  15. You can find a small perl program at the end.
  16. The way I use it is:
  17.  
  18. :set   errorformat=%f>%l:%c:%t:%n:%m
  19. :set   makeprg=clearmake\ -C\ gnu
  20. :set   shellpipe=2>&1\|\ vimccparse
  21.  
  22. If somebody thinks this is useful: feel free to do whatever you can think
  23. of with this code.
  24.  
  25. -Ives
  26. ____________________________________________________________
  27. Ives Aerts (SW Developer)           Sony Telecom Europe
  28. ives@sonytel.be                     St.Stevens Woluwestr. 55
  29. `Death could create most things,    B-1130 Brussels, Belgium
  30.  except for plumbing.'              PHONE : +32 2 724 19 67
  31.          (Soul Music - T.Pratchett) FAX   : +32 2 726 26 86
  32.  
  33. #!/usr/gnu/bin/perl
  34. #
  35. # This program works as a filter that reads from stdin, copies to
  36. # stdout *and* creates an error file that can be read by vim.
  37. #
  38. # This program has only been tested on SGI, Irix5.3.
  39. #
  40. # Written by Ives Aerts in 1996. This little program is not guaranteed
  41. # to do (or not do) anything at all and can be freely used for
  42. # whatever purpose you can think of.
  43.  
  44. $args = @ARGV;
  45.  
  46. unless ($args == 1) {
  47.   die("Usage: vimccparse <output filename>\n");
  48. }
  49.  
  50. $filename = @ARGV[0];
  51. open (OUT, ">$filename") || die ("Can't open file: \"$filename\"");
  52.  
  53. while (<STDIN>) {
  54.   print;
  55.   if (   (/"(.*)", line (\d+): (e)rror\((\d+)\):/)
  56.       || (/"(.*)", line (\d+): (w)arning\((\d+)\):/) ) {
  57.     $file=$1;
  58.     $line=$2;
  59.     $errortype="\u$3";
  60.     $errornr=$4;
  61.     chop($errormsg=<STDIN>);
  62.     $errormsg =~ s/^\s*//;
  63.     $sourceline=<STDIN>;
  64.     $column=index(<STDIN>, "^") - 1;
  65.  
  66.     print OUT "$file>$line:$column:$errortype:$errornr:$errormsg\n";
  67.   }
  68. }
  69.  
  70. close(OUT);
  71. exit(0);
  72.