Function: semantic-repeat-parse-whole-stream

semantic-repeat-parse-whole-stream is a byte-compiled function defined in semantic.el.gz.

Signature

(semantic-repeat-parse-whole-stream STREAM NONTERM &optional RETURNONERROR)

Documentation

Iteratively parse the entire stream STREAM starting with NONTERM.

Optional argument RETURNONERROR indicates that the parser should exit with the current results on a parse error. This function returns semantic tags without overlays.

Source Code

;; Defined in /usr/src/emacs/lisp/cedet/semantic.el.gz
;;; Iterative parser helper function
;;
;; Iterative parsers are better than rule-based iterative functions
;; in that they can handle obscure errors more cleanly.
;;
;; `semantic-repeat-parse-whole-stream' abstracts this action for
;; other parser centric routines.
;;
(defun semantic-repeat-parse-whole-stream
  (stream nonterm &optional returnonerror)
  "Iteratively parse the entire stream STREAM starting with NONTERM.
Optional argument RETURNONERROR indicates that the parser should exit
with the current results on a parse error.
This function returns semantic tags without overlays."
  (let ((result nil)
        (case-fold-search semantic-case-fold)
        nontermsym tag)
    (while stream
      (setq nontermsym (semantic-parse-stream stream nonterm)
            tag (car (cdr nontermsym)))
      (if (not nontermsym)
          (error "Parse error @ %d" (car (cdr (car stream)))))
      (if (eq (car nontermsym) stream)
	  (error "Parser error: Infinite loop?"))
      (if tag
          (if (car tag)
              (setq tag (mapcar
                         (lambda (tag)
                           ;; Set the 'reparse-symbol property to
                           ;; NONTERM unless it was already setup
                           ;; by a tag expander
                           (or (semantic--tag-get-property
                                tag 'reparse-symbol)
                               (semantic--tag-put-property
                                tag 'reparse-symbol nonterm))
                           tag)
                         (semantic--tag-expand tag))
                    result (append result tag))
            ;; No error in this case, a purposeful nil means don't
            ;; store anything.
            )
        (if returnonerror
            (setq stream nil)
          ;; The current item in the stream didn't match, so add it to
          ;; the list of syntax items which didn't match.
          (setq semantic-unmatched-syntax-cache
                (cons (car stream) semantic-unmatched-syntax-cache))
          ))
      ;; Designated to ignore.
      (setq stream (car nontermsym))
      (if stream
	  ;; Use Emacs's built-in progress reporter:
	  (and (boundp 'semantic--progress-reporter)
	       semantic--progress-reporter
	       (eq semantic-working-type 'percent)
	       (progress-reporter-update
		semantic--progress-reporter
		(floor (* 100.0 (semantic-lex-token-start (car stream)))
		       (point-max))))))
    result))