/diff-js.ss
Scheme | 49 lines | 10 code | 18 blank | 21 comment | 0 complexity | f7f19548a058d78d10676e8bdbffd2fb MD5 | raw file
1;; ydiff - a language-aware tool for comparing programs 2;; Copyright (C) 2011 Yin Wang (yinwang0@gmail.com) 3 4;; This program is free software: you can redistribute it and/or modify 5;; it under the terms of the GNU General Public License as published by 6;; the Free Software Foundation, either version 3 of the License, or 7;; (at your option) any later version. 8 9;; This program is distributed in the hope that it will be useful, 10;; but WITHOUT ANY WARRANTY; without even the implied warranty of 11;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12;; GNU General Public License for more details. 13 14;; You should have received a copy of the GNU General Public License 15;; along with this program. If not, see <http://www.gnu.org/licenses/>. 16 17 18 19(load "parse-js.ss") 20(load "diff.ss") 21 22 23 24;------------------------------------------------------------- 25; overrides 26;------------------------------------------------------------- 27 28(define get-name 29 (lambda (node) 30 (let ([id-exp (match-tags node '(name identifier id))]) 31 (and id-exp (get-symbol (car (Expr-elts id-exp))))))) 32 33 34;; (same-def? (car (parse1 $statement "function f(x) {}")) 35;; (car (parse1 $statement "function f(x) {}"))) 36 37 38;; (different-def? (car (parse1 $statement "function f(x) {}")) 39;; (car (parse1 $statement "function g(x) {}"))) 40 41 42;--------------------------------------------- 43(define diff-js 44 (lambda (file1 file2) 45 (load "diff-js.ss") 46 (diff file1 file2 parse-js))) 47 48; (diff-js "tests/nav.js" "tests/nav-div.js") 49