mirror of
https://gitlab.com/embeddable-common-lisp/ecl.git
synced 2026-03-13 00:10:35 -07:00
exceptions: make reader.d usable in the early env
This commit is contained in:
parent
d715593e20
commit
89457d91f0
3 changed files with 29 additions and 4 deletions
|
|
@ -95,6 +95,12 @@ ecl_exception_handler(cl_object o)
|
|||
case ECL_EX_STRM_UNREAD:
|
||||
FEunread_stream(arg1, arg2);
|
||||
break;
|
||||
case ECL_EX_READ_BADELT:
|
||||
FEreader_error("Found invalid character ~:C", arg1, 1, arg2);
|
||||
break;
|
||||
case ECL_EX_READ_VALUES:
|
||||
FEerror("The readmacro ~S returned ~D values.", 2, arg1, arg2);
|
||||
break;
|
||||
case ECL_EX_EOF:
|
||||
FEend_of_file(arg1);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -26,6 +26,24 @@
|
|||
#include <ecl/ecl-inl.h>
|
||||
#include <ecl/bytecodes.h>
|
||||
|
||||
static void
|
||||
_FEreader_invalid_character(cl_object in, cl_object ch)
|
||||
{
|
||||
ecl_ferror3(ECL_EX_READ_BADELT, in, ch);
|
||||
}
|
||||
|
||||
static void
|
||||
_FEreader_too_many_values(cl_object x, cl_object n)
|
||||
{
|
||||
ecl_ferror3(ECL_EX_READ_VALUES, x, n);
|
||||
}
|
||||
|
||||
static void
|
||||
_FEend_of_file(cl_object in)
|
||||
{
|
||||
ecl_ferror2(ECL_EX_EOF, in);
|
||||
}
|
||||
|
||||
int
|
||||
ecl_readtable_get(cl_object readtable, int c, cl_object *macro, cl_object *table)
|
||||
{
|
||||
|
|
@ -314,7 +332,7 @@ ecl_read_token(cl_object rtbl, cl_object in, int flags)
|
|||
break;
|
||||
}
|
||||
unlikely_if (ecl_invalid_character_p(c) && !suppress) {
|
||||
FEreader_error("Found invalid character ~:C", in, 1, ECL_CODE_CHAR(c));
|
||||
_FEreader_invalid_character(in, ECL_CODE_CHAR(c));
|
||||
}
|
||||
if (read_case != ecl_case_preserve) {
|
||||
if (ecl_upper_case_p(c)) {
|
||||
|
|
@ -369,7 +387,7 @@ ecl_read_object_with_delimiter(cl_object rtbl, cl_object in, int delimiter, int
|
|||
return OBJNULL;
|
||||
}
|
||||
if (c == EOF)
|
||||
FEend_of_file(in);
|
||||
_FEend_of_file(in);
|
||||
a = ecl_readtable_get(rtbl, c, &x, NULL);
|
||||
} while (a == cat_whitespace);
|
||||
if ((a == cat_terminating || a == cat_non_terminating)) {
|
||||
|
|
@ -380,8 +398,7 @@ ecl_read_object_with_delimiter(cl_object rtbl, cl_object in, int delimiter, int
|
|||
goto BEGIN;
|
||||
}
|
||||
unlikely_if (the_env->nvalues > 1) {
|
||||
FEerror("The readmacro ~S returned ~D values.",
|
||||
2, x, ecl_make_fixnum(the_env->nvalues));
|
||||
_FEreader_too_many_values(x, ecl_make_fixnum(the_env->nvalues));
|
||||
}
|
||||
return o;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -976,6 +976,8 @@ typedef enum {
|
|||
ECL_EX_STRM_BADELT, /* invalid stream element type */
|
||||
ECL_EX_STRM_CLOSED, /* the stream is closed */
|
||||
ECL_EX_STRM_UNREAD, /* error while unreading into the stream */
|
||||
ECL_EX_READ_BADELT, /* invalid character when reading a token */
|
||||
ECL_EX_READ_VALUES, /* character macro returned too many values */
|
||||
/* Kludges for the bytecodes VM */
|
||||
ECL_EX_VM_BADARG_EXCD,
|
||||
ECL_EX_VM_BADARG_UNKK,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue