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

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

[nongnu] elpa/dart-mode 39909e6bd9 3/5: Simplify numeric literal regexp


From: ELPA Syncer
Subject: [nongnu] elpa/dart-mode 39909e6bd9 3/5: Simplify numeric literal regexp
Date: Sun, 3 Apr 2022 23:58:13 -0400 (EDT)

branch: elpa/dart-mode
commit 39909e6bd9ad10d3a66a5c45b4836c093fc17e35
Author: Brady Trainor <git_commit@tangential.info>
Commit: Brady Trainor <git_commit@tangential.info>

    Simplify numeric literal regexp
---
 dart-mode.el | 31 +++++++++++++------------------
 1 file changed, 13 insertions(+), 18 deletions(-)

diff --git a/dart-mode.el b/dart-mode.el
index d7e3b3a2d8..90217071a7 100644
--- a/dart-mode.el
+++ b/dart-mode.el
@@ -194,22 +194,18 @@ indentation levels from right to left."
                                     word-end
                                     (zero-or-one ?*)))
 
-(defvar dart--number-re (rx symbol-start
-                            (zero-or-one ?-)
-                            (group (or (and (one-or-more digit)
-                                            (zero-or-one
-                                             (and ?. (one-or-more digit))))
-                                       (and ?. (one-or-more digit)))
-                                   (zero-or-one (and (or ?e ?E)
-                                                     (zero-or-one (or ?+ ?-))
-                                                     (one-or-more digit))))))
-
-(defvar dart--hex-number-re (rx symbol-start
-                                (zero-or-one ?-)
-                                (group (or "0x" "0X")
-                                       (one-or-more (any (?a . ?f)
-                                                         (?A . ?F)
-                                                         digit)))))
+;; https://dart.dev/guides/language/specifications/DartLangSpec-v2.10.pdf
+;; 17.5 Numbers
+(defvar dart--numeric-literal-re (rx-let
+                                     ((numeric-literal (| number hex-number))
+                                      (number (: (| (: (1+ digit) (? (: ?. (1+ 
digit))))
+                                                    (: ?. (1+ digit)))
+                                                 (? exponent)))
+                                      (exponent (: (| ?e ?E)
+                                                   (? (| ?+ ?-))
+                                                   (1+ digit)))
+                                      (hex-number (: ?0 (| ?x ?X) (1+ 
hex-digit))))
+                                   (rx bow numeric-literal eow)))
 
 (defvar dart--operator-declaration-re (rx "operator"
                                           (one-or-more space)
@@ -583,8 +579,7 @@ untyped parameters. For example, in
     ,(regexp-opt dart--keywords 'words)
     (,(regexp-opt dart--builtins 'words)  . font-lock-builtin-face)
     (,(regexp-opt dart--constants 'words) . font-lock-constant-face)
-    (,dart--hex-number-re                 . (1 font-lock-constant-face))
-    (,dart--number-re                     . (1 font-lock-constant-face))
+    (,dart--numeric-literal-re            . font-lock-constant-face)
     (,dart--metadata-re                   . font-lock-constant-face)
     (,dart--constants-re                   . font-lock-constant-face)
     (,(regexp-opt dart--types 'words)     . font-lock-type-face)



reply via email to

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