;;; Variables
;;
-(defvar-local semantic-bovinate-nonterminal-check-obarray nil
+(defvar-local semantic-bovinate-nonterminal-check-map nil
"Obarray of streams already parsed for nonterminal symbols.
Use this to detect infinite recursion during a parse.")
(defun semantic-bovinate-nonterminal-check (stream nonterminal)
"Check if STREAM not already parsed for NONTERMINAL.
If so abort because an infinite recursive parse is suspected."
- (or (vectorp semantic-bovinate-nonterminal-check-obarray)
- (setq semantic-bovinate-nonterminal-check-obarray
- (make-vector 13 nil)))
- (let* ((nt (symbol-name nonterminal))
- (vs (symbol-value
- (intern-soft
- nt semantic-bovinate-nonterminal-check-obarray))))
+ (or (hash-table-p semantic-bovinate-nonterminal-check-map)
+ (setq semantic-bovinate-nonterminal-check-map
+ (make-hash-table :test #'eq)))
+ (let* ((vs (gethash nonterminal semantic-bovinate-nonterminal-check-map)))
(if (memq stream vs)
;; Always enter debugger to see the backtrace
(let ((debug-on-signal t)
(debug-on-error t))
- (setq semantic-bovinate-nonterminal-check-obarray nil)
- (error "Infinite recursive parse suspected on %s" nt))
- (set (intern nt semantic-bovinate-nonterminal-check-obarray)
- (cons stream vs)))))
+ (setq semantic-bovinate-nonterminal-check-map nil)
+ (error "Infinite recursive parse suspected on %s" nonterminal))
+ (push stream
+ (gethash nonterminal semantic-bovinate-nonterminal-check-map)))))
;;;###autoload
(defun semantic-bovinate-stream (stream &optional nonterminal)
(or semantic--buffer-cache
(semantic-bovinate-nonterminal-check stream nonterminal))
+ ;; FIXME: `semantic-parse-region-c-mode' inspects `lse' to try and
+ ;; detect a recursive call (used with macroexpansion, to avoid inf-loops).
+ (with-suppressed-warnings ((lexical lse)) (defvar lse))
(let* ((table semantic--parse-table)
(matchlist (cdr (assq nonterminal table)))
(starting-stream stream)
(setq cvl (cons
(if (memq (semantic-lex-token-class lse)
'(comment semantic-list))
- valdot val) cvl))) ;append unchecked value.
+ valdot val)
+ cvl))) ;append unchecked value.
(setq end (semantic-lex-token-end lse))
)
(setq lte nil cvl nil)) ;No more matches, exit
binding of variables.
START, END, NONTERMINAL, DEPTH, and RETURNONERRORS are the same
as for the parent."
- (if (and (boundp 'lse) (or (/= start 1) (/= end (point-max))))
+ ;; FIXME: We shouldn't depend on the internals of `semantic-bovinate-stream'.
+ (with-suppressed-warnings ((lexical lse)) (defvar lse))
+ (if (and (boundp 'lse) (or (/= start (point-min)) (/= end (point-max))))
(let* ((last-lexical-token lse)
(llt-class (semantic-lex-token-class last-lexical-token))
(llt-fakebits (car (cdr last-lexical-token)))