sexp-diff

Vincent St-Amour <stamourv@ccs.neu.edu>

This package provides an S-expression-aware diffing tool based on Levenshtein-like tree edit distance.

(sexp-diff e1 e2)  sexp?
  e1 : sexp?
  e2 : sexp?
Produces a tree that corresponds to the common structure of e1 and e2, with e1-specific parts tagged with #:old and e2-specific parts tagged with #:new.

Examples:

> (sexp-diff
   '(define (f x) (+ (* x 2) 1))
   '(define (f x) (- (* x 2) 3 1)))

'((define (f x) (#:new - #:old + (* x 2) #:new 3 1)))

> (sexp-diff
   '(define (f x) (+ (* x 2) 4 1))
   '(define (f x) (- (* x 2) 5 3 1)))

'((define (f x) (#:new - #:old + (* x 2) #:new 5 #:new 3 #:old 4 1)))

> (sexp-diff
   '(define (f x) (+ (* x 2) 4 4 1))
   '(define (f x) (- (* x 2) 5 5 3 1)))

'((define (f x) (#:new - #:old + (* x 2) #:new 5 #:new 5 #:new 3 #:old 4 #:old 4 1)))