New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

portable way to handle extra right parentheses reader error? #356

Open
alanruttenberg opened this Issue Oct 30, 2016 · 0 comments

Comments

Projects
None yet
1 participant
@alanruttenberg
Contributor

alanruttenberg commented Oct 30, 2016

I hate having it throw an exception. I didn't see how to manage that other than in swank.lisp eval-region. Unfortunately it breaks the backend separation. Can someone suggest a better way of doing this?

(defun eval-region (string)
  "Evaluate STRING.
Return the results of the last form as a list and as secondary value the 
last form."
  (with-input-from-string (stream string)
    (let (- values)
      (loop
    (handler-bind (#+abcl(reader-error
             (lambda (condition)
               (if (equal (slot-value condition 'sys::format-control)
                      "Unmatched right parenthesis.")
                   (progn  
                                 ;; this has got to be the most irritating way to get into the debugger.
                                 ;; stop it.
                                 (warn "ignoring extra right parenthesis")
                                 (return-from eval-region (values values -)))
                   (error condition)))))
      (let ((form (read stream nil stream)))
        (when (eq form stream)
          (finish-output)
          (return (values values -)))
        (setq - form)
        (setq values (multiple-value-list (eval form)))
        (finish-output)))))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment