| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |
text.parse - Parsing input stream
You can use this module in place of his
input-parse.scm and look-for-str.scm.
I reimplemented the functions to be efficient on Gauche.
Especially, usage of string-set! is totally avoided.
I extended the interface a bit so that they can deal with character sets
and predicates, as well as a list of characters.
These functions work sequentially on the given input port, that is, they read from the port as much as they need, without buffering extra characters.
If str is found, this function returns the number of characters
it has read. The next read from in-port returns the next char
of str. If str is not found, it returns #f.
Note: Although this procedure has `?' in its name,
it may return non-boolean value, contrary to the Scheme convention.
In the following functions, char-list refers to one of the followings:
*eof*.
*eof* is
included, the EOF condition is also included. Without *eof*,
the EOF condition is regarded as an error.
#f.
If the input is not long enough, an error is signalled.
IF char-list/number is a char-list, it reads from port
until it sees a character that belongs to the char-list.
Then the character is returned.
If port is omitted, the current input port is used.
This example skips whitespaces from input. Next read from port returns the first non-whitespace character.
(skip-while #[\s] port) |
If the function encounters EOF and *eof* is not included in
break-char-list, an error is signalled with comment is
included in the message.
char-list/pred may be a char-list or a predicate that takes a character. If it is a predicate, each character is passed to it, and the character is regarded to "belong to" char-list/pred when it returns a true value.
| [ < ] | [ > ] | [ << ] | [ Up ] | [ >> ] | [Top] | [Contents] | [Index] | [ ? ] |