Function: semantic-lex-catch-errors
semantic-lex-catch-errors is a macro defined in lex.el.gz.
Signature
(semantic-lex-catch-errors SYMBOL &rest FORMS)
Documentation
Using SYMBOL, execute FORMS catching lexical errors.
If FORMS results in a call to the parser that throws a lexical error, the error will be caught here without the buffer's cache being thrown out of date. If there is an error, the syntax that failed is returned. If there is no error, then the last value of FORMS is returned.
Source Code
;; Defined in /usr/src/emacs/lisp/cedet/semantic/lex.el.gz
;;; Lexical Safety
;;
;; The semantic lexers, unlike other lexers, can throw errors on
;; unbalanced syntax. Since editing is all about changing text
;; we need to provide a convenient way to protect against syntactic
;; inequalities.
(defmacro semantic-lex-catch-errors (symbol &rest forms)
"Using SYMBOL, execute FORMS catching lexical errors.
If FORMS results in a call to the parser that throws a lexical error,
the error will be caught here without the buffer's cache being thrown
out of date.
If there is an error, the syntax that failed is returned.
If there is no error, then the last value of FORMS is returned."
(declare (indent 1) (debug (symbolp def-body)))
(let ((ret (make-symbol "ret"))
(syntax (make-symbol "syntax"))
(start (make-symbol "start"))
(end (make-symbol "end")))
`(let* ((semantic-lex-unterminated-syntax-end-function
(lambda (,syntax ,start ,end)
(throw ',symbol ,syntax)))
(,ret (catch ',symbol
(save-excursion
,@forms
nil))))
;; Great Sadness. Assume that FORMS execute within the
;; confines of the current buffer only! Mark this thing
;; unparsable iff the special symbol was thrown. This
;; will prevent future calls from parsing, but will allow
;; then to still return the cache.
(when ,ret
;; Leave this message off. If an APP using this fcn wants
;; a message, they can do it themselves. This cleans up
;; problems with the idle scheduler obscuring useful data.
;;(message "Buffer not currently parsable (%S)." ,ret)
(semantic-parse-tree-unparseable))
,ret)))