fixing some error handling in brace syntax

This commit is contained in:
Alex Shinn 2011-08-28 18:18:30 +09:00
parent 34638780bd
commit 5abb66e86d

11
sexp.c
View file

@ -79,7 +79,8 @@ sexp sexp_write_simple_object (sexp ctx sexp_api_params(self, n), sexp obj, sexp
for (i=0; i<len; i++) { for (i=0; i<len; i++) {
x = sexp_slot_ref(obj, i); x = sexp_slot_ref(obj, i);
if (x) { if (x) {
while (nulls--) sexp_write_string(ctx, " #<null>", out); if (nulls)
while (--nulls) sexp_write_string(ctx, " #<null>", out);
sexp_write_char(ctx, ' ', out); sexp_write_char(ctx, ' ', out);
sexp_write(ctx, sexp_slot_ref(obj, i), out); sexp_write(ctx, sexp_slot_ref(obj, i), out);
} else { } else {
@ -2074,7 +2075,7 @@ sexp sexp_read_raw (sexp ctx, sexp in) {
break; break;
} else if (tmp2 == SEXP_CLOSE_BRACE) { } else if (tmp2 == SEXP_CLOSE_BRACE) {
break; break;
} else if (c1 >= sexp_type_num_slots_of_object(ctx, tmp)) { } else if (c1 >= sexp_type_field_len_base(tmp)) {
res = sexp_read_error(ctx, "too many slots in object literal", res, in); res = sexp_read_error(ctx, "too many slots in object literal", res, in);
break; break;
} else { } else {
@ -2299,7 +2300,11 @@ sexp sexp_read_op (sexp ctx sexp_api_params(self, n), sexp in) {
res = sexp_read_raw(ctx, in); res = sexp_read_raw(ctx, in);
if (res == SEXP_CLOSE) if (res == SEXP_CLOSE)
res = sexp_read_error(ctx, "too many ')'s", SEXP_NULL, in); res = sexp_read_error(ctx, "too many ')'s", SEXP_NULL, in);
if (res == SEXP_RAWDOT) #if SEXP_USE_OBJECT_BRACE_LITERALS
else if (res == SEXP_CLOSE_BRACE)
res = sexp_read_error(ctx, "too many '}'s", SEXP_NULL, in);
#endif
else if (res == SEXP_RAWDOT)
res = sexp_read_error(ctx, "unexpected '.'", SEXP_NULL, in); res = sexp_read_error(ctx, "unexpected '.'", SEXP_NULL, in);
return res; return res;
} }