1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-10 14:00:21 +02:00

* libguile/eval.c (s_expression): Added comment.

(s_empty_combination, error_unbound_variable): New static
	identifiers.

	(SCM_VALIDATE_NON_EMPTY_COMBINATION, SCM_EVALIM2, scm_lookupcar1):
	Use ASSERT_SYNTAX, syntax_error or error_unbound_variable to
	signal syntax errors.

	(SCM_CEVAL): Separated handling of evaluator bytecodes and other
	scheme objects.

	* test-suite/tests/syntax.test (exception:missing/extra-expr-misc):
	Removed.

	(exception:illegal-empty-combination): New.

	(exception:missing/extra-expr): Unified capitalization.

	Adapted test for '()' to the new way of error reporting.
This commit is contained in:
Dirk Herrmann 2003-11-01 07:26:44 +00:00
parent 60a4984209
commit 89bff2fc10
4 changed files with 63 additions and 20 deletions

View file

@ -1,3 +1,17 @@
2003-11-01 Dirk Herrmann <D.Herrmann@tu-bs.de>
* eval.c (s_expression): Added comment.
(s_empty_combination, error_unbound_variable): New static
identifiers.
(SCM_VALIDATE_NON_EMPTY_COMBINATION, SCM_EVALIM2, scm_lookupcar1):
Use ASSERT_SYNTAX, syntax_error or error_unbound_variable to
signal syntax errors.
(SCM_CEVAL): Separated handling of evaluator bytecodes and other
scheme objects.
2003-10-25 Dirk Herrmann <D.Herrmann@tu-bs.de>
* eval.c (unmemocar, sym_three_question_marks, scm_unmemocar):

View file

