]> code.delx.au - gnu-emacs/blobdiff - lisp/cedet/semantic/wisent/comp.el
Merge from trunk.
[gnu-emacs] / lisp / cedet / semantic / wisent / comp.el
index 371a1947304ec477c5397bcb3ac1cee840d10cbb..f92ae88c14ee5250b2cd3c6d8f3499cbb0ab7cc8 100644 (file)
@@ -1,7 +1,7 @@
 ;;; semantic/wisent/comp.el --- GNU Bison for Emacs - Grammar compiler
 
-;; Copyright (C) 1984, 1986, 1989, 1992, 1995, 2000, 2001, 2002, 2003,
-;; 2004, 2005, 2006, 2007, 2009, 2010 Free Software Foundation, Inc.
+;; Copyright (C) 1984, 1986, 1989, 1992, 1995, 2000-2007, 2009-2011
+;;   Free Software Foundation, Inc.
 
 ;; Author: David Ponce <david@dponce.com>
 ;; Maintainer: David Ponce <david@dponce.com>
@@ -160,12 +160,6 @@ If optional LEFT is non-nil insert spaces on left."
   (not (zerop (logand (aref x (/ i wisent-BITS-PER-WORD))
                       (lsh 1 (% i wisent-BITS-PER-WORD))))))
 
-(eval-when-compile
-  (or (fboundp 'noninteractive)
-      ;; Silence the Emacs byte compiler
-      (defun noninteractive nil))
-  )
-
 (defsubst wisent-noninteractive ()
   "Return non-nil if running without interactive terminal."
   (if (featurep 'xemacs)
@@ -205,7 +199,7 @@ Its name is defined in constant `wisent-log-buffer-name'."
   `(with-current-buffer (wisent-log-buffer)
      (erase-buffer)))
 
-(eval-when-compile (defvar byte-compile-current-file))
+(defvar byte-compile-current-file)
 
 (defun wisent-source ()
   "Return the current source file name or nil."
@@ -3458,15 +3452,13 @@ where:
   (if (wisent-automaton-p grammar)
       grammar ;; Grammar already compiled just return it
     (wisent-with-context compile-grammar
-      (let* ((gc-cons-threshold 1000000)
-             automaton)
+      (let* ((gc-cons-threshold 1000000))
         (garbage-collect)
        (setq wisent-new-log-flag t)
        ;; Parse input grammar
        (wisent-parse-grammar grammar start-list)
        ;; Generate the LALR(1) automaton
-       (setq automaton (wisent-parser-automaton))
-       automaton))))
+       (wisent-parser-automaton)))))
 \f
 ;;;; --------------------------
 ;;;; Byte compile input grammar
@@ -3482,8 +3474,19 @@ Automatically called by the Emacs Lisp byte compiler as a
   ;; automaton internal data structure.  Then, because the internal
   ;; data structure contains an obarray, convert it to a lisp form so
   ;; it can be byte-compiled.
-  (byte-compile-form (wisent-automaton-lisp-form (eval form))))
-
+  (byte-compile-form
+   ;; FIXME: we macroexpand here since `byte-compile-form' expects
+   ;; macroexpanded code, but that's just a workaround: for lexical-binding
+   ;; the lisp form should have to pass through closure-conversion and
+   ;; `wisent-byte-compile-grammar' is called much too late for that.
+   ;; Why isn't this `wisent-automaton-lisp-form' performed at
+   ;; macroexpansion time?  --Stef
+   (macroexpand-all
+    (wisent-automaton-lisp-form (eval form)))))
+
+;; FIXME: We shouldn't use a `byte-compile' handler.  Maybe using a hash-table
+;; instead of an obarray would work around the problem that obarrays
+;; aren't printable.  Then (put 'wisent-compile-grammar 'side-effect-free t).
 (put 'wisent-compile-grammar 'byte-compile 'wisent-byte-compile-grammar)
 
 (defun wisent-automaton-lisp-form (automaton)
@@ -3536,5 +3539,4 @@ See also `wisent-compile-grammar' for more details on AUTOMATON."
 
 (provide 'semantic/wisent/comp)
 
-;; arch-tag: 758ea04c-ea97-466b-9b35-aea0861033c9
 ;;; semantic/wisent/comp.el ends here