File: anomaly-traces-parser.el

package info (click to toggle)
coq 8.6-4
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 26,884 kB
  • sloc: ml: 183,693; ansic: 1,858; lisp: 1,425; sh: 1,138; makefile: 713; xml: 24; sed: 2
file content (28 lines) | stat: -rw-r--r-- 1,320 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
;; This Elisp snippet adds a regexp parser for the format of Anomaly
;; backtraces (coqc -bt ...), to the error parser of the Compilation
;; mode (C-c C-c: "Compile command: ..."). Once the
;; coq-change-error-alist-for-backtraces function has run, file
;; locations in traces are recognized and can be jumped from easily
;; from the *compilation* buffer.

;; You can just copy everything below to your .emacs and this will be
;; enabled from any compilation command launched from an OCaml file.

(defun coq-change-error-alist-for-backtraces ()
  "Hook to change the compilation-error-regexp-alist variable, to
   search the coq backtraces for error locations"
  (interactive)
  (add-to-list
   'compilation-error-regexp-alist-alist
   '(coq-backtrace
     "^ *\\(?:raise\\|frame\\) @ file \\(\"?\\)\\([^,\" \n\t<>]+\\)\\1,\
      lines? \\([0-9]+\\)-?\\([0-9]+\\)?\\(?:$\\|,\
      \\(?: characters? \\([0-9]+\\)-?\\([0-9]+\\)?:?\\)?\\)"
     2 (3 . 4) (5 . 6)))
  (add-to-list 'compilation-error-regexp-alist 'coq-backtrace))

;; this Anomaly parser should be available when one is hacking
;; on the *OCaml* code of Coq (adding bugs), so we enable it
;; through the OCaml mode hooks.
(add-hook 'caml-mode-hook 'coq-change-error-alist-for-backtraces)
(add-hook 'tuareg-mode-hook 'coq-change-error-alist-for-backtraces)