@ -101,6 +101,11 @@ char *alloca ();
* expression is expected, a 'Bad expression' error is signalled. */
static const char s_bad_expression[] = "Bad expression";
/* If a form is detected that holds a different number of expressions than are
* required in that context, a 'Missing or extra expression' error is
* signalled. */
static const char s_expression[] = "Missing or extra expression in";
/* If a form is detected that holds less expressions than are required in that
* context, a 'Missing expression' error is signalled. */
static const char s_missing_expression[] = "Missing expression in";
@ -109,6 +114,13 @@ static const char s_missing_expression[] = "Missing expression in";
* context, an 'Extra expression' error is signalled. */
static const char s_extra_expression[] = "Extra expression in";
/* The empty combination '()' is not allowed as an expression in scheme. If
* it is detected in a place where an expression is expected, an 'Illegal
* empty combination' error is signalled. Note: If you encounter this error
* message, it is very likely that you intended to denote the empty list. To
* do so, you need to quote the empty list like (quote ()) or '(). */
static const char s_empty_combination[] = "Illegal empty combination";
/* Case or cond expressions must have at least one clause. If a case or cond
* expression without any clauses is detected, a 'Missing clauses' error is
* signalled. */
@ -327,10 +339,7 @@ SCM_DEFINE (scm_dbg_iloc_p, "dbg-iloc?", 1, 0, 0,
#define SCM_VALIDATE_NON_EMPTY_COMBINATION(x) \
do { \
if (SCM_EQ_P ((x), SCM_EOL)) \
scm_misc_error (NULL, s_expression, SCM_EOL); \
} while (0)
ASSERT_SYNTAX (!SCM_EQ_P ((x), SCM_EOL), s_empty_combination, x)
@ -367,7 +376,7 @@ SCM_DEFINE (scm_dbg_iloc_p, "dbg-iloc?", 1, 0, 0,
#define SCM_EVALIM2(x) \
((SCM_EQ_P ((x), SCM_EOL) \
? scm_misc_error (NULL, s_expression, SCM_EOL), 0 \
? syntax_error (s_empty_combination, (x), SCM_UNDEFINED), 0 \
: 0), \
(x))
@ -394,7 +403,6 @@ SCM_DEFINE (scm_dbg_iloc_p, "dbg-iloc?", 1, 0, 0,
SCM_REC_MUTEX (source_mutex);
static const char s_expression[] = "missing or extra expression";
static const char s_test[] = "bad test";
static const char s_body[] = "bad body";
static const char s_bindings[] = "bad bindings";
@ -431,6 +439,18 @@ scm_ilookup (SCM iloc, SCM env)
}
SCM_SYMBOL (scm_unbound_variable_key, "unbound-variable");
static void error_unbound_variable (SCM symbol) SCM_NORETURN;
static void
error_unbound_variable (SCM symbol)
{
scm_error (scm_unbound_variable_key, NULL,
"Unbound variable: ~S",
scm_list_1 (symbol), SCM_BOOL_F);
}
/* The Lookup Car Race
- by Eva Luator
@ -504,8 +524,6 @@ scm_ilookup (SCM iloc, SCM env)
for NULL. I think I've found the only places where this
applies. */
SCM_SYMBOL (scm_unbound_variable_key, "unbound-variable");
static SCM *
scm_lookupcar1 (SCM vloc, SCM genv, int check)
{
@ -568,9 +586,7 @@ scm_lookupcar1 (SCM vloc, SCM genv, int check)
if (check)
{
if (SCM_NULLP (env))
scm_error (scm_unbound_variable_key, NULL,
"Unbound variable: ~S",
scm_list_1 (var), SCM_BOOL_F);
error_unbound_variable (var);
else
scm_misc_error (NULL, "Damaged environment: ~S",
scm_list_1 (var));
@ -1840,6 +1856,7 @@ scm_m_expand_body (SCM xorig, SCM env)
return xorig;
}
SCM
scm_macroexp (SCM x, SCM env)
{
@ -2602,11 +2619,6 @@ dispatch:
SCM_TICK;
switch (SCM_TYP7 (x))
{
case scm_tc7_symbol:
/* Only happens when called at top level. */
x = scm_cons (x, SCM_UNDEFINED);
RETURN (*scm_lookupcar (x, env, 1));
case SCM_BIT7 (SCM_IM_AND):
x = SCM_CDR (x);
while (!SCM_NULLP (SCM_CDR (x)))
@ -3286,10 +3298,12 @@ dispatch:
goto evapply;
}
default:
proc = x;
goto evapply;
case scm_tc7_vector:
case scm_tc7_wvect:
#if SCM_HAVE_ARRAYS
@ -3315,6 +3329,11 @@ dispatch:
case scm_tcs_struct:
RETURN (x);
case scm_tc7_symbol:
/* Only happens when called at top level. */
x = scm_cons (x, SCM_UNDEFINED);
RETURN (*scm_lookupcar (x, env, 1));
case scm_tc7_variable:
RETURN (SCM_VARIABLE_REF(x));

View file

@ -1,3 +1,13 @@
2003-11-01 Dirk Herrmann <D.Herrmann@tu-bs.de>
* tests/syntax.test (exception:missing/extra-expr-misc): Removed.
(exception:illegal-empty-combination): New.
(exception:missing/extra-expr): Unified capitalization.
Adapted test for '()' to the new way of error reporting.
2003-10-19 Kevin Ryde <user42@zip.com.au>
* tests/numbers.test: Use define-module to hide helper defines.

View file

@ -24,14 +24,14 @@
(define exception:bad-expression
(cons 'syntax-error "Bad expression"))
(define exception:missing/extra-expr-misc
(cons 'misc-error "^missing or extra expression"))
(define exception:missing/extra-expr
(cons 'syntax-error "missing or extra expression"))
(cons 'syntax-error "Missing or extra expression"))
(define exception:missing-expr
(cons 'syntax-error "Missing expression"))
(define exception:extra-expr
(cons 'syntax-error "Extra expression"))
(define exception:illegal-empty-combination
(cons 'syntax-error "Illegal empty combination"))
(define exception:bad-bindings
(cons 'syntax-error "Bad bindings"))
@ -86,7 +86,7 @@
;; Fixed on 2001-3-3
(pass-if-exception "empty parentheses \"()\""
exception:missing/extra-expr-misc
exception:illegal-empty-combination
(eval '()
(interaction-environment)))))