(module detect-the-doubles (main start)) ;; (define *THE-PORT* #unspecified) (define *LINE-NUMBER* 1) ;; (define (start args) (let loop ((file-list (cdr args))) (if (not (null? file-list)) (let ((the-file (car file-list))) (set! *LINE-NUMBER* 1) (print the-file " : ") (set! *THE-PORT* (open-input-file the-file)) (the-reader) (close-input-port *THE-PORT*) (loop (cdr file-list)))))) ;; (define (the-reader) (read/rp the-grammar *THE-PORT*)) ;; (define the-grammar (let ((previous-word "") (last-word "")) (regular-grammar () ((: #\newline) (set! *LINE-NUMBER* (+ *LINE-NUMBER* 1)) (ignore)) ((+ (in #\space #\tab #\ #\" #\' #\/ #\* #` "&:.,;!?+=-_|%$@^#()<>[]{}«»" digit #a160)) (ignore)) ((+ (in alpha "éèàâùêîïôüûëçÉÈÀÂÙÊÎÏÔÜÛËÇ")) (set! previous-word last-word) (set! last-word (the-string)) (if (string-ci=? previous-word last-word) (print " line n° " *LINE-NUMBER* " : " previous-word " " last-word )) (ignore)) (else (let ((this-char (the-failure))) (if (not (eof-object? this-char)) (begin (print #\newline "----") (display* "Ligne " *LINE-NUMBER*) (print " the wrong character : " this-char " its ASCII code : " (char->integer this-char)))))) )))