[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[nongnu] elpa/tuareg e46ce6f 1/2: Parse `class type` correctly (#239)
From: |
ELPA Syncer |
Subject: |
[nongnu] elpa/tuareg e46ce6f 1/2: Parse `class type` correctly (#239) |
Date: |
Sun, 27 Jun 2021 18:57:17 -0400 (EDT) |
branch: elpa/tuareg
commit e46ce6f99bc950b53f42df26aa41aa5ca2698f00
Author: Mattias EngdegÄrd <mattiase@acm.org>
Commit: Mattias EngdegÄrd <mattiase@acm.org>
Parse `class type` correctly (#239)
Lex "type" after "class" as "c-type", in analogy with "m-type".
---
tuareg-tests.el | 19 +++++++++++++++++++
tuareg.el | 7 ++++---
2 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/tuareg-tests.el b/tuareg-tests.el
index fd152d1..cef8733 100644
--- a/tuareg-tests.el
+++ b/tuareg-tests.el
@@ -342,4 +342,23 @@ Returns the value of the last FORM."
(list p3 (1- p4) (1- p4))))
)))
+(ert-deftest tuareg-class-type ()
+ (with-temp-buffer
+ (tuareg-mode)
+ (tuareg--lets
+ (insert "class type my_class_type =\n"
+ " object\n"
+ " method meth_1 : int\n"
+ " method meth_2 : unit\n"
+ " end;;\n")
+ (let p1 (point))
+
+ (goto-char (point-min))
+ (end-of-defun)
+ (should (equal (point) p1))
+ (beginning-of-defun)
+ (should (equal (point) (point-min)))
+ (should (equal (tuareg-discover-phrase (point-min))
+ (list (point-min) (1- p1) (1- p1)))))))
+
(provide 'tuareg-tests)
diff --git a/tuareg.el b/tuareg.el
index 81a67ba..700808d 100644
--- a/tuareg.el
+++ b/tuareg.el
@@ -1476,7 +1476,7 @@ For use on `electric-indent-functions'."
(def-in-exp (defs "in" exp))
(def (var "d=" exp) (id "d=" datatype) (id "d=" module))
(idtype (id ":" type))
- (var (id) ("m-type" var) ("d-type" var) ("rec" var)
+ (var (id) ("m-type" var) ("d-type" var) ("c-type" var) ("rec" var)
("private" var) (idtype)
("l-module" var) ("l-class" var))
(exception (id "of" type))
@@ -1932,12 +1932,13 @@ Return values can be
(tuareg-smie--label-colon-p))))
(if (member nearest '("with" "|" "fun" "function" "functor"))
tok "t->"))))
- ;; Handle "module type", mod-constraint's "with/and type" and
- ;; polymorphic syntax.
+ ;; Handle "module type", "class type", mod-constraint's "with/and type"
+ ;; and polymorphic syntax.
((equal tok "type")
(save-excursion
(let ((prev (tuareg-smie--backward-token)))
(cond ((equal prev "module") "m-type")
+ ((equal prev "class") "c-type")
((member prev '("and" "with")) "w-type")
((equal prev ":") "d-type"); ": type a. ..."
(t tok)))))