]> code.delx.au - gnu-emacs-elpa/blobdiff - packages/wisi/wisi-compile.el
Merge commit '6238e7402adabd0003f6ffcf5c57d9f18f1e7684'
[gnu-emacs-elpa] / packages / wisi / wisi-compile.el
old mode 100755 (executable)
new mode 100644 (file)
index a17b7f6..463fb01
@@ -1,6 +1,6 @@
-;;; Grammar compiler for the wisent LALR parser, integrating Wisi OpenToken output.
+;;; Grammar compiler for the wisent LALR parser, integrating Wisi OpenToken output.  -*- lexical-binding:t -*-
 ;;
-;; Copyright (C) 2012, 2013 Free Software Foundation, Inc.
+;; Copyright (C) 2012, 2013, 2015 Free Software Foundation, Inc.
 ;;
 ;; Author: Stephen Leake <stephen_leake@member.fsf.org>
 ;;
 ;;
 ;;;;
 
-(eval-when-compile
-  ;; can't just 'require'; `wisent-with-context' doesn't work.
-  ;; also can't load .elc; must load .el or .el.gz
-  (let ((file (locate-library "semantic/wisent/comp.el")))
-    (if file
-       (load file)
-      (error "source library semantic/wisent/comp.el not installed; install emacs lisp sources"))))
-
-(eval-and-compile
-  (require 'semantic/wisent/comp))
+(require 'semantic/wisent/comp)
 
 (defun wisi-compose-action (value symbol-array nonterms)
   (let ((symbol (intern-soft (format "%s:%d" (car value) (cdr value)) symbol-array))
@@ -144,6 +135,13 @@ side-effects only."
     (list (car (aref actn 2)) action-symbol n)))
 
 (defun wisi-compile-grammar (grammar)
+  ;; FIXME: This docstring is full of ambiguities making it unclear whether
+  ;; we're talking for example about data that includes the symbol `nonterm' as
+  ;; opposed to data that includes some non terminal object we denote
+  ;; with the meta-variable "nonterm".
+  ;; The convention in Elisp's docstrings is to use all-caps for metavariables
+  ;; (and `...' quoting as opposed to the '... quoting used below in a few
+  ;; spots).
   "Compile the LALR(1) GRAMMAR; return the automaton for wisi-parse.
 GRAMMAR is a list TERMINALS NONTERMS ACTIONS GOTOS, where:
 
@@ -178,10 +176,10 @@ state.
 The automaton is an array with 3 elements:
 
 parser-actions is a copy of the input ACTIONS, with reduction
-actions replaced by a list (nonterm action-symbol token-count),
-where `nonterm' is a symbol from NONTERMS, and is the
-non-terminal to reduce to, token-count is the number of tokens in
-the reduction, action-symbol is nil if there is no user action,
+actions replaced by a list (NONTERM ACTION-SYMBOL TOKEN-COUNT),
+where NONTERM is a symbol from NONTERMS, and is the
+non-terminal to reduce to, TOKEN-COUNT is the number of tokens in
+the reduction, ACTION-SYMBOL is nil if there is no user action,
 or a symbol from semantic-actions (below).
 
 gotos is a copy of GOTOS.
@@ -189,7 +187,9 @@ gotos is a copy of GOTOS.
 semantic-actions is an obarray containing functions that
 implement the user action for each nonterminal; the function
 names have the format nonterm:index."
-  (wisent-with-context compile-grammar
+  (defvar nrules) (defvar ptable) (defvar rcode) (defvar rlhs) (defvar tags)
+  (defvar token-list) (defvar var-list)
+  (let (nrules ptable rcode rlhs tags token-list var-list)
     (wisent-parse-grammar;; set global vars used by wisent-semantic-action
      (cons
       (nth 0 grammar);; TOKENS
@@ -223,4 +223,4 @@ names have the format nonterm:index."
 
 (provide 'wisi-compile)
 
-;;;; end of file
+;;; wisi-compile.el ends here