Function: semantic-grammar-tokens

semantic-grammar-tokens is a byte-compiled function defined in grammar.el.gz.

Signature

(semantic-grammar-tokens)

Documentation

Return defined lexical tokens.

That is an alist (TYPE . DEFS) where type is a %token <type> symbol and DEFS is an alist of (TOKEN . VALUE). TOKEN is the terminal symbol identifying the token and VALUE is the string value of the token or nil.

Source Code

;; Defined in /usr/src/emacs/lisp/cedet/semantic/grammar.el.gz
(defun semantic-grammar-tokens ()
  "Return defined lexical tokens.
That is an alist (TYPE . DEFS) where type is a %token <type> symbol
and DEFS is an alist of (TOKEN . VALUE).  TOKEN is the terminal symbol
identifying the token and VALUE is the string value of the token or
nil."
  (let (tags alist assoc tag type term names value)

    ;; Check for <type> in %left, %right & %nonassoc declarations
    (setq tags (semantic-find-tags-by-class
                'assoc (current-buffer)))
    (while tags
      (setq tag  (car tags)
            tags (cdr tags))
      (when (setq type (semantic-tag-type tag))
        (setq names (semantic-tag-get-attribute tag :value)
              assoc (assoc type alist))
        (or assoc (setq assoc (list type)
                        alist (cons assoc alist)))
        (while names
          (setq term  (car names)
                names (cdr names))
          (or (string-match semantic-grammar-lex-c-char-re term)
              (setcdr assoc (cons (list (intern term))
                                  (cdr assoc)))))))

    ;; Then process %token declarations so they can override any
    ;; previous specifications
    (setq tags (semantic-find-tags-by-class
                'token (current-buffer)))
    (while tags
      (setq tag  (car tags)
            tags (cdr tags))
      (setq names (cons (semantic-tag-name tag)
                        (semantic-tag-get-attribute tag :rest))
            type  (or (semantic-tag-type tag) "<no-type>")
            value (semantic-tag-get-attribute tag :value)
            assoc (assoc type alist))
      (or assoc (setq assoc (list type)
                      alist (cons assoc alist)))
      (while names
        (setq term  (intern (car names))
              names (cdr names))
        (setcdr assoc (cons (cons term value) (cdr assoc)))))
    alist))