[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/swift-mode 31fb250 248/496: added elseguard to lexer
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/swift-mode 31fb250 248/496: added elseguard to lexer |
Date: |
Sun, 29 Aug 2021 11:33:45 -0400 (EDT) |
branch: elpa/swift-mode
commit 31fb250e2b58a76ffa0504be980698cc6cffd812
Author: Anthony Green <akoaysigod@gmail.com>
Commit: Anthony Green <akoaysigod@gmail.com>
added elseguard to lexer
---
swift-mode.el | 16 ++++++++++++----
test/indentation-tests.el | 11 +++++++++++
2 files changed, 23 insertions(+), 4 deletions(-)
diff --git a/swift-mode.el b/swift-mode.el
index aca877c..362edb2 100644
--- a/swift-mode.el
+++ b/swift-mode.el
@@ -131,8 +131,8 @@
(method-call "{" closure "}")
("enum" decl-exp "{" enum-body "}")
("switch" exp "{" switch-body "}")
- (guard-statement)
(if-clause)
+ (guard-statement)
("for" for-head "{" insts "}")
("while" exp "{" insts "}"))
@@ -161,7 +161,7 @@
(for-head (in-exp) (op-exp) (for-head ";" for-head))
(guard-conditional (exp) (let-decl) (var-decl))
- (guard-statement ("guard" guard-conditional "else" "{" insts "return"
"}"))
+ (guard-statement ("guard" guard-conditional "elseguard" "{" insts "}"))
(if-conditional (exp) (let-decl))
(if-body ("if" if-conditional "{" insts "}"))
@@ -274,13 +274,17 @@
((looking-at "else if")
(goto-char (match-end 0)) "elseif")
-
+
(t (let ((tok (smie-default-forward-token)))
(cond
((equal tok "case")
(if (looking-at "\\([\n\t ]\\|.\\)+?\\(where.*[,]\\|:\\)")
"case"
"ecase"))
+ ((equal tok "else")
+ (if (looking-back "\\(guard.*\\)")
+ "elseguard"
+ "else"))
(t tok))))
))
@@ -328,6 +332,10 @@
(if (looking-at "\\([\n\t ]\\|.\\)+?\\(where.*[,]\\|:\\)")
"case"
"ecase"))
+ ((equal tok "else")
+ (if (looking-back "\\(guard.*\\)")
+ "elseguard"
+ "else"))
(t tok))))
)))
@@ -424,7 +432,7 @@
(defvar swift-mode--statement-keywords
'("break" "case" "continue" "default" "do" "else" "fallthrough"
- "if" "in" "for" "return" "switch" "where" "while"))
+ "if" "in" "for" "return" "switch" "where" "while" "guard"))
(defvar swift-mode--contextual-keywords
'("associativity" "didSet" "get" "infix" "inout" "left" "mutating" "none"
diff --git a/test/indentation-tests.el b/test/indentation-tests.el
index 256f3d7..60c7dcb 100644
--- a/test/indentation-tests.el
+++ b/test/indentation-tests.el
@@ -2065,6 +2065,17 @@ func foo() {
}
")
+(check-indentation indents-guard-statement/1
+ "
+guard let x = y else {
+ |return
+}
+" "
+guard let x = y else {
+ |return
+}
+")
+
(provide 'indentation-tests)
;;; indentation-tests.el ends here
- [nongnu] elpa/swift-mode 20134ed 193/496: Use postive lookahead for declaration specifier lexer rule, (continued)
- [nongnu] elpa/swift-mode 20134ed 193/496: Use postive lookahead for declaration specifier lexer rule, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode c2c3c01 199/496: Improve support for optional types, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode d6483e1 207/496: Add ?? to the lexer rule for operators, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 9e6c538 210/496: Correct DECSPEC regex and lexer rule, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 2c67d92 213/496: Fix indentation of the closure arguments inside parentheses, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 5a858c7 218/496: Improve indentation of the array and dictionary expressions, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 195d040 227/496: Merge pull request #76 from ap4y/batch_smie_fixes, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode dbf48a1 232/496: Merge pull request #90 from nathankot/flycheck-framework-search-paths, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode e6f1a3c 237/496: More configurability for flycheck, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 3e8befa 238/496: Merge pull request #92 from apiology/more_flycheck_option_vars, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 31fb250 248/496: added elseguard to lexer,
ELPA Syncer <=
- [nongnu] elpa/swift-mode 071cd18 249/496: Merge pull request #100 from uk-ar/enable-pairing-for-curly-bracket, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 7cefd8c 255/496: Fix token for generics, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode c51eaf8 257/496: Fix token for ! & ?, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode ce816a8 270/496: Fix backward-sexp test by adding brackets, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 85e05ea 271/496: Merge pull request #105 from uk-ar/fix-move-by-sexp, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode befeb2a 017/496: Highlight bools and nil as constants, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 654d5e2 006/496: More work on font locking, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode c4943a8 025/496: Add to auto-mode-alist, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 0ad90f8 035/496: Fix a typo, ELPA Syncer, 2021/08/29
- [nongnu] elpa/swift-mode 19a61d9 022/496: fixup! Copy syntax table from rust-mode., ELPA Syncer, 2021/08/29