emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[nongnu] elpa/tuareg 64fada7 01/10: Rewrite `tuareg--error-regexp` in rx


From: ELPA Syncer
Subject: [nongnu] elpa/tuareg 64fada7 01/10: Rewrite `tuareg--error-regexp` in rx
Date: Fri, 30 Jul 2021 16:57:26 -0400 (EDT)

branch: elpa/tuareg
commit 64fada7f1abbcc78359155a0ab4640e6b0fef0f6
Author: Mattias EngdegÄrd <mattiase@acm.org>
Commit: Mattias EngdegÄrd <mattiase@acm.org>

    Rewrite `tuareg--error-regexp` in rx
    
    Much more readable and maintainable. The regexp remains unchanged;
    mechanised conversion to rx guarantees equivalence.
---
 tuareg.el | 32 +++++++++++++++++++++++++++-----
 1 file changed, 27 insertions(+), 5 deletions(-)

diff --git a/tuareg.el b/tuareg.el
index f8ecab0..8cf560c 100644
--- a/tuareg.el
+++ b/tuareg.el
@@ -3149,11 +3149,33 @@ Short cuts for interactions with the REPL:
 ;; the language is not English.  Hence we add a regexp.
 
 (defconst tuareg--error-regexp
-  "^ *\\(File \\(\"?\\)\\([^,\" \n\t<>]+\\)\\2, \
-lines? \\([0-9]+\\)-?\\([0-9]+\\)?\
-\\(?:, characters? \\([0-9]+\\)-?\\([0-9]+\\)?\\)?:\\)\
-\\(?:\n[ \t]*\\(?:\\(?:[0-9]+ | .*\\|\\^+\\)\n[ \t]*\\)*\
-\\(Warning\\(?: [0-9]+\\)?\\):\\)?"
+  (rx bol
+      (* " ")
+      (group                                ; 1: HIGHLIGHT
+       "File "
+       (group (? "\""))                     ; 2
+       (group (+ (not (in "\t\n \",<>"))))  ; 3: FILE
+       (backref 2)
+       ", 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
+       ":")
+      (? "\n"
+         (* (in "\t "))
+         (* (or (seq (+ (in "0-9"))
+                     " | "
+                     (* nonl))
+                (+ "^"))
+            "\n"
+            (* (in "\t ")))
+         (group "Warning"                   ; 8: WARNING
+                (? " " (+ (in "0-9"))))
+         ":"))
   "Regular expression matching the error messages produced by 
ocamlc/ocamlopt.")
 
 (when (boundp 'compilation-error-regexp-alist-alist)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]