Function: semantic-lex-spp-stream-for-macro
semantic-lex-spp-stream-for-macro is a byte-compiled function defined
in lex-spp.el.gz.
Signature
(semantic-lex-spp-stream-for-macro EOS)
Documentation
Lex up a stream of tokens for a #define statement.
Parsing starts at the current point location. EOS is the end of the stream to lex for this macro.
Source Code
;; Defined in /usr/src/emacs/lisp/cedet/semantic/lex-spp.el.gz
;;;; FIRST DRAFT
;; This is the fist version of semantic-lex-spp-stream-for-arglist
;; that worked pretty well. It doesn't work if the TOKEN was derived
;; from some other buffer, in which case it can get the wrong answer
;; or throw an error if the token location in the originating buffer is
;; larger than the current buffer.
;;(defun semantic-lex-spp-stream-for-arglist-orig (token)
;; "Lex up the contents of the arglist TOKEN.
;; Parsing starts inside the parens, and ends at the end of TOKEN."
;; (save-excursion
;; (let ((end (semantic-lex-token-end token))
;; (fresh-toks nil)
;; (toks nil))
;; (goto-char (semantic-lex-token-start token))
;; ;; A cheat for going into the semantic list.
;; (forward-char 1)
;; (setq fresh-toks (semantic-lex-spp-stream-for-macro (1- end)))
;; (dolist (tok fresh-toks)
;; (when (memq (semantic-lex-token-class tok) '(symbol semantic-list))
;; (setq toks (cons tok toks))))
;; (nreverse toks))
;; ))
;;;; USING SPLIT
;; This doesn't work, because some arguments passed into a macro
;; might contain non-simple symbol words, which this doesn't handle.
;;
;; Thus, you need a full lex to occur.
;; (defun semantic-lex-spp-stream-for-arglist-split (token)
;; "Lex up the contents of the arglist TOKEN.
;; Parsing starts inside the parens, and ends at the end of TOKEN."
;; (let* ((txt (semantic-lex-token-text token))
;; (split (split-string (substring txt 1 (1- (length txt)))
;; "(), " t))
;; ;; Hack for lexing.
;; (semantic-lex-spp-analyzer-push-tokens-for-symbol nil))
;; (dolist (S split)
;; (semantic-lex-spp-analyzer-push-tokens-for-symbol S 0 1))
;; (reverse semantic-lex-spp-analyzer-push-tokens-for-symbol)))
(defun semantic-lex-spp-stream-for-macro (eos)
"Lex up a stream of tokens for a #define statement.
Parsing starts at the current point location.
EOS is the end of the stream to lex for this macro."
(let ((stream nil))
(while (< (point) eos)
(let* ((tok (semantic-lex-spp-one-token-and-move-for-macro eos))
(str (when tok
(semantic-lex-token-text tok)))
)
(if str
(push (semantic-lex-token (semantic-lex-token-class tok)
(semantic-lex-token-start tok)
(semantic-lex-token-end tok)
str)
stream)
;; Nothing to push.
nil)))
(goto-char eos)
;; Fix the order
(nreverse stream)
))