comparison lisp/progmodes/verilog-mode.el @ 103734:503d12c87acd

(verilog-error-regexp-emacs-alist): Coded custom representation of verilog error regular expressions to work with Emacs-22's new format. (verilog-error-regexp-xemacs-alist): Coded custom representation of verilog error regular expressions to work with XEmacs format (verilog-error-regexp-add-xemacs): Hook routine to install verilog error recognition into XEmacs. (verilog-error-regexp-add-emacs): Hook routine to install verilog error recognition into Emacs-22.
author Dan Nicolaescu <dann@ics.uci.edu>
date Mon, 06 Jul 2009 08:32:48 +0000
parents af77bf73dfe0
children 60489d78df5a
comparison
equal deleted inserted replaced
103733:c7fd75d1d71e 103734:503d12c87acd
116 ;; (This section is required to appease checkdoc.) 116 ;; (This section is required to appease checkdoc.)
117 117
118 ;;; Code: 118 ;;; Code:
119 119
120 ;; This variable will always hold the version number of the mode 120 ;; This variable will always hold the version number of the mode
121 (defconst verilog-mode-version "520" 121 (defconst verilog-mode-version "525"
122 "Version of this Verilog mode.") 122 "Version of this Verilog mode.")
123 (defconst verilog-mode-release-date "2009-06-12-GNU" 123 (defconst verilog-mode-release-date "2009-07-02-GNU"
124 "Release date of this Verilog mode.") 124 "Release date of this Verilog mode.")
125 (defconst verilog-mode-release-emacs t 125 (defconst verilog-mode-release-emacs t
126 "If non-nil, this version of Verilog mode was released with Emacs itself.") 126 "If non-nil, this version of Verilog mode was released with Emacs itself.")
127 127
128 (defun verilog-version () 128 (defun verilog-version ()
625 "Modification tick at which autos were last performed.") 625 "Modification tick at which autos were last performed.")
626 626
627 (defvar verilog-auto-last-file-locals nil 627 (defvar verilog-auto-last-file-locals nil
628 "Text from file-local-variables during last evaluation.") 628 "Text from file-local-variables during last evaluation.")
629 629
630 (defvar verilog-error-regexp-add-didit nil)
631 (defvar verilog-error-regexp nil)
632 ;;; Compile support 630 ;;; Compile support
633 (require 'compile) 631 (require 'compile)
634 (make-variable-buffer-local 'compilation-error-regexp-systems-list) 632 (defvar verilog-error-regexp-added nil)
635 (defvar compilation-error-regexp-alist) ; in case not
636 (make-variable-buffer-local 'compilation-error-regexp-alist)
637
638 ; List of regexps for Verilog compilers, like verilint. See compilation-error-regexp-alist 633 ; List of regexps for Verilog compilers, like verilint. See compilation-error-regexp-alist
639 ; for the formatting. 634 ; for the formatting.
640 (defvar verilog-error-regexp-alist 635 ; Here is the version for Emacs 22:
641 '(verilog 636 (defvar verilog-error-regexp-emacs-alist
642 ; SureLint 637 '(
643 ("[^\n]*\\[\\([^:]+\\):\\([0-9]+\\)\\]" 1 2) 638 (verilog-xl-1
644 ("\\(WARNING\\|ERROR\\|INFO\\)[^:]*: \\([^,]+\\), \\(line \\|\\)\\([0-9]+\\):" 2 4 ) 639 "\\(Error\\|Warning\\)!.*\n?.*\"\\([^\"]+\\)\", \\([0-9]+\\)" 2 3)
645 ("\ 640 (verilog-xl-2
641 "([WE][0-9A-Z]+)[ \t]+\\([^ \t\n,]+\\)[, \t]+\\(line[ \t]+\\)?\\([0-9]+\\):.*$" 1 3)
642 (verilog-IES
643 ".*\\*[WE],[0-9A-Z]+ (\\([^ \t,]+\\),\\([0-9]+\\)" 1 2)
644 (verilog-surefire-1
645 "[^\n]*\\[\\([^:]+\\):\\([0-9]+\\)\\]" 1 2)
646 (verilog-surefire-2
647 "\\(WARNING\\|ERROR\\|INFO\\)[^:]*: \\([^,]+\\),\\s-+\\(line \\)?\\([0-9]+\\):" 2 4 )
648 (verilog-verbose
649 "\
650 \\([a-zA-Z]?:?[^:( \t\n]+\\)[:(][ \t]*\\([0-9]+\\)\\([) \t]\\|\
651 :\\([^0-9\n]\\|\\([0-9]+:\\)\\)\\)" 1 2 5)
652 (verilog-xsim
653 "\\(Error\\|Warning\\).*in file (\\([^ \t]+\\) at line *\\([0-9]+\\))" 2 3)
654 (verilog-vcs-1
655 "\\(Error\\|Warning\\):[^(]*(\\([^ \t]+\\) line *\\([0-9]+\\))" 2 3)
656 (verilog-vcs-2
657 "Warning:.*(port.*(\\([^ \t]+\\) line \\([0-9]+\\))" 1 2)
658 (verilog-vcs-3
659 "\\(Error\\|Warning\\):[\n.]*\\([^ \t]+\\) *\\([0-9]+\\):" 2 3)
660 (verilog-vcs-4
661 "syntax error:.*\n\\([^ \t]+\\) *\\([0-9]+\\):" 1 2)
662 (verilog-verilator
663 "%?\\(Error\\|Warning\\)\\(-[^:]+\\|\\):[\n ]*\\([^ \t:]+\\):\\([0-9]+\\):" 3 4)
664 (verilog-leda
665 "In file \\([^ \t]+\\)[ \t]+line[ \t]+\\([0-9]+\\):
666 .*
667 .*
668 .*
669 \\(Warning\\|Error\\|Failure\\)" 1 2)
670 ))
671 ;; And the version for XEmacs:
672 (defvar verilog-error-regexp-xemacs-alist
673 '(verilog
674 ("[^\n]*\\[\\([^:]+\\):\\([0-9]+\\)\\]" 1 2)
675 ("\\(WARNING\\|ERROR\\|INFO\\)[^:]*: \\([^,]+\\),\\s-+\\(line \\)?\\([0-9]+\\):" 2 4 )
676 ("\
646 \\([a-zA-Z]?:?[^:( \t\n]+\\)[:(][ \t]*\\([0-9]+\\)\\([) \t]\\|\ 677 \\([a-zA-Z]?:?[^:( \t\n]+\\)[:(][ \t]*\\([0-9]+\\)\\([) \t]\\|\
647 :\\([^0-9\n]\\|\\([0-9]+:\\)\\)\\)" 1 2 5) 678 :\\([^0-9\n]\\|\\([0-9]+:\\)\\)\\)" 1 2 5)
648 ; xsim 679 ; xsim
649 ; Error! in file /homes/mac/Axis/Xsim/test.v at line 13 [OBJ_NOT_DECLARED] 680 ; Error! in file /homes/mac/Axis/Xsim/test.v at line 13 [OBJ_NOT_DECLARED]
650 ("\\(Error\\|Warning\\).*in file (\\([^ \t]+\\) at line *\\([0-9]+\\))" 2 3) 681 ("\\(Error\\|Warning\\).*in file (\\([^ \t]+\\) at line *\\([0-9]+\\))" 2 3)
651 ; vcs 682 ; vcs
652 ("\\(Error\\|Warning\\):[^(]*(\\([^ \t]+\\) line *\\([0-9]+\\))" 2 3) 683 ("\\(Error\\|Warning\\):[^(]*(\\([^ \t]+\\) line *\\([0-9]+\\))" 2 3)
653 ("Warning:.*(port.*(\\([^ \t]+\\) line \\([0-9]+\\))" 1 2) 684 ("Warning:.*(port.*(\\([^ \t]+\\) line \\([0-9]+\\))" 1 2)
654 ("\\(Error\\|Warning\\):[\n.]*\\([^ \t]+\\) *\\([0-9]+\\):" 2 3) 685 ("\\(Error\\|Warning\\):[\n.]*\\([^ \t]+\\) *\\([0-9]+\\):" 2 3)
655 ("syntax error:.*\n\\([^ \t]+\\) *\\([0-9]+\\):" 1 2) 686 ("syntax error:.*\n\\([^ \t]+\\) *\\([0-9]+\\):" 1 2)
656 ; Verilator 687 ; Verilator
657 ("%?\\(Error\\|Warning\\)\\(-[^:]+\\|\\):[\n ]*\\([^ \t:]+\\):\\([0-9]+\\):" 3 4) 688 ("%?\\(Error\\|Warning\\)\\(-[^:]+\\|\\):[\n ]*\\([^ \t:]+\\):\\([0-9]+\\):" 3 4)
658 ("%?\\(Error\\|Warning\\)\\(-[^:]+\\|\\):[\n ]*\\([^ \t:]+\\):\\([0-9]+\\):" 3 4)
659 ; verilog-xl 689 ; verilog-xl
660 ("\\(Error\\|Warning\\)!.*\n?.*\"\\([^\"]+\\)\", \\([0-9]+\\)" 2 3) 690 ("\\(Error\\|Warning\\)!.*\n?.*\"\\([^\"]+\\)\", \\([0-9]+\\)" 2 3)
661 ("([WE][0-9A-Z]+)[ \t]+\\([^ \t\n,]+\\)[, \t]+\\([0-9]+\\):.*$" 1 2) ; vxl 691 ("([WE][0-9A-Z]+)[ \t]+\\([^ \t\n,]+\\)[, \t]+\\([0-9]+\\):.*$" 1 2) ; vxl
662 ("([WE][0-9A-Z]+)[ \t]+\\([^ \t\n,]+\\)[, \t]+line[ \t]+\\([0-9]+\\):.*$" 1 2) 692 ("([WE][0-9A-Z]+)[ \t]+\\([^ \t\n,]+\\)[, \t]+line[ \t]+\\([0-9]+\\):.*$" 1 2)
663 ; nc-verilog 693 ; nc-verilog
664 (".*\\*[WE],[0-9A-Z]+ (\\([^ \t,]+\\),\\([0-9]+\\)|" 1 2) 694 (".*\\*[WE],[0-9A-Z]+ (\\([^ \t,]+\\),\\([0-9]+\\)|" 1 2)
665 ; Leda 695 ; Leda
666 ("In file \\([^ \t]+\\)[ \t]+line[ \t]+\\([0-9]+\\):\n[^\n]*\n[^\n]*\n\\[\\(Warning\\|Error\\|Failure\\)\\][^\n]*" 1 2) 696 ("In file \\([^ \t]+\\)[ \t]+line[ \t]+\\([0-9]+\\):\n[^\n]*\n[^\n]*\n\\[\\(Warning\\|Error\\|Failure\\)\\][^\n]*" 1 2)
667 )) 697 )
698 )
668 699
669 (defvar verilog-error-font-lock-keywords 700 (defvar verilog-error-font-lock-keywords
670 '( 701 '(
671 ("[^\n]*\\[\\([^:]+\\):\\([0-9]+\\)\\]" 1 bold t) 702 ("[^\n]*\\[\\([^:]+\\):\\([0-9]+\\)\\]" 1 bold t)
672 ("[^\n]*\\[\\([^:]+\\):\\([0-9]+\\)\\]" 2 bold t) 703 ("[^\n]*\\[\\([^:]+\\):\\([0-9]+\\)\\]" 2 bold t)
673 704
674 ("\\(WARNING\\|ERROR\\|INFO\\): \\([^,]+\\), line \\([0-9]+\\):" 2 bold t) 705 ("\\(WARNING\\|ERROR\\|INFO\\): \\([^,]+\\), line \\([0-9]+\\):" 2 bold t)
675 ("\\(WARNING\\|ERROR\\|INFO\\): \\([^,]+\\), line \\([0-9]+\\):" 3 bold t) 706 ("\\(WARNING\\|ERROR\\|INFO\\): \\([^,]+\\), line \\([0-9]+\\):" 3 bold t)
676 707
677 ("\ 708 ("\
678 \\([a-zA-Z]?:?[^:( \t\n]+\\)[:(][ \t]*\\([0-9]+\\)\\([) \t]\\|\ 709 \\([a-zA-Z]?:?[^:( \t\n]+\\)[:(][ \t]*\\([0-9]+\\)\\([) \t]\\|\
1422 (verilog-string-replace-matches 1453 (verilog-string-replace-matches
1423 "\\b__FILE__\\b" (file-name-nondirectory (buffer-file-name)) 1454 "\\b__FILE__\\b" (file-name-nondirectory (buffer-file-name))
1424 t t compile-command)))) 1455 t t compile-command))))
1425 1456
1426 ;; Following code only gets called from compilation-mode-hook on XEmacs to add error handling. 1457 ;; Following code only gets called from compilation-mode-hook on XEmacs to add error handling.
1427 ;; There is no way to add this on the fly to Emacs; instead we must update compile.el 1458 (defun verilog-error-regexp-add-xemacs ()
1428 (if (featurep 'xemacs) 1459 "Teach XEmacs about verilog errors.
1429 (defun verilog-error-regexp-add-xemacs ()
1430 "Teach XEmacs about verilog errors.
1431 Called by `compilation-mode-hook'. This allows \\[next-error] to 1460 Called by `compilation-mode-hook'. This allows \\[next-error] to
1432 find the errors." 1461 find the errors."
1433 (interactive) 1462 (interactive)
1434 (if 't ; (not verilog-error-regexp-add-didit) 1463 (if (boundp 'compilation-error-regexp-systems-alist)
1435 (progn 1464 (if (and
1436 (if (or (equal compilation-error-regexp-systems-list 'all) 1465 (not (equal compilation-error-regexp-systems-list 'all))
1437 (not (member 'verilog compilation-error-regexp-systems-list))) 1466 (not (member compilation-error-regexp-systems-list 'verilog)))
1438 (setq compilation-error-regexp-systems-list 1467 (push 'verilog compilation-error-regexp-systems-list)))
1439 (if (listp compilation-error-regexp-systems-list) 1468 (if (boundp 'compilation-error-regexp-alist-alist)
1440 (nconc compilation-error-regexp-systems-list 'verilog) 1469 (if (not (assoc 'verilog compilation-error-regexp-alist-alist))
1441 'verilog))) 1470 (setcdr compilation-error-regexp-alist-alist
1442 (if (not (assoc 'verilog compilation-error-regexp-alist-alist)) 1471 (cons verilog-error-regexp-xemacs-alist
1443 (setcdr compilation-error-regexp-alist-alist 1472 (cdr compilation-error-regexp-alist-alist)))))
1444 (cons verilog-error-regexp-alist 1473 (if (boundp 'compilation-font-lock-keywords)
1445 (cdr compilation-error-regexp-alist-alist)))) 1474 (progn
1446 ;; Need to re-run compilation-error-regexp builder 1475 (make-variable-buffer-local 'compilation-font-lock-keywords)
1447 (compilation-build-compilation-error-regexp-alist)))) 1476 (setq compilation-font-lock-keywords verilog-error-font-lock-keywords)
1477 (font-lock-set-defaults)))
1478 ;; Need to re-run compilation-error-regexp builder
1479 (if (fboundp 'compilation-build-compilation-error-regexp-alist)
1480 (compilation-build-compilation-error-regexp-alist))
1448 ) 1481 )
1482
1483 ;; Following code only gets called from compilation-mode-hook on Emacs to add error handling.
1449 (defun verilog-error-regexp-add-emacs () 1484 (defun verilog-error-regexp-add-emacs ()
1450 "Tell Emacs compile that we are Verilog. 1485 "Tell Emacs compile that we are Verilog.
1451 Called by `compilation-mode-hook'. This allows \\[next-error] to 1486 Called by `compilation-mode-hook'. This allows \\[next-error] to
1452 find the errors." 1487 find the errors."
1453 (interactive) 1488 (interactive)
1454 ;; Turned off because there seems no way to do this outside of compile.el 1489 (if (boundp 'compilation-error-regexp-alist-alist)
1455 ;; 1490 (progn
1456 ;; (if (or (equal compilation-error-regexp-alist 'all) 1491 (if (not (assoc 'verilog-xl-1 compilation-error-regexp-alist-alist))
1457 ;; (not (member 'verilog compilation-error-regexp-alist))) 1492 (mapcar
1458 ;; (setq compilation-error-regexp-alist 1493 (lambda (item)
1459 ;; (if (listp compilation-error-regexp-alist) 1494 (push (car item) compilation-error-regexp-alist)
1460 ;; (append '(verilog) compilation-error-regexp-alist) 1495 (push item compilation-error-regexp-alist-alist)
1461 ;; '(verilog) ))) 1496 )
1462 ) 1497 verilog-error-regexp-emacs-alist)))))
1463 1498
1464 (if (featurep 'xemacs) 1499 (if (featurep 'xemacs) (add-hook 'compilation-mode-hook 'verilog-error-regexp-add-xemacs))
1465 (add-hook 'compilation-mode-hook 'verilog-error-regexp-add-xemacs) 1500 (if (featurep 'emacs) (add-hook 'compilation-mode-hook 'verilog-error-regexp-add-emacs))
1466 (add-hook 'compilation-mode-hook 'verilog-error-regexp-add-emacs))
1467 1501
1468 (defconst verilog-directive-re 1502 (defconst verilog-directive-re
1469 ;; "`case" "`default" "`define" "`define" "`else" "`endfor" "`endif" 1503 ;; "`case" "`default" "`define" "`define" "`else" "`endfor" "`endif"
1470 ;; "`endprotect" "`endswitch" "`endwhile" "`for" "`format" "`if" "`ifdef" 1504 ;; "`endprotect" "`endswitch" "`endwhile" "`for" "`format" "`if" "`ifdef"
1471 ;; "`ifndef" "`include" "`let" "`protect" "`switch" "`timescale" 1505 ;; "`ifndef" "`include" "`let" "`protect" "`switch" "`timescale"