-;;; lex-spp.el --- Semantic Lexical Pre-processor
+;;; semantic/lex-spp.el --- Semantic Lexical Pre-processor
-;; Copyright (C) 2006, 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 2006-2012 Free Software Foundation, Inc.
;; Author: Eric M. Ludlam <zappo@gnu.org>
(setq semantic-lex-spp-dynamic-macro-symbol-obarray-stack
(make-vector 13 0))))
+(defun semantic-lex-spp-value-valid-p (value)
+ "Return non-nil if VALUE is valid."
+ (or (null value)
+ (stringp value)
+ (and (consp value)
+ (or (semantic-lex-token-p (car value))
+ (eq (car (car value)) 'spp-arg-list)))))
+
+(defvar semantic-lex-spp-debug-symbol nil
+ "A symbol to break on if it is being set somewhere.")
+
+(defun semantic-lex-spp-enable-debug-symbol (sym)
+ "Enable debugging for symbol SYM.
+Disable debugging by entering nothing."
+ (interactive "sSymbol: ")
+ (if (string= sym "")
+ (setq semantic-lex-spp-debug-symbol nil)
+ (setq semantic-lex-spp-debug-symbol sym)))
+
+(defmacro semantic-lex-spp-validate-value (name value)
+ "Validate the NAME and VALUE of a macro before it is set."
+; `(progn
+; (when (not (semantic-lex-spp-value-valid-p ,value))
+; (error "Symbol \"%s\" with bogus value %S" ,name ,value))
+; (when (and semantic-lex-spp-debug-symbol
+; (string= semantic-lex-spp-debug-symbol name))
+; (debug))
+; )
+ nil
+ )
+
(defun semantic-lex-spp-symbol-set (name value &optional obarray-in)
"Set value of spp symbol with NAME to VALUE and return VALUE.
If optional OBARRAY-IN is non-nil, then use that obarray instead of
the dynamic map."
+ (semantic-lex-spp-validate-value name value)
(if (and (stringp value) (string= value "")) (setq value nil))
(set (intern name (or obarray-in
(semantic-lex-spp-dynamic-map)))
(defun semantic-lex-spp-symbol-push (name value)
"Push macro NAME with VALUE into the map.
Reverse with `semantic-lex-spp-symbol-pop'."
+ (semantic-lex-spp-validate-value name value)
(let* ((map (semantic-lex-spp-dynamic-map))
(stack (semantic-lex-spp-dynamic-map-stack))
(mapsym (intern name map))
;; If val is nil, that's probably wrong.
;; Found a system header case where this was true.
((null val) "")
- ;; Debug wierd stuff.
+ ;; Debug weird stuff.
(t (debug)))
))
((stringp txt)
(cond
;; CASE 3: Merge symbols together.
((eq (semantic-lex-token-class v) 'spp-symbol-merge)
- ;; We need to merge the tokens in the 'text segement together,
+ ;; We need to merge the tokens in the 'text segment together,
;; and produce a single symbol from it.
(let ((newsym
(mapconcat (lambda (tok)
;;; Macro Merging
;;
-;; Used when token streams from different macros include eachother.
+;; Used when token streams from different macros include each other.
;; Merged macro streams perform in place replacements.
(defun semantic-lex-spp-merge-streams (raw-stream)
;;; Symbol Is Macro
;;
-;; An analyser that will push tokens from a macro in place
+;; An analyzer that will push tokens from a macro in place
;; of the macro symbol.
;;
(defun semantic-lex-spp-anlyzer-do-replace (sym val beg end)
;; a macro.
(defun semantic-lex-spp-first-token-arg-list (token)
- "If TOKEN is a semantic-list, turn it into a an SPP ARG LIST."
+ "If TOKEN is a semantic-list, turn it into an SPP ARG LIST."
(when (and (consp token)
(symbolp (car token))
(eq 'semantic-list (car token)))
;;
;; These analyzers help a language define how include files
;; are identified. These are ONLY for languages that perform
-;; an actual textual includesion, and not for imports.
+;; an actual textual inclusion, and not for imports.
;;
;; This section is supposed to allow the macros from the headers to be
;; added to the local dynamic macro table, but that hasn't been
;; generated-autoload-load-name: "semantic/lex-spp"
;; End:
-;; arch-tag: 8877d83e-07ea-4d86-a960-e3562138d8a5
-;;; semantic-lex-spp.el ends here
+;;; semantic/lex-spp.el ends here