Common Lisp Package: COM.INFORMATIMAGO.COMMON-LISP.LISP-TEXT.SOURCE-TEXT

This package exports functions to read and manipulate Common Lisp sources. Most of the text source properties are kept (file position, line number, comments, feature tests, etc), while no package is created and no symbol is interned. Copyright Pascal J. Bourguignon 2007 - 2007 This package is provided under the GNU General Public License. See the source file for details.

README:

FUNCTION

Public

BUILD-LINE-INDEX (FILE-PATH &KEY (EXTERNAL-FORMAT DEFAULT))

DO: Build an index of the line positions in the file. FILE-PATH: The pathname of a text file. EXTERNAL-FORMAT: Passed to OPEN. Default: :default. RETURN: A vector of file positions of the beginning of each line.

MAP-SOURCE-FILE (FUN SOURCE-FILE &KEY (DEEPLY T) (ONLY-ATOMS NIL) (EXTERNAL-FORMAT DEFAULT))

FUN: A function (source-object) source-object: An instance of source-object parsed from a source file. When atoms is true, FUN is called only on source-objects not representing cons cells (lists).

Undocumented

GET-LINE-AND-COLUMN (LINE-POSITIONS POS)

MAP-SOURCE-STREAM (FUN SOURCE-STREAM &KEY (DEEPLY T) (ONLY-ATOMS NIL))

SOURCE-READ (&OPTIONAL INPUT-STREAM (EOF-ERROR-P T) (EOF-VALUE NIL) (RECURSIVE-P NIL) (PRESERVE-WHITESPACE-P NIL))

Private

COPY-READTABLE (&OPTIONAL (FROM-READTABLE *READTABLE*) (TO-READTABLE NIL))

DO: Copy the readtable. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_cp_rdt.htm>

GET-DISPATCH-MACRO-CHARACTER (DISP-CHAR SUB-CHAR &OPTIONAL (READTABLE *READTABLE*))

RETURN: The dispatch macro character function. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_set__1.htm>

GET-MACRO-CHARACTER (CHAR &OPTIONAL (READTABLE *READTABLE*))

RETURN: The macro character function. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_set_ma.htm>

MAKE-DISPATCH-MACRO-CHARACTER (CHAR &OPTIONAL (NON-TERMINATING-P NIL) (READTABLE *READTABLE*))

DO: Make the character a dispatch macro character in the readtable. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_mk_dis.htm>

MAKE-SOURCE-DISPATCH-MACRO-CHARACTER (MACRO-CHARACTER &OPTIONAL (READTABLE *READTABLE*))

PRE: MACRO-CHARACTER is a reader dispatch macro character. POST: The dispatching reader macro function for the MACRO-CHARACTER is replaced by a function that encapsulates the original dispatching reader macro function, in a binding to *START* of the file position of the MACRO-CHARACTER.

MAKE-SOURCE-READTABLE

RETURN: A new readtable where all the reader macros are set to return source objects instead of lisp objects.

READ (&OPTIONAL INPUT-STREAM (EOF-ERROR-P T) (EOF-VALUE NIL) (RECURSIVE-P NIL))

RETURN: An object read. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_rd_rd.htm>

READ-DELIMITED-LIST (CHAR &OPTIONAL (INPUT-STREAM *STANDARD-INPUT*) (RECURSIVE-P NIL))

RETURN: A list of objects read. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_rd_del.htm>

READ-FROM-STRING (STRING &OPTIONAL (EOF-ERROR-P T) (EOF-VALUE NIL) &KEY (START 0) (END NIL) (PRESERVE-WHITESPACE NIL))

RETURN: An object read from the string. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_rd_fro.htm>

READ-PRESERVING-WHITESPACE (&OPTIONAL INPUT-STREAM (EOF-ERROR-P T) (EOF-VALUE NIL) (RECURSIVE-P NIL))

RETURN: An object read. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_rd_rd.htm>

READ-SOURCE-OBJECT (STREAM START CLASS MAKE-ARGUMENTS)

DO: Read a source-object instance, of class CLASS, and re-read the STREAM from START to the file position after reading the source-object instance, as SOURCE-OBJECT-TEXT. START: The file position in STREAM of the first character of the source object. The current file position may be beyond this START position, when we're called from a reader macro (1) or a reader dispatch macro (2+). MAKE-ARGUMENTS: A function returning a plist of keyword and values to be passed as argument to (make-instance class ...) This function should be doing the reading of the source-object. RETURN: A new source-object instance of class CLASS, or an instance of SOURCE-LEXICAL-ERROR in case of error (READER-ERROR).

READ-STRING-BETWEEN-FILE-POSITIONS (STREAM START END)

PRE: (eq 'character (stream-element-type stream)) and START and END are file positions of this STREAM. RETURN: A string containing the characters read between the START and END file positions in the STREAM. POST: (= end (file-position stream))

READTABLE-CASE (READTABLE)

RETURN: The case of the readtable. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_rdtabl.htm>

SETFREADTABLE-CASE (VALUE READTABLE)

DO: Set the case of the readtable. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_rdtabl.htm>

READTABLEP (OBJECT)

RETURN: Whether the object is a readtable. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_rdta_1.htm>

SET-DISPATCH-MACRO-CHARACTER (DISP-CHAR SUB-CHAR NEW-FUNCTION &OPTIONAL (READTABLE *READTABLE*))

DO: Set the dispatch macro character function. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_set__1.htm>

SET-MACRO-CHARACTER (CHAR NEW-FUNCTION &OPTIONAL (NON-TERMINATING-P NIL) (READTABLE *READTABLE*))

DO: Set then macro character function. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_set_ma.htm>

SET-SYNTAX-FROM-CHAR (TO-CHAR FROM-CHAR &OPTIONAL (TO-READTABLE *READTABLE*) (FROM-READTABLE *STANDARD-READTABLE*))

DO: Copy the syntax between characters in the readtable. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/f_set_sy.htm>

SOURCE-PARSE-TOKEN (TOKEN)

DO: Parse the lisp reader token and return a source token object. RETURN: okp ; the parsed lisp object if okp, or an error message if (not okp)

SOURCE-READER-DISPATCH-MACRO-ARRAY (STREAM ARG SUB-CHAR)

Source reader #A dispatch macro reader.

SOURCE-READER-DISPATCH-MACRO-BINARY (STREAM ARG SUB-CHAR)

Source reader #B dispatch macro reader.

SOURCE-READER-DISPATCH-MACRO-BIT-VECTOR (STREAM ARG SUB-CHAR)

Source reader #* dispatch macro reader. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/02_dhd.htm>

SOURCE-READER-DISPATCH-MACRO-CHAR (STREAM ARG SUB-CHAR)

Source reader #\ dispatch macro reader.

SOURCE-READER-DISPATCH-MACRO-COMMENT (STREAM ARG SUB-CHAR)

Source reader #| dispatch macro reader.

SOURCE-READER-DISPATCH-MACRO-COMPLEX (STREAM ARG SUB-CHAR)

Source reader #C dispatch macro reader.

SOURCE-READER-DISPATCH-MACRO-FEATURE (STREAM ARG SUB-CHAR)

Source reader #+ dispatch macro reader.

SOURCE-READER-DISPATCH-MACRO-FUNCTION (STREAM ARG SUB-CHAR)

Source reader #' dispatch macro reader.

SOURCE-READER-DISPATCH-MACRO-HEXADECIMAL (STREAM ARG SUB-CHAR)

Source reader #X dispatch macro reader.

SOURCE-READER-DISPATCH-MACRO-LABEL-DEFINITION (STREAM ARG SUB-CHAR)

Source reader #= dispatch macro reader.

SOURCE-READER-DISPATCH-MACRO-LABEL-REFERENCE (STREAM ARG SUB-CHAR)

Source reader ## dispatch macro reader.

SOURCE-READER-DISPATCH-MACRO-NOT-FEATURE (STREAM ARG SUB-CHAR)

Source reader #- dispatch macro reader.

SOURCE-READER-DISPATCH-MACRO-OCTAL (STREAM ARG SUB-CHAR)

Source reader #O dispatch macro reader.

SOURCE-READER-DISPATCH-MACRO-PATHNAME (STREAM ARG SUB-CHAR)

Source reader #P dispatch macro reader.

SOURCE-READER-DISPATCH-MACRO-RADIX (STREAM ARG SUB-CHAR)

Source reader #R dispatch macro reader.

SOURCE-READER-DISPATCH-MACRO-READ-EVAL (STREAM ARG SUB-CHAR)

Source reader #. dispatch macro reader.

SOURCE-READER-DISPATCH-MACRO-STRUCTURE (STREAM ARG SUB-CHAR)

Source reader #S dispatch macro reader.

SOURCE-READER-DISPATCH-MACRO-UNINTERNED (STREAM ARG SUB-CHAR)

Source reader #: dispatch macro reader.

SOURCE-READER-DISPATCH-MACRO-UNREADABLE (STREAM ARG SUB-CHAR)

Source reader #< dispatch macro reader.

SOURCE-READER-DISPATCH-MACRO-VECTOR (STREAM ARG SUB-CHAR)

Source reader #( dispatch macro reader.

SOURCE-READER-MACRO-BACKQUOTE (STREAM CH)

Source reader ` macro reader.

SOURCE-READER-MACRO-COMMA (STREAM CH)

Source reader , macro reader.

SOURCE-READER-MACRO-LEFT-PARENTHESIS (STREAM CH)

Source reader ( macro reader.

SOURCE-READER-MACRO-LINE-COMMENT (STREAM CH)

Source reader ; macro reader.

SOURCE-READER-MACRO-QUOTE (STREAM CH)

Source reader ' macro reader.

SOURCE-READER-MACRO-STRING (STREAM DELIM)

Source reader " macro reader.

Undocumented

SOURCE-READER-DISPATCH-MACRO-ERROR-INVALID (STREAM SUB-CHAR ARG)

SOURCE-READER-MACRO-ERROR-START (STREAM CH)

MACRO

Private

BUILDING-READER-MACRO-SOURCE-OBJECT (STREAM MACRO-CHARACTER CLASS &REST ARGS &KEY &ALLOW-OTHER-KEYS)

DO: Calls BUILDING-SOURCE-OBJECT, keeping track of the file position of the MACRO-CHARACTER. MACRO-CHARACTER: The macro character that has been read (as passed to the reader macro).

BUILDING-SOURCE-OBJECT (STREAM START CLASS &REST ARGS &KEY &ALLOW-OTHER-KEYS)

USAGE: (building-source-object stream *start* 'source-object-class :attribute (source-read stream t nil t) :other-attribute (read-line stream t nil t) #| ... |#) RETURN: the source-object-class instance build. DO: Keep track of the file position to seek back and read again the source, for the text attribute of the instance.

Undocumented

BUILDING-READER-DISPATCH-MACRO-SOURCE-OBJECT (STREAM ARGUMENT SUB-CHAR CLASS &REST INITARGS &KEY &ALLOW-OTHER-KEYS)

WITH-STANDARD-IO-SYNTAX (&BODY BODY)

GENERIC-FUNCTION

Public

Undocumented

SOURCE-ATOM-P (SELF)

Private

Undocumented

MAP-SUBFORMS (FUN SELF)

SLOT-ACCESSOR

Public

COMMENT-TEXT (COMMENT)

The The text of the comment.

SETFCOMMENT-TEXT (NEW-VALUE OBJECT)

Set the The text of the comment.

SOURCE-OBJECT-POSITION (OBJECT)

This are file-positions. We don't keep track of line/column, since this can be done by reading the source file again, as a character file instead of a sexp file..

SETFSOURCE-OBJECT-POSITION (NEW-VALUE OBJECT)

This are file-positions. We don't keep track of line/column, since this can be done by reading the source file again, as a character file instead of a sexp file..

SOURCE-SEQUENCE-ELEMENTS (OBJECT)

Works for conses, lists, and invalid stuff put in parentheses, like ( . . ) Dots are represented by a source-object, so they can appear even in invalid syntaxes.

SETFSOURCE-SEQUENCE-ELEMENTS (NEW-VALUE OBJECT)

Works for conses, lists, and invalid stuff put in parentheses, like ( . . ) Dots are represented by a source-object, so they can appear even in invalid syntaxes.

Undocumented

DISPATCH-MACRO-ARGUMENT (OBJECT)

SETFDISPATCH-MACRO-ARGUMENT (NEW-VALUE OBJECT)

DISPATCH-MACRO-SUB-CHARACTER (OBJECT)

SETFDISPATCH-MACRO-SUB-CHARACTER (NEW-VALUE OBJECT)

MACRO-CHARACTER (OBJECT)

SETFMACRO-CHARACTER (NEW-VALUE OBJECT)

SOURCE-BASE-NUMBER-BASE (OBJECT)

SETFSOURCE-BASE-NUMBER-BASE (NEW-VALUE OBJECT)

SOURCE-BASE-NUMBER-SPECIFIC (OBJECT)

SETFSOURCE-BASE-NUMBER-SPECIFIC (NEW-VALUE OBJECT)

SOURCE-CHARACTER (OBJECT)

SETFSOURCE-CHARACTER (NEW-VALUE OBJECT)

SOURCE-LABEL-DEFINITION-FORM (OBJECT)

SETFSOURCE-LABEL-DEFINITION-FORM (NEW-VALUE OBJECT)

SOURCE-LABEL-DEFINITION-LABEL (OBJECT)

SETFSOURCE-LABEL-DEFINITION-LABEL (NEW-VALUE OBJECT)

SOURCE-LABEL-REFERENCE-LABEL (OBJECT)

SETFSOURCE-LABEL-REFERENCE-LABEL (NEW-VALUE OBJECT)

SOURCE-LEXICAL-ERROR-ERROR (OBJECT)

SETFSOURCE-LEXICAL-ERROR-ERROR (NEW-VALUE OBJECT)

SOURCE-NUMBER-VALUE (OBJECT)

SETFSOURCE-NUMBER-VALUE (NEW-VALUE OBJECT)

SOURCE-OBJECT-FILE (OBJECT)

SETFSOURCE-OBJECT-FILE (NEW-VALUE OBJECT)

SOURCE-OBJECT-SUBFORM (OBJECT)

SETFSOURCE-OBJECT-SUBFORM (NEW-VALUE OBJECT)

SOURCE-OBJECT-TEXT (OBJECT)

SETFSOURCE-OBJECT-TEXT (NEW-VALUE OBJECT)

SOURCE-STRING-VALUE (OBJECT)

SETFSOURCE-STRING-VALUE (NEW-VALUE OBJECT)

SOURCE-TOKEN-TEXT (OBJECT)

SETFSOURCE-TOKEN-TEXT (NEW-VALUE OBJECT)

SOURCE-TOKEN-TRAITS (OBJECT)

SETFSOURCE-TOKEN-TRAITS (NEW-VALUE OBJECT)

VARIABLE

Public

*SOURCE-READTABLE*

The source readtable.

*SOURCE-SIGNAL-ERRORS*

NIL ==> return source-lexical-error objects T ==> signal the errors.

Private

*FILE*

The pathname of the source file.

*MACRO-CHARACTER*

The current dispatch macro character.

*READ-BASE*

Controls the interpretation of tokens by READ as being integers or ratios. The value of *READ-BASE*, called the current input base, is the radix in which integers and ratios are to be read by the Lisp reader. The parsing of other numeric types (e.g., floats) is not affected by this option. The effect of *READ-BASE* on the reading of any particular rational number can be locally overridden by explicit use of the #O, #X, #B, or #nR syntax or by a trailing decimal point. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/v_rd_bas.htm>

*READ-DEFAULT-FLOAT-FORMAT*

Controls the floating-point format that is to be used when reading a floating-point number that has no exponent marker or that has e or E for an exponent marker. Other exponent markers explicitly prescribe the floating-point format to be used. The printer uses *read-default-float-format* to guide the choice of exponent markers when printing floating-point numbers. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/v_rd_def.htm>

*READ-EVAL*

If it is true, the #. reader macro has its normal effect. Otherwise, that reader macro signals an error of type reader-error. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/v_rd_eva.htm>

*READ-SUPPRESS*

This variable is intended primarily to support the operation of the read-time conditional notations #+ and #-. If it is false, the Lisp reader operates normally. If the value of *read-suppress* is true, read, read-preserving-whitespace, read-delimited-list, and read-from-string all return a primary value of nil when they complete successfully. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/v_rd_sup.htm>

*READTABLE*

The value of *READTABLE* is called the current readtable. It controls the parsing behavior of the Lisp reader, and can also influence the Lisp printer (e.g., see the function READTABLE-CASE). URL: <http://www.lispworks.com/documentation/HyperSpec/Body/v_rdtabl.htm>

*START*

The start file position of the current reader dispatch macro character.

*STREAM*

The source stream.

CLASS

Public

COMMENT

Represents a source comment.

Undocumented

DISPATCH-MACRO-CHARACTER-MIXIN

MACRO-CHARACTER-MIXIN

SOURCE-ARRAY

SOURCE-BACKQUOTE

SOURCE-BASE-NUMBER

SOURCE-BIT-VECTOR

SOURCE-CHARACTER (OBJECT)

SOURCE-COMPLEX

SOURCE-FEATURE

SOURCE-FUNCTION

SOURCE-LABEL-DEFINITION

SOURCE-LABEL-REFERENCE

SOURCE-LEXICAL-ERROR

SOURCE-LIST

SOURCE-NOT-FEATURE

SOURCE-NUMBER

SOURCE-OBJECT

SOURCE-PATHNAME

SOURCE-QUOTE

SOURCE-READ-EVAL

SOURCE-SEMICOLON-COMMENT

SOURCE-SEQUENCE

SOURCE-SHARP-PIPE-COMMENT

SOURCE-SPLICE

SOURCE-STRING

SOURCE-STRUCTURE

SOURCE-SUBFORM

SOURCE-TOKEN

SOURCE-UNQUOTE

SOURCE-VECTOR

Private

READTABLE

A READTABLE maps characters into syntax types for the Lisp reader; see Section 2 (Syntax). A readtable also contains associations between macro characters and their reader macro functions, and records information about the case conversion rules to be used by the Lisp reader when parsing symbols. Each simple character must be representable in the readtable. It is implementation-defined whether non-simple characters can have syntax descriptions in the readtable. URL: <http://www.lispworks.com/documentation/HyperSpec/Body/t_rdtabl.htm>