Function: define-lex-string-type-analyzer
define-lex-string-type-analyzer is a macro defined in lex.el.gz.
Signature
(define-lex-string-type-analyzer NAME DOC SYNTAX MATCHES DEFAULT)
Documentation
Define a string type analyzer NAME with DOC string.
SYNTAX is the regexp that matches a syntactic expression. MATCHES is an alist of lexical elements used to refine the syntactic expression. DEFAULT is the default lexical token returned when no MATCHES.
Source Code
;; Defined in /usr/src/emacs/lisp/cedet/semantic/lex.el.gz
(defmacro define-lex-string-type-analyzer (name doc syntax matches default)
"Define a string type analyzer NAME with DOC string.
SYNTAX is the regexp that matches a syntactic expression.
MATCHES is an alist of lexical elements used to refine the syntactic
expression.
DEFAULT is the default lexical token returned when no MATCHES."
(if matches
(let* ((val (make-symbol "val"))
(lst (make-symbol "lst"))
(elt (make-symbol "elt"))
(pos (make-symbol "pos"))
(end (make-symbol "end"))
(len (make-symbol "len")))
`(define-lex-analyzer ,name
,doc
(and (looking-at ,syntax)
(let* ((,val (match-string 0))
(,pos (match-beginning 0))
(,end (match-end 0))
(,len (- ,end ,pos))
(,lst ,matches)
,elt)
;; Starting with the longest one, search if a lexical
;; value match a token defined for this language.
(while (and (> ,len 0) (not (setq ,elt (rassoc ,val ,lst))))
(setq ,len (1- ,len)
,val (substring ,val 0 ,len)))
(when ,elt ;; Adjust token end position.
(setq ,elt (car ,elt)
,end (+ ,pos ,len)))
(semantic-lex-push-token
(semantic-lex-token (or ,elt ,default) ,pos ,end))))
))
`(define-lex-simple-regex-analyzer ,name
,doc
,syntax ,default)
))