changeset 54714:fc6e53c00fcf

ebnf2ps 4.2
author Vinicius Jose Latorre <viniciusjl@ig.com.br>
date Mon, 05 Apr 2004 02:00:42 +0000
parents d7ed72c5a5bc
children d8d0a55983fb
files lisp/ChangeLog lisp/progmodes/ebnf-abn.el lisp/progmodes/ebnf-bnf.el lisp/progmodes/ebnf-ebx.el lisp/progmodes/ebnf-iso.el lisp/progmodes/ebnf-yac.el lisp/progmodes/ebnf2ps.el
diffstat 7 files changed, 136 insertions(+), 72 deletions(-) [+]
line wrap: on
line diff
--- a/lisp/ChangeLog	Mon Apr 05 01:58:47 2004 +0000
+++ b/lisp/ChangeLog	Mon Apr 05 02:00:42 2004 +0000
@@ -8,6 +8,37 @@
 	* format.el (format-write-file): Add optional argument CONFIRM
 	and make it behave like the analogous argument to `write-file'.
 
+2004-04-04  Vinicius Jose Latorre  <viniciusjl@ig.com.br>
+
+	* progmodes/ebnf2ps.el: Doc fix.
+	(ebnf-version): New version number (4.2).
+	(ebnf-syntax): Customization and docstring fix.
+	(ebnf-eliminate-empty-rules, ebnf-optimize, ebnf-otz-initialize): Put
+	autoloaded funs before first use.
+	(ebnf-style-database): Add dtd entry.
+	(ebnf-syntax-alist): Add dtd initialization.
+	(ebnf-token-sequence): New fun.
+	(ebnf-comment-table): Add new comment action character.
+	(ebnf-dtd-parser, ebnf-dtd-initialize): Autoloaded funs from ebnf-dtd.
+
+	* progmodes/ebnf-dtd.el: New file, implement a parser for DTD (Data
+	Type Definition for XML).
+
+	* progmodes/ebnf-abn.el (ebnf-abn-concatenation): Code simplification:
+	call ebnf-token-sequence.
+
+	* progmodes/ebnf-bnf.el (ebnf-sequence): Code simplification: call
+	ebnf-token-sequence.
+
+	* progmodes/ebnf-ebx.el (ebnf-ebx-concatenation): Code simplification:
+	call ebnf-token-sequence.
+
+	* progmodes/ebnf-iso.el (ebnf-iso-single-definition): Code
+	simplification: call ebnf-token-sequence.
+
+	* progmodes/ebnf-yac.el (ebnf-yac-sequence): Code simplification: call
+	ebnf-token-sequence.
+
 2004-04-04  Eli Zaretskii  <eliz@gnu.org>
 
 	* calendar/timeclock.el (timeclock-relative)
--- a/lisp/progmodes/ebnf-abn.el	Mon Apr 05 01:58:47 2004 +0000
+++ b/lisp/progmodes/ebnf-abn.el	Mon Apr 05 02:00:42 2004 +0000
@@ -4,9 +4,9 @@
 
 ;; Author: Vinicius Jose Latorre <viniciusjl@ig.com.br>
 ;; Maintainer: Vinicius Jose Latorre <viniciusjl@ig.com.br>
-;; Time-stamp: <2004/03/18 23:49:58 vinicius>
+;; Time-stamp: <2004/04/03 16:43:57 vinicius>
 ;; Keywords: wp, ebnf, PostScript
-;; Version: 1.0
+;; Version: 1.1
 
 ;; This file is part of GNU Emacs.
 
@@ -316,11 +316,7 @@
 		 term  (cdr term))
       (setq seq (cons term seq)))
     (cons token
-	  (if (= (length seq) 1)
-	      ;; sequence with only one element
-	      (car seq)
-	    ;; a real sequence
-	    (ebnf-make-sequence (nreverse seq))))))
+	  (ebnf-token-sequence seq))))
 
 
 ;;;    repetition     =  [repeat] element
--- a/lisp/progmodes/ebnf-bnf.el	Mon Apr 05 01:58:47 2004 +0000
+++ b/lisp/progmodes/ebnf-bnf.el	Mon Apr 05 02:00:42 2004 +0000
@@ -5,9 +5,9 @@
 
 ;; Author: Vinicius Jose Latorre <viniciusjl@ig.com.br>
 ;; Maintainer: Vinicius Jose Latorre <viniciusjl@ig.com.br>
-;; Time-stamp: <2004/02/28 18:25:52 vinicius>
+;; Time-stamp: <2004/04/03 16:42:18 vinicius>
 ;; Keywords: wp, ebnf, PostScript
-;; Version: 1.8
+;; Version: 1.9
 
 ;; This file is part of GNU Emacs.
 
@@ -206,17 +206,7 @@
 		 term  (cdr term))
       (setq seq (cons term seq)))
     (cons token
-	  (cond
-	   ;; null sequence
-	   ((null seq)
-	    (ebnf-make-empty))
-	   ;; sequence with only one element
-	   ((= (length seq) 1)
-	    (car seq))
-	   ;; a real sequence
-	   (t
-	    (ebnf-make-sequence (nreverse seq)))
-	   ))))
+	  (ebnf-token-sequence seq))))
 
 
 ;;; exception = repeat [ "-" repeat].
--- a/lisp/progmodes/ebnf-ebx.el	Mon Apr 05 01:58:47 2004 +0000
+++ b/lisp/progmodes/ebnf-ebx.el	Mon Apr 05 02:00:42 2004 +0000
@@ -4,9 +4,9 @@
 
 ;; Author: Vinicius Jose Latorre <viniciusjl@ig.com.br>
 ;; Maintainer: Vinicius Jose Latorre <viniciusjl@ig.com.br>
-;; Time-stamp: <2004/03/22 08:53:21 vinicius>
+;; Time-stamp: <2004/04/03 16:45:34 vinicius>
 ;; Keywords: wp, ebnf, PostScript
-;; Version: 1.0
+;; Version: 1.1
 
 ;; This file is part of GNU Emacs.
 
@@ -282,11 +282,7 @@
 		 term  (cdr term))
       (setq seq (cons term seq)))
     (cons token
-	  (if (= (length seq) 1)
-	      ;; sequence with only one element
-	      (car seq)
-	    ;; a real sequence
-	    (ebnf-make-sequence (nreverse seq))))))
+	  (ebnf-token-sequence seq))))
 
 
 ;;; exception ::= term ('-' term)?
--- a/lisp/progmodes/ebnf-iso.el	Mon Apr 05 01:58:47 2004 +0000
+++ b/lisp/progmodes/ebnf-iso.el	Mon Apr 05 02:00:42 2004 +0000
@@ -5,9 +5,9 @@
 
 ;; Author: Vinicius Jose Latorre <viniciusjl@ig.com.br>
 ;; Maintainer: Vinicius Jose Latorre <viniciusjl@ig.com.br>
-;; Time-stamp: <2004/02/29 18:31:33 vinicius>
+;; Time-stamp: <2004/04/03 16:48:52 vinicius>
 ;; Keywords: wp, ebnf, PostScript
-;; Version: 1.7
+;; Version: 1.8
 
 ;; This file is part of GNU Emacs.
 
@@ -203,17 +203,9 @@
 		(eq token 'catenate))
       (setq seq (cons term seq)))
     (cons token
-	  (cond
-	   ;; null sequence
-	   ((null seq)
-	    term)
-	   ;; sequence with only one element
-	   ((and (null term) (= (length seq) 1))
-	    (car seq))
-	   ;; a real sequence
-	   (t
-	    (ebnf-make-sequence (nreverse (cons term seq))))
-	   ))))
+	  (ebnf-token-sequence (if term
+				   (cons term seq)
+				 seq)))))
 
 
 ;;; term = factor, ['-', exception];
--- a/lisp/progmodes/ebnf-yac.el	Mon Apr 05 01:58:47 2004 +0000
+++ b/lisp/progmodes/ebnf-yac.el	Mon Apr 05 02:00:42 2004 +0000
@@ -5,9 +5,9 @@
 
 ;; Author: Vinicius Jose Latorre <viniciusjl@ig.com.br>
 ;; Maintainer: Vinicius Jose Latorre <viniciusjl@ig.com.br>
-;; Time-stamp: <2004/02/29 20:23:29 vinicius>
+;; Time-stamp: <2004/04/03 16:50:46 vinicius>
 ;; Keywords: wp, ebnf, PostScript
-;; Version: 1.2.1
+;; Version: 1.3
 
 ;; This file is part of GNU Emacs.
 
@@ -218,20 +218,10 @@
 		 factor (ebnf-yac-factor token))
       (setq seq (cons factor seq)))
     (cons token
-	  (cond
-	   ;; ignore error recovery
-	   ((and ebnf-yac-ignore-error-recovery ebnf-yac-error)
-	    nil)
-	   ;; null sequence
-	   ((null seq)
-	    (ebnf-make-empty))
-	   ;; sequence with only one element
-	   ((= (length seq) 1)
-	    (car seq))
-	   ;; a real sequence
-	   (t
-	    (ebnf-make-sequence (nreverse seq)))
-	   ))))
+	  (if (and ebnf-yac-ignore-error-recovery ebnf-yac-error)
+	      ;; ignore error recovery
+	      nil
+	    (ebnf-token-sequence seq)))))
 
 
 ;;; Factor = Name
--- a/lisp/progmodes/ebnf2ps.el	Mon Apr 05 01:58:47 2004 +0000
+++ b/lisp/progmodes/ebnf2ps.el	Mon Apr 05 02:00:42 2004 +0000
@@ -5,9 +5,9 @@
 
 ;; Author: Vinicius Jose Latorre <viniciusjl@ig.com.br>
 ;; Maintainer: Vinicius Jose Latorre <viniciusjl@ig.com.br>
-;; Time-stamp: <2004/03/30 21:49:21 vinicius>
+;; Time-stamp: <2004/04/04 21:40:30 vinicius>
 ;; Keywords: wp, ebnf, PostScript
-;; Version: 4.1
+;; Version: 4.2
 ;; X-URL: http://www.cpqd.com.br/~vinicius/emacs/
 
 ;; This file is part of GNU Emacs.
@@ -27,8 +27,8 @@
 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
 ;; Boston, MA 02111-1307, USA.
 
-(defconst ebnf-version "4.1"
-  "ebnf2ps.el, v 4.1 <2004/03/18 vinicius>
+(defconst ebnf-version "4.2"
+  "ebnf2ps.el, v 4.2 <2004/04/04 vinicius>
 
 Vinicius's last change version.  When reporting bugs, please also
 report the version of Emacs, if any, that ebnf2ps was running with.
@@ -177,9 +177,36 @@
 ;;   (global-set-key '(control f22) 'ebnf-despool)
 ;;
 ;;
+;; Invoking Ebnf2ps in Batch
+;; -------------------------
+;;
+;; It's possible also to run ebnf2ps in batch, this is useful when, for
+;; example, you have a directory with a lot of files containing the EBNF to be
+;; translated to PostScript.
+;;
+;; To run ebnf2ps in batch type, for example:
+;;
+;;    emacs -batch -l setup-ebnf2ps.el -f ebnf-eps-directory
+;;
+;; Where setup-ebnf2ps.el should be a file containing:
+;;
+;;    ;; set load-path if ebnf2ps isn't installed in your Emacs environment
+;;    (setq load-path (append (list "/dir/of/ebnf2ps") load-path))
+;;    (require 'ebnf2ps)
+;;    ;; insert here your ebnf2ps settings
+;;    (setq ebnf-terminal-shape 'bevel)
+;;    ;; etc.
+;;
+;;
 ;; EBNF Syntax
 ;; -----------
 ;;
+;; BNF (Backus Naur Form) notation is defined like languages, and like
+;; languages there are rules about name formation and syntax.  In this section
+;; it's defined a BNF syntax that it's called simply EBNF (Extended BNF).
+;; ebnf2ps package also deal with other BNF notation.  Please, see the variable
+;; `ebnf-syntax' documentation below in this section.
+;;
 ;; The current EBNF that ebnf2ps accepts has the following constructions:
 ;;
 ;;    ;			comment (until end of line)
