Skip to content

Commit d1c7b6d

Browse files
committed
Merge branch 'sb/userdiff-lisp-family' into seen
The userdiff driver for the Scheme language has been extended to cover other Lisp dialects. * sb/userdiff-lisp-family: userdiff: extend Scheme support to cover other Lisp dialects userdiff: tighten word-diff test case of the scheme driver
2 parents 8cdb2c9 + b79f7a3 commit d1c7b6d

File tree

10 files changed

+43
-11
lines changed

10 files changed

+43
-11
lines changed

Documentation/gitattributes.adoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -911,7 +911,8 @@ patterns are available:
911911

912912
- `rust` suitable for source code in the Rust language.
913913

914-
- `scheme` suitable for source code in the Scheme language.
914+
- `scheme` suitable for source code in most Lisp dialects,
915+
including Scheme, Emacs Lisp, Common Lisp, and Clojure.
915916

916917
- `tex` suitable for source code for LaTeX documents.
917918

t/t4018/scheme-lisp-defun-a

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
(defun some-func (x y z) RIGHT
2+
(let ((a x)
3+
(b y))
4+
(ChangeMe a b)))

t/t4018/scheme-lisp-defun-b

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
(macrolet ((foo (x) `(bar ,x)))
2+
(defun mumble (x) ; RIGHT
3+
(when (> x 0)
4+
(foo x)))) ; ChangeMe

t/t4018/scheme-lisp-eval-when

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
(eval-when (:compile-toplevel :load-toplevel :execute) ; RIGHT
2+
(set-macro-character #\?
3+
(lambda (stream char)
4+
`(make-pattern-variable ,(read stream))))) ; ChangeMe

t/t4018/scheme-module-b

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
(module A
2+
(export with-display-exception)
3+
(extern (display-exception display-exception))
4+
(def (with-display-exception thunk) RIGHT
5+
(with-catch (lambda (e) (display-exception e (current-error-port)) e)
6+
thunk ChangeMe)))

t/t4034/scheme/expect

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
<BOLD>index 74b6605..63b6ac4 100644<RESET>
33
<BOLD>--- a/pre<RESET>
44
<BOLD>+++ b/post<RESET>
5-
<CYAN>@@ -1,6 +1,6 @@<RESET>
5+
<CYAN>@@ -1,7 +1,7 @@<RESET>
66
(define (<RED>myfunc a b<RESET><GREEN>my-func first second<RESET>)
77
; This is a <RED>really<RESET><GREEN>(moderately)<RESET> cool function.
88
(<RED>this\place<RESET><GREEN>that\place<RESET> (+ 3 4))
9-
(define <RED>some-text<RESET><GREEN>|a greeting|<RESET> "hello")
9+
(define <RED>|the \| \greeting|<RESET><GREEN>|a \greeting|<RESET> |hello there|)
10+
({<RED>}<RESET>(([<RED>]<RESET>(func-n)<RED>[<RESET>]))<RED>{<RESET>})
1011
(let ((c (<RED>+ a b<RESET><GREEN>add1 first<RESET>)))
1112
(format "one more than the total is %d" (<RED>add1<RESET><GREEN>+<RESET> c <GREEN>second<RESET>))))

t/t4034/scheme/post

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
(define (my-func first second)
22
; This is a (moderately) cool function.
33
(that\place (+ 3 4))
4-
(define |a greeting| "hello")
4+
(define |a \greeting| |hello there|)
5+
({(([(func-n)]))})
56
(let ((c (add1 first)))
67
(format "one more than the total is %d" (+ c second))))

t/t4034/scheme/pre

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
(define (myfunc a b)
22
; This is a really cool function.
33
(this\place (+ 3 4))
4-
(define some-text "hello")
4+
(define |the \| \greeting| |hello there|)
5+
({}(([](func-n)[])){})
56
(let ((c (+ a b)))
67
(format "one more than the total is %d" (add1 c))))

userdiff.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -344,14 +344,24 @@ PATTERNS("rust",
344344
"|[0-9][0-9_a-fA-Fiosuxz]*(\\.([0-9]*[eE][+-]?)?[0-9_fF]*)?"
345345
"|[-+*\\/<>%&^|=!:]=|<<=?|>>=?|&&|\\|\\||->|=>|\\.{2}=|\\.{3}|::"),
346346
PATTERNS("scheme",
347-
"^[\t ]*(\\(((define|def(struct|syntax|class|method|rules|record|proto|alias)?)[-*/ \t]|(library|module|struct|class)[*+ \t]).*)$",
348347
/*
349-
* R7RS valid identifiers include any sequence enclosed
350-
* within vertical lines having no backslashes
348+
* An unindented opening parenthesis identifies a top-level
349+
* expression in all Lisp dialects.
351350
*/
352-
"\\|([^\\\\]*)\\|"
353-
/* All other words should be delimited by spaces or parentheses */
354-
"|([^][)(}{[ \t])+"),
351+
"^(\\(.*)$\n"
352+
/* For Scheme: a possibly indented left paren followed by a keyword. */
353+
"^[\t ]*(\\(((define|def(struct|syntax|class|method|rules|record|proto|alias)?)[-*/ \t]|(library|module|struct|class)[*+ \t]).*)$\n"
354+
/*
355+
* For all Lisp dialects: a slightly indented line starting with "(def".
356+
*/
357+
"^ ?(\\([Dd][Ee][Ff].*)$",
358+
/*
359+
* The union of R7RS and Common Lisp symbol syntax: allows arbitrary
360+
* strings between vertical bars, including any escaped characters.
361+
*/
362+
"\\|([^|\\\\]|\\\\.)*\\|"
363+
/* All other words should be delimited by spaces or parentheses. */
364+
"|([^][)(}{ \t])+"),
355365
PATTERNS("tex", "^(\\\\((sub)*section|chapter|part)\\*{0,1}\\{.*)$",
356366
"\\\\[a-zA-Z@]+|\\\\.|([a-zA-Z0-9]|[^\x01-\x7f])+"),
357367
{ .name = "default", .binary = -1 },

0 commit comments

Comments
 (0)