Skip to content

Instantly share code, notes, and snippets.

@pnwamk
Created October 19, 2017 01:26
Show Gist options
  • Save pnwamk/02ce911d8a28e32a29bfc621c5c2f273 to your computer and use it in GitHub Desktop.
Save pnwamk/02ce911d8a28e32a29bfc621c5c2f273 to your computer and use it in GitHub Desktop.
;; read from p, return a funny symbol if it fails for some reason
(define (try-read p)
(with-handlers ([(λ _ #t) (λ (_) 'READ-ERROR-ENCOUNTERED)])
(read p)))
;; for each racket source file, look for usages of "sort"
(for ([p (in-directory dir)]
#:when (regexp-match? #rx"\\.rkt" (path->string p)))
(define file (open-input-file p))
(set! files (add1 files))
(let loop! ([next (try-read file)])
(search-sexp! next)
(when (not (eof-object? next))
(loop! (try-read file))))
(close-input-port file))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment