branch: elpa/d-mode
commit ac898c0e6c873cb89c9a1f048d78f631852934ac
Author: Vladimir Panteleev <[email protected]>
Commit: Vladimir Panteleev <[email protected]>
Fix parsing of scope-statements
---
d-mode.el | 11 +++++++++++
tests/fonts.d | 3 +++
tests/fonts.d.html | 3 +++
3 files changed, 17 insertions(+)
diff --git a/d-mode.el b/d-mode.el
index d6756df..c1ebebb 100644
--- a/d-mode.el
+++ b/d-mode.el
@@ -690,6 +690,17 @@ Each list item should be a regexp matching a single
identifier."
(looking-at (c-make-keywords-re t '("in"))))))
nil)
+ ;; D: cc-mode gets confused due to "scope" being a keyword that can
+ ;; both be part of declarations (as a storage class), and a
+ ;; statement (e.g. "scope(exit)"). Disambiguate them here.
+ ((save-excursion
+ (and
+ (looking-at (c-make-keywords-re t '("scope")))
+ (progn
+ (c-forward-token-2)
+ (looking-at "("))))
+ nil)
+
;; D: The "else" following a "version" or "static if" can start a
;; declaration even without a { } block. For this reason, "else" is
;; in `c-decl-start-kwds'.
diff --git a/tests/fonts.d b/tests/fonts.d
index 7cb6789..eb995c2 100644
--- a/tests/fonts.d
+++ b/tests/fonts.d
@@ -16,3 +16,6 @@ version(none) string readLink();
static if (true) {} else fun();
static if (true) {} else void fun();
+
+scope(exit) fun();
+scope(exit) void fun();
diff --git a/tests/fonts.d.html b/tests/fonts.d.html
index ff8b85d..0df8a38 100644
--- a/tests/fonts.d.html
+++ b/tests/fonts.d.html
@@ -16,3 +16,6 @@
<span class="keyword">static if</span> (<span class="constant">true</span>) {}
<span class="keyword">else</span> fun();
<span class="keyword">static if</span> (<span class="constant">true</span>) {}
<span class="keyword">else</span> <span class="type">void</span> <span
class="function-name">fun</span>();
+
+<span class="keyword">scope</span>(exit) fun();
+<span class="keyword">scope</span>(exit) <span class="type">void</span> <span
class="function-name">fun</span>();