[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/swift-mode 00393f7 262/496: Merge pull request #103 from u
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/swift-mode 00393f7 262/496: Merge pull request #103 from uk-ar/fix-lexer |
Date: |
Sun, 29 Aug 2021 11:33:47 -0400 (EDT) |
branch: elpa/swift-mode
commit 00393f7b0e67edd559db9cdc372a016f44c78c0c
Merge: ae4f08b ba39552
Author: Arthur Evstifeev <mail@ap4y.me>
Commit: Arthur Evstifeev <mail@ap4y.me>
Merge pull request #103 from uk-ar/fix-lexer
Fix lexer
---
swift-mode.el | 41 +++++++++++++++++++++++++++++++++++------
test/indentation-tests.el | 6 ++++--
2 files changed, 39 insertions(+), 8 deletions(-)
diff --git a/swift-mode.el b/swift-mode.el
index 5cb0293..592179a 100644
--- a/swift-mode.el
+++ b/swift-mode.el
@@ -32,6 +32,7 @@
(require 'rx)
(require 'comint)
+(require 'cl-lib)
(eval-and-compile
;; Added in Emacs 24.3
@@ -218,7 +219,7 @@
"<<" ">>" "??")))
(defvar swift-smie--decl-specifier-regexp
-
"\\(?1:class\\|mutating\\|override\\|static\\|unowned\\|weak\\)\\(?:[[:space:]]*func\\)")
+ "\\(?1:mutating\\|override\\|static\\|unowned\\|weak\\)")
(defvar swift-smie--access-modifier-regexp
(regexp-opt '("private" "public" "internal")))
@@ -249,6 +250,22 @@
(not (looking-back "[[:upper:]]>" (- (point) 2) t)))
))))
+(defun swift-smie--forward-token-debug ()
+ (let ((token (swift-smie--forward-token)))
+ (unless (equal token "")
+ (cl-assert (equal token
+ (save-excursion (swift-smie--backward-token))) t))
+ token
+ ))
+
+(defun swift-smie--backward-token-debug ()
+ (let ((token (swift-smie--backward-token)))
+ (unless (equal token "")
+ (cl-assert (equal token
+ (save-excursion (swift-smie--forward-token))) t))
+ token
+ ))
+
(defun swift-smie--forward-token ()
(skip-chars-forward " \t")
(cond
@@ -272,7 +289,9 @@
((looking-at "<") (forward-char 1)
(if (looking-at "[[:upper:]]") "<T" "OP"))
- ((looking-at ">") (forward-char 1)
+
+ ((looking-at ">[?!]?")
+ (goto-char (match-end 0))
(if (looking-back "[[:space:]]>" 2 t) "OP" "T>"))
((looking-at swift-smie--operators-regexp)
@@ -332,6 +351,10 @@
(goto-char (match-beginning 0))
(if (looking-back "[[:space:]]" 1 t) "OP" "T>"))
+ ((looking-back (regexp-opt swift-mode--type-decl-keywords) (- (point) 9)
t)
+ (goto-char (match-beginning 0))
+ (match-string-no-properties 0))
+
((looking-back swift-smie--operators-regexp (- (point) 3) t)
(goto-char (match-beginning 0)) "OP")
@@ -421,8 +444,12 @@
(smie-rule-parent 0)))
(`(:after . "(")
- (if (smie-rule-parent-p "(") 0
- (smie-rule-parent swift-indent-offset)))
+ (cond
+ ((smie-rule-parent-p "(") 0)
+ ((and (smie-rule-parent-p "." "func")
+ (not (smie-rule-hanging-p))) 1)
+ (t (smie-rule-parent swift-indent-offset))))
+
(`(:before . "(")
(cond
((smie-rule-next-p "[") (smie-rule-parent))
@@ -744,7 +771,7 @@ You can send text to the REPL process from other buffers
containing source.
(let ((table (make-syntax-table)))
;; Operators
- (dolist (i '(?+ ?- ?* ?/ ?& ?| ?^ ?! ?< ?> ?~))
+ (dolist (i '(?+ ?- ?* ?/ ?& ?| ?^ ?< ?> ?~))
(modify-syntax-entry i "." table))
;; Strings
@@ -753,7 +780,9 @@ You can send text to the REPL process from other buffers
containing source.
;; Additional symbols
(modify-syntax-entry ?_ "w" table)
- (modify-syntax-entry ?: "_" table)
+ (modify-syntax-entry ?? "_" table)
+ (modify-syntax-entry ?! "_" table)
+ (modify-syntax-entry ?: "." table)
;; Comments
(modify-syntax-entry ?/ ". 124b" table)
diff --git a/test/indentation-tests.el b/test/indentation-tests.el
index 3abd8be..e03b982 100644
--- a/test/indentation-tests.el
+++ b/test/indentation-tests.el
@@ -68,6 +68,8 @@ values of customisable variables."
(search-forward "|")
(delete-char -1)
(swift-mode)
+ (setq smie-forward-token-function 'swift-smie--forward-token-debug)
+ (setq smie-backward-token-function
'swift-smie--backward-token-debug)
(indent-according-to-mode)
(should (equal expected-state (buffer-string)))
@@ -1213,7 +1215,7 @@ foo?[bar] +
|a
" "
foo?[bar] +
- |a
+ |a
")
(check-indentation indents-multiline-expressions/10
@@ -1222,7 +1224,7 @@ foo?(bar) +
|a
" "
foo?(bar) +
- |a
+ |a
")
(check-indentation indents-multiline-expressions/11
- [nongnu] elpa/swift-mode c8cdb81 153/496: Shortcut linked sources flycheck logic when corresponding variable is nil, (continued)
- [nongnu] elpa/swift-mode c8cdb81 153/496: Shortcut linked sources flycheck logic when corresponding variable is nil, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode a3caf1d 163/496: Change '_' character class to 'symbol constituent', ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 0ad5865 171/496: Merge pull request #71 from ap4y/access_modifiers_font_lock, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 69289fe 180/496: Lexer improvement: don't use implicit semicolon when ":" and "?" token, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 7a7038b 202/496: Remove supported for trailing dot in multi-line expression (invalid, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode d27b851 181/496: Add indentation rules for ternary operator, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 3026464 206/496: Merge pull request #79 from dougbeal/fix-custom-types, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode ae4f08b 253/496: Correct implicit semicolon rule for in keyword, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 3aa3dcd 254/496: Add test code for checking tokens, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode b97b570 260/496: Fix indent rule for '(' and pass all test, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 00393f7 262/496: Merge pull request #103 from uk-ar/fix-lexer,
ELPA Syncer <=
- [nongnu] elpa/swift-mode ed1ed46 264/496: Add test for forward-sexp, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode a3377bf 266/496: Fix forward-sexp test by adding brackets, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 228b50c 267/496: Fix case-: for multiline case-exps, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 3931734 283/496: fix multi-line expressions, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode e5b569e 284/496: Add keyword for attribute, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode d614017 298/496: Update copyright years, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 174bccc 309/496: Tweak .travis.yml, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode f9f4bc5 311/496: Fix `beginning/end-of-defun`, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode c659c45 329/496: Highlight anchor point for debugging., ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode b6512fa 325/496: Fix indentation of attributes, ELPA Syncer, 2021/08/29