Function: semantic-lex-expand-block-specs

semantic-lex-expand-block-specs is a byte-compiled function defined in lex.el.gz.

Signature

(semantic-lex-expand-block-specs SPECS)

Documentation

Expand block specifications SPECS into a Lisp form.

SPECS is a list of (BLOCK BEGIN END) elements where BLOCK, BEGIN, and END are token class symbols that indicate to produce one collapsed BLOCK token from tokens found between BEGIN and END ones. BLOCK must be a non-nil symbol, and at least one of the BEGIN or END symbols must be non-nil too. When BEGIN is non-nil, generate a call to semantic-lex-start-block when a BEGIN token class is encountered. When END is non-nil, generate a call to semantic-lex-end-block when an END token class is encountered.

Source Code

;; Defined in /usr/src/emacs/lisp/cedet/semantic/lex.el.gz
(defun semantic-lex-expand-block-specs (specs)
  "Expand block specifications SPECS into a Lisp form.
SPECS is a list of (BLOCK BEGIN END) elements where BLOCK, BEGIN, and
END are token class symbols that indicate to produce one collapsed
BLOCK token from tokens found between BEGIN and END ones.
BLOCK must be a non-nil symbol, and at least one of the BEGIN or END
symbols must be non-nil too.
When BEGIN is non-nil, generate a call to `semantic-lex-start-block'
when a BEGIN token class is encountered.
When END is non-nil, generate a call to `semantic-lex-end-block' when
an END token class is encountered."
  (let ((class (make-symbol "class"))
        (form nil))
    (dolist (spec specs)
      (when (car spec)
        (when (nth 1 spec)
          (push `((eq ',(nth 1 spec) ,class)
                  (semantic-lex-start-block ',(car spec)))
                form))
        (when (nth 2 spec)
          (push `((eq ',(nth 2 spec) ,class)
                  (semantic-lex-end-block ',(car spec)))
                form))))
    (when form
      `((let ((,class (semantic-lex-token-class
                       (car semantic-lex-token-stream))))
          (cond ,@(nreverse form))))
      )))