[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/caml 5231413 02/10: Update the regexp for OCaml errors
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/caml 5231413 02/10: Update the regexp for OCaml errors |
Date: |
Wed, 25 Aug 2021 02:57:18 -0400 (EDT) |
branch: elpa/caml
commit 523141321667fc46caa018a5e8f6e202b3b0c428
Author: Christophe Troestler <Christophe.Troestler@umons.ac.be>
Commit: Christophe Troestler <Christophe.Troestler@umons.ac.be>
Update the regexp for OCaml errors
Fixes https://github.com/ocaml/caml-mode/issues/5
---
caml.el | 85 ++++++++++++++++++++++++++++++++++-------------------------------
1 file changed, 45 insertions(+), 40 deletions(-)
diff --git a/caml.el b/caml.el
index 4494ced..b8f1196 100644
--- a/caml.el
+++ b/caml.el
@@ -758,46 +758,51 @@ variable `caml-mode-indentation'."
(require 'compile)
-;; In Emacs 19, the regexps in compilation-error-regexp-alist do not
-;; match the error messages when the language is not English.
-;; Hence we add a regexp.
-;; FIXME do we (still) have i18n of error messages ???
-
-(defconst caml-error-regexp
- "^[ A-\377]+ \"\\([^\"\n]+\\)\", [A-\377]+ \\([0-9]+\\)[-,:]"
- "Regular expression matching the error messages produced by ocamlc.")
-
-;; Newer emacs versions support line/char ranges
-;; We will adapt OCaml to output error messages in a compatible format.
-;; In the meantime we add new formats here in addition to the old one.
-(defconst caml-error-regexp-newstyle
- (concat "^[ A-\377]+ \"\\([^\"\n]+\\)\", line \\([0-9]+\\),"
- "char \\([0-9]+\\) to line \\([0-9]+\\), char \\([0-9]+\\):")
- "Regular expression matching the error messages produced by
ocamlc/ocamlopt.")
-
-(defconst caml-error-regexp-new-newstyle
- (concat "^[ A-\377]+ \"\\([^\"\n]+\\)\", line \\([0-9]+\\), "
- "characters \\([0-9]+\\)-\\([0-9]+\\):")
- "Regular expression matching the error messages produced by
ocamlc/ocamlopt.")
-
-
-(if (boundp 'compilation-error-regexp-alist)
- (progn
- (or (assoc caml-error-regexp
- compilation-error-regexp-alist)
- (setq compilation-error-regexp-alist
- (cons (list caml-error-regexp 1 2)
- compilation-error-regexp-alist)))
- (or (assoc caml-error-regexp-newstyle
- compilation-error-regexp-alist)
- (setq compilation-error-regexp-alist
- (cons (list caml-error-regexp-newstyle 1 '(2 . 4) '(3 . 5))
- compilation-error-regexp-alist)))
- (or (assoc caml-error-regexp-new-newstyle
- compilation-error-regexp-alist)
- (setq compilation-error-regexp-alist
- (cons (list caml-error-regexp-new-newstyle 1 2 '(3 . 4))
- compilation-error-regexp-alist)))))
+(defconst caml--error-regexp
+ (rx bol
+ (* " ")
+ (group ; 1: HIGHLIGHT
+ (or "File "
+ ;; Exception backtrace.
+ (seq
+ (or "Raised at" "Re-raised at" "Raised by primitive operation at"
+ "Called from")
+ (* nonl) ; OCaml ≥4.11: " FUNCTION in"
+ " file "))
+ (group (? "\"")) ; 2
+ (group (+ (not (in "\t\n \",<>")))) ; 3: FILE
+ (backref 2)
+ (? " (inlined)")
+ ", line" (? "s") " "
+ (group (+ (in "0-9"))) ; 4: LINE-START
+ (? "-" (group (+ (in "0-9")))) ; 5; LINE-END
+ (? ", character" (? "s") " "
+ (group (+ (in "0-9"))) ; 6: COL-START
+ (? "-" (group (+ (in "0-9"))))) ; 7: COL-END
+ ;; Colon not present in backtraces.
+ (? ":"))
+ (? "\n"
+ (* (in "\t "))
+ (* (or (seq (+ (in "0-9"))
+ " | "
+ (* nonl))
+ (+ "^"))
+ "\n"
+ (* (in "\t ")))
+ (group "Warning" ; 8: WARNING
+ (? " " (+ (in "0-9")))
+ (? " [" (+ (in "a-z0-9-")) "]")
+ ":")))
+ "Regular expression matching the error messages produced by ocamlc/ocamlopt.
+Also matches source references in exception backtraces.")
+
+(when (boundp 'compilation-error-regexp-alist-alist)
+ (push `(ocaml ,caml--error-regexp 3 (4 . 5) (6 . tuareg--end-column) (8) 1
+ (8 font-lock-function-name-face))
+ compilation-error-regexp-alist-alist))
+
+(when (boundp 'compilation-error-regexp-alist)
+ (push 'ocaml compilation-error-regexp-alist))
;; A regexp to extract the range info
- [nongnu] elpa/caml updated (ab175f6 -> 3b6913e), ELPA Syncer, 2021/08/25
- [nongnu] elpa/caml 6b24877 06/10: Fix the warning “‘view-mode-exit’ is not known to be defined”, ELPA Syncer, 2021/08/25
- [nongnu] elpa/caml 742a910 01/10: Get the synopsis from caml.el, ELPA Syncer, 2021/08/25
- [nongnu] elpa/caml 3b6913e 10/10: Improve the instructions to install, ELPA Syncer, 2021/08/25
- [nongnu] elpa/caml 5231413 02/10: Update the regexp for OCaml errors,
ELPA Syncer <=
- [nongnu] elpa/caml a95aaca 03/10: [fix] Update the regexp for OCaml errors, ELPA Syncer, 2021/08/25
- [nongnu] elpa/caml 97211bf 07/10: Remove all mentions of XEmacs, ELPA Syncer, 2021/08/25
- [nongnu] elpa/caml f0c0c50 04/10: [fix] Reconcile how to get the synopsis from caml.el, ELPA Syncer, 2021/08/25
- [nongnu] elpa/caml 7d6b256 09/10: Add a link to the home page of NonGNU ELPA, ELPA Syncer, 2021/08/25
- [nongnu] elpa/caml 061c561 08/10: Add a badge for NonGNU ELPA, ELPA Syncer, 2021/08/25
- [nongnu] elpa/caml 419a950 05/10: Fix the warning “reference to free variable ‘Info-directory-list’”, ELPA Syncer, 2021/08/25