aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVinicius Jose Latorre2004-02-25 00:07:33 +0000
committerVinicius Jose Latorre2004-02-25 00:07:33 +0000
commitac4780a12cd50a1e185a88a19236c705554d463b (patch)
tree610959432195e5af36c8fe48f718b9e394eacdc3
parentda8f925e2d8a2a77f72ab1e34518d0756f575996 (diff)
downloademacs-ac4780a12cd50a1e185a88a19236c705554d463b.tar.gz
emacs-ac4780a12cd50a1e185a88a19236c705554d463b.zip
ABNF parser. Fix bug on productions like test = {"test"}* | ("tt" ["test"]). Reported by Markus Dreyer.
-rw-r--r--lisp/ChangeLog40
-rw-r--r--lisp/progmodes/ebnf-bnf.el15
-rw-r--r--lisp/progmodes/ebnf-iso.el20
-rw-r--r--lisp/progmodes/ebnf-otz.el9
-rw-r--r--lisp/progmodes/ebnf-yac.el52
-rw-r--r--lisp/progmodes/ebnf2ps.el563
6 files changed, 562 insertions, 137 deletions
diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index 9bf1ae47cc1..3394f764c8d 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -1,3 +1,43 @@
12004-02-24 Vinicius Jose Latorre <viniciusjl@ig.com.br>
2
3 * ebnf-abn.el: New file, implements an ABNF parser.
4
5 * ebnf2ps.el: Doc fix. Accept ABNF (Augmented BNF). New arrow shapes:
6 semi-up-hollow, semi-up-full, semi-down-hollow and semi-down-full. Fix
7 a bug on productions like test = {"test"}* | ( "tt" ["test"] ).
8 Reported by Markus Dreyer <mdreyer@ix.urz.uni-heidelberg.de>.
9 (ebnf-version): New version number (4.0).
10 (ebnf-print-directory, ebnf-print-file, ebnf-spool-directory)
11 (ebnf-spool-file, ebnf-eps-directory, ebnf-eps-file)
12 (ebnf-delete-style): New commands.
13 (ebnf-directory, ebnf-file): New funs.
14 (ebnf-special-show-delimiter, ebnf-file-suffix-regexp)
15 (ebnf-production-name-p, ebnf-stop-on-error): New options.
16 (ebnf-syntax-alist): New var.
17 (ebnf-element-width): New fun replacing ebnf-list-width.
18 (ebnf-arrow-shape, ebnf-syntax): Custom fix.
19 (ebnf-style-custom-list, ebnf-style-database, ebnf-arrow-shape-alist)
20 (ebnf-prologue): Adjust vars.
21 (ebnf-setup, ebnf-insert-style, ebnf-merge-style, ebnf-apply-style)
22 (ebnf-reset-style, ebnf-push-style, ebnf-pop-style)
23 (ebnf-check-style-values, ebnf-generate-production)
24 (ebnf-generate-region, ebnf-production-dimension, ebnf-justify-list)
25 (ebnf-make-terminal1, ebnf-make-or-more1, ebnf-make-repeat)
26 (ebnf-token-repeat): Code fix.
27
28 * ebnf-yac.el: Doc fix. Handle Bison pragmas %nonassoc, %right, %left
29 and %prec. Suggested by Matthew K. Junker <junker@alum.mit.edu>.
30 (ebnf-yac-definitions, ebnf-yac-lex): Code fix.
31
32 * ebnf-iso.el: Doc fix.
33 (ebnf-iso-token-table, ebnf-iso-non-terminal-chars): Adjust vars.
34 (ebnf-iso-lex): Code fix.
35
36 * ebnf-bnf.el: Doc fix.
37 (ebnf-bnf-lex): Code fix.
38
39 * ebnf-otz.el: Doc fix.
40
12004-02-23 Luc Teirlinck <teirllm@auburn.edu> 412004-02-23 Luc Teirlinck <teirllm@auburn.edu>
2 42
3 * abbrev.el (write-abbrev-file): Make argument optional. Doc fix. 43 * abbrev.el (write-abbrev-file): Make argument optional. Doc fix.
diff --git a/lisp/progmodes/ebnf-bnf.el b/lisp/progmodes/ebnf-bnf.el
index f9d1c718d4f..41bd0cd0d49 100644
--- a/lisp/progmodes/ebnf-bnf.el
+++ b/lisp/progmodes/ebnf-bnf.el
@@ -1,12 +1,13 @@
1;;; ebnf-bnf.el --- parser for EBNF 1;;; ebnf-bnf.el --- parser for EBNF
2 2
3;; Copyright (C) 1999, 2000, 2001 Free Sofware Foundation, Inc. 3;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004
4;; Free Sofware Foundation, Inc.
4 5
5;; Author: Vinicius Jose Latorre <vinicius@cpqd.com.br> 6;; Author: Vinicius Jose Latorre <viniciusjl@ig.com.br>
6;; Maintainer: Vinicius Jose Latorre <vinicius@cpqd.com.br> 7;; Maintainer: Vinicius Jose Latorre <viniciusjl@ig.com.br>
8;; Time-stamp: <2004/02/22 14:25:06 vinicius>
7;; Keywords: wp, ebnf, PostScript 9;; Keywords: wp, ebnf, PostScript
8;; Time-stamp: <2003-02-10 10:29:48 jbarranquero> 10;; Version: 1.8
9;; Version: 1.7
10 11
11;; This file is part of GNU Emacs. 12;; This file is part of GNU Emacs.
12 13
@@ -462,9 +463,9 @@ See documentation for variable `ebnf-bnf-lex'."
462 'integer) 463 'integer)
463 ;; special: ?special? 464 ;; special: ?special?
464 ((eq token 'special) 465 ((eq token 'special)
465 (setq ebnf-bnf-lex (concat "?" 466 (setq ebnf-bnf-lex (concat (and ebnf-special-show-delimiter "?")
466 (ebnf-string " ->@-~" ?\? "special") 467 (ebnf-string " ->@-~" ?\? "special")
467 "?")) 468 (and ebnf-special-show-delimiter "?")))
468 'special) 469 'special)
469 ;; terminal: "string" 470 ;; terminal: "string"
470 ((eq token 'terminal) 471 ((eq token 'terminal)
diff --git a/lisp/progmodes/ebnf-iso.el b/lisp/progmodes/ebnf-iso.el
index 9329f90af5e..148f23d2cab 100644
--- a/lisp/progmodes/ebnf-iso.el
+++ b/lisp/progmodes/ebnf-iso.el
@@ -1,12 +1,13 @@
1;;; ebnf-iso.el --- parser for ISO EBNF 1;;; ebnf-iso.el --- parser for ISO EBNF
2 2
3;; Copyright (C) 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc. 3;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004
4;; Free Software Foundation, Inc.
4 5
5;; Author: Vinicius Jose Latorre <vinicius@cpqd.com.br> 6;; Author: Vinicius Jose Latorre <viniciusjl@ig.com.br>
6;; Maintainer: Vinicius Jose Latorre <vinicius@cpqd.com.br> 7;; Maintainer: Vinicius Jose Latorre <viniciusjl@ig.com.br>
8;; Time-stamp: <2004/02/22 14:24:55 vinicius>
7;; Keywords: wp, ebnf, PostScript 9;; Keywords: wp, ebnf, PostScript
8;; Time-stamp: <2003/08/12 21:29:14 vinicius> 10;; Version: 1.7
9;; Version: 1.6
10 11
11;; This file is part of GNU Emacs. 12;; This file is part of GNU Emacs.
12 13
@@ -112,7 +113,7 @@
112;; ISO EBNF accepts the characters given by <character> production above, 113;; ISO EBNF accepts the characters given by <character> production above,
113;; HORIZONTAL TAB (^I), VERTICAL TAB (^K), NEWLINE (^J or ^M) and FORM FEED 114;; HORIZONTAL TAB (^I), VERTICAL TAB (^K), NEWLINE (^J or ^M) and FORM FEED
114;; (^L), any other characters are illegal. But ebnf2ps accepts also the 115;; (^L), any other characters are illegal. But ebnf2ps accepts also the
115;; european 8-bit accentuated characters (from \240 to \377). 116;; european 8-bit accentuated characters (from \240 to \377) and underscore.
116;; 117;;
117;; 118;;
118;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 119;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -346,6 +347,7 @@
346 ;; Override form feed character: 347 ;; Override form feed character:
347 (aset table ?\f 'form-feed) ; [FF] form feed 348 (aset table ?\f 'form-feed) ; [FF] form feed
348 ;; Override other lexical characters: 349 ;; Override other lexical characters:
350 (aset table ?_ 'non-terminal)
349 (aset table ?\" 'double-terminal) 351 (aset table ?\" 'double-terminal)
350 (aset table ?\' 'single-terminal) 352 (aset table ?\' 'single-terminal)
351 (aset table ?\? 'special) 353 (aset table ?\? 'special)
@@ -390,7 +392,7 @@
390 392
391;; replace the range "\240-\377" (see `ebnf-range-regexp'). 393;; replace the range "\240-\377" (see `ebnf-range-regexp').
392(defconst ebnf-iso-non-terminal-chars 394(defconst ebnf-iso-non-terminal-chars
393 (ebnf-range-regexp " 0-9A-Za-z" ?\240 ?\377)) 395 (ebnf-range-regexp " 0-9A-Za-z_" ?\240 ?\377))
394 396
395 397
396(defun ebnf-iso-lex () 398(defun ebnf-iso-lex ()
@@ -439,9 +441,9 @@ See documentation for variable `ebnf-iso-lex'."
439 'integer) 441 'integer)
440 ;; special: ?special? 442 ;; special: ?special?
441 ((eq token 'special) 443 ((eq token 'special)
442 (setq ebnf-iso-lex (concat "?" 444 (setq ebnf-iso-lex (concat (and ebnf-special-show-delimiter "?")
443 (ebnf-string " ->@-~" ?\? "special") 445 (ebnf-string " ->@-~" ?\? "special")
444 "?")) 446 (and ebnf-special-show-delimiter "?")))
445 'special) 447 'special)
446 ;; terminal: "string" 448 ;; terminal: "string"
447 ((eq token 'double-terminal) 449 ((eq token 'double-terminal)
diff --git a/lisp/progmodes/ebnf-otz.el b/lisp/progmodes/ebnf-otz.el
index 9f2a5aa7889..aae8906c384 100644
--- a/lisp/progmodes/ebnf-otz.el
+++ b/lisp/progmodes/ebnf-otz.el
@@ -1,11 +1,12 @@
1;;; ebnf-otz.el --- syntactic chart OpTimiZer 1;;; ebnf-otz.el --- syntactic chart OpTimiZer
2 2
3;; Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. 3;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004
4;; Free Sofware Foundation, Inc.
4 5
5;; Author: Vinicius Jose Latorre <vinicius@cpqd.com.br> 6;; Author: Vinicius Jose Latorre <viniciusjl@ig.com.br>
6;; Maintainer: Vinicius Jose Latorre <vinicius@cpqd.com.br> 7;; Maintainer: Vinicius Jose Latorre <viniciusjl@ig.com.br>
8;; Time-stamp: <2004/02/22 14:24:37 vinicius>
7;; Keywords: wp, ebnf, PostScript 9;; Keywords: wp, ebnf, PostScript
8;; Time-stamp: <2003-02-10 10:46:51 jbarranquero>
9;; Version: 1.0 10;; Version: 1.0
10 11
11;; This file is part of GNU Emacs. 12;; This file is part of GNU Emacs.
diff --git a/lisp/progmodes/ebnf-yac.el b/lisp/progmodes/ebnf-yac.el
index d0e85fe1444..199e076ad61 100644
--- a/lisp/progmodes/ebnf-yac.el
+++ b/lisp/progmodes/ebnf-yac.el
@@ -1,12 +1,13 @@
1;;; ebnf-yac.el --- parser for Yacc/Bison 1;;; ebnf-yac.el --- parser for Yacc/Bison
2 2
3;; Copyright (C) 1999, 2000, 2001 Free Sofware Foundation, Inc. 3;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004
4;; Free Sofware Foundation, Inc.
4 5
5;; Author: Vinicius Jose Latorre <vinicius@cpqd.com.br> 6;; Author: Vinicius Jose Latorre <viniciusjl@ig.com.br>
6;; Maintainer: Vinicius Jose Latorre <vinicius@cpqd.com.br> 7;; Maintainer: Vinicius Jose Latorre <viniciusjl@ig.com.br>
8;; Time-stamp: <2004/02/22 14:24:17 vinicius>
7;; Keywords: wp, ebnf, PostScript 9;; Keywords: wp, ebnf, PostScript
8;; Time-stamp: <2003-02-10 10:47:04 jbarranquero> 10;; Version: 1.2.1
9;; Version: 1.2
10 11
11;; This file is part of GNU Emacs. 12;; This file is part of GNU Emacs.
12 13
@@ -42,7 +43,9 @@
42;; 43;;
43;; YACC = { YACC-Definitions }* "%%" { YACC-Rule }* [ "%%" [ YACC-Code ] ]. 44;; YACC = { YACC-Definitions }* "%%" { YACC-Rule }* [ "%%" [ YACC-Code ] ].
44;; 45;;
45;; YACC-Definitions = "%token" [ "<" Name ">" ] Name-List 46;; YACC-Definitions = ( "%token" | "%left" | "%right" | "%nonassoc" )
47;; [ "<" Name ">" ] Name-List
48;; | "%prec" Name
46;; | "any other Yacc definition" 49;; | "any other Yacc definition"
47;; . 50;; .
48;; 51;;
@@ -68,6 +71,19 @@
68;; | "//" "any character" "\\n". 71;; | "//" "any character" "\\n".
69;; 72;;
70;; 73;;
74;; In other words, a valid Name begins with a letter (upper or lower case)
75;; followed by letters, decimal digits, underscore (_) or point (.). For
76;; example: this_is_a_valid.name, Another_EXAMPLE, mIxEd.CaSe.
77;;
78;;
79;; Acknowledgements
80;; ----------------
81;;
82;; Thanks to Matthew K. Junker <junker@alum.mit.edu> for the suggestion to deal
83;; with %right, %left and %prec pragmas. His suggestion was extended to deal
84;; with %nonassoc pragma too.
85;;
86;;
71;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 87;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
72 88
73;;; Code: 89;;; Code:
@@ -126,7 +142,9 @@
126 syntax-list)) 142 syntax-list))
127 143
128 144
129;;; YACC-Definitions = "%token" [ "<" Name ">" ] Name-List 145;;; YACC-Definitions = ( "%token" | "%left" | "%right" | "%nonassoc" )
146;;; [ "<" Name ">" ] Name-List
147;;; | "%prec" Name
130;;; | "any other Yacc definition" 148;;; | "any other Yacc definition"
131;;; . 149;;; .
132 150
@@ -135,7 +153,8 @@
135 (while (not (memq token '(yac-separator end-of-input))) 153 (while (not (memq token '(yac-separator end-of-input)))
136 (setq token 154 (setq token
137 (cond 155 (cond
138 ;; "%token" [ "<" Name ">" ] Name-List 156 ;; ( "%token" | "%left" | "%right" | "%nonassoc" )
157 ;; [ "<" Name ">" ] Name-List
139 ((eq token 'yac-token) 158 ((eq token 'yac-token)
140 (setq token (ebnf-yac-lex)) 159 (setq token (ebnf-yac-lex))
141 (when (eq token 'open-angle) 160 (when (eq token 'open-angle)
@@ -148,7 +167,12 @@
148 ebnf-yac-token-list (nconc (cdr token) 167 ebnf-yac-token-list (nconc (cdr token)
149 ebnf-yac-token-list)) 168 ebnf-yac-token-list))
150 (car token)) 169 (car token))
151 ;; "any other Yacc definition" 170 ;; "%prec" Name
171 ((eq token 'yac-prec)
172 (or (eq (ebnf-yac-lex) 'non-terminal)
173 (error "Missing prec name"))
174 (ebnf-yac-lex))
175 ;; "any other Yacc definition"
152 (t 176 (t
153 (ebnf-yac-lex)) 177 (ebnf-yac-lex))
154 ))) 178 )))
@@ -360,9 +384,13 @@ See documentation for variable `ebnf-yac-lex'."
360 ((eq (following-char) ?%) 384 ((eq (following-char) ?%)
361 (forward-char) 385 (forward-char)
362 'yac-separator) 386 'yac-separator)
363 ;; %TOKEN 387 ;; %TOKEN, %RIGHT, %LEFT, %PREC, %NONASSOC
364 ((string= (upcase (ebnf-buffer-substring "0-9A-Za-z_")) "TOKEN") 388 ((cdr (assoc (upcase (ebnf-buffer-substring "0-9A-Za-z_"))
365 'yac-token) 389 '(("TOKEN" . yac-token)
390 ("RIGHT" . yac-token)
391 ("LEFT" . yac-token)
392 ("NONASSOC" . yac-token)
393 ("PREC" . yac-prec)))))
366 ;; other Yacc pragmas 394 ;; other Yacc pragmas
367 (t 395 (t
368 'yac-pragma) 396 'yac-pragma)
diff --git a/lisp/progmodes/ebnf2ps.el b/lisp/progmodes/ebnf2ps.el
index a069b83b15d..352767e508e 100644
--- a/lisp/progmodes/ebnf2ps.el
+++ b/lisp/progmodes/ebnf2ps.el
@@ -1,12 +1,13 @@
1;;; ebnf2ps.el --- translate an EBNF to a syntactic chart on PostScript 1;;; ebnf2ps.el --- translate an EBNF to a syntactic chart on PostScript
2 2
3;; Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. 3;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004
4;; Free Software Foundation, Inc.
4 5
5;; Author: Vinicius Jose Latorre <vinicius@cpqd.com.br> 6;; Author: Vinicius Jose Latorre <viniciusjl@ig.com.br>
6;; Maintainer: Vinicius Jose Latorre <vinicius@cpqd.com.br> 7;; Maintainer: Vinicius Jose Latorre <viniciusjl@ig.com.br>
8;; Time-stamp: <2004/02/24 20:48:53 vinicius>
7;; Keywords: wp, ebnf, PostScript 9;; Keywords: wp, ebnf, PostScript
8;; Time-stamp: <2003/08/08 23:09:36 vinicius> 10;; Version: 4.0
9;; Version: 3.6.1
10;; X-URL: http://www.cpqd.com.br/~vinicius/emacs/ 11;; X-URL: http://www.cpqd.com.br/~vinicius/emacs/
11 12
12;; This file is part of GNU Emacs. 13;; This file is part of GNU Emacs.
@@ -26,14 +27,14 @@
26;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, 27;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
27;; Boston, MA 02111-1307, USA. 28;; Boston, MA 02111-1307, USA.
28 29
29(defconst ebnf-version "3.6.1" 30(defconst ebnf-version "4.0"
30 "ebnf2ps.el, v 3.6.1 <2001/09/24 vinicius> 31 "ebnf2ps.el, v 4.0 <2004/02/24 vinicius>
31 32
32Vinicius's last change version. When reporting bugs, please also 33Vinicius's last change version. When reporting bugs, please also
33report the version of Emacs, if any, that ebnf2ps was running with. 34report the version of Emacs, if any, that ebnf2ps was running with.
34 35
35Please send all bug fixes and enhancements to 36Please send all bug fixes and enhancements to
36 Vinicius Jose Latorre <vinicius@cpqd.com.br>. 37 Vinicius Jose Latorre <viniciusjl@ig.com.br>.
37") 38")
38 39
39 40
@@ -72,10 +73,16 @@ Please send all bug fixes and enhancements to
72;; ebnf2ps provides six commands for generating PostScript syntactic chart 73;; ebnf2ps provides six commands for generating PostScript syntactic chart
73;; images of Emacs buffers: 74;; images of Emacs buffers:
74;; 75;;
76;; ebnf-print-directory
77;; ebnf-print-file
75;; ebnf-print-buffer 78;; ebnf-print-buffer
76;; ebnf-print-region 79;; ebnf-print-region
80;; ebnf-spool-directory
81;; ebnf-spool-file
77;; ebnf-spool-buffer 82;; ebnf-spool-buffer
78;; ebnf-spool-region 83;; ebnf-spool-region
84;; ebnf-eps-directory
85;; ebnf-eps-file
79;; ebnf-eps-buffer 86;; ebnf-eps-buffer
80;; ebnf-eps-region 87;; ebnf-eps-region
81;; 88;;
@@ -110,12 +117,16 @@ Please send all bug fixes and enhancements to
110;; you'll be asked to confirm the exit; this is modeled on the confirmation 117;; you'll be asked to confirm the exit; this is modeled on the confirmation
111;; that Emacs uses for modified buffers. 118;; that Emacs uses for modified buffers.
112;; 119;;
113;; The word "buffer" or "region" in the command name determines how much of the 120;; The word "directory", "file", "buffer" or "region" in the command name
114;; buffer is printed: 121;; determines how much of the buffer is printed:
115;; 122;;
116;; buffer - Print the entire buffer. 123;; directory - Read files in the directory and print them.
117;; 124;;
118;; region - Print just the current region. 125;; file - Read file and print it.
126;;
127;; buffer - Print the entire buffer.
128;;
129;; region - Print just the current region.
119;; 130;;
120;; Two ebnf- command examples: 131;; Two ebnf- command examples:
121;; 132;;
@@ -126,9 +137,10 @@ Please send all bug fixes and enhancements to
126;; spool the image in Emacs to send to the printer 137;; spool the image in Emacs to send to the printer
127;; later. 138;; later.
128;; 139;;
129;; Note that `ebnf-eps-buffer' and `ebnf-eps-region' never spool the EPS image, 140;; Note that `ebnf-eps-directory', `ebnf-eps-file', `ebnf-eps-buffer' and
130;; so they don't use the ps-print spooling mechanism. See section "Actions in 141;; `ebnf-eps-region' never spool the EPS image, so they don't use the ps-print
131;; Comments" for an explanation about EPS file generation. 142;; spooling mechanism. See section "Actions in Comments" for an explanation
143;; about EPS file generation.
132;; 144;;
133;; 145;;
134;; Invoking Ebnf2ps 146;; Invoking Ebnf2ps
@@ -223,14 +235,30 @@ Please send all bug fixes and enhancements to
223;; . 235;; .
224;; 236;;
225;; non_terminal = "[!#%&'*-,0-:<>@-Z\\\\^-z~\\240-\\377]+". 237;; non_terminal = "[!#%&'*-,0-:<>@-Z\\\\^-z~\\240-\\377]+".
238;; ;; that is, a valid non_terminal accepts decimal digits, letters (upper
239;; ;; and lower), 8-bit accentuated characters,
240;; ;; "!", "#", "%", "&", "'", "*", "+", ",", ":",
241;; ;; "<", ">", "@", "\", "^", "_", "`" and "~".
226;; 242;;
227;; terminal = "\\([^\"\\]\\|\\\\[ -~\\240-\\377]\\)+". 243;; terminal = "\\([^\"\\]\\|\\\\[ -~\\240-\\377]\\)+".
244;; ;; that is, a valid terminal accepts any printable character (including
245;; ;; 8-bit accentuated characters) except `"', as `"' is used to delimit a
246;; ;; terminal. Also, accepts escaped characters, that is, a character
247;; ;; pair starting with `\' followed by a printable character, for
248;; ;; example: \", \\.
228;; 249;;
229;; special = "[^?\\n\\000-\\010\\016-\\037\\177-\\237]*". 250;; special = "[^?\\000-\\010\\012-\\037\\177-\\237]*".
251;; ;; that is, a valid special accepts any printable character (including
252;; ;; 8-bit accentuated characters) and tabs except `?', as `?' is used to
253;; ;; delimit a special.
230;; 254;;
231;; integer = "[0-9]+". 255;; integer = "[0-9]+".
256;; ;; that is, an integer is a sequence of one or more decimal digits.
232;; 257;;
233;; comment = ";" "[^\\n\\000-\\010\\016-\\037\\177-\\237]*" "\\n". 258;; comment = ";" "[^\\n\\000-\\010\\016-\\037\\177-\\237]*" "\\n".
259;; ;; that is, a comment starts with the character `;' and terminates at end
260;; ;; of line. Also, it only accepts printable characters (including 8-bit
261;; ;; accentuated characters) and tabs.
234;; 262;;
235;; Try to use the above EBNF to test ebnf2ps. 263;; Try to use the above EBNF to test ebnf2ps.
236;; 264;;
@@ -273,6 +301,10 @@ Please send all bug fixes and enhancements to
273;; `ebnf-terminal-regexp', `ebnf-case-fold-search', 301;; `ebnf-terminal-regexp', `ebnf-case-fold-search',
274;; `ebnf-lex-comment-char' and `ebnf-lex-eop-char'. 302;; `ebnf-lex-comment-char' and `ebnf-lex-eop-char'.
275;; 303;;
304;; `abnf' ebnf2ps recognizes the syntax described in the URL:
305;; `http://www.faqs.org/rfcs/rfc2234.html'
306;; ("Augmented BNF for Syntax Specifications: ABNF").
307;;
276;; `iso-ebnf' ebnf2ps recognizes the syntax described in the URL: 308;; `iso-ebnf' ebnf2ps recognizes the syntax described in the URL:
277;; `http://www.cl.cam.ac.uk/~mgk25/iso-ebnf.html' 309;; `http://www.cl.cam.ac.uk/~mgk25/iso-ebnf.html'
278;; ("International Standard of the ISO EBNF Notation"). 310;; ("International Standard of the ISO EBNF Notation").
@@ -545,6 +577,9 @@ Please send all bug fixes and enhancements to
545;; 577;;
546;; `ebnf-terminal-border-color' Specify border color for terminal box. 578;; `ebnf-terminal-border-color' Specify border color for terminal box.
547;; 579;;
580;; `ebnf-production-name-p' Non-nil means production name will be
581;; printed.
582;;
548;; `ebnf-sort-production' Specify how productions are sorted. 583;; `ebnf-sort-production' Specify how productions are sorted.
549;; 584;;
550;; `ebnf-production-font' Specify production font. 585;; `ebnf-production-font' Specify production font.
@@ -562,6 +597,9 @@ Please send all bug fixes and enhancements to
562;; `ebnf-non-terminal-border-color' Specify border color for non-terminal 597;; `ebnf-non-terminal-border-color' Specify border color for non-terminal
563;; box. 598;; box.
564;; 599;;
600;; `ebnf-special-show-delimiter' Non-nil means special delimiter
601;; (character `?') is shown.
602;;
565;; `ebnf-special-font' Specify special font. 603;; `ebnf-special-font' Specify special font.
566;; 604;;
567;; `ebnf-special-shape' Specify special box shape. 605;; `ebnf-special-shape' Specify special box shape.
@@ -629,10 +667,16 @@ Please send all bug fixes and enhancements to
629;; default terminal, non-terminal or 667;; default terminal, non-terminal or
630;; special. 668;; special.
631;; 669;;
670;; `ebnf-file-suffix-regexp' Specify file name suffix that contains
671;; EBNF.
672;;
632;; `ebnf-eps-prefix' Specify EPS prefix file name. 673;; `ebnf-eps-prefix' Specify EPS prefix file name.
633;; 674;;
634;; `ebnf-use-float-format' Non-nil means use `%f' float format. 675;; `ebnf-use-float-format' Non-nil means use `%f' float format.
635;; 676;;
677;; `ebnf-stop-on-error' Non-nil means signal error and stop.
678;; Nil means signal error and continue.
679;;
636;; `ebnf-yac-ignore-error-recovery' Non-nil means ignore error recovery. 680;; `ebnf-yac-ignore-error-recovery' Non-nil means ignore error recovery.
637;; 681;;
638;; `ebnf-ignore-empty-rule' Non-nil means ignore empty rules. 682;; `ebnf-ignore-empty-rule' Non-nil means ignore empty rules.
@@ -695,21 +739,24 @@ Please send all bug fixes and enhancements to
695;; `ebnf-insert-style' Insert a new style NAME with inheritance INHERITS and 739;; `ebnf-insert-style' Insert a new style NAME with inheritance INHERITS and
696;; values VALUES. 740;; values VALUES.
697;; 741;;
742;; `ebnf-delete-style' Delete style NAME.
743;;
698;; `ebnf-merge-style' Merge values of style NAME with style VALUES. 744;; `ebnf-merge-style' Merge values of style NAME with style VALUES.
699;; 745;;
700;; `ebnf-apply-style' Set STYLE to current style. 746;; `ebnf-apply-style' Set STYLE as the current style.
701;; 747;;
702;; `ebnf-reset-style' Reset current style. 748;; `ebnf-reset-style' Reset current style.
703;; 749;;
704;; `ebnf-push-style' Push the current style and set STYLE to current style. 750;; `ebnf-push-style' Push the current style and set STYLE as the current
751;; style.
705;; 752;;
706;; `ebnf-pop-style' Pop a style and set it to current style. 753;; `ebnf-pop-style' Pop a style and set it as the current style.
707;; 754;;
708;; These commands helps to put together a lot of variable settings in a group 755;; These commands help to put together a lot of variable settings in a group
709;; and name this group. So when you wish to apply these settings it's only 756;; and name this group. So when you wish to apply these settings it's only
710;; needed to give the name. 757;; needed to give the name.
711;; 758;;
712;; There is also a notion of simple inheritance of style; so if you declare 759;; There is also a notion of simple inheritance of style; so, if you declare
713;; that a style A inherits from a style B, all settings of B is applied first 760;; that a style A inherits from a style B, all settings of B is applied first
714;; and then the settings of A is applied. This is useful when you wish to 761;; and then the settings of A is applied. This is useful when you wish to
715;; modify some aspects of an existing style, but at same time wish to keep it 762;; modify some aspects of an existing style, but at same time wish to keep it
@@ -994,6 +1041,17 @@ Please send all bug fixes and enhancements to
994;; Acknowledgements 1041;; Acknowledgements
995;; ---------------- 1042;; ----------------
996;; 1043;;
1044;; Thanks to Drew Adams <?@?> for suggestions:
1045;; - `ebnf-production-name-p', `ebnf-stop-on-error',
1046;; `ebnf-file-suffix-regexp'and `ebnf-special-show-delimiter' variables.
1047;; - `ebnf-delete-style', `ebnf-eps-file' and `ebnf-eps-directory'
1048;; commands.
1049;; - some docs fix.
1050;;
1051;; Thanks to Matthew K. Junker <junker@alum.mit.edu> for the suggestion to deal
1052;; with some Bison features (%right, %left and %prec pragmas). His suggestion
1053;; was extended to deal with %nonassoc pragma too.
1054;;
997;; Thanks to all who emailed comments. 1055;; Thanks to all who emailed comments.
998;; 1056;;
999;; 1057;;
@@ -1140,6 +1198,12 @@ Valid values are:
1140 :group 'ebnf-displacement) 1198 :group 'ebnf-displacement)
1141 1199
1142 1200
1201(defcustom ebnf-special-show-delimiter t
1202 "*Non-nil means special delimiter (character `?') is shown."
1203 :type 'boolean
1204 :group 'ebnf-special)
1205
1206
1143(defcustom ebnf-special-font '(7 Courier "Black" "Gray95" bold italic) 1207(defcustom ebnf-special-font '(7 Courier "Black" "Gray95" bold italic)
1144 "*Specify special font. 1208 "*Specify special font.
1145 1209
@@ -1332,6 +1396,12 @@ See documentation for `ebnf-non-terminal-shape'."
1332 :group 'ebnf-terminal) 1396 :group 'ebnf-terminal)
1333 1397
1334 1398
1399(defcustom ebnf-production-name-p t
1400 "*Non-nil means production name will be printed."
1401 :type 'boolean
1402 :group 'ebnf-production)
1403
1404
1335(defcustom ebnf-sort-production nil 1405(defcustom ebnf-sort-production nil
1336 "*Specify how productions are sorted. 1406 "*Specify how productions are sorted.
1337 1407
@@ -1482,14 +1552,28 @@ Valid values are:
1482 |* 1552 |*
1483 * 1553 *
1484 1554
1555 `semi-up-hollow' `semi-up-full'
1556 * *
1557 |* |*
1558 | * |X*
1559 ==+==* ==+==*
1560
1561 `semi-down-hollow' `semi-down-full'
1562 ==+==* ==+==*
1563 | * |X*
1564 |* |*
1565 * *
1566
1485 `user' See also documentation for variable `ebnf-user-arrow'. 1567 `user' See also documentation for variable `ebnf-user-arrow'.
1486 1568
1487Any other value is treated as `none'." 1569Any other value is treated as `none'."
1488 :type '(radio :tag "Arrow Shape" 1570 :type '(radio :tag "Arrow Shape"
1489 (const none) (const semi-up) 1571 (const none) (const semi-up)
1490 (const semi-down) (const simple) 1572 (const semi-down) (const simple)
1491 (const transparent) (const hollow) 1573 (const transparent) (const hollow)
1492 (const full) (const user)) 1574 (const full) (const semi-up-hollow)
1575 (const semi-down-hollow) (const semi-up-full)
1576 (const semi-down-full) (const user))
1493 :group 'ebnf-shape) 1577 :group 'ebnf-shape)
1494 1578
1495 1579
@@ -1553,6 +1637,10 @@ Valid values are:
1553 `ebnf-terminal-regexp', `ebnf-case-fold-search', 1637 `ebnf-terminal-regexp', `ebnf-case-fold-search',
1554 `ebnf-lex-comment-char' and `ebnf-lex-eop-char'. 1638 `ebnf-lex-comment-char' and `ebnf-lex-eop-char'.
1555 1639
1640 `abnf' ebnf2ps recognizes the syntax described in the URL:
1641 `http://www.faqs.org/rfcs/rfc2234.html'
1642 (\"Augmented BNF for Syntax Specifications: ABNF\").
1643
1556 `iso-ebnf' ebnf2ps recognizes the syntax described in the URL: 1644 `iso-ebnf' ebnf2ps recognizes the syntax described in the URL:
1557 `http://www.cl.cam.ac.uk/~mgk25/iso-ebnf.html' 1645 `http://www.cl.cam.ac.uk/~mgk25/iso-ebnf.html'
1558 (\"International Standard of the ISO EBNF Notation\"). 1646 (\"International Standard of the ISO EBNF Notation\").
@@ -1567,7 +1655,7 @@ Valid values are:
1567 1655
1568Any other value is treated as `ebnf'." 1656Any other value is treated as `ebnf'."
1569 :type '(radio :tag "Syntax" 1657 :type '(radio :tag "Syntax"
1570 (const ebnf) (const iso-ebnf) (const yacc)) 1658 (const ebnf) (const abnf) (const iso-ebnf) (const yacc))
1571 :group 'ebnf-syntactic) 1659 :group 'ebnf-syntactic)
1572 1660
1573 1661
@@ -1638,6 +1726,14 @@ It's only used when `ebnf-syntax' is `iso-ebnf'."
1638 :group 'ebnf-syntactic) 1726 :group 'ebnf-syntactic)
1639 1727
1640 1728
1729(defcustom ebnf-file-suffix-regexp "\.[Bb][Nn][Ff]$"
1730 "*Specify file name suffix that contains EBNF.
1731
1732See `ebnf-eps-directory' command."
1733 :type 'regexp
1734 :group 'ebnf2ps)
1735
1736
1641(defcustom ebnf-eps-prefix "ebnf--" 1737(defcustom ebnf-eps-prefix "ebnf--"
1642 "*Specify EPS prefix file name. 1738 "*Specify EPS prefix file name.
1643 1739
@@ -1704,6 +1800,12 @@ when executing ebnf2ps, set `ebnf-use-float-format' to nil."
1704 :group 'ebnf2ps) 1800 :group 'ebnf2ps)
1705 1801
1706 1802
1803(defcustom ebnf-stop-on-error nil
1804 "*Non-nil means signal error and stop. Nil means signal error and continue."
1805 :type 'boolean
1806 :group 'ebnf2ps)
1807
1808
1707(defcustom ebnf-yac-ignore-error-recovery nil 1809(defcustom ebnf-yac-ignore-error-recovery nil
1708 "*Non-nil means ignore error recovery. 1810 "*Non-nil means ignore error recovery.
1709 1811
@@ -1763,6 +1865,34 @@ The above optimizations are specially useful when `ebnf-syntax' is `yacc'."
1763 1865
1764 1866
1765;;;###autoload 1867;;;###autoload
1868(defun ebnf-print-directory (&optional directory)
1869 "Generate and print a PostScript syntactic chart image of DIRECTORY.
1870
1871If DIRECTORY is nil, it's used `default-directory'.
1872
1873The files in DIRECTORY that matches `ebnf-file-suffix-regexp' (which see) are
1874processed.
1875
1876See also `ebnf-print-buffer'."
1877 (interactive
1878 (list (read-file-name "Directory containing EBNF files (print): "
1879 nil default-directory)))
1880 (ebnf-directory 'ebnf-print-buffer directory))
1881
1882
1883;;;###autoload
1884(defun ebnf-print-file (file &optional do-not-kill-buffer-when-done)
1885 "Generate and print a PostScript syntactic chart image of the file FILE.
1886
1887If optional arg DO-NOT-KILL-BUFFER-WHEN-DONE is non-nil, the buffer isn't
1888killed after process termination.
1889
1890See also `ebnf-print-buffer'."
1891 (interactive "fEBNF file to generate PostScript and print from: ")
1892 (ebnf-file 'ebnf-print-buffer file do-not-kill-buffer-when-done))
1893
1894
1895;;;###autoload
1766(defun ebnf-print-buffer (&optional filename) 1896(defun ebnf-print-buffer (&optional filename)
1767 "Generate and print a PostScript syntactic chart image of the buffer. 1897 "Generate and print a PostScript syntactic chart image of the buffer.
1768 1898
@@ -1789,6 +1919,34 @@ Like `ebnf-print-buffer', but prints just the current region."
1789 1919
1790 1920
1791;;;###autoload 1921;;;###autoload
1922(defun ebnf-spool-directory (&optional directory)
1923 "Generate and spool a PostScript syntactic chart image of DIRECTORY.
1924
1925If DIRECTORY is nil, it's used `default-directory'.
1926
1927The files in DIRECTORY that matches `ebnf-file-suffix-regexp' (which see) are
1928processed.
1929
1930See also `ebnf-spool-buffer'."
1931 (interactive
1932 (list (read-file-name "Directory containing EBNF files (spool): "
1933 nil default-directory)))
1934 (ebnf-directory 'ebnf-spool-buffer directory))
1935
1936
1937;;;###autoload
1938(defun ebnf-spool-file (file &optional do-not-kill-buffer-when-done)
1939 "Generate and spool a PostScript syntactic chart image of the file FILE.
1940
1941If optional arg DO-NOT-KILL-BUFFER-WHEN-DONE is non-nil, the buffer isn't
1942killed after process termination.
1943
1944See also `ebnf-spool-buffer'."
1945 (interactive "fEBNF file to generate PostScript and spool from: ")
1946 (ebnf-file 'ebnf-spool-buffer file do-not-kill-buffer-when-done))
1947
1948
1949;;;###autoload
1792(defun ebnf-spool-buffer () 1950(defun ebnf-spool-buffer ()
1793 "Generate and spool a PostScript syntactic chart image of the buffer. 1951 "Generate and spool a PostScript syntactic chart image of the buffer.
1794Like `ebnf-print-buffer' except that the PostScript image is saved in a 1952Like `ebnf-print-buffer' except that the PostScript image is saved in a
@@ -1810,6 +1968,34 @@ Use the command `ebnf-despool' to send the spooled images to the printer."
1810 1968
1811 1969
1812;;;###autoload 1970;;;###autoload
1971(defun ebnf-eps-directory (&optional directory)
1972 "Generate EPS files from EBNF files in DIRECTORY.
1973
1974If DIRECTORY is nil, it's used `default-directory'.
1975
1976The files in DIRECTORY that matches `ebnf-file-suffix-regexp' (which see) are
1977processed.
1978
1979See also `ebnf-eps-buffer'."
1980 (interactive
1981 (list (read-file-name "Directory containing EBNF files (EPS): "
1982 nil default-directory)))
1983 (ebnf-directory 'ebnf-eps-buffer directory))
1984
1985
1986;;;###autoload
1987(defun ebnf-eps-file (file &optional do-not-kill-buffer-when-done)
1988 "Generate an EPS file from EBNF file FILE.
1989
1990If optional arg DO-NOT-KILL-BUFFER-WHEN-DONE is non-nil, the buffer isn't
1991killed after EPS generation.
1992
1993See also `ebnf-eps-buffer'."
1994 (interactive "fEBNF file to generate EPS file from: ")
1995 (ebnf-file 'ebnf-eps-buffer file do-not-kill-buffer-when-done))
1996
1997
1998;;;###autoload
1813(defun ebnf-eps-buffer () 1999(defun ebnf-eps-buffer ()
1814 "Generate a PostScript syntactic chart image of the buffer in a EPS file. 2000 "Generate a PostScript syntactic chart image of the buffer in a EPS file.
1815 2001
@@ -1883,7 +2069,8 @@ WARNING: It's *NOT* asked any confirmation to override an existing file."
1883 " 2069 "
1884;;; ebnf2ps.el version %s 2070;;; ebnf2ps.el version %s
1885 2071
1886\(setq ebnf-special-font %s 2072\(setq ebnf-special-show-delimiter %S
2073 ebnf-special-font %s
1887 ebnf-special-shape %s 2074 ebnf-special-shape %s
1888 ebnf-special-shadow %S 2075 ebnf-special-shadow %S
1889 ebnf-special-border-width %S 2076 ebnf-special-border-width %S
@@ -1910,6 +2097,7 @@ WARNING: It's *NOT* asked any confirmation to override an existing file."
1910 ebnf-non-terminal-shadow %S 2097 ebnf-non-terminal-shadow %S
1911 ebnf-non-terminal-border-width %S 2098 ebnf-non-terminal-border-width %S
1912 ebnf-non-terminal-border-color %S 2099 ebnf-non-terminal-border-color %S
2100 ebnf-production-name-p %S
1913 ebnf-sort-production %s 2101 ebnf-sort-production %s
1914 ebnf-production-font %s 2102 ebnf-production-font %s
1915 ebnf-arrow-shape %s 2103 ebnf-arrow-shape %s
@@ -1925,6 +2113,7 @@ WARNING: It's *NOT* asked any confirmation to override an existing file."
1925 ebnf-syntax %s 2113 ebnf-syntax %s
1926 ebnf-iso-alternative-p %S 2114 ebnf-iso-alternative-p %S
1927 ebnf-iso-normalize-p %S 2115 ebnf-iso-normalize-p %S
2116 ebnf-file-suffix-regexp %S
1928 ebnf-eps-prefix %S 2117 ebnf-eps-prefix %S
1929 ebnf-entry-percentage %S 2118 ebnf-entry-percentage %S
1930 ebnf-color-p %S 2119 ebnf-color-p %S
@@ -1932,6 +2121,7 @@ WARNING: It's *NOT* asked any confirmation to override an existing file."
1932 ebnf-line-color %S 2121 ebnf-line-color %S
1933 ebnf-debug-ps %S 2122 ebnf-debug-ps %S
1934 ebnf-use-float-format %S 2123 ebnf-use-float-format %S
2124 ebnf-stop-on-error %S
1935 ebnf-yac-ignore-error-recovery %S 2125 ebnf-yac-ignore-error-recovery %S
1936 ebnf-ignore-empty-rule %S 2126 ebnf-ignore-empty-rule %S
1937 ebnf-optimize %S) 2127 ebnf-optimize %S)
@@ -1939,6 +2129,7 @@ WARNING: It's *NOT* asked any confirmation to override an existing file."
1939;;; ebnf2ps.el - end of settings 2129;;; ebnf2ps.el - end of settings
1940" 2130"
1941 ebnf-version 2131 ebnf-version
2132 ebnf-special-show-delimiter
1942 (ps-print-quote ebnf-special-font) 2133 (ps-print-quote ebnf-special-font)
1943 (ps-print-quote ebnf-special-shape) 2134 (ps-print-quote ebnf-special-shape)
1944 ebnf-special-shadow 2135 ebnf-special-shadow
@@ -1966,6 +2157,7 @@ WARNING: It's *NOT* asked any confirmation to override an existing file."
1966 ebnf-non-terminal-shadow 2157 ebnf-non-terminal-shadow
1967 ebnf-non-terminal-border-width 2158 ebnf-non-terminal-border-width
1968 ebnf-non-terminal-border-color 2159 ebnf-non-terminal-border-color
2160 ebnf-production-name-p
1969 (ps-print-quote ebnf-sort-production) 2161 (ps-print-quote ebnf-sort-production)
1970 (ps-print-quote ebnf-production-font) 2162 (ps-print-quote ebnf-production-font)
1971 (ps-print-quote ebnf-arrow-shape) 2163 (ps-print-quote ebnf-arrow-shape)
@@ -1981,6 +2173,7 @@ WARNING: It's *NOT* asked any confirmation to override an existing file."
1981 (ps-print-quote ebnf-syntax) 2173 (ps-print-quote ebnf-syntax)
1982 ebnf-iso-alternative-p 2174 ebnf-iso-alternative-p
1983 ebnf-iso-normalize-p 2175 ebnf-iso-normalize-p
2176 ebnf-file-suffix-regexp
1984 ebnf-eps-prefix 2177 ebnf-eps-prefix
1985 ebnf-entry-percentage 2178 ebnf-entry-percentage
1986 ebnf-color-p 2179 ebnf-color-p
@@ -1988,6 +2181,7 @@ WARNING: It's *NOT* asked any confirmation to override an existing file."
1988 ebnf-line-color 2181 ebnf-line-color
1989 ebnf-debug-ps 2182 ebnf-debug-ps
1990 ebnf-use-float-format 2183 ebnf-use-float-format
2184 ebnf-stop-on-error
1991 ebnf-yac-ignore-error-recovery 2185 ebnf-yac-ignore-error-recovery
1992 ebnf-ignore-empty-rule 2186 ebnf-ignore-empty-rule
1993 ebnf-optimize)) 2187 ebnf-optimize))
@@ -2007,7 +2201,8 @@ WARNING: It's *NOT* asked any confirmation to override an existing file."
2007 2201
2008 2202
2009(defconst ebnf-style-custom-list 2203(defconst ebnf-style-custom-list
2010 '(ebnf-special-font 2204 '(ebnf-special-show-delimiter
2205 ebnf-special-font
2011 ebnf-special-shape 2206 ebnf-special-shape
2012 ebnf-special-shadow 2207 ebnf-special-shadow
2013 ebnf-special-border-width 2208 ebnf-special-border-width
@@ -2034,6 +2229,7 @@ WARNING: It's *NOT* asked any confirmation to override an existing file."
2034 ebnf-non-terminal-shadow 2229 ebnf-non-terminal-shadow
2035 ebnf-non-terminal-border-width 2230 ebnf-non-terminal-border-width
2036 ebnf-non-terminal-border-color 2231 ebnf-non-terminal-border-color
2232 ebnf-production-name-p
2037 ebnf-sort-production 2233 ebnf-sort-production
2038 ebnf-production-font 2234 ebnf-production-font
2039 ebnf-arrow-shape 2235 ebnf-arrow-shape
@@ -2049,6 +2245,7 @@ WARNING: It's *NOT* asked any confirmation to override an existing file."
2049 ebnf-syntax 2245 ebnf-syntax
2050 ebnf-iso-alternative-p 2246 ebnf-iso-alternative-p
2051 ebnf-iso-normalize-p 2247 ebnf-iso-normalize-p
2248 ebnf-file-suffix-regexp
2052 ebnf-eps-prefix 2249 ebnf-eps-prefix
2053 ebnf-entry-percentage 2250 ebnf-entry-percentage
2054 ebnf-color-p 2251 ebnf-color-p
@@ -2056,6 +2253,7 @@ WARNING: It's *NOT* asked any confirmation to override an existing file."
2056 ebnf-line-color 2253 ebnf-line-color
2057 ebnf-debug-ps 2254 ebnf-debug-ps
2058 ebnf-use-float-format 2255 ebnf-use-float-format
2256 ebnf-stop-on-error
2059 ebnf-yac-ignore-error-recovery 2257 ebnf-yac-ignore-error-recovery
2060 ebnf-ignore-empty-rule 2258 ebnf-ignore-empty-rule
2061 ebnf-optimize) 2259 ebnf-optimize)
@@ -2066,6 +2264,7 @@ WARNING: It's *NOT* asked any confirmation to override an existing file."
2066 '(;; EBNF default 2264 '(;; EBNF default
2067 (default 2265 (default
2068 nil 2266 nil
2267 (ebnf-special-show-delimiter . t)
2069 (ebnf-special-font . '(7 Courier "Black" "Gray95" bold italic)) 2268 (ebnf-special-font . '(7 Courier "Black" "Gray95" bold italic))
2070 (ebnf-special-shape . 'bevel) 2269 (ebnf-special-shape . 'bevel)
2071 (ebnf-special-shadow . nil) 2270 (ebnf-special-shadow . nil)
@@ -2093,6 +2292,7 @@ WARNING: It's *NOT* asked any confirmation to override an existing file."
2093 (ebnf-non-terminal-shadow . nil) 2292 (ebnf-non-terminal-shadow . nil)
2094 (ebnf-non-terminal-border-width . 1.0) 2293 (ebnf-non-terminal-border-width . 1.0)
2095 (ebnf-non-terminal-border-color . "Black") 2294 (ebnf-non-terminal-border-color . "Black")
2295 (ebnf-production-name-p . t)
2096 (ebnf-sort-production . nil) 2296 (ebnf-sort-production . nil)
2097 (ebnf-production-font . '(10 Helvetica "Black" "White" bold)) 2297 (ebnf-production-font . '(10 Helvetica "Black" "White" bold))
2098 (ebnf-arrow-shape . 'hollow) 2298 (ebnf-arrow-shape . 'hollow)
@@ -2108,6 +2308,7 @@ WARNING: It's *NOT* asked any confirmation to override an existing file."
2108 (ebnf-syntax . 'ebnf) 2308 (ebnf-syntax . 'ebnf)
2109 (ebnf-iso-alternative-p . nil) 2309 (ebnf-iso-alternative-p . nil)
2110 (ebnf-iso-normalize-p . nil) 2310 (ebnf-iso-normalize-p . nil)
2311 (ebnf-file-suffix-regexp . "\.[Bb][Nn][Ff]$")
2111 (ebnf-eps-prefix . "ebnf--") 2312 (ebnf-eps-prefix . "ebnf--")
2112 (ebnf-entry-percentage . 0.5) 2313 (ebnf-entry-percentage . 0.5)
2113 (ebnf-color-p . (or (fboundp 'x-color-values) ; Emacs 2314 (ebnf-color-p . (or (fboundp 'x-color-values) ; Emacs
@@ -2116,6 +2317,7 @@ WARNING: It's *NOT* asked any confirmation to override an existing file."
2116 (ebnf-line-color . "Black") 2317 (ebnf-line-color . "Black")
2117 (ebnf-debug-ps . nil) 2318 (ebnf-debug-ps . nil)
2118 (ebnf-use-float-format . t) 2319 (ebnf-use-float-format . t)
2320 (ebnf-stop-on-error . nil)
2119 (ebnf-yac-ignore-error-recovery . nil) 2321 (ebnf-yac-ignore-error-recovery . nil)
2120 (ebnf-ignore-empty-rule . nil) 2322 (ebnf-ignore-empty-rule . nil)
2121 (ebnf-optimize . nil)) 2323 (ebnf-optimize . nil))
@@ -2125,6 +2327,10 @@ WARNING: It's *NOT* asked any confirmation to override an existing file."
2125 (ebnf-justify-sequence . 'left) 2327 (ebnf-justify-sequence . 'left)
2126 (ebnf-lex-comment-char . ?\#) 2328 (ebnf-lex-comment-char . ?\#)
2127 (ebnf-lex-eop-char . ?\;)) 2329 (ebnf-lex-eop-char . ?\;))
2330 ;; ABNF default
2331 (abnf
2332 default
2333 (ebnf-syntax . 'abnf))
2128 ;; ISO EBNF default 2334 ;; ISO EBNF default
2129 (iso-ebnf 2335 (iso-ebnf
2130 default 2336 default
@@ -2138,19 +2344,31 @@ WARNING: It's *NOT* asked any confirmation to override an existing file."
2138 2344
2139Each element has the following form: 2345Each element has the following form:
2140 2346
2141 (CUSTOM INHERITS (VAR . VALUE)...) 2347 (NAME INHERITS (VAR . VALUE)...)
2142 2348
2143CUSTOM is a symbol name style. 2349Where:
2144INHERITS is a symbol name style from which the current style inherits the
2145context. If INHERITS is nil, means that there is no inheritance.
2146VAR is a valid ebnf2ps symbol custom variable. See `ebnf-style-custom-list'
2147for valid symbol variable.
2148VALUE is a sexp which it'll be evaluated to set the value to VAR. So, don't
2149forget to quote symbols and constant lists. See `default' style for an
2150example.
2151 2350
2152Don't handle this variable directly. Use functions `ebnf-insert-style' and 2351NAME is a symbol name style.
2153`ebnf-merge-style'.") 2352
2353INHERITS is a symbol name style from which the current style inherits
2354 the context. If INHERITS is nil, means that there is no
2355 inheritance.
2356
2357 This is a simple inheritance of style; so if you declare that a
2358 style A inherits from a style B, all settings of B is applied
2359 first and then the settings of A is applied. This is useful
2360 when you wish to modify some aspects of an existing style, but
2361 at same time wish to keep it unmodified.
2362
2363VAR is a valid ebnf2ps symbol custom variable.
2364 See `ebnf-style-custom-list' for valid symbol variable.
2365
2366VALUE is a sexp which it'll be evaluated to set the value to VAR.
2367 So, don't forget to quote symbols and constant lists.
2368 See `default' style for an example.
2369
2370Don't handle this variable directly. Use functions `ebnf-insert-style',
2371`ebnf-delete-style' and `ebnf-merge-style'.")
2154 2372
2155 2373
2156;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; 2374;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
@@ -2159,8 +2377,10 @@ Don't handle this variable directly. Use functions `ebnf-insert-style' and
2159 2377
2160;;;###autoload 2378;;;###autoload
2161(defun ebnf-insert-style (name inherits &rest values) 2379(defun ebnf-insert-style (name inherits &rest values)
2162 "Insert a new style NAME with inheritance INHERITS and values VALUES." 2380 "Insert a new style NAME with inheritance INHERITS and values VALUES.
2163 (interactive) 2381
2382See `ebnf-style-database' documentation."
2383 (interactive "SStyle name: \nSStyle inherits from: \nXStyle values: ")
2164 (and (assoc name ebnf-style-database) 2384 (and (assoc name ebnf-style-database)
2165 (error "Style name already exists: %s" name)) 2385 (error "Style name already exists: %s" name))
2166 (or (assoc inherits ebnf-style-database) 2386 (or (assoc inherits ebnf-style-database)
@@ -2171,9 +2391,28 @@ Don't handle this variable directly. Use functions `ebnf-insert-style' and
2171 2391
2172 2392
2173;;;###autoload 2393;;;###autoload
2394(defun ebnf-delete-style (name)
2395 "Delete style NAME.
2396
2397See `ebnf-style-database' documentation."
2398 (interactive "SDelete style name: ")
2399 (or (assoc name ebnf-style-database)
2400 (error "Style name doesn't exist: %s" name))
2401 (let ((db ebnf-style-database))
2402 (while db
2403 (and (eq (nth 1 (car db)) name)
2404 (error "Style name `%s' is inherited by `%s' style"
2405 name (nth 0 (car db))))
2406 (setq db (cdr db))))
2407 (setq ebnf-style-database (assq-delete-all name ebnf-style-database)))
2408
2409
2410;;;###autoload
2174(defun ebnf-merge-style (name &rest values) 2411(defun ebnf-merge-style (name &rest values)
2175 "Merge values of style NAME with style VALUES." 2412 "Merge values of style NAME with style VALUES.
2176 (interactive) 2413
2414See `ebnf-style-database' documentation."
2415 (interactive "SStyle name: \nXStyle values: ")
2177 (let ((style (or (assoc name ebnf-style-database) 2416 (let ((style (or (assoc name ebnf-style-database)
2178 (error "Style name does'nt exist: %s" name))) 2417 (error "Style name does'nt exist: %s" name)))
2179 (merge (ebnf-check-style-values values)) 2418 (merge (ebnf-check-style-values values))
@@ -2193,10 +2432,12 @@ Don't handle this variable directly. Use functions `ebnf-insert-style' and
2193 2432
2194;;;###autoload 2433;;;###autoload
2195(defun ebnf-apply-style (style) 2434(defun ebnf-apply-style (style)
2196 "Set STYLE to current style. 2435 "Set STYLE as the current style.
2197 2436
2198It returns the old style symbol." 2437It returns the old style symbol.
2199 (interactive) 2438
2439See `ebnf-style-database' documentation."
2440 (interactive "SApply style: ")
2200 (prog1 2441 (prog1
2201 ebnf-current-style 2442 ebnf-current-style
2202 (and (ebnf-apply-style1 style) 2443 (and (ebnf-apply-style1 style)
@@ -2207,18 +2448,22 @@ It returns the old style symbol."
2207(defun ebnf-reset-style (&optional style) 2448(defun ebnf-reset-style (&optional style)
2208 "Reset current style. 2449 "Reset current style.
2209 2450
2210It returns the old style symbol." 2451It returns the old style symbol.
2211 (interactive) 2452
2453See `ebnf-style-database' documentation."
2454 (interactive "SReset style: ")
2212 (setq ebnf-stack-style nil) 2455 (setq ebnf-stack-style nil)
2213 (ebnf-apply-style (or style 'default))) 2456 (ebnf-apply-style (or style 'default)))
2214 2457
2215 2458
2216;;;###autoload 2459;;;###autoload
2217(defun ebnf-push-style (&optional style) 2460(defun ebnf-push-style (&optional style)
2218 "Push the current style and set STYLE to current style. 2461 "Push the current style and set STYLE as the current style.
2219 2462
2220It returns the old style symbol." 2463It returns the old style symbol.
2221 (interactive) 2464
2465See `ebnf-style-database' documentation."
2466 (interactive "SPush style: ")
2222 (prog1 2467 (prog1
2223 ebnf-current-style 2468 ebnf-current-style
2224 (setq ebnf-stack-style (cons ebnf-current-style ebnf-stack-style)) 2469 (setq ebnf-stack-style (cons ebnf-current-style ebnf-stack-style))
@@ -2228,9 +2473,11 @@ It returns the old style symbol."
2228 2473
2229;;;###autoload 2474;;;###autoload
2230(defun ebnf-pop-style () 2475(defun ebnf-pop-style ()
2231 "Pop a style and set it to current style. 2476 "Pop a style and set it as the current style.
2477
2478It returns the old style symbol.
2232 2479
2233It returns the old style symbol." 2480See `ebnf-style-database' documentation."
2234 (interactive) 2481 (interactive)
2235 (prog1 2482 (prog1
2236 (ebnf-apply-style (car ebnf-stack-style)) 2483 (ebnf-apply-style (car ebnf-stack-style))
@@ -2249,7 +2496,7 @@ It returns the old style symbol."
2249(defun ebnf-check-style-values (values) 2496(defun ebnf-check-style-values (values)
2250 (let (style) 2497 (let (style)
2251 (while values 2498 (while values
2252 (and (memq (car values) ebnf-style-custom-list) 2499 (and (memq (caar values) ebnf-style-custom-list)
2253 (setq style (cons (car values) style))) 2500 (setq style (cons (car values) style)))
2254 (setq values (cdr values))) 2501 (setq values (cdr values)))
2255 (nreverse style))) 2502 (nreverse style)))
@@ -2297,14 +2544,18 @@ documentation.")
2297 2544
2298 2545
2299(defconst ebnf-arrow-shape-alist 2546(defconst ebnf-arrow-shape-alist
2300 '((none . 0) 2547 '((none . 0)
2301 (semi-up . 1) 2548 (semi-up . 1)
2302 (semi-down . 2) 2549 (semi-down . 2)
2303 (simple . 3) 2550 (simple . 3)
2304 (transparent . 4) 2551 (transparent . 4)
2305 (hollow . 5) 2552 (hollow . 5)
2306 (full . 6) 2553 (full . 6)
2307 (user . 7)) 2554 (semi-up-hollow . 7)
2555 (semi-up-full . 8)
2556 (semi-down-hollow . 9)
2557 (semi-down-full . 10)
2558 (user . 11))
2308 "Alist associating values for `ebnf-arrow-shape'. 2559 "Alist associating values for `ebnf-arrow-shape'.
2309 2560
2310See documentation for `ebnf-arrow-shape'.") 2561See documentation for `ebnf-arrow-shape'.")
@@ -2464,19 +2715,39 @@ See documentation for `ebnf-terminal-shape', `ebnf-non-terminal-shape' and
2464 2715
2465/ArrowPath{c newpath moveto Arrow closepath}bind def 2716/ArrowPath{c newpath moveto Arrow closepath}bind def
2466 2717
2718/UpPath
2719{c newpath moveto
2720 hT2 neg 0 rmoveto
2721 0 hT4 rlineto
2722 hT2 hT4 neg rlineto
2723 closepath
2724}bind def
2725
2726/DownPath
2727{c newpath moveto
2728 hT2 neg 0 rmoveto
2729 0 hT4 neg rlineto
2730 hT2 hT4 rlineto
2731 closepath
2732}bind def
2733
2467%>Right Arrow: RA 2734%>Right Arrow: RA
2468% \\ 2735% \\
2469% *---+ 2736% *---+
2470% / 2737% /
2471/RA-vector 2738/RA-vector
2472[{} % 0 - none 2739[{} % 0 - none
2473 {hT2 neg hT4 rlineto} % 1 - semi-up 2740 {hT2 neg hT4 rlineto} % 1 - semi-up
2474 {Down} % 2 - semi-down 2741 {Down} % 2 - semi-down
2475 {Arrow} % 3 - simple 2742 {Arrow} % 3 - simple
2476 {Gstroke ArrowPath} % 4 - transparent 2743 {Gstroke ArrowPath} % 4 - transparent
2477 {Gstroke ArrowPath 1 FillGray} % 5 - hollow 2744 {Gstroke ArrowPath 1 FillGray} % 5 - hollow
2478 {Gstroke ArrowPath LineColor FillRGB} % 6 - full 2745 {Gstroke ArrowPath LineColor FillRGB} % 6 - full
2479 {Gstroke gsave UserArrow grestore} % 7 - user 2746 {Gstroke UpPath 1 FillGray} % 7 - semi-up-hollow
2747 {Gstroke UpPath LineColor FillRGB} % 8 - semi-up-full
2748 {Gstroke DownPath 1 FillGray} % 9 - semi-down-hollow
2749 {Gstroke DownPath LineColor FillRGB} % 10 - semi-down-full
2750 {Gstroke gsave UserArrow grestore} % 11 - user
2480]def 2751]def
2481 2752
2482/RA 2753/RA
@@ -3168,10 +3439,11 @@ See documentation for `ebnf-terminal-shape', `ebnf-non-terminal-shape' and
3168{xyp 3439{xyp
3169 neg yp add /yw exch def 3440 neg yp add /yw exch def
3170 xp add T sub /xw exch def 3441 xp add T sub /xw exch def
3171 /Effect EffectP def 3442 dup length 0 gt % empty string ==> no production name
3172 /fP F ForegroundP SetRGB BackgroundP aload pop true BG S 3443 {/Effect EffectP def
3173 /Effect 0 def 3444 /fP F ForegroundP SetRGB BackgroundP aload pop true BG S
3174 ( :) S false BG 3445 /Effect 0 def
3446 ( :) S false BG}if
3175 xw yw moveto 3447 xw yw moveto
3176 hT EL RA 3448 hT EL RA
3177 xp yw moveto 3449 xp yw moveto
@@ -3909,11 +4181,15 @@ end
3909(defun ebnf-generate-production (production) 4181(defun ebnf-generate-production (production)
3910 (ebnf-message-info "Generating") 4182 (ebnf-message-info "Generating")
3911 (run-hooks 'ebnf-production-hook) 4183 (run-hooks 'ebnf-production-hook)
3912 (ps-output-string (ebnf-node-name production)) 4184 (ps-output-string (if ebnf-production-name-p
4185 (ebnf-node-name production)
4186 ""))
3913 (ps-output " " 4187 (ps-output " "
3914 (ebnf-format-float 4188 (ebnf-format-float
3915 (ebnf-node-width production) 4189 (ebnf-node-width production)
3916 (+ ebnf-basic-height 4190 (+ (if ebnf-production-name-p
4191 ebnf-basic-height
4192 0.0)
3917 (ebnf-node-entry (ebnf-node-production production)))) 4193 (ebnf-node-entry (ebnf-node-production production))))
3918 " BOP\n") 4194 " BOP\n")
3919 (ebnf-node-generation (ebnf-node-production production)) 4195 (ebnf-node-generation (ebnf-node-production production))
@@ -4102,6 +4378,35 @@ end
4102;; Internal functions 4378;; Internal functions
4103 4379
4104 4380
4381(defun ebnf-directory (fun &optional directory)
4382 "Process files in DIRECTORY applying function FUN on each file.
4383
4384If DIRECTORY is nil, it's used `default-directory'.
4385
4386The files in DIRECTORY that matches `ebnf-file-suffix-regexp' (which see) are
4387processed."
4388 (let ((files (directory-files (or directory default-directory)
4389 t ebnf-file-suffix-regexp)))
4390 (while files
4391 (set-buffer (find-file-noselect (car files)))
4392 (funcall fun)
4393 (setq buffer-backed-up t) ; Do not back it up.
4394 (save-buffer) ; Just save new version.
4395 (kill-buffer (current-buffer))
4396 (setq files (cdr files)))))
4397
4398
4399(defun ebnf-file (fun file &optional do-not-kill-buffer-when-done)
4400 "Process file FILE applying function FUN.
4401
4402If optional arg DO-NOT-KILL-BUFFER-WHEN-DONE is non-nil, the buffer isn't
4403killed after process termination."
4404 (set-buffer (find-file-noselect file))
4405 (funcall fun)
4406 (or do-not-kill-buffer-when-done
4407 (kill-buffer (current-buffer))))
4408
4409
4105;; function `ebnf-range-regexp' is used to avoid a bug of `skip-chars-forward' 4410;; function `ebnf-range-regexp' is used to avoid a bug of `skip-chars-forward'
4106;; on version 20.4.1, that is, it doesn't accept ranges like "\240-\377" (or 4411;; on version 20.4.1, that is, it doesn't accept ranges like "\240-\377" (or
4107;; "\177-\237"), but it accepts the character sequence from \240 to \377 (or 4412;; "\177-\237"), but it accepts the character sequence from \240 to \377 (or
@@ -4143,6 +4448,7 @@ end
4143(defun ebnf-generate-region (from to gen-func) 4448(defun ebnf-generate-region (from to gen-func)
4144 (run-hooks 'ebnf-hook) 4449 (run-hooks 'ebnf-hook)
4145 (let ((ebnf-limit (max from to)) 4450 (let ((ebnf-limit (max from to))
4451 (error-msg "SYNTAX")
4146 the-point) 4452 the-point)
4147 (save-excursion 4453 (save-excursion
4148 (save-restriction 4454 (save-restriction
@@ -4150,20 +4456,38 @@ end
4150 (condition-case data 4456 (condition-case data
4151 (let ((tree (ebnf-parse-and-sort (min from to)))) 4457 (let ((tree (ebnf-parse-and-sort (min from to))))
4152 (when gen-func 4458 (when gen-func
4153 (funcall gen-func 4459 (setq error-msg "EMPTY RULES"
4154 (ebnf-dimensions 4460 tree (ebnf-eliminate-empty-rules tree))
4155 (ebnf-optimize 4461 (setq error-msg "OPTMIZE"
4156 (ebnf-eliminate-empty-rules tree)))))) 4462 tree (ebnf-optimize tree))
4463 (setq error-msg "DIMENSIONS"
4464 tree (ebnf-dimensions tree))
4465 (setq error-msg "GENERATION")
4466 (funcall gen-func tree))
4467 (setq error-msg nil)) ; here it's ok
4157 ;; handler 4468 ;; handler
4158 ((quit error) 4469 ((quit error)
4159 (ding) 4470 (ding)
4160 (setq the-point (max (1- (point)) (point-min))) 4471 (setq the-point (max (1- (point)) (point-min))
4161 (message (error-message-string data))))))) 4472 error-msg (concat error-msg ": "
4473 (error-message-string data)
4474 (if (string= error-msg "SYNTAX")
4475 (format ". At %d in buffer \"%s\"."
4476 the-point
4477 (buffer-name))
4478 (format ". In buffer \"%s\"."
4479 (buffer-name))))))))))
4162 (cond 4480 (cond
4163 (the-point 4481 ;; error occurred
4164 (goto-char the-point)) 4482 (error-msg
4483 (goto-char the-point)
4484 (if ebnf-stop-on-error
4485 (error error-msg)
4486 (message error-msg)))
4487 ;; generated output OK
4165 (gen-func 4488 (gen-func
4166 nil) 4489 nil)
4490 ;; syntax checked OK
4167 (t 4491 (t
4168 (message "EBNF syntactic analysis: NO ERRORS."))))) 4492 (message "EBNF syntactic analysis: NO ERRORS.")))))
4169 4493
@@ -4267,6 +4591,15 @@ end
4267 (ebnf-font-select font 'line-height)) 4591 (ebnf-font-select font 'line-height))
4268 4592
4269 4593
4594(defconst ebnf-syntax-alist
4595 ;; 0.syntax 1.parser 2.initializer
4596 '((iso-ebnf ebnf-iso-parser ebnf-iso-initialize)
4597 (yacc ebnf-yac-parser ebnf-yac-initialize)
4598 (abnf ebnf-abn-parser ebnf-abn-initialize)
4599 (ebnf ebnf-bnf-parser ebnf-bnf-initialize))
4600 "Alist associating ebnf syntax with a parser and a initializer.")
4601
4602
4270(defun ebnf-begin-job () 4603(defun ebnf-begin-job ()
4271 (ps-printing-region nil nil nil) 4604 (ps-printing-region nil nil nil)
4272 (if ebnf-use-float-format 4605 (if ebnf-use-float-format
@@ -4276,15 +4609,10 @@ end
4276 ebnf-message-float "%s")) 4609 ebnf-message-float "%s"))
4277 (ebnf-otz-initialize) 4610 (ebnf-otz-initialize)
4278 ;; to avoid compilation gripes when calling autoloaded functions 4611 ;; to avoid compilation gripes when calling autoloaded functions
4279 (funcall (cond ((eq ebnf-syntax 'iso-ebnf) 4612 (let ((init (or (assoc ebnf-syntax ebnf-syntax-alist)
4280 (setq ebnf-parser-func 'ebnf-iso-parser) 4613 (assoc 'ebnf ebnf-syntax-alist))))
4281 'ebnf-iso-initialize) 4614 (setq ebnf-parser-func (nth 1 init))
4282 ((eq ebnf-syntax 'yacc) 4615 (funcall (nth 2 init)))
4283 (setq ebnf-parser-func 'ebnf-yac-parser)
4284 'ebnf-yac-initialize)
4285 (t
4286 (setq ebnf-parser-func 'ebnf-bnf-parser)
4287 'ebnf-bnf-initialize)))
4288 (and ebnf-terminal-regexp ; ensures that it's a string or nil 4616 (and ebnf-terminal-regexp ; ensures that it's a string or nil
4289 (not (stringp ebnf-terminal-regexp)) 4617 (not (stringp ebnf-terminal-regexp))
4290 (setq ebnf-terminal-regexp nil)) 4618 (setq ebnf-terminal-regexp nil))
@@ -4588,12 +4916,16 @@ end
4588 (ebnf-message-info "Calculating dimensions") 4916 (ebnf-message-info "Calculating dimensions")
4589 (ebnf-node-dimension-func (ebnf-node-production production)) 4917 (ebnf-node-dimension-func (ebnf-node-production production))
4590 (let* ((prod (ebnf-node-production production)) 4918 (let* ((prod (ebnf-node-production production))
4591 (height (+ ebnf-font-height-P 4919 (height (+ (if ebnf-production-name-p
4920 ebnf-font-height-P
4921 0.0)
4922 ebnf-line-width ebnf-line-width
4592 ebnf-basic-height 4923 ebnf-basic-height
4593 (ebnf-node-height prod)))) 4924 (ebnf-node-height prod))))
4594 (ebnf-node-entry production height) 4925 (ebnf-node-entry production height)
4595 (ebnf-node-height production height) 4926 (ebnf-node-height production height)
4596 (ebnf-node-width production (+ (ebnf-node-width prod) 4927 (ebnf-node-width production (+ (ebnf-node-width prod)
4928 ebnf-line-width
4597 ebnf-horizontal-space)))) 4929 ebnf-horizontal-space))))
4598 4930
4599 4931
@@ -4850,7 +5182,7 @@ end
4850 5182
4851;; [one-or-more width-fun dim-fun entry height width element separator] 5183;; [one-or-more width-fun dim-fun entry height width element separator]
4852;; [zero-or-more width-fun dim-fun entry height width element separator] 5184;; [zero-or-more width-fun dim-fun entry height width element separator]
4853(defun ebnf-list-width (or-more width) 5185(defun ebnf-element-width (or-more width)
4854 (setq width (- width ebnf-horizontal-space)) 5186 (setq width (- width ebnf-horizontal-space))
4855 (ebnf-node-list or-more 5187 (ebnf-node-list or-more
4856 (ebnf-justify-list or-more 5188 (ebnf-justify-list or-more
@@ -4881,7 +5213,10 @@ end
4881 ;; right justify terms 5213 ;; right justify terms
4882 ((eq ebnf-justify-sequence 'right) 5214 ((eq ebnf-justify-sequence 'right)
4883 (ebnf-justify node seq seq-width width nil)) 5215 (ebnf-justify node seq seq-width width nil))
4884 ;; centralize terms 5216 ;; centralize terms -- element
5217 ((vectorp seq)
5218 (ebnf-adjust-width seq width))
5219 ;; centralize terms -- list
4885 (t 5220 (t
4886 (let ((the-width (/ (- width seq-width) (length seq))) 5221 (let ((the-width (/ (- width seq-width) (length seq)))
4887 (lis seq)) 5222 (lis seq))
@@ -5040,10 +5375,11 @@ end
5040 0.0 5375 0.0
5041 0.0 5376 0.0
5042 (let ((len (length name))) 5377 (let ((len (length name)))
5043 (cond ((> len 2) name) 5378 (cond ((> len 3) name)
5044 ((= len 2) (concat " " name)) 5379 ((= len 3) (concat name " "))
5045 ((= len 1) (concat " " name " ")) 5380 ((= len 2) (concat " " name " "))
5046 (t " "))) 5381 ((= len 1) (concat " " name " "))
5382 (t " ")))
5047 ebnf-default-p)) 5383 ebnf-default-p))
5048 5384
5049 5385
@@ -5063,7 +5399,7 @@ end
5063 5399
5064(defun ebnf-make-or-more1 (gen-func dim-func list-part sep-part) 5400(defun ebnf-make-or-more1 (gen-func dim-func list-part sep-part)
5065 (vector gen-func 5401 (vector gen-func
5066 'ebnf-list-width 5402 'ebnf-element-width
5067 dim-func 5403 dim-func
5068 0.0 5404 0.0
5069 0.0 5405 0.0
@@ -5119,14 +5455,25 @@ end
5119 exception)) 5455 exception))
5120 5456
5121 5457
5122(defun ebnf-make-repeat (times primary) 5458(defun ebnf-make-repeat (times primary &optional upper)
5123 (vector 'ebnf-generate-repeat 5459 (vector 'ebnf-generate-repeat
5124 'ignore 5460 'ignore
5125 'ebnf-repeat-dimension 5461 'ebnf-repeat-dimension
5126 0.0 5462 0.0
5127 0.0 5463 0.0
5128 0.0 5464 0.0
5129 (concat times " *") 5465 (cond ((and times upper) ; L * U, L * L
5466 (if (string= times upper)
5467 (if (string= times "")
5468 " * "
5469 times)
5470 (concat times " * " upper)))
5471 (times ; L *
5472 (concat times " *"))
5473 (upper ; * U
5474 (concat "* " upper))
5475 (t ; *
5476 " * "))
5130 primary)) 5477 primary))
5131 5478
5132 5479
@@ -5198,13 +5545,13 @@ end
5198 ))))) 5545 )))))
5199 5546
5200 5547
5201(defun ebnf-token-repeat (times repeat) 5548(defun ebnf-token-repeat (times repeat &optional upper)
5202 (if (null (cdr repeat)) 5549 (if (null (cdr repeat))
5203 ;; n * EMPTY ==> EMPTY 5550 ;; n * EMPTY ==> EMPTY
5204 repeat 5551 repeat
5205 ;; n * term 5552 ;; n * term
5206 (cons (car repeat) 5553 (cons (car repeat)
5207 (ebnf-make-repeat times (cdr repeat))))) 5554 (ebnf-make-repeat times (cdr repeat) upper))))
5208 5555
5209 5556
5210(defun ebnf-token-optional (body) 5557(defun ebnf-token-optional (body)
@@ -5263,6 +5610,12 @@ end
5263;; To make this file smaller, some commands go in a separate file. 5610;; To make this file smaller, some commands go in a separate file.
5264;; But autoload them here to make the separation invisible. 5611;; But autoload them here to make the separation invisible.
5265 5612
5613(autoload 'ebnf-abn-parser "ebnf-abn"
5614 "ABNF parser.")
5615
5616(autoload 'ebnf-abn-initialize "ebnf-abn"
5617 "Initialize ABNF token table.")
5618
5266(autoload 'ebnf-bnf-parser "ebnf-bnf" 5619(autoload 'ebnf-bnf-parser "ebnf-bnf"
5267 "EBNF parser.") 5620 "EBNF parser.")
5268 5621