mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2026-03-09 06:30:32 -07:00
[nucl] adjust to the new reader implementation
This commit is contained in:
parent
c4bbfad258
commit
758de4e73f
1 changed files with 15 additions and 12 deletions
27
src/c/nucl.c
27
src/c/nucl.c
|
|
@ -156,7 +156,8 @@ nucl_alloc_readtable(void) {
|
|||
rtable->readtable.table = rtab;
|
||||
for (int i = 0; i < RTABSIZE; i++) {
|
||||
rtab[i].syntax_type = cat_constituent; /* enum ecl_chattrib */
|
||||
rtab[i].dispatch = ECL_NIL;
|
||||
rtab[i].macro = ECL_NIL;
|
||||
rtab[i].table = ECL_NIL;
|
||||
}
|
||||
#ifdef ECL_UNICODE
|
||||
rtable->readtable.hash = ECL_NIL;
|
||||
|
|
@ -554,7 +555,8 @@ nucl_readtable_set(cl_object self, cl_fixnum c, enum ecl_chattrib cat,
|
|||
if (c >= RTABSIZE) {
|
||||
ecl_internal_error("Character is too big!");
|
||||
}
|
||||
self->readtable.table[c].dispatch = macro;
|
||||
self->readtable.table[c].macro = macro;
|
||||
self->readtable.table[c].table = ECL_NIL;
|
||||
self->readtable.table[c].syntax_type = cat;
|
||||
}
|
||||
|
||||
|
|
@ -678,8 +680,8 @@ mixnum_reader(int narg, cl_object c)
|
|||
cl_object reg = nucl_read_char(ECL_NIL);
|
||||
struct ecl_readtable_entry *entry
|
||||
= nucl_readtable_get(rtable, ECL_CHAR_CODE(reg));
|
||||
if(entry->dispatch == _fixnum_reader || entry->dispatch == _hexnum_reader) {
|
||||
reg = _ecl_funcall2(entry->dispatch, reg);
|
||||
if(entry->macro == _fixnum_reader || entry->macro == _hexnum_reader) {
|
||||
reg = _ecl_funcall2(entry->macro, reg);
|
||||
return ecl_eql(c, ECL_CODE_CHAR('-'))
|
||||
? ecl_make_fixnum(-ecl_fixnum(reg))
|
||||
: reg;
|
||||
|
|
@ -696,15 +698,16 @@ init_nucl_reader(void)
|
|||
|
||||
for (int i = 0; i < RTABSIZE; i++) {
|
||||
rtab[i].syntax_type = cat_constituent;
|
||||
rtab[i].dispatch = _symbol_reader;
|
||||
rtab[i].macro = _symbol_reader;
|
||||
rtab[i].table = ECL_NIL;
|
||||
}
|
||||
|
||||
for (char *s="123456789"; *s!='\0'; s++)
|
||||
rtab[*s].dispatch = _fixnum_reader;
|
||||
rtab[*s].macro = _fixnum_reader;
|
||||
|
||||
rtab['0'].dispatch = _hexnum_reader;
|
||||
rtab['-'].dispatch = _mixnum_reader;
|
||||
rtab['+'].dispatch = _mixnum_reader;
|
||||
rtab['0'].macro = _hexnum_reader;
|
||||
rtab['-'].macro = _mixnum_reader;
|
||||
rtab['+'].macro = _mixnum_reader;
|
||||
|
||||
nucl_readtable_set(rtable, '\t', cat_whitespace, ECL_NIL);
|
||||
nucl_readtable_set(rtable, '\n', cat_whitespace, ECL_NIL);
|
||||
|
|
@ -750,13 +753,13 @@ nucl_accept(cl_object delim)
|
|||
/* Here's some nuance -- if the first constituent character has an
|
||||
associated dispatch function, then we use it instead of a default
|
||||
reader. In our case this always happens. */
|
||||
if(Null(entry->dispatch))
|
||||
if(Null(entry->macro))
|
||||
default_reader(1, ch);
|
||||
else
|
||||
result = _ecl_funcall2(entry->dispatch, ch);
|
||||
result = _ecl_funcall2(entry->macro, ch);
|
||||
break;
|
||||
case cat_terminating:
|
||||
result = _ecl_funcall2(entry->dispatch, ch);
|
||||
result = _ecl_funcall2(entry->macro, ch);
|
||||
break;
|
||||
default:
|
||||
ecl_internal_error("Expecting too much, aren't we?");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue