       (insert-buffer-substring buffer) ; lose the text properties
       (psl-remove-comments)
       (goto-char (point-min))
-      (let ((sexp (mpd-match 'expr psl-tokens psl-token-funcs)))
+      (let ((sexp
+             (let ((max-lisp-eval-depth
+                    (floor (* psl-stack-multiplier max-lisp-eval-depth))))
+               (mpd-match 'expr psl-tokens psl-token-funcs))))
         (mpd-skip-whitespace)
         (if (= (point) (point-max))
             sexp

;; can use `psl-eval-buffer' to compile the current buffer and
;; evaluate the result. Compilation output (mainly for compiler
;; debugging) can be viewed with `psl-show-elisp-compilation'.

;;; Known bugs:


(require 'cl)
(require 'pp)

(defvar psl-stack-multiplier 4
  "Increase `max-lisp-eval-depth' by this factor when parsing.")

(defun psl-compile-to-elisp ()
  "Compile the current buffer into an Emacs Lisp s-expression."
  (let ((buffer (current-buffer)))