@@ -324,6 +351,10 @@
 ;;		     `http://www.w3.org/TR/2004/REC-xml-20040204/#sec-notation'
 ;;		     ("Extensible Markup Language (XML) 1.0 (Third Edition)")
 ;;
+;;    `dtd'		ebnf2ps recognizes the syntax described in the URL:
+;;			`http://www.w3.org/TR/2004/REC-xml-20040204/'
+;;		     ("Extensible Markup Language (XML) 1.0 (Third Edition)")
+;;
 ;; Any other value is treated as `ebnf'.
 ;;
 ;; The default value is `ebnf'.
@@ -395,6 +426,8 @@
 ;;
 ;; ebnf2ps accepts the following actions in comments:
 ;;
+;;    ;^	same as form feed.  See section Form Feed above.
+;;
 ;;    ;>	the next production starts in the same line as the current one.
 ;;		It is useful when `ebnf-horizontal-orientation' is nil.
 ;;
@@ -459,8 +492,8 @@
 ;; Only the ;> will take effect, that is, A and B will be drawn in the same
 ;; line.
 ;;
-;; In ISO EBNF the above actions are specified as (*>*), (*<*), (*[EPS*) and
-;; (*]EPS*).  The first example above should be written:
+;; In ISO EBNF the above actions are specified as (*^*), (*>*), (*<*), (*[EPS*)
+;; and (*]EPS*).  The first example above should be written:
 ;;
 ;;    A = t;
 ;;    C = x;
