{
SCM new_tail;
+ if (c == ')' || (SCM_SQUARE_BRACKETS_P && c == ']'))
+ scm_i_input_error (FUNC_NAME, port,
+ "in pair: mismatched close paren: ~A",
+ scm_list_1 (SCM_MAKE_CHAR (c)));
+
scm_ungetc (c, port);
- if (scm_is_eq (scm_sym_dot,
- (tmp = scm_read_expression (port))))
+ tmp = scm_read_expression (port);
+
+ if (scm_is_eq (scm_sym_dot, tmp))
{
SCM_SETCDR (tl, tmp = scm_read_expression (port));
(cons 'read-error "illegal character in escape sequence: .*$"))
(define exception:missing-expression
(cons 'read-error "no expression after #;"))
+(define exception:mismatched-paren
+ (cons 'read-error "mismatched close paren"))
(define (read-string s)
;; mutable objects.
(let ((str (with-input-from-string "\"hello, world\"" read)))
(string-set! str 0 #\H)
- (string=? str "Hello, world"))))
+ (string=? str "Hello, world")))
+
+ (pass-if "square brackets are parens"
+ (equal? '() (read-string "[]")))
+
+ (pass-if-exception "paren mismatch" exception:unexpected-rparen
+ (read-string "'[)"))
+
+ (pass-if-exception "paren mismatch (2)" exception:mismatched-paren
+ (read-string "'(]")))
+
\f
(pass-if-exception "radix passed to number->string can't be zero"