Common Lisp Package: READER-INTERCEPTION

README:

FUNCTION

Public

PREPARE-READER-INTERCEPTION (HINT &KEY (EXTERNAL-FORMAT DEFAULT))

Before you may intercept the CL reader, you MUST prime the reader-interception with the first character to be read. You may give the character itself, NIL for no character (e.g. EOF), T for any ASCII characters (assuming the first one won't be further unicode), a stream to read the character from, a string that will be used as input stream, a pathname to be open as a stream to read from with specified external-format

Private

Undocumented

CALL-WITH-READER-INTERCEPTION (THUNK &OPTIONAL HINT (READER *READER*))

INITIALIZE-INTERCEPTION

INTERCEPT-CHAR-READER (STREAM CHAR)

PREPARE-ALL-ASCII

PREPARE-CHARACTER (X)

STANDARD-READ (&KEY (STREAM *STANDARD-INPUT*) (EOF-ERROR-P T) (EOF-VALUE NIL) (RECURSIVE-P NIL))

MACRO

Public

WITH-READER-INTERCEPTION ((HINT READER) &BODY BODY)

You may override the Common Lisp reader, e.g. around LOAD or COMPILE-FILE, by using WITH-READER-INTERCEPTION (HINT READER) BODY... thus replacing the CL syntax with any syntax of your choice. By combining this with ASDF 2.018's :around-compile hook, you could compile any language with CL via a proper translation frontend. You *must* specify a HINT to pass to PREPARE-READER-INTERCEPTION, to help the interception find the first (next) character that will be read, so it can intercept reading from there. You must specify your READER, a function taking a STREAM as argument, and either returning an object or raising an error such as READER-ERROR or END-OF-FILE. Inside the BODY, the *READTABLE* is set so that you may READ from a stream starting with the hinted character, and it will use your specified parser instead of the CL reader. Inside the READER itself, READ will behave like the unintercepted CL reader.

VARIABLE

Private

Undocumented

*INTERCEPTED-CHARACTERS*

*INTERCEPTION-READTABLE*

*READER*

*SAVED-READTABLE*

*STANDARD-READTABLE*