@@ -1687,10 +1720,14 @@
 		`http://www.w3.org/TR/2004/REC-xml-20040204/#sec-notation'
 		(\"Extensible Markup Language (XML) 1.0 (Third Edition)\")
 
+   `dtd'	ebnf2ps recognizes the syntax described in the URL:
+		`http://www.w3.org/TR/2004/REC-xml-20040204/'
+		(\"Extensible Markup Language (XML) 1.0 (Third Edition)\")
+
 Any other value is treated as `ebnf'."
   :type '(radio :tag "Syntax"
 		(const ebnf) (const abnf)  (const iso-ebnf)
-		(const yacc) (const ebnfx))
+		(const yacc) (const ebnfx) (const dtd))
   :group 'ebnf-syntactic)
 
 
@@ -1885,6 +1922,21 @@
 
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
+;; To make this file smaller, some commands go in a separate file.
+;; But autoload them here to make the separation invisible.
+;; Autoload is here to avoid compilation gripes.
+
+(autoload 'ebnf-eliminate-empty-rules "ebnf-otz"
+  "Eliminate empty rules.")
+
+(autoload 'ebnf-optimize              "ebnf-otz"
+  "Syntactic chart optimizer.")
+
+(autoload 'ebnf-otz-initialize        "ebnf-otz"
+  "Initialize optimizer.")
+
+
+;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Customization
 
 
@@ -2406,6 +2458,10 @@
     (ebnfx
      default
      (ebnf-syntax                      . 'ebnfx))
+    ;; dtd default
+    (dtd
+     default
+     (ebnf-syntax                      . 'dtd))
     )
   "Style database.
 
@@ -4664,7 +4720,8 @@
     (yacc      ebnf-yac-parser  ebnf-yac-initialize)
     (abnf      ebnf-abn-parser  ebnf-abn-initialize)
     (ebnf      ebnf-bnf-parser  ebnf-bnf-initialize)
-    (ebnfx     ebnf-ebx-parser  ebnf-ebx-initialize))
+    (ebnfx     ebnf-ebx-parser  ebnf-ebx-initialize)
+    (dtd       ebnf-dtd-parser  ebnf-dtd-initialize))
   "Alist associating ebnf syntax with a parser and a initializer.")
 
 
