(rapid read)

Scheme reader with source-location information.This library provides a reader for external representations of Scheme objects compatible with the R7RS syntax. It has two advantages over the standard reader in (scheme read). Firstly, it accurately reports parsing errors by raising a continuable exception, so that parsing can be continued after reporting the error. Secondly, all the parsed datums are provided with exact source locations by returning the parsed datums wrapped in syntax objects as defined by the library (rapid syntax).

Source ports

A source port is a port-like object wrapping a textual input port that maintains line and column information and a case-insensitivity flag.

Reader errors

Readers errors are signaled by raising a continuable exception, a syntax error object from (rapid syntax). If an exception handler handling a reader error returns, the reader continues and tries to parse the next datum.

Procedures

(make-source-port port source ci?)

Returns a new source port wrapping the textual input port port with position initialized to the start of a text file (line number 0 and column number 1), and case-insensitivity set according to ci?.

(source-port? obj)

Returns #t if obj is a source port, and #f otherwise.

(source-port-set-ci! ci?)

Sets the case-insensitivity flag of source-port according to ci?.

(source-port-fold-case! source-port)

Sets the case-insensitivity flag of source-port.

(source-port-no-fold-case! source-port)

Clears the case-insensitivity flag of source-port.

(read-syntax source-port)

Reads the next datum available at source-port wrapped in a syntax object.

(read-file context pathname ci?)

Returns the list of syntax objects parsed from reading all external representations in the file pathname with case-insensitivity flag set to ci?. Context is used for syntax error objects when raised.

(read-files-reverse context filenames body ci?)

Reads the list of syntax objects parsed from reading all external representations in the files filenames in the vinicity of the syntax object context with case-insensitivity flag set to ci?. Prepends this list in reverse order to the list body and returns the results. The list filenames is a list of syntax objects each wrapping a string. A syntax error is raised if any syntax object in filenames does not wrap a string.

(current-file-reader)

By rebinding this parameter object to a custom procedure, the behaviour of read-file and read-files-reverse can be customized. It is expected that the new binding is a procedure with the same signature and semantics as read-file.