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

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

[nongnu] elpa/swift-mode 2b17f71 183/496: Improve grammar and lexer to s


From: ELPA Syncer
Subject: [nongnu] elpa/swift-mode 2b17f71 183/496: Improve grammar and lexer to support access modifier in class definitions
Date: Sun, 29 Aug 2021 11:33:32 -0400 (EDT)

branch: elpa/swift-mode
commit 2b17f714eb86eb4535784313f924649e4c00236e
Author: ap4y <lod@pisem.net>
Commit: ap4y <lod@pisem.net>

    Improve grammar and lexer to support access modifier in class definitions
---
 swift-mode.el | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/swift-mode.el b/swift-mode.el
index 95d16c8..c61ca5c 100644
--- a/swift-mode.el
+++ b/swift-mode.el
@@ -99,7 +99,7 @@
        (top-level-st
         ("import" type)
         (decl)
-        ("class" class-decl-exp "{" class-level-sts "}"))
+        ("ACCESSMOD" "class" class-decl-exp "{" class-level-sts "}"))
 
        (class-level-sts (class-level-st) (class-level-st ";" class-level-st))
        (class-level-st
@@ -195,6 +195,9 @@
   (rx (? (or "class" "mutating" "override" "static" "unowned" "weak"))
       (* space) "func"))
 
+(defvar swift-smie--access-modifier-regexp
+  (regexp-opt '("private" "public" "internal")))
+
 (defun swift-smie--implicit-semi-p ()
   (save-excursion
     (not (or (memq (char-before) '(?\{ ?\[ ?, ?. ?\? ?\:))
@@ -225,6 +228,9 @@
    ((looking-at swift-smie--decl-specifier-regexp)
     (goto-char (match-end 0)) "DECSPEC")
 
+   ((looking-at swift-smie--access-modifier-regexp)
+    (goto-char (match-end 0)) "ACCESSMOD")
+
    (t (let ((tok (smie-default-forward-token)))
         (cond
          ((equal tok "case")
@@ -259,6 +265,9 @@
      ((looking-back swift-smie--decl-specifier-regexp (- (point) 8) t)
       (goto-char (match-beginning 0)) "DECSPEC")
 
+     ((looking-back swift-smie--access-modifier-regexp (- (point) 8) t)
+      (goto-char (match-beginning 0)) "ACCESSMOD")
+
      (t (let ((tok (smie-default-backward-token)))
           (cond
            ((equal tok "case")



reply via email to

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