Wiki
Download
Manual
Eggs
API
Tests
Bugs
show
edit
history
You can edit this page using
wiki syntax
for markup.
Article contents:
[[tags: manual]] [[toc:]] == Module (chicken read-syntax) This module provides procedures which can be used to extend the reader with custom read syntax. === define-reader-ctor <procedure>(define-reader-ctor SYMBOL PROC)</procedure> Define new read-time constructor for {{#,}} read syntax. For further information, see the documentation for [[http://srfi.schemers.org/srfi-10/srfi-10.html|SRFI-10]]. === set-read-syntax! <procedure>(set-read-syntax! CHAR-OR-SYMBOL PROC)</procedure> When the reader encounters the non-whitespace character {{CHAR}} while reading an expression from a given port, then the procedure {{PROC}} will be called with that port as its argument. The procedure should return a value that will be returned to the reader: <enscript highlight=scheme> ; A simple RGB color syntax: (set-read-syntax! #\% (lambda (port) (apply vector (map (cut string->number <> 16) (string-chop (read-string 6 port) 2) ) ) ) ) (with-input-from-string "(1 2 %f0f0f0 3)" read) ; ==> (1 2 #(240 240 240) 3) </enscript> If {{CHAR-OR-SYMBOL}} is a symbol, then a so-called ''read-mark'' handler is defined. In that case the handler procedure will be called when a character-sequence of the form {{#!SYMBOL}} is encountered. You can undo special handling of read-syntax by passing {{#f}} as the second argument (if the syntax was previously defined via {{set-read-syntax!}}). As a special case, your handler can return zero values, via {{(values)}}. This causes the reader to completely ignore whatever input you've read, rather than returning some possibly unspecified value. This can be useful in macro context, reading comments, conditional compilation, and so forth. Available in CHICKEN 4.6.6 and later. Note that all of CHICKEN's special non-standard read-syntax is handled directly by the reader. To disable built-in read-syntax, define a handler that triggers an error (for example). === set-sharp-read-syntax! <procedure>(set-sharp-read-syntax! CHAR-OR-SYMBOL PROC)</procedure> Similar to {{set-read-syntax!}}, but allows defining new {{#<CHAR> ...}} reader syntax. If the first argument is a symbol, then this procedure is equivalent to {{set-read-syntax!}}. {{PROC}} may be {{#f}} to disable previously defined "sharp" read syntax. === set-parameterized-read-syntax! <procedure>(set-parameterized-read-syntax! CHAR-OR-SYMBOL PROC)</procedure> Similar to {{set-sharp-read-syntax!}}, but intended for defining reader syntax of the form {{#<NUMBER><CHAR> ...}}. The handler procedure {{PROC}} will be called with two arguments: the input port and the number preceding the dispatching character. If the first argument is a symbol, then this procedure is equivalent to {{set-read-syntax!}}. {{PROC}} may be {{#f}} to disable previously defined parameterized read syntax. === copy-read-table <procedure>(copy-read-table READ-TABLE)</procedure> Returns a copy of the given read-table. You can access the currently active read-table with {{(current-read-table)}}. This procedure can be useful to restore an old read-table after temporarily introducing new read syntax. === current-read-table <parameter>(current-read-table)</parameter> A read-table object that holds read-procedures for special non-standard read-syntax (see {{set-read-syntax!}} for more information). --- Previous: [[Module (chicken random)]] Next: [[Module (chicken repl)]]
Description of your changes:
I would like to authenticate
Authentication
Username:
Password:
Spam control
What do you get when you multiply 9 by 7?