Function: define-lex-regex-type-analyzer
define-lex-regex-type-analyzer is a macro defined in lex.el.gz.
Signature
(define-lex-regex-type-analyzer NAME DOC SYNTAX MATCHES DEFAULT)
Documentation
Define a regexp 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-regex-type-analyzer (name doc syntax matches default)
"Define a regexp 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."
(declare (indent 1))
(if matches
(let* ((val (make-symbol "val"))
(lst (make-symbol "lst"))
(elt (make-symbol "elt"))
(pos (make-symbol "pos"))
(end (make-symbol "end")))
`(define-lex-analyzer ,name
,doc
(and (looking-at ,syntax)
(let* ((,val (match-string 0))
(,pos (match-beginning 0))
(,end (match-end 0))
(,lst ,matches)
,elt)
(while (and ,lst (not ,elt))
(if (string-match (cdar ,lst) ,val)
(setq ,elt (caar ,lst))
(setq ,lst (cdr ,lst))))
(semantic-lex-push-token
(semantic-lex-token (or ,elt ,default) ,pos ,end))))
))
`(define-lex-simple-regex-analyzer ,name
,doc
,syntax ,default)
))