]> code.delx.au - gnu-emacs/blobdiff - lisp/cedet/semantic/wisent/comp.el
Update copyright year to 2015
[gnu-emacs] / lisp / cedet / semantic / wisent / comp.el
index b0daabd10635b95a8dbdabb604253e6d15b3110c..2e4072f89b4d5f9f7b7fdb15ecf52ea7b810383e 100644 (file)
@@ -1,7 +1,7 @@
 ;;; semantic/wisent/comp.el --- GNU Bison for Emacs - Grammar compiler
 
-;; Copyright (C) 1984, 1986, 1989, 1992, 1995, 2000-2007, 2009-2012
-;;   Free Software Foundation, Inc.
+;; Copyright (C) 1984, 1986, 1989, 1992, 1995, 2000-2007, 2009-2015 Free
+;; Software Foundation, Inc.
 
 ;; Author: David Ponce <david@dponce.com>
 ;; Maintainer: David Ponce <david@dponce.com>
@@ -41,6 +41,7 @@
 
 ;;; Code:
 (require 'semantic/wisent)
+(eval-when-compile (require 'cl))
 \f
 ;;;; -------------------
 ;;;; Misc. useful things
 
 (defmacro wisent-defcontext (name &rest vars)
   "Define a context NAME that will bind variables VARS."
+  (declare (indent 1))
   (let* ((context (wisent-context-name name))
-         (bindings (mapcar #'(lambda (v) (list 'defvar v)) vars)))
-    `(eval-when-compile
-       ,@bindings
-       (defvar ,context ',vars))))
-(put 'wisent-defcontext 'lisp-indent-function 1)
+         (declarations (mapcar #'(lambda (v) (list 'defvar v)) vars)))
+    `(progn
+       ,@declarations
+       (eval-when-compile
+         (defvar ,context ',vars)))))
 
 (defmacro wisent-with-context (name &rest body)
   "Bind variables in context NAME then eval BODY."
-  `(let* ,(wisent-context-bindings name)
-     ,@body))
-(put 'wisent-with-context 'lisp-indent-function 1)
+  (declare (indent 1))
+  (let ((bindings (wisent-context-bindings name)))
+    `(progn
+       ,@(mapcar (lambda (binding) `(defvar ,(or (car-safe binding) binding)))
+                 bindings)
+       (let* ,bindings
+         ,@body))))
 
 ;; A naive implementation of data structures!  But it suffice here ;-)
 
@@ -134,8 +140,11 @@ If optional LEFT is non-nil insert spaces on left."
 ;;;; ------------------------
 
 (defconst wisent-BITS-PER-WORD
-  (let ((i 1))
-    (while (not (zerop (lsh 1 i)))
+  (let ((i 1)
+       (do-shift (if (boundp 'most-positive-fixnum)
+                     (lambda (i) (lsh most-positive-fixnum (- i)))
+                   (lambda (i) (lsh 1 i)))))
+    (while (not (zerop (funcall do-shift i)))
       (setq i (1+ i)))
     i))
 
@@ -550,7 +559,7 @@ S must be a vector of integers."
               N  Ns)))
     (setq N Np)))
 
-(defun wisent-inaccessable-symbols ()
+(defun wisent-inaccessible-symbols ()
   "Find out which productions are reachable and which symbols are used."
   ;; Starting with an empty set of productions and a set of symbols
   ;; which only has the start symbol in it, iterate over all
@@ -709,7 +718,7 @@ S must be a vector of integers."
         nuseless-productions  0)
 
   (wisent-useless-nonterminals)
-  (wisent-inaccessable-symbols)
+  (wisent-inaccessible-symbols)
 
   (when (> (+ nuseless-nonterminals nuseless-productions) 0)
     (wisent-total-useless)
@@ -2893,7 +2902,7 @@ references found in BODY, and XBODY is BODY expression with
       (progn
         (if (wisent-check-$N body n)
             ;; Accumulate $i symbol
-            (add-to-list 'found body))
+            (pushnew body found :test #'equal))
         (cons found body))
     ;; BODY is a list, expand inside it
     (let (xbody sexpr)
@@ -2913,7 +2922,7 @@ references found in BODY, and XBODY is BODY expression with
          ;; $i symbol
          ((wisent-check-$N sexpr n)
           ;; Accumulate $i symbol
-          (add-to-list 'found sexpr))
+          (pushnew sexpr found :test #'equal))
          )
         ;; Accumulate expanded forms
         (setq xbody (nconc xbody (list sexpr))))
@@ -3539,4 +3548,13 @@ See also `wisent-compile-grammar' for more details on AUTOMATON."
 
 (provide 'semantic/wisent/comp)
 
+;; Disable messages with regards to lexical scoping, since this will
+;; produce a bunch of 'lacks a prefix' warnings with the
+;; `wisent-defcontext' trickery above.
+
+;; Local variables:
+;; byte-compile-warnings: (not lexical)
+;; generated-autoload-load-name: "semantic/wisent/comp"
+;; End:
+
 ;;; semantic/wisent/comp.el ends here