Function: semantic-c-do-lex-if

semantic-c-do-lex-if is a byte-compiled function defined in c.el.gz.

Signature

(semantic-c-do-lex-if)

Documentation

Handle lexical CPP if statements.

Enables a takeover of some hideif functions, then uses hideif to evaluate the #if expression and enables us to make decisions on which code to parse.

Source Code

;; Defined in /usr/src/emacs/lisp/cedet/semantic/bovine/c.el.gz
(defun semantic-c-do-lex-if ()
  "Handle lexical CPP if statements.
Enables a takeover of some hideif functions, then uses hideif to
evaluate the #if expression and enables us to make decisions on which
code to parse."
  ;; Enable our advice, and use hideif to parse.
  (let* ((semantic-c-takeover-hideif t)
	 (hif-ifx-regexp (concat hif-cpp-prefix "\\(elif\\|if\\(n?def\\)?\\)[ \t]+"))
	 (parsedtokelist
	  (condition-case nil
	      ;; This is imperfect, so always assume on error.
	      (hif-canonicalize hif-ifx-regexp)
	    (error nil))))

    (let ((eval-form (condition-case err
			 (eval parsedtokelist t)
		       (error
			(semantic-push-parser-warning
			 (format "Hideif forms produced an error.  Assuming false.\n%S" err)
			 (point) (1+ (point)))
			nil))))
      (if (or (not eval-form)
              (and (numberp eval-form)
                   (equal eval-form 0)));; ifdef line resulted in false

	;; The if indicates to skip this preprocessor section
	(let () ;; (pt nil)
          (semantic-push-parser-warning (format "Skip %s" (buffer-substring-no-properties
                                                           (line-beginning-position)
                                                           (line-end-position)))
                                        (line-beginning-position) (line-end-position))
	  (beginning-of-line)
	  ;; (setq pt (point))
	  ;; This skips only a section of a conditional.  Once that section
	  ;; is opened, encountering any new #else or related conditional
	  ;; should be skipped.
	  (semantic-c-skip-conditional-section)
	  (setq semantic-lex-end-point (point))

	  ;; @TODO -somewhere around here, we also need to skip
	  ;; other sections of the conditional.

	  nil)
      ;; Else, don't ignore it, but do handle the internals.
      (end-of-line)
      (setq semantic-lex-end-point (point))
      nil))))