;;; 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>
(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)
`(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."
(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
;; 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)
(provide 'semantic/wisent/comp)
-;; arch-tag: 758ea04c-ea97-466b-9b35-aea0861033c9
;;; semantic/wisent/comp.el ends here