@@ -5661,6 +5718,20 @@
 						   (cons seq body)
 						 body))))))))
 
+
+(defun ebnf-token-sequence (sequence)
+  (cond
+   ;; null sequence
+   ((null sequence)
+    (ebnf-make-empty))
+   ;; sequence with only one element
+   ((= (length sequence) 1)
+    (car sequence))
+   ;; a real sequence
+   (t
+    (ebnf-make-sequence (nreverse sequence)))
+   ))
+
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;; Variables used by parsers
@@ -5671,6 +5742,7 @@
     ;; Override special comment character:
     (aset table ?< 'newline)
     (aset table ?> 'keep-line)
+    (aset table ?^ 'form-feed)
     table)
   "Vector used to map characters to a special comment token.")
 
@@ -5709,14 +5781,11 @@
 (autoload 'ebnf-ebx-initialize        "ebnf-ebx"
   "Initializations for EBNFX parser.")
 
-(autoload 'ebnf-eliminate-empty-rules "ebnf-otz"
-  "Eliminate empty rules.")
-
-(autoload 'ebnf-optimize              "ebnf-otz"
-  "Syntactic chart optimizer.")
-
-(autoload 'ebnf-otz-initialize        "ebnf-otz"
-  "Initialize optimizer.")
+(autoload 'ebnf-dtd-parser            "ebnf-dtd"
+  "DTD parser.")
+
+(autoload 'ebnf-dtd-initialize        "ebnf-dtd"
+  "Initializations for DTD parser.")
 
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;