aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaroly Lorentey2004-02-26 00:39:34 +0000
committerKaroly Lorentey2004-02-26 00:39:34 +0000
commit49c04a9f6d18e3df5fd0aa832061d4da75a4d8ff (patch)
tree3a68f8a8c66c5c84d8d9c2774fc5207feddc1521
parent1a10e2b72257d3c594dbd92216a4a2bd7b066e74 (diff)
parentdd341dd9c2dfa102585d11d0ad773c0ff074507f (diff)
downloademacs-49c04a9f6d18e3df5fd0aa832061d4da75a4d8ff.tar.gz
emacs-49c04a9f6d18e3df5fd0aa832061d4da75a4d8ff.zip
Merged in changes from CVS HEAD
Patches applied: * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-113 Update from CVS * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-114 Merge some minor redisplay bug-fixes from emacs--tiling--0 * miles@gnu.org--gnu-2004/emacs--cvs-trunk--0--patch-115 Update from CVS * miles@gnu.org--gnu-2004/emacs--tiling--0--patch-9 Remove bogus xassert * miles@gnu.org--gnu-2004/emacs--tiling--0--patch-10 Avoid negative descents for images with ascent > height * miles@gnu.org--gnu-2004/emacs--tiling--0--patch-13 Fix iterator-inconsistency bug in redisplay git-archimport-id: lorentey@elte.hu--2004/emacs--multi-tty--0--patch-101
-rw-r--r--lisp/ChangeLog40
-rw-r--r--lisp/progmodes/ebnf-abn.el663
-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
-rw-r--r--src/ChangeLog29
-rw-r--r--src/w32fns.c26
-rw-r--r--src/xdisp.c127
-rw-r--r--src/xfns.c3
11 files changed, 1352 insertions, 195 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-abn.el b/lisp/progmodes/ebnf-abn.el
new file mode 100644
index 00000000000..ec96109e0a0
--- /dev/null
+++ b/lisp/progmodes/ebnf-abn.el
@@ -0,0 +1,663 @@
1;;; ebnf-abn.el --- parser for ABNF (Augmented BNF)
2
3;; Copyright (C) 2004 Free Sofware Foundation, Inc.
4
5;; Author: Vinicius Jose Latorre <viniciusjl@ig.com.br>
6;; Maintainer: Vinicius Jose Latorre <viniciusjl@ig.com.br>
7;; Time-stamp: <2004/02/23 22:38:59 vinicius>
8;; Keywords: wp, ebnf, PostScript
9;; Version: 1.0
10
11;; This file is part of GNU Emacs.
12
13;; GNU Emacs is free software; you can redistribute it and/or modify
14;; it under the terms of the GNU General Public License as published by
15;; the Free Software Foundation; either version 2, or (at your option)
16;; any later version.
17
18;; GNU Emacs is distributed in the hope that it will be useful,
19;; but WITHOUT ANY WARRANTY; without even the implied warranty of
20;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21;; GNU General Public License for more details.
22
23;; You should have received a copy of the GNU General Public License
24;; along with GNU Emacs; see the file COPYING. If not, write to the
25;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
26;; Boston, MA 02111-1307, USA.
27
28;;; Commentary:
29
30;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
31;;
32;;
33;; This is part of ebnf2ps package.
34;;
35;; This package defines a parser for ABNF (Augmented BNF).
36;;
37;; See ebnf2ps.el for documentation.
38;;
39;;
40;; ABNF Syntax
41;; -----------
42;;
43;; See the URL:
44;; `http://www.faqs.org/rfcs/rfc2234.html'
45;; or
46;; `http://www.rnp.br/ietf/rfc/rfc2234.txt'
47;; ("Augmented BNF for Syntax Specifications: ABNF").
48;;
49;;
50;; rulelist = 1*( rule / (*c-wsp c-nl) )
51;;
52;; rule = rulename defined-as elements c-nl
53;; ; continues if next line starts with white space
54;;
55;; rulename = ALPHA *(ALPHA / DIGIT / "-")
56;;
57;; defined-as = *c-wsp ("=" / "=/") *c-wsp
58;; ; basic rules definition and incremental
59;; ; alternatives
60;;
61;; elements = alternation *c-wsp
62;;
63;; c-wsp = WSP / (c-nl WSP)
64;;
65;; c-nl = comment / CRLF
66;; ; comment or newline
67;;
68;; comment = ";" *(WSP / VCHAR) CRLF
69;;
70;; alternation = concatenation
71;; *(*c-wsp "/" *c-wsp concatenation)
72;;
73;; concatenation = repetition *(1*c-wsp repetition)
74;;
75;; repetition = [repeat] element
76;;
77;; repeat = 1*DIGIT / (*DIGIT "*" *DIGIT)
78;;
79;; element = rulename / group / option /
80;; char-val / num-val / prose-val
81;;
82;; group = "(" *c-wsp alternation *c-wsp ")"
83;;
84;; option = "[" *c-wsp alternation *c-wsp "]"
85;;
86;; char-val = DQUOTE *(%x20-21 / %x23-7E) DQUOTE
87;; ; quoted string of SP and VCHAR without DQUOTE
88;;
89;; num-val = "%" (bin-val / dec-val / hex-val)
90;;
91;; bin-val = "b" 1*BIT
92;; [ 1*("." 1*BIT) / ("-" 1*BIT) ]
93;; ; series of concatenated bit values
94;; ; or single ONEOF range
95;;
96;; dec-val = "d" 1*DIGIT
97;; [ 1*("." 1*DIGIT) / ("-" 1*DIGIT) ]
98;;
99;; hex-val = "x" 1*HEXDIG
100;; [ 1*("." 1*HEXDIG) / ("-" 1*HEXDIG) ]
101;;
102;; prose-val = "<" *(%x20-3D / %x3F-7E) ">"
103;; ; bracketed string of SP and VCHAR without
104;; ; angles
105;; ; prose description, to be used as last resort
106;;
107;; ; Core rules -- the coding depends on the system, here is used 7-bit ASCII
108;;
109;; ALPHA = %x41-5A / %x61-7A
110;; ; A-Z / a-z
111;;
112;; BIT = "0" / "1"
113;;
114;; CHAR = %x01-7F
115;; ; any 7-bit US-ASCII character, excluding NUL
116;;
117;; CR = %x0D
118;; ; carriage return
119;;
120;; CRLF = CR LF
121;; ; Internet standard newline
122;;
123;; CTL = %x00-1F / %x7F
124;; ; controls
125;;
126;; DIGIT = %x30-39
127;; ; 0-9
128;;
129;; DQUOTE = %x22
130;; ; " (Double Quote)
131;;
132;; HEXDIG = DIGIT / "A" / "B" / "C" / "D" / "E" / "F"
133;;
134;; HTAB = %x09
135;; ; horizontal tab
136;;
137;; LF = %x0A
138;; ; linefeed
139;;
140;; LWSP = *(WSP / CRLF WSP)
141;; ; linear white space (past newline)
142;;
143;; OCTET = %x00-FF
144;; ; 8 bits of data
145;;
146;; SP = %x20
147;; ; space
148;;
149;; VCHAR = %x21-7E
150;; ; visible (printing) characters
151;;
152;; WSP = SP / HTAB
153;; ; white space
154;;
155;;
156;; NOTES:
157;;
158;; 1. Rules name and terminal strings are case INSENSITIVE.
159;; So, the following rule names are all equals:
160;; Rule-name, rule-Name, rule-name, RULE-NAME
161;; Also, the following strings are equals:
162;; "abc", "ABC", "aBc", "Abc", "aBC", etc.
163;;
164;; 2. To have a case SENSITIVE string, use the character notation.
165;; For example, to specify the lowercase string "abc", use:
166;; %d97.98.99
167;;
168;; 3. There are no implicit spaces between elements, for example, the
169;; following rules:
170;;
171;; foo = %x61 ; a
172;;
173;; bar = %x62 ; b
174;;
175;; mumble = foo bar foo
176;;
177;; Are equivalent to the following rule:
178;;
179;; mumble = %x61.62.61
180;;
181;; If spaces are needed, it should be explicit specified, like:
182;;
183;; spaces = 1*(%x20 / %x09) ; one or more spaces or tabs
184;;
185;; mumble = foo spaces bar spaces foo
186;;
187;; 4. Lines starting with space or tab are considered a continuation line.
188;; For example, the rule:
189;;
190;; rule = foo
191;; bar
192;;
193;; Is equivalent to:
194;;
195;; rule = foo bar
196;;
197;;
198;; Differences Between ABNF And ebnf2ps ABNF
199;; -----------------------------------------
200;;
201;; Besides the characters that ABNF accepts, ebnf2ps ABNF accepts also the
202;; underscore (_) for rule name and european 8-bit accentuated characters (from
203;; \240 to \377) for rule name, string and comment.
204;;
205;;
206;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
207
208;;; Code:
209
210
211(require 'ebnf-otz)
212
213
214(defvar ebnf-abn-lex nil
215 "Value returned by `ebnf-abn-lex' function.")
216
217
218;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
219;; Syntactic analyzer
220
221
222;;; rulelist = 1*( rule / (*c-wsp c-nl) )
223
224(defun ebnf-abn-parser (start)
225 "ABNF parser."
226 (let ((total (+ (- ebnf-limit start) 1))
227 (bias (1- start))
228 (origin (point))
229 rule-list token rule)
230 (goto-char start)
231 (setq token (ebnf-abn-lex))
232 (and (eq token 'end-of-input)
233 (error "Invalid ABNF file format"))
234 (while (not (eq token 'end-of-input))
235 (ebnf-message-float
236 "Parsing...%s%%"
237 (/ (* (- (point) bias) 100.0) total))
238 (setq token (ebnf-abn-rule token)
239 rule (cdr token)
240 token (car token))
241 (or (ebnf-add-empty-rule-list rule)
242 (setq rule-list (cons rule rule-list))))
243 (goto-char origin)
244 rule-list))
245
246
247;;; rule = rulename defined-as elements c-nl
248;;; ; continues if next line starts with white space
249;;;
250;;; rulename = ALPHA *(ALPHA / DIGIT / "-")
251;;;
252;;; defined-as = *c-wsp ("=" / "=/") *c-wsp
253;;; ; basic rules definition and incremental
254;;; ; alternatives
255;;;
256;;; elements = alternation *c-wsp
257;;;
258;;; c-wsp = WSP / (c-nl WSP)
259;;;
260;;; c-nl = comment / CRLF
261;;; ; comment or newline
262;;;
263;;; comment = ";" *(WSP / VCHAR) CRLF
264
265
266(defun ebnf-abn-rule (token)
267 (let ((name ebnf-abn-lex)
268 (action ebnf-action)
269 elements)
270 (setq ebnf-action nil)
271 (or (eq token 'non-terminal)
272 (error "Invalid rule name"))
273 (setq token (ebnf-abn-lex))
274 (or (memq token '(equal incremental-alternative))
275 (error "Invalid rule: missing `=' or `=/'"))
276 (and (eq token 'incremental-alternative)
277 (setq name (concat name " =/")))
278 (setq elements (ebnf-abn-alternation))
279 (or (memq (car elements) '(end-of-rule end-of-input))
280 (error "Invalid rule: there is no end of rule"))
281 (setq elements (cdr elements))
282 (ebnf-eps-add-production name)
283 (cons (ebnf-abn-lex)
284 (ebnf-make-production name elements action))))
285
286
287;;; alternation = concatenation
288;;; *(*c-wsp "/" *c-wsp concatenation)
289
290
291(defun ebnf-abn-alternation ()
292 (let (body concatenation)
293 (while (eq (car (setq concatenation
294 (ebnf-abn-concatenation (ebnf-abn-lex))))
295 'alternative)
296 (setq body (cons (cdr concatenation) body)))
297 (ebnf-token-alternative body concatenation)))
298
299
300;;; concatenation = repetition *(1*c-wsp repetition)
301
302
303(defun ebnf-abn-concatenation (token)
304 (let ((term (ebnf-abn-repetition token))
305 seq)
306 (or (setq token (car term)
307 term (cdr term))
308 (error "Empty element"))
309 (setq seq (cons term seq))
310 (while (setq term (ebnf-abn-repetition token)
311 token (car term)
312 term (cdr term))
313 (setq seq (cons term seq)))
314 (cons token
315 (if (= (length seq) 1)
316 ;; sequence with only one element
317 (car seq)
318 ;; a real sequence
319 (ebnf-make-sequence (nreverse seq))))))
320
321
322;;; repetition = [repeat] element
323;;;
324;;; repeat = 1*DIGIT / (*DIGIT "*" *DIGIT)
325
326
327(defun ebnf-abn-repetition (token)
328 (let (lower upper)
329 ;; INTEGER [ "*" [ INTEGER ] ]
330 (when (eq token 'integer)
331 (setq lower ebnf-abn-lex
332 token (ebnf-abn-lex))
333 (or (eq token 'repeat)
334 (setq upper lower)))
335 ;; "*" [ INTEGER ]
336 (when (eq token 'repeat)
337 ;; only * ==> lower & upper are empty string
338 (or lower
339 (setq lower ""
340 upper ""))
341 (when (eq (setq token (ebnf-abn-lex)) 'integer)
342 (setq upper ebnf-abn-lex
343 token (ebnf-abn-lex))))
344 (let ((element (ebnf-abn-element token)))
345 (cond
346 ;; there is a repetition
347 (lower
348 (or element
349 (error "Missing element repetition"))
350 (setq token (ebnf-abn-lex))
351 (cond
352 ;; one or more
353 ((and (string= lower "1") (null upper))
354 (cons token (ebnf-make-one-or-more element)))
355 ;; zero or more
356 ((or (and (string= lower "0") (null upper))
357 (and (string= lower "") (string= upper "")))
358 (cons token (ebnf-make-zero-or-more element)))
359 ;; real repetition
360 (t
361 (ebnf-token-repeat lower (cons token element) upper))))
362 ;; there is an element
363 (element
364 (cons (ebnf-abn-lex) element))
365 ;; something that caller has to deal
366 (t
367 (cons token nil))))))
368
369
370;;; element = rulename / group / option /
371;;; char-val / num-val / prose-val
372;;;
373;;; group = "(" *c-wsp alternation *c-wsp ")"
374;;;
375;;; option = "[" *c-wsp alternation *c-wsp "]"
376;;;
377;;; char-val = DQUOTE *(%x20-21 / %x23-7E) DQUOTE
378;;; ; quoted string of SP and VCHAR without DQUOTE
379;;;
380;;; num-val = "%" (bin-val / dec-val / hex-val)
381;;;
382;;; bin-val = "b" 1*BIT
383;;; [ 1*("." 1*BIT) / ("-" 1*BIT) ]
384;;; ; series of concatenated bit values
385;;; ; or single ONEOF range
386;;;
387;;; dec-val = "d" 1*DIGIT
388;;; [ 1*("." 1*DIGIT) / ("-" 1*DIGIT) ]
389;;;
390;;; hex-val = "x" 1*HEXDIG
391;;; [ 1*("." 1*HEXDIG) / ("-" 1*HEXDIG) ]
392;;;
393;;; prose-val = "<" *(%x20-3D / %x3F-7E) ">"
394;;; ; bracketed string of SP and VCHAR without
395;;; ; angles
396;;; ; prose description, to be used as last resort
397
398
399(defun ebnf-abn-element (token)
400 (cond
401 ;; terminal
402 ((eq token 'terminal)
403 (ebnf-make-terminal ebnf-abn-lex))
404 ;; non-terminal
405 ((eq token 'non-terminal)
406 (ebnf-make-non-terminal ebnf-abn-lex))
407 ;; group
408 ((eq token 'begin-group)
409 (let ((body (ebnf-abn-alternation)))
410 (or (eq (car body) 'end-group)
411 (error "Missing `)'"))
412 (cdr body)))
413 ;; optional
414 ((eq token 'begin-optional)
415 (let ((body (ebnf-abn-alternation)))
416 (or (eq (car body) 'end-optional)
417 (error "Missing `]'"))
418 (ebnf-token-optional (cdr body))))
419 ;; no element
420 (t
421 nil)
422 ))
423
424
425;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
426;; Lexical analyzer
427
428
429(defconst ebnf-abn-token-table (make-vector 256 'error)
430 "Vector used to map characters to a lexical token.")
431
432
433(defun ebnf-abn-initialize ()
434 "Initialize EBNF token table."
435 ;; control character & control 8-bit character are set to `error'
436 (let ((char ?\060))
437 ;; digits: 0-9
438 (while (< char ?\072)
439 (aset ebnf-abn-token-table char 'integer)
440 (setq char (1+ char)))
441 ;; printable character: A-Z
442 (setq char ?\101)
443 (while (< char ?\133)
444 (aset ebnf-abn-token-table char 'non-terminal)
445 (setq char (1+ char)))
446 ;; printable character: a-z
447 (setq char ?\141)
448 (while (< char ?\173)
449 (aset ebnf-abn-token-table char 'non-terminal)
450 (setq char (1+ char)))
451 ;; European 8-bit accentuated characters:
452 (setq char ?\240)
453 (while (< char ?\400)
454 (aset ebnf-abn-token-table char 'non-terminal)
455 (setq char (1+ char)))
456 ;; Override end of line characters:
457 (aset ebnf-abn-token-table ?\n 'end-of-rule) ; [NL] linefeed
458 (aset ebnf-abn-token-table ?\r 'end-of-rule) ; [CR] carriage return
459 ;; Override space characters:
460 (aset ebnf-abn-token-table ?\013 'space) ; [VT] vertical tab
461 (aset ebnf-abn-token-table ?\t 'space) ; [HT] horizontal tab
462 (aset ebnf-abn-token-table ?\ 'space) ; [SP] space
463 ;; Override form feed character:
464 (aset ebnf-abn-token-table ?\f 'form-feed) ; [FF] form feed
465 ;; Override other lexical characters:
466 (aset ebnf-abn-token-table ?< 'non-terminal)
467 (aset ebnf-abn-token-table ?% 'terminal)
468 (aset ebnf-abn-token-table ?\" 'terminal)
469 (aset ebnf-abn-token-table ?\( 'begin-group)
470 (aset ebnf-abn-token-table ?\) 'end-group)
471 (aset ebnf-abn-token-table ?* 'repeat)
472 (aset ebnf-abn-token-table ?= 'equal)
473 (aset ebnf-abn-token-table ?\[ 'begin-optional)
474 (aset ebnf-abn-token-table ?\] 'end-optional)
475 (aset ebnf-abn-token-table ?/ 'alternative)
476 ;; Override comment character:
477 (aset ebnf-abn-token-table ?\; 'comment)))
478
479
480;; replace the range "\240-\377" (see `ebnf-range-regexp').
481(defconst ebnf-abn-non-terminal-chars
482 (ebnf-range-regexp "-_0-9A-Za-z" ?\240 ?\377))
483(defconst ebnf-abn-non-terminal-letter-chars
484 (ebnf-range-regexp "A-Za-z" ?\240 ?\377))
485
486
487(defun ebnf-abn-lex ()
488 "Lexical analyser for ABNF.
489
490Return a lexical token.
491
492See documentation for variable `ebnf-abn-lex'."
493 (if (>= (point) ebnf-limit)
494 'end-of-input
495 (let (token)
496 ;; skip spaces and comments
497 (while (if (> (following-char) 255)
498 (progn
499 (setq token 'error)
500 nil)
501 (setq token (aref ebnf-abn-token-table (following-char)))
502 (cond
503 ((eq token 'space)
504 (skip-chars-forward " \013\t" ebnf-limit)
505 (< (point) ebnf-limit))
506 ((eq token 'comment)
507 (ebnf-abn-skip-comment))
508 ((eq token 'form-feed)
509 (forward-char)
510 (setq ebnf-action 'form-feed))
511 ((eq token 'end-of-rule)
512 (ebnf-abn-skip-end-of-rule))
513 (t nil)
514 )))
515 (cond
516 ;; end of input
517 ((>= (point) ebnf-limit)
518 'end-of-input)
519 ;; error
520 ((eq token 'error)
521 (error "Illegal character"))
522 ;; end of rule
523 ((eq token 'end-of-rule)
524 'end-of-rule)
525 ;; integer
526 ((eq token 'integer)
527 (setq ebnf-abn-lex (ebnf-buffer-substring "0-9"))
528 'integer)
529 ;; terminal: "string" or %[bdx]NNN((.NNN)+|-NNN)?
530 ((eq token 'terminal)
531 (setq ebnf-abn-lex
532 (if (= (following-char) ?\")
533 (ebnf-abn-string)
534 (ebnf-abn-character)))
535 'terminal)
536 ;; non-terminal: NAME or <NAME>
537 ((eq token 'non-terminal)
538 (let ((prose-p (= (following-char) ?<)))
539 (when prose-p
540 (forward-char)
541 (or (looking-at ebnf-abn-non-terminal-letter-chars)
542 (error "Invalid prose value")))
543 (setq ebnf-abn-lex
544 (ebnf-buffer-substring ebnf-abn-non-terminal-chars))
545 (when prose-p
546 (or (= (following-char) ?>)
547 (error "Invalid prose value"))
548 (setq ebnf-abn-lex (concat "<" ebnf-abn-lex ">"))))
549 'non-terminal)
550 ;; equal: =, =/
551 ((eq token 'equal)
552 (forward-char)
553 (if (/= (following-char) ?/)
554 'equal
555 (forward-char)
556 'incremental-alternative))
557 ;; miscellaneous: (, ), [, ], /, *
558 (t
559 (forward-char)
560 token)
561 ))))
562
563
564(defun ebnf-abn-skip-end-of-rule ()
565 (let (eor-p)
566 (while (progn
567 ;; end of rule ==> 2 or more consecutive end of lines
568 (setq eor-p (or (> (skip-chars-forward "\r\n" ebnf-limit) 1)
569 eor-p))
570 ;; skip spaces
571 (skip-chars-forward " \013\t" ebnf-limit)
572 ;; skip comments
573 (and (= (following-char) ?\;)
574 (ebnf-abn-skip-comment))))
575 (not eor-p)))
576
577
578;; replace the range "\177-\237" (see `ebnf-range-regexp').
579(defconst ebnf-abn-comment-chars
580 (ebnf-range-regexp "^\n\000-\010\016-\037" ?\177 ?\237))
581
582
583(defun ebnf-abn-skip-comment ()
584 (forward-char)
585 (cond
586 ;; open EPS file
587 ((and ebnf-eps-executing (= (following-char) ?\[))
588 (ebnf-eps-add-context (ebnf-abn-eps-filename)))
589 ;; close EPS file
590 ((and ebnf-eps-executing (= (following-char) ?\]))
591 (ebnf-eps-remove-context (ebnf-abn-eps-filename)))
592 ;; any other action in comment
593 (t
594 (setq ebnf-action (aref ebnf-comment-table (following-char)))
595 (skip-chars-forward ebnf-abn-comment-chars ebnf-limit))
596 )
597 ;; check for a valid end of comment
598 (cond ((>= (point) ebnf-limit)
599 nil)
600 ((= (following-char) ?\n)
601 t)
602 (t
603 (error "Illegal character"))
604 ))
605
606
607(defun ebnf-abn-eps-filename ()
608 (forward-char)
609 (ebnf-buffer-substring ebnf-abn-comment-chars))
610
611
612;; replace the range "\240-\377" (see `ebnf-range-regexp').
613(defconst ebnf-abn-string-chars
614 (ebnf-range-regexp " -!#-~" ?\240 ?\377))
615
616
617(defun ebnf-abn-string ()
618 (buffer-substring-no-properties
619 (progn
620 (forward-char)
621 (point))
622 (progn
623 (skip-chars-forward ebnf-abn-string-chars ebnf-limit)
624 (or (= (following-char) ?\")
625 (error "Missing `\"'"))
626 (prog1
627 (point)
628 (forward-char)))))
629
630
631(defun ebnf-abn-character ()
632 ;; %[bdx]NNN((-NNN)|(.NNN)+)?
633 (buffer-substring-no-properties
634 (point)
635 (progn
636 (forward-char)
637 (let* ((char (following-char))
638 (chars (cond ((or (= char ?B) (= char ?b)) "01")
639 ((or (= char ?D) (= char ?d)) "0-9")
640 ((or (= char ?X) (= char ?x)) "0-9A-Fa-f")
641 (t (error "Invalid terminal value")))))
642 (forward-char)
643 (or (> (skip-chars-forward chars ebnf-limit) 0)
644 (error "Invalid terminal value"))
645 (if (= (following-char) ?-)
646 (progn
647 (forward-char)
648 (or (> (skip-chars-forward chars ebnf-limit) 0)
649 (error "Invalid terminal value range")))
650 (while (= (following-char) ?.)
651 (forward-char)
652 (or (> (skip-chars-forward chars ebnf-limit) 0)
653 (error "Invalid terminal value")))))
654 (point))))
655
656
657;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
658
659
660(provide 'ebnf-abn)
661
662;;; arch-tag: 8d1b3c4d-4226-4393-b9ae-b7ccf07cf779
663;;; ebnf-abn.el ends here
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
diff --git a/src/ChangeLog b/src/ChangeLog
index 1a2f7f4e20b..ddd92927a17 100644
--- a/src/ChangeLog
+++ b/src/ChangeLog
@@ -1,3 +1,32 @@
12004-02-26 Kim F. Storm <storm@cua.dk>
2
3 * xdisp.c (handle_single_display_prop): Handle left-fringe and
4 right-fringe similar to a display margin image. Specifically,
5 the characters having the fringe prop are no longer shown, and
6 we use IT_IMAGE/next_element_from_image with image_id = -1 to
7 do this. Set fringe bitmap face_id in it->face_id.
8 (produce_image_glyph): Handle image_id < 0 as "no image" case, but
9 still realize it->face (i.e. the fringe bitmap face).
10
112004-02-25 Miles Bader <miles@gnu.org>
12
13 * xdisp.c (check_it): Check string/string_pos consistency.
14 (init_iterator): Initialize string-related fields properly.
15
162004-02-11 Miles Bader <miles@gnu.org>
17
18 * xdisp.c (produce_image_glyph): Force negative descents to zero.
19
202004-02-10 Miles Bader <miles@gnu.org>
21
22 * xfns.c (lookup_image): Remove xassert(!interrupt_input_blocked);
23 BLOCK_INPUT can be nested, so it doesn't make much sense.
24
252004-02-24 Michael Mauger <mmaug@yahoo.com>
26
27 * w32fns.c (slurp_file, xbm_scan, xbm_load_image)
28 (xbm_read_bitmap_data): Use unsigned char for image data.
29
12004-02-23 Luc Teirlinck <teirllm@auburn.edu> 302004-02-23 Luc Teirlinck <teirllm@auburn.edu>
2 31
3 * abbrev.c (Finsert_abbrev_table_description): Doc fix. 32 * abbrev.c (Finsert_abbrev_table_description): Doc fix.
diff --git a/src/w32fns.c b/src/w32fns.c
index 3b53bade2ad..015b406db88 100644
--- a/src/w32fns.c
+++ b/src/w32fns.c
@@ -8243,7 +8243,7 @@ x_put_x_image (f, ximg, pixmap, width, height)
8243 ***********************************************************************/ 8243 ***********************************************************************/
8244 8244
8245static Lisp_Object x_find_image_file P_ ((Lisp_Object)); 8245static Lisp_Object x_find_image_file P_ ((Lisp_Object));
8246static char *slurp_file P_ ((char *, int *)); 8246static unsigned char *slurp_file P_ ((char *, int *));
8247 8247
8248 8248
8249/* Find image file FILE. Look in data-directory, then 8249/* Find image file FILE. Look in data-directory, then
@@ -8279,13 +8279,13 @@ x_find_image_file (file)
8279 with xmalloc holding FILE's contents. Value is null if an error 8279 with xmalloc holding FILE's contents. Value is null if an error
8280 occurred. *SIZE is set to the size of the file. */ 8280 occurred. *SIZE is set to the size of the file. */
8281 8281
8282static char * 8282static unsigned char *
8283slurp_file (file, size) 8283slurp_file (file, size)
8284 char *file; 8284 char *file;
8285 int *size; 8285 int *size;
8286{ 8286{
8287 FILE *fp = NULL; 8287 FILE *fp = NULL;
8288 char *buf = NULL; 8288 unsigned char *buf = NULL;
8289 struct stat st; 8289 struct stat st;
8290 8290
8291 if (stat (file, &st) == 0 8291 if (stat (file, &st) == 0
@@ -8316,13 +8316,13 @@ slurp_file (file, size)
8316 XBM images 8316 XBM images
8317 ***********************************************************************/ 8317 ***********************************************************************/
8318 8318
8319static int xbm_scan P_ ((char **, char *, char *, int *)); 8319static int xbm_scan P_ ((unsigned char **, unsigned char *, char *, int *));
8320static int xbm_load P_ ((struct frame *f, struct image *img)); 8320static int xbm_load P_ ((struct frame *f, struct image *img));
8321static int xbm_load_image P_ ((struct frame *f, struct image *img, 8321static int xbm_load_image P_ ((struct frame *f, struct image *img,
8322 char *, char *)); 8322 unsigned char *, unsigned char *));
8323static int xbm_image_p P_ ((Lisp_Object object)); 8323static int xbm_image_p P_ ((Lisp_Object object));
8324static int xbm_read_bitmap_data P_ ((char *, char *, int *, int *, 8324static int xbm_read_bitmap_data P_ ((unsigned char *, unsigned char *,
8325 unsigned char **)); 8325 int *, int *, unsigned char **));
8326static int xbm_file_p P_ ((Lisp_Object)); 8326static int xbm_file_p P_ ((Lisp_Object));
8327 8327
8328 8328
@@ -8511,11 +8511,11 @@ xbm_image_p (object)
8511 8511
8512static int 8512static int
8513xbm_scan (s, end, sval, ival) 8513xbm_scan (s, end, sval, ival)
8514 char **s, *end; 8514 unsigned char **s, *end;
8515 char *sval; 8515 char *sval;
8516 int *ival; 8516 int *ival;
8517{ 8517{
8518 int c; 8518 unsigned int c;
8519 8519
8520 loop: 8520 loop:
8521 8521
@@ -8645,11 +8645,11 @@ w32_create_pixmap_from_bitmap_data (int width, int height, char *data)
8645 8645
8646static int 8646static int
8647xbm_read_bitmap_data (contents, end, width, height, data) 8647xbm_read_bitmap_data (contents, end, width, height, data)
8648 char *contents, *end; 8648 unsigned char *contents, *end;
8649 int *width, *height; 8649 int *width, *height;
8650 unsigned char **data; 8650 unsigned char **data;
8651{ 8651{
8652 char *s = contents; 8652 unsigned char *s = contents;
8653 char buffer[BUFSIZ]; 8653 char buffer[BUFSIZ];
8654 int padding_p = 0; 8654 int padding_p = 0;
8655 int v10 = 0; 8655 int v10 = 0;
@@ -8827,7 +8827,7 @@ static int
8827xbm_load_image (f, img, contents, end) 8827xbm_load_image (f, img, contents, end)
8828 struct frame *f; 8828 struct frame *f;
8829 struct image *img; 8829 struct image *img;
8830 char *contents, *end; 8830 unsigned char *contents, *end;
8831{ 8831{
8832 int rc; 8832 int rc;
8833 unsigned char *data; 8833 unsigned char *data;
@@ -8915,7 +8915,7 @@ xbm_load (f, img)
8915 if (STRINGP (file_name)) 8915 if (STRINGP (file_name))
8916 { 8916 {
8917 Lisp_Object file; 8917 Lisp_Object file;
8918 char *contents; 8918 unsigned char *contents;
8919 int size; 8919 int size;
8920 struct gcpro gcpro1; 8920 struct gcpro gcpro1;
8921 8921
diff --git a/src/xdisp.c b/src/xdisp.c
index 246b30549f6..67f21446320 100644
--- a/src/xdisp.c
+++ b/src/xdisp.c
@@ -1900,10 +1900,14 @@ check_it (it)
1900 xassert (STRINGP (it->string)); 1900 xassert (STRINGP (it->string));
1901 xassert (IT_STRING_CHARPOS (*it) >= 0); 1901 xassert (IT_STRING_CHARPOS (*it) >= 0);
1902 } 1902 }
1903 else if (it->method == next_element_from_buffer) 1903 else
1904 { 1904 {
1905 /* Check that character and byte positions agree. */ 1905 xassert (IT_STRING_CHARPOS (*it) < 0);
1906 xassert (IT_CHARPOS (*it) == BYTE_TO_CHAR (IT_BYTEPOS (*it))); 1906 if (it->method == next_element_from_buffer)
1907 {
1908 /* Check that character and byte positions agree. */
1909 xassert (IT_CHARPOS (*it) == BYTE_TO_CHAR (IT_BYTEPOS (*it)));
1910 }
1907 } 1911 }
1908 1912
1909 if (it->dpvec) 1913 if (it->dpvec)
@@ -2016,6 +2020,8 @@ init_iterator (it, w, charpos, bytepos, row, base_face_id)
2016 it->current.overlay_string_index = -1; 2020 it->current.overlay_string_index = -1;
2017 it->current.dpvec_index = -1; 2021 it->current.dpvec_index = -1;
2018 it->base_face_id = base_face_id; 2022 it->base_face_id = base_face_id;
2023 it->string = Qnil;
2024 IT_STRING_CHARPOS (*it) = IT_STRING_BYTEPOS (*it) = -1;
2019 2025
2020 /* The window in which we iterate over current_buffer: */ 2026 /* The window in which we iterate over current_buffer: */
2021 XSETWINDOW (it->window, w); 2027 XSETWINDOW (it->window, w);
@@ -3482,43 +3488,6 @@ handle_single_display_prop (it, prop, object, position,
3482 } 3488 }
3483#endif /* HAVE_WINDOW_SYSTEM */ 3489#endif /* HAVE_WINDOW_SYSTEM */
3484 } 3490 }
3485 else if (CONSP (prop)
3486 && (EQ (XCAR (prop), Qleft_fringe)
3487 || EQ (XCAR (prop), Qright_fringe))
3488 && CONSP (XCDR (prop)))
3489 {
3490 unsigned face_id = DEFAULT_FACE_ID;
3491
3492 /* `(left-fringe BITMAP FACE)'. */
3493 if (FRAME_TERMCAP_P (it->f) || FRAME_MSDOS_P (it->f))
3494 return 0;
3495
3496#ifdef HAVE_WINDOW_SYSTEM
3497 value = XCAR (XCDR (prop));
3498 if (!NUMBERP (value)
3499 || !valid_fringe_bitmap_id_p (XINT (value)))
3500 return 0;
3501
3502 if (CONSP (XCDR (XCDR (prop))))
3503 {
3504 Lisp_Object face_name = XCAR (XCDR (XCDR (prop)));
3505 face_id = lookup_named_face (it->f, face_name, 'A');
3506 if (face_id < 0)
3507 return 0;
3508 }
3509
3510 if (EQ (XCAR (prop), Qleft_fringe))
3511 {
3512 it->left_user_fringe_bitmap = XINT (value);
3513 it->left_user_fringe_face_id = face_id;
3514 }
3515 else
3516 {
3517 it->right_user_fringe_bitmap = XINT (value);
3518 it->right_user_fringe_face_id = face_id;
3519 }
3520#endif /* HAVE_WINDOW_SYSTEM */
3521 }
3522 else if (!it->string_from_display_prop_p) 3491 else if (!it->string_from_display_prop_p)
3523 { 3492 {
3524 /* `((margin left-margin) VALUE)' or `((margin right-margin) 3493 /* `((margin left-margin) VALUE)' or `((margin right-margin)
@@ -3537,6 +3506,64 @@ handle_single_display_prop (it, prop, object, position,
3537 text properties change there. */ 3506 text properties change there. */
3538 it->stop_charpos = position->charpos; 3507 it->stop_charpos = position->charpos;
3539 3508
3509 if (CONSP (prop)
3510 && (EQ (XCAR (prop), Qleft_fringe)
3511 || EQ (XCAR (prop), Qright_fringe))
3512 && CONSP (XCDR (prop)))
3513 {
3514 unsigned face_id = DEFAULT_FACE_ID;
3515
3516 /* Save current settings of IT so that we can restore them
3517 when we are finished with the glyph property value. */
3518
3519 /* `(left-fringe BITMAP FACE)'. */
3520 if (FRAME_TERMCAP_P (it->f) || FRAME_MSDOS_P (it->f))
3521 return 0;
3522
3523#ifdef HAVE_WINDOW_SYSTEM
3524 value = XCAR (XCDR (prop));
3525 if (!NUMBERP (value)
3526 || !valid_fringe_bitmap_id_p (XINT (value)))
3527 return 0;
3528
3529 if (CONSP (XCDR (XCDR (prop))))
3530 {
3531 Lisp_Object face_name = XCAR (XCDR (XCDR (prop)));
3532
3533 face_id = lookup_named_face (it->f, face_name, 'A');
3534 if (face_id < 0)
3535 return 0;
3536 }
3537
3538 push_it (it);
3539
3540 it->area = TEXT_AREA;
3541 it->what = IT_IMAGE;
3542 it->image_id = -1; /* no image */
3543 it->position = start_pos;
3544 it->object = NILP (object) ? it->w->buffer : object;
3545 it->method = next_element_from_image;
3546 it->face_id = face_id;
3547
3548 /* Say that we haven't consumed the characters with
3549 `display' property yet. The call to pop_it in
3550 set_iterator_to_next will clean this up. */
3551 *position = start_pos;
3552
3553 if (EQ (XCAR (prop), Qleft_fringe))
3554 {
3555 it->left_user_fringe_bitmap = XINT (value);
3556 it->left_user_fringe_face_id = face_id;
3557 }
3558 else
3559 {
3560 it->right_user_fringe_bitmap = XINT (value);
3561 it->right_user_fringe_face_id = face_id;
3562 }
3563#endif /* HAVE_WINDOW_SYSTEM */
3564 return 1;
3565 }
3566
3540 location = Qunbound; 3567 location = Qunbound;
3541 if (CONSP (prop) && CONSP (XCAR (prop))) 3568 if (CONSP (prop) && CONSP (XCAR (prop)))
3542 { 3569 {
@@ -17673,17 +17700,31 @@ produce_image_glyph (it)
17673 xassert (it->what == IT_IMAGE); 17700 xassert (it->what == IT_IMAGE);
17674 17701
17675 face = FACE_FROM_ID (it->f, it->face_id); 17702 face = FACE_FROM_ID (it->f, it->face_id);
17703 xassert (face);
17704 /* Make sure X resources of the face is loaded. */
17705 PREPARE_FACE_FOR_DISPLAY (it->f, face);
17706
17707 if (it->image_id < 0)
17708 {
17709 /* Fringe bitmap. */
17710 it->nglyphs = 0;
17711 return;
17712 }
17713
17676 img = IMAGE_FROM_ID (it->f, it->image_id); 17714 img = IMAGE_FROM_ID (it->f, it->image_id);
17677 xassert (img); 17715 xassert (img);
17678 17716 /* Make sure X resources of the image is loaded. */
17679 /* Make sure X resources of the face and image are loaded. */
17680 PREPARE_FACE_FOR_DISPLAY (it->f, face);
17681 prepare_image_for_display (it->f, img); 17717 prepare_image_for_display (it->f, img);
17682 17718
17683 it->ascent = it->phys_ascent = glyph_ascent = image_ascent (img, face); 17719 it->ascent = it->phys_ascent = glyph_ascent = image_ascent (img, face);
17684 it->descent = it->phys_descent = img->height + 2 * img->vmargin - it->ascent; 17720 it->descent = it->phys_descent = img->height + 2 * img->vmargin - it->ascent;
17685 it->pixel_width = img->width + 2 * img->hmargin; 17721 it->pixel_width = img->width + 2 * img->hmargin;
17686 17722
17723 /* It's quite possible for images to have an ascent greater than
17724 their height, so don't get confused in that case. */
17725 if (it->descent < 0)
17726 it->descent = 0;
17727
17687 /* If this glyph is alone on the last line, adjust it.ascent to minimum row ascent. */ 17728 /* If this glyph is alone on the last line, adjust it.ascent to minimum row ascent. */
17688 face_ascent = face->font ? FONT_BASE (face->font) : FRAME_BASELINE_OFFSET (it->f); 17729 face_ascent = face->font ? FONT_BASE (face->font) : FRAME_BASELINE_OFFSET (it->f);
17689 if (face_ascent > it->ascent) 17730 if (face_ascent > it->ascent)
diff --git a/src/xfns.c b/src/xfns.c
index a649ddd1068..5b3f8ffe552 100644
--- a/src/xfns.c
+++ b/src/xfns.c
@@ -1,5 +1,5 @@
1/* Functions for the X window system. 1/* Functions for the X window system.
2 Copyright (C) 1989, 92, 93, 94, 95, 96, 97, 98, 99, 2000, 01, 02, 03 2 Copyright (C) 1989, 92, 93, 94, 95, 96, 97, 98, 99, 2000,01,02,03,04
3 Free Software Foundation. 3 Free Software Foundation.
4 4
5This file is part of GNU Emacs. 5This file is part of GNU Emacs.
@@ -5323,7 +5323,6 @@ lookup_image (f, spec)
5323 } 5323 }
5324 5324
5325 UNBLOCK_INPUT; 5325 UNBLOCK_INPUT;
5326 xassert (!interrupt_input_blocked);
5327 } 5326 }
5328 5327
5329 /* We're using IMG, so set its timestamp to `now'. */ 5328 /* We're using IMG, so set its timestamp to `now'. */