Skip to content

pve1/buffering-readtable

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Buffering readtable

Creates a readtable that buffers all input from a non-interactive stream passed to READ. The input can be transformed before being returned by READ.

Some examples:

Appending an additional symbol to the forms read from a stream.

(let ((*readtable* (buffering-readtable:make-buffering-readtable
                    :translate-all (lambda (forms)
                                     (append forms (list 'extra))))))
  (with-input-from-string (s "a b c")
    (list (read s)
          (read s)
          (read s)
          (read s))))

=> (A B C EXTRA)

Replacing a symbol with another.

(let ((*readtable* (buffering-readtable:make-buffering-readtable
                    :translate-one (lambda (form)
                                     (if (eql form 'x)
                                         'c
                                         form)))))

  (with-input-from-string (s "a b x")
    (list (read s)
          (read s)
          (read s))))

=> (A B C)

Manipulating the buffered input string.

(let ((*readtable* (buffering-readtable:make-buffering-readtable
                    :translate-string
                    (lambda (string)
                      (cl-ppcre:regex-replace-all "x" string "")))))
  (with-input-from-string (s "a x b x c")
    (list (read s)
          (read s)
          (read s))))

=> (A B C)

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published