[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master ab9a23e: Enhance syntax-tests.el to test nestable comments (Lisp
From: |
Alan Mackenzie |
Subject: |
master ab9a23e: Enhance syntax-tests.el to test nestable comments (Lisp style) |
Date: |
Tue, 17 Nov 2020 11:54:04 -0500 (EST) |
branch: master
commit ab9a23e029ce1507d9e863e086db8796d727d1a4
Author: Alan Mackenzie <acm@muc.de>
Commit: Alan Mackenzie <acm@muc.de>
Enhance syntax-tests.el to test nestable comments (Lisp style)
Also add some tests for braces and parse-partial-sexp amongst Lisp style
comments.
* test/src/syntax-tests.el (\;-in, \;-out): Add syntax for { and }.
(top-level): Add new tests for Lisp style comments.
(\#|-in, \#|-out): New functions.
(top-level): Add new tests for nested Lisp style comments, and mixtures of
nested comments with "ordinary" comments.
* test/src/syntax-resources/syntax-comments.txt (top-level): Add new test
fragments for #|...|#, etc.
---
test/src/syntax-resources/syntax-comments.txt | 26 +++++++++++
test/src/syntax-tests.el | 66 +++++++++++++++++++++++++--
2 files changed, 89 insertions(+), 3 deletions(-)
diff --git a/test/src/syntax-resources/syntax-comments.txt
b/test/src/syntax-resources/syntax-comments.txt
index 6f595e4..a292d81 100644
--- a/test/src/syntax-resources/syntax-comments.txt
+++ b/test/src/syntax-resources/syntax-comments.txt
@@ -62,7 +62,33 @@
33; \
33
+/* Lisp comments within lists */
+40)40
+41(;90 comment
+91)41
+42(;92\
+93)42
+43( ;94
+95
+
+/* Nested Lisp comments */
+100|#100
+101#|#
+102#||#102
+103#| Comment |#103
+104#| Comment
+|#104
+105#|#|#105
+106#| #| Comment |# |#106
+107#|#|#|#|#|#|#|#|#| Comment |#|#|#|#|#|#|#|#|#107
+
+/* Mixed Lisp comments */
+110; #|
+110
+111#| ; |#111
+
Local Variables:
mode: fundamental
eval: (set-syntax-table (make-syntax-table))
End:
+999
\ No newline at end of file
diff --git a/test/src/syntax-tests.el b/test/src/syntax-tests.el
index 4b9c3f2..edee01e 100644
--- a/test/src/syntax-tests.el
+++ b/test/src/syntax-tests.el
@@ -220,7 +220,7 @@ missing or nil, the value of -START- is assumed for it."
(cond
((eq -dir- 'forward) t)
((eq -dir- 'backward) nil)
- (t (error "Invalid -dir- argument \"%s\" to `syntax-comments'"
-dir-))))
+ (t (error "Invalid -dir- argument \"%s\" to `syntax-br-comments'"
-dir-))))
(start -start-)
(start-str (format "%d" (abs start)))
(type -type-))
@@ -338,10 +338,14 @@ the `parse-partial-sexp's are expected to stop. See
(setq parse-sexp-ignore-comments t)
(setq comment-end-can-be-escaped nil)
(modify-syntax-entry ?\n ">")
- (modify-syntax-entry ?\; "<"))
+ (modify-syntax-entry ?\; "<")
+ (modify-syntax-entry ?{ ".")
+ (modify-syntax-entry ?} "."))
(defun \;-out ()
(modify-syntax-entry ?\n " ")
- (modify-syntax-entry ?\; "."))
+ (modify-syntax-entry ?\; ".")
+ (modify-syntax-entry ?{ "(}")
+ (modify-syntax-entry ?} "){"))
(eval-and-compile
(setq syntax-comments-section "lisp"))
@@ -353,6 +357,62 @@ the `parse-partial-sexp's are expected to stop. See
(syntax-comments \; forward t 33)
(syntax-comments \; backward t 33)
+;; "Lisp" style comments inside lists.
+(syntax-br-comments \; backward nil 40)
+(syntax-br-comments \; forward t 41)
+(syntax-br-comments \; backward t 41)
+(syntax-br-comments \; forward t 42)
+(syntax-br-comments \; backward t 42)
+(syntax-br-comments \; forward nil 43)
+
+;; "Lisp" style comments parsed by `parse-partial-sexp'.
+(syntax-pps-comments \; 41 90 91)
+(syntax-pps-comments \; 42 92 93)
+(syntax-pps-comments \; 43 94 95 -999)
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; "Lisp" style nested comments: between delimiters #| |#.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+(defun \#|-in ()
+ (setq parse-sexp-ignore-comments t)
+ (modify-syntax-entry ?# ". 14")
+ (modify-syntax-entry ?| ". 23n")
+ (modify-syntax-entry ?\; "< b")
+ (modify-syntax-entry ?\n "> b"))
+(defun \#|-out ()
+ (modify-syntax-entry ?# ".")
+ (modify-syntax-entry ?| ".")
+ (modify-syntax-entry ?\; ".")
+ (modify-syntax-entry ?\n " "))
+(eval-and-compile
+ (setq syntax-comments-section "lisp-n"))
+
+(syntax-comments \#| forward nil 100 0)
+(syntax-comments \#| backward nil 100 0)
+(syntax-comments \#| forward nil 101 -999)
+(syntax-comments \#| forward t 102)
+(syntax-comments \#| backward t 102)
+
+(syntax-comments \#| forward t 103)
+(syntax-comments \#| backward t 103)
+(syntax-comments \#| forward t 104)
+(syntax-comments \#| backward t 104)
+
+(syntax-comments \#| forward nil 105 -999)
+(syntax-comments \#| backward t 105)
+(syntax-comments \#| forward t 106)
+(syntax-comments \#| backward t 106)
+(syntax-comments \#| forward t 107)
+(syntax-comments \#| backward t 107)
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; Mixed "Lisp" style (nested and unnested) comments.
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+(syntax-comments \#| forward t 110)
+(syntax-comments \#| backward t 110)
+(syntax-comments \#| forward t 111)
+(syntax-comments \#| backward t 111)
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Emacs 27 "C" style comments - `comment-end-can-be-escaped' is non-nil.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master ab9a23e: Enhance syntax-tests.el to test nestable comments (Lisp style),
Alan Mackenzie <=