The read-as-string Reference Manual

This is the read-as-string Reference Manual, version 3.0.0, generated automatically by Declt version 4.0 beta 2 "William Riker" on Mon Feb 26 17:44:43 2024 GMT+0.

Table of Contents


1 Introduction


2 Systems

The main system appears first, followed by any subsystem dependency.


2.1 read-as-string

Reading S-Expression string from stream.

Author

SATO Shinichi

Source Control

(GIT git@github.com:hyotang666/read-as-string)

Bug Tracker

https://github.com/hyotang666/read-as-string/issues

License

MIT

Long Description

# READ-AS-STRING 3.0.0
## What is this?
Reading S-Expression string from stream.

## Current lisp world
Unlike UNIX, Lisp has READ.
Lisp programmer does not make effort to make S-Expression parser (UNIX has awk though).

## Issues
Sometime we need to analyze S-Expression statically.
In this context, ’static’ means does not construct lisp object but string.
But lisp does not have such feature.

## Proposal
READ-AS-STRING do it.

## Usage
“‘lisp
(let ((sexp "(CAR (liSt :a 45.))"))
(print (read-from-string sexp))
(with-input-from-string (s sexp)
(print (read-as-string s))))
(CAR (LIST :A 45)) ; <— Output of CL:READ-FROM-STRING.
"(CAR (liSt :a 45.))" ; <— Output of READ-AS-STRING.
“‘
Usually ‘(read-from-string (read-as-string stream))‘ is same with ‘(read stream)‘.

## Exception
### Comment
Read-as-string does not discard comment.

“‘lisp
(with-input-from-string (s "; line comment")
(read-as-string s))
"; line comment"
“‘

### Read time condition.
Read-as-string does not discard any read time condition.

“‘lisp
(with-input-from-string (s "#+() test")
(read-as-string s))
"#+() test"
“‘

## Readtable.

### Readers.
For efficiency, in other words, in order to avoid constructing the intermediate string repeatedly,
each reader is designed as a printer to the standard output.
Read-as-string the top-level interface captures all output and then builds a string.

If you want to extend a readtable, your reader should have API as (function * null).

### How to extend.
Read-as-string provides readtable named as-string.
To extend macro character, you can do it with an ordinary lisp manner
but to extend dispatch macro character, you need to obey our manner.
Under the hood, we need to use our own # macro character for generating the dispatch macro character notation string. In other words, we can not use common lisp default dispatch macro character features.
In order to extend the dispatch macro character,
you should use read-as-string:set-dispatcher instead of cl:set-dispatch-macro-character.

“‘lisp
(let ((read-as-string:*default-readtable*
(named-readtables:copy-named-readtable ’read-as-string:as-string)))
(read-as-string:set-dispatcher #\! ’|#!reader|)
(read-as-string:read-as-string))
“‘

## From developer

### Product’s goal
Eliminate bugs.
### License
MIT

### Tested with
* SBCL/2.2.5
* CCL/1.12.1
* CLISP/2.49
* ECL/21.2.1
* Allegro/10.1
* CMUCL/21D
* ABCL/1.9.0

Version

3.0.0

Dependencies
  • named-readtables (system).
  • core-reader (system).
Source

read-as-string.asd.

Child Component

read-as-string.lisp (file).


3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


3.1 Lisp


3.1.1 read-as-string/read-as-string.asd

Source

read-as-string.asd.

Parent Component

read-as-string (system).

ASDF Systems

read-as-string.


3.1.2 read-as-string/read-as-string.lisp

Source

read-as-string.asd.

Parent Component

read-as-string (system).

Packages

read-as-string.

Public Interface
Internals

4 Packages

Packages are listed by definition order.


4.1 read-as-string

Source

read-as-string.lisp.

Use List
  • common-lisp.
  • core-reader.
Public Interface
Internals

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


5.1 Public Interface


5.1.1 Special variables

Special Variable: *default-readtable*
Package

read-as-string.

Source

read-as-string.lisp.

Special Variable: *muffle-reader-error*
Package

read-as-string.

Source

read-as-string.lisp.


5.1.2 Ordinary functions

Function: get-dispatcher (char &optional *readtable*)
Package

read-as-string.

Source

read-as-string.lisp.

Function: read-as-string (&optional stream eof-error-p eof-value recursive-p)
Package

read-as-string.

Source

read-as-string.lisp.

Function: read-token (&optional stream)
Package

read-as-string.

Source

read-as-string.lisp.

Function: set-dispatcher (char fun &optional readtable)
Package

read-as-string.

Source

read-as-string.lisp.


5.1.3 Conditions

Condition: no-dispatch-function
Package

read-as-string.

Source

read-as-string.lisp.

Direct superclasses
  • cell-error.
  • reader-error.
Condition: read-unreadable-object
Package

read-as-string.

Source

read-as-string.lisp.

Direct superclasses

reader-error.


5.2 Internals


5.2.1 Special variables

Special Variable: *dispatch-macros*
Package

read-as-string.

Source

read-as-string.lisp.


5.2.2 Ordinary functions

Function: "reader (stream character)
Package

read-as-string.

Source

read-as-string.lisp.

Function: ##reader (stream character number)
Package

read-as-string.

Source

read-as-string.lisp.

Function: #+reader (stream character number)
Package

read-as-string.

Source

read-as-string.lisp.

Function: #<reader (stream character number)
Package

read-as-string.

Source

read-as-string.lisp.

Function: #=reader (stream character number)
Package

read-as-string.

Source

read-as-string.lisp.

Function: #\reader (stream character number)
Package

read-as-string.

Source

read-as-string.lisp.

Function: #paren-reader (stream character number)
Package

read-as-string.

Source

read-as-string.lisp.

Function: #reader (stream character)
Package

read-as-string.

Source

read-as-string.lisp.

Function: #|reader (stream character number)
Package

read-as-string.

Source

read-as-string.lisp.

Function: %read-as-string (&optional stream eof-error-p eof-value recursive-p)
Package

read-as-string.

Source

read-as-string.lisp.

Function: %read-token (&optional stream)
Package

read-as-string.

Source

read-as-string.lisp.

Function: 'reader (stream character)
Package

read-as-string.

Source

read-as-string.lisp.

Function: ,reader (stream character)
Package

read-as-string.

Source

read-as-string.lisp.

Function: ;reader (stream character)
Package

read-as-string.

Source

read-as-string.lisp.

Function: `reader (stream character)
Package

read-as-string.

Source

read-as-string.lisp.

Function: paren-reader (stream character)
Package

read-as-string.

Source

read-as-string.lisp.


Appendix A Indexes


A.1 Concepts


A.2 Functions

Jump to:   "   #   %   '   ,   ;   `  
F   G   P   R   S  
Index Entry  Section

"
"reader: Private ordinary functions

#
##reader: Private ordinary functions
#+reader: Private ordinary functions
#<reader: Private ordinary functions
#=reader: Private ordinary functions
#paren-reader: Private ordinary functions
#reader: Private ordinary functions
#\reader: Private ordinary functions
#|reader: Private ordinary functions

%
%read-as-string: Private ordinary functions
%read-token: Private ordinary functions

'
'reader: Private ordinary functions

,
,reader: Private ordinary functions

;
;reader: Private ordinary functions

`
`reader: Private ordinary functions

F
Function, "reader: Private ordinary functions
Function, ##reader: Private ordinary functions
Function, #+reader: Private ordinary functions
Function, #<reader: Private ordinary functions
Function, #=reader: Private ordinary functions
Function, #paren-reader: Private ordinary functions
Function, #reader: Private ordinary functions
Function, #\reader: Private ordinary functions
Function, #|reader: Private ordinary functions
Function, %read-as-string: Private ordinary functions
Function, %read-token: Private ordinary functions
Function, 'reader: Private ordinary functions
Function, ,reader: Private ordinary functions
Function, ;reader: Private ordinary functions
Function, get-dispatcher: Public ordinary functions
Function, paren-reader: Private ordinary functions
Function, read-as-string: Public ordinary functions
Function, read-token: Public ordinary functions
Function, set-dispatcher: Public ordinary functions
Function, `reader: Private ordinary functions

G
get-dispatcher: Public ordinary functions

P
paren-reader: Private ordinary functions

R
read-as-string: Public ordinary functions
read-token: Public ordinary functions

S
set-dispatcher: Public ordinary functions