mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2026-03-11 23:40:36 -07:00
reader: low level functions accept explicit readtable argument
Previously the readtable was accessed as a value of a variable *READTABLE*.
This commit is contained in:
parent
f1c3edfeb3
commit
83aa9b8df4
4 changed files with 35 additions and 31 deletions
29
src/c/read.d
29
src/c/read.d
|
|
@ -122,7 +122,8 @@ ecl_read_object_non_recursive(cl_object in)
|
|||
cl_object
|
||||
ecl_read_object(cl_object in)
|
||||
{
|
||||
return ecl_read_object_with_delimiter(in, EOF, 0);
|
||||
cl_object rtbl = ecl_current_readtable();
|
||||
return ecl_read_object_with_delimiter(rtbl, in, EOF, 0);
|
||||
}
|
||||
|
||||
cl_object
|
||||
|
|
@ -130,10 +131,10 @@ si_read_object_or_ignore(cl_object in, cl_object eof)
|
|||
{
|
||||
cl_object x;
|
||||
const cl_env_ptr env = ecl_process_env();
|
||||
|
||||
cl_object rtbl = ecl_current_readtable();
|
||||
ecl_bds_bind(env, @'si::*sharp-eq-context*', ECL_NIL);
|
||||
ecl_bds_bind(env, @'si::*backq-level*', ecl_make_fixnum(0));
|
||||
x = ecl_read_object_with_delimiter(in, EOF, ECL_READ_RETURN_IGNORABLE);
|
||||
x = ecl_read_object_with_delimiter(rtbl, in, EOF, ECL_READ_RETURN_IGNORABLE);
|
||||
if (x == OBJNULL) {
|
||||
env->nvalues = 1;
|
||||
x = eof;
|
||||
|
|
@ -415,8 +416,9 @@ ecl_read_delimited_list(int d, cl_object in, bool proper_list)
|
|||
bool suppress = read_suppress;
|
||||
cl_object x, y = ECL_NIL;
|
||||
cl_object *p = &y;
|
||||
cl_object rtbl = ecl_current_readtable();
|
||||
do {
|
||||
x = ecl_read_object_with_delimiter(in, d, ECL_READ_LIST_DOT);
|
||||
x = ecl_read_object_with_delimiter(rtbl, in, d, ECL_READ_LIST_DOT);
|
||||
if (x == OBJNULL) {
|
||||
/* End of the list. */
|
||||
unlikely_if (after_dot == 1) {
|
||||
|
|
@ -646,6 +648,25 @@ ecl_read_delimited_list(int d, cl_object in, bool proper_list)
|
|||
@(return si_do_read_sequence(sequence, stream, start, end));
|
||||
@)
|
||||
|
||||
cl_object
|
||||
si_read_object(cl_object strm, cl_object delimiter)
|
||||
{
|
||||
cl_env_ptr the_env = ecl_process_env();
|
||||
int ch = Null(delimiter) ? 0 : ecl_char_code(delimiter);
|
||||
cl_object rtbl = ecl_current_readtable();
|
||||
cl_object object = ecl_read_object_with_delimiter(rtbl, strm, ch, 0);
|
||||
ecl_return1(the_env, object);
|
||||
}
|
||||
|
||||
cl_object
|
||||
si_read_token(cl_object strm)
|
||||
{
|
||||
cl_env_ptr the_env = ecl_process_env();
|
||||
cl_object rtbl = ecl_current_readtable();
|
||||
cl_object object = ecl_read_token(rtbl, strm, 0);
|
||||
ecl_return1(the_env, object);
|
||||
}
|
||||
|
||||
/*
|
||||
*----------------------------------------------------------------------
|
||||
*
|
||||
|
|
|
|||
|
|
@ -151,14 +151,13 @@ ecl_dispatch_reader_fun(cl_object in, cl_object dc)
|
|||
}
|
||||
|
||||
cl_object
|
||||
ecl_read_token(cl_object in, bool escape_first_p)
|
||||
ecl_read_token(cl_object rtbl, cl_object in, bool escape_first_p)
|
||||
{
|
||||
int c;
|
||||
cl_object token, string, escape;
|
||||
cl_index length;
|
||||
enum ecl_chattrib a;
|
||||
cl_env_ptr the_env = ecl_process_env();
|
||||
cl_object rtbl = ecl_current_readtable();
|
||||
enum ecl_readtable_case read_case = rtbl->readtable.read_case;
|
||||
cl_fixnum upcase; /* # uppercase characters - # downcase characters */
|
||||
cl_fixnum count; /* number of unescaped characters */
|
||||
|
|
@ -250,13 +249,12 @@ ecl_read_token(cl_object in, bool escape_first_p)
|
|||
}
|
||||
|
||||
cl_object
|
||||
ecl_read_object_with_delimiter(cl_object in, int delimiter, int flags)
|
||||
ecl_read_object_with_delimiter(cl_object rtbl, cl_object in, int delimiter, int flags)
|
||||
{
|
||||
cl_object x, token;
|
||||
int c;
|
||||
enum ecl_chattrib a;
|
||||
cl_env_ptr the_env = ecl_process_env();
|
||||
cl_object rtbl = ecl_current_readtable();
|
||||
bool suppress = read_suppress;
|
||||
BEGIN:
|
||||
do {
|
||||
|
|
@ -294,7 +292,7 @@ ecl_read_object_with_delimiter(cl_object in, int delimiter, int flags)
|
|||
return o;
|
||||
}
|
||||
ecl_unread_char(c, in);
|
||||
token = ecl_read_token(in, 0);
|
||||
token = ecl_read_token(rtbl, in, 0);
|
||||
if (suppress) {
|
||||
x = ECL_NIL;
|
||||
} else {
|
||||
|
|
@ -303,20 +301,3 @@ ecl_read_object_with_delimiter(cl_object in, int delimiter, int flags)
|
|||
ecl_put_reader_token(token);
|
||||
return x;
|
||||
}
|
||||
|
||||
cl_object
|
||||
si_read_object(cl_object strm, cl_object delimiter)
|
||||
{
|
||||
cl_env_ptr the_env = ecl_process_env();
|
||||
int ch = Null(delimiter) ? 0 : ecl_char_code(delimiter);
|
||||
cl_object object = ecl_read_object_with_delimiter(strm, ch, 0);
|
||||
ecl_return1(the_env, object);
|
||||
}
|
||||
|
||||
cl_object
|
||||
si_read_token(cl_object strm)
|
||||
{
|
||||
cl_env_ptr the_env = ecl_process_env();
|
||||
cl_object object = ecl_read_token(strm, 0);
|
||||
ecl_return1(the_env, object);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -214,6 +214,7 @@ sharp_backslash_reader(cl_object in, cl_object c, cl_object d)
|
|||
{
|
||||
const cl_env_ptr the_env = ecl_process_env();
|
||||
cl_object token, string;
|
||||
cl_object rtbl = ecl_current_readtable();
|
||||
bool suppress = read_suppress;
|
||||
if (d != ECL_NIL && !suppress) {
|
||||
unlikely_if (!ECL_FIXNUMP(d) || d != ecl_make_fixnum(0)) {
|
||||
|
|
@ -221,10 +222,10 @@ sharp_backslash_reader(cl_object in, cl_object c, cl_object d)
|
|||
}
|
||||
}
|
||||
if(suppress) {
|
||||
ecl_read_token(in, 1);
|
||||
ecl_read_token(rtbl, in, 1);
|
||||
return ECL_NIL;
|
||||
}
|
||||
token = ecl_read_token(in, 1);
|
||||
token = ecl_read_token(rtbl, in, 1);
|
||||
string = token->token.string;
|
||||
if (TOKEN_STRING_FILLP(string) == 1) {
|
||||
c = ECL_CODE_CHAR(TOKEN_STRING_CHAR(string,0));
|
||||
|
|
@ -389,6 +390,7 @@ sharp_left_parenthesis_reader(cl_object in, cl_object c, cl_object d)
|
|||
extern int _cl_backq_car(cl_object *);
|
||||
const cl_env_ptr the_env = ecl_process_env();
|
||||
cl_object v;
|
||||
cl_object rtbl = ecl_current_readtable();
|
||||
unlikely_if (!Null(d) &&
|
||||
(!ECL_FIXNUMP(d) || ecl_fixnum_minusp(d) ||
|
||||
ecl_fixnum_greater(d, ecl_make_fixnum(ECL_ARRAY_DIMENSION_LIMIT))))
|
||||
|
|
@ -423,7 +425,7 @@ sharp_left_parenthesis_reader(cl_object in, cl_object c, cl_object d)
|
|||
cl_index dim = ecl_fixnum(d), i;
|
||||
v = ecl_alloc_simple_vector(dim, ecl_aet_object);
|
||||
for (i = 0, last = ECL_NIL;; i++) {
|
||||
cl_object aux = ecl_read_object_with_delimiter(in, ')', 0);
|
||||
cl_object aux = ecl_read_object_with_delimiter(rtbl, in, ')', 0);
|
||||
if (aux == OBJNULL)
|
||||
break;
|
||||
unlikely_if (i >= dim) {
|
||||
|
|
|
|||
|
|
@ -1577,9 +1577,9 @@ extern ECL_API cl_object ecl_read_delimited_list(int d, cl_object strm, bool pro
|
|||
extern ECL_API cl_object ecl_dispatch_reader_fun(cl_object in, cl_object dc);
|
||||
extern ECL_API cl_object ecl_read_eval(cl_object in);
|
||||
extern ECL_API cl_object ecl_read_object_non_recursive(cl_object in);
|
||||
extern ECL_API cl_object ecl_read_object_with_delimiter(cl_object in, int del, int flags);
|
||||
extern ECL_API cl_object ecl_read_object_with_delimiter(cl_object rtbl, cl_object in, int del, int flags);
|
||||
extern ECL_API cl_object ecl_read_object(cl_object in);
|
||||
extern ECL_API cl_object ecl_read_token(cl_object in, bool esc);
|
||||
extern ECL_API cl_object ecl_read_token(cl_object rtbl, cl_object in, bool esc);
|
||||
extern ECL_API cl_object ecl_parse_token(cl_object token, cl_object in, int flags);
|
||||
extern ECL_API cl_object ecl_parse_number(cl_object s, cl_index start, cl_index end, cl_index *ep, unsigned int radix);
|
||||
extern ECL_API cl_object ecl_parse_integer(cl_object s, cl_index start, cl_index end, cl_index *ep, unsigned int radix);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue