27451
|
1 ;;; ebnf2ps --- Translate an EBNF to a syntatic chart on PostScript
|
|
2
|
|
3 ;; Copyright (C) 1999 Vinicius Jose Latorre
|
|
4
|
|
5 ;; Author: Vinicius Jose Latorre <vinicius@cpqd.com.br>
|
|
6 ;; Maintainer: Vinicius Jose Latorre <vinicius@cpqd.com.br>
|
|
7 ;; Keywords: wp, ebnf, PostScript
|
|
8 ;; Time-stamp: <99/12/11 21:41:24 vinicius>
|
|
9 ;; Version: 3.1
|
|
10
|
|
11 (defconst ebnf-version "3.1"
|
|
12 "ebnf2ps.el, v 3.1 <99/12/11 vinicius>
|
|
13
|
|
14 Vinicius's last change version. When reporting bugs, please also
|
|
15 report the version of Emacs, if any, that ebnf2ps was running with.
|
|
16
|
|
17 Please send all bug fixes and enhancements to
|
|
18 Vinicius Jose Latorre <vinicius@cpqd.com.br>.
|
|
19 ")
|
|
20
|
|
21 ;; This file is *NOT* (yet?) part of GNU Emacs.
|
|
22
|
|
23 ;; This program is free software; you can redistribute it and/or modify
|
|
24 ;; it under the terms of the GNU General Public License as published by
|
|
25 ;; the Free Software Foundation; either version 2, or (at your option)
|
|
26 ;; any later version.
|
|
27
|
|
28 ;; This program is distributed in the hope that it will be useful,
|
|
29 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
30 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
31 ;; GNU General Public License for more details.
|
|
32
|
|
33 ;; You should have received a copy of the GNU General Public License
|
|
34 ;; along with GNU Emacs; see the file COPYING. If not, write to the
|
|
35 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
36 ;; Boston, MA 02111-1307, USA.
|
|
37
|
|
38 ;;; Commentary:
|
|
39
|
|
40 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
41 ;;
|
|
42 ;; Introduction
|
|
43 ;; ------------
|
|
44 ;;
|
|
45 ;; This package translates an EBNF to a syntatic chart on PostScript.
|
|
46 ;;
|
|
47 ;; To use ebnf2ps, insert in your ~/.emacs:
|
|
48 ;;
|
|
49 ;; (require 'ebnf2ps)
|
|
50 ;;
|
|
51 ;; ebnf2ps uses ps-print package (version 3.05.1 or later), so see ps-print to
|
|
52 ;; know how to set options like landscape printing, page headings, margins, etc.
|
|
53 ;;
|
|
54 ;; NOTE: ps-print zebra stripes and line number options doesn't have effect on
|
|
55 ;; ebnf2ps, they behave as it's turned off.
|
|
56 ;;
|
|
57 ;; For good performance, be sure to byte-compile ebnf2ps.el, e.g.
|
|
58 ;;
|
|
59 ;; M-x byte-compile-file <give the path to ebnf2ps.el when prompted>
|
|
60 ;;
|
|
61 ;; This will generate ebnf2ps.elc, which will be loaded instead of ebnf2ps.el.
|
|
62 ;;
|
|
63 ;; ebnf2ps was tested with GNU Emacs 20.4.1.
|
|
64 ;;
|
|
65 ;;
|
|
66 ;; Using ebnf2ps
|
|
67 ;; -------------
|
|
68 ;;
|
|
69 ;; ebnf2ps provides six commands for generating PostScript syntatic chart images
|
|
70 ;; of Emacs buffers:
|
|
71 ;;
|
|
72 ;; ebnf-print-buffer
|
|
73 ;; ebnf-print-region
|
|
74 ;; ebnf-spool-buffer
|
|
75 ;; ebnf-spool-region
|
|
76 ;; ebnf-eps-buffer
|
|
77 ;; ebnf-eps-region
|
|
78 ;;
|
|
79 ;; These commands all perform essentially the same function: they generate
|
|
80 ;; PostScript syntatic chart images suitable for printing on a PostScript
|
|
81 ;; printer or displaying with GhostScript. These commands are collectively
|
|
82 ;; referred to as "ebnf- commands".
|
|
83 ;;
|
|
84 ;; The word "print", "spool" and "eps" in the command name determines when the
|
|
85 ;; PostScript image is sent to the printer (or file):
|
|
86 ;;
|
|
87 ;; print - The PostScript image is immediately sent to the printer;
|
|
88 ;;
|
|
89 ;; spool - The PostScript image is saved temporarily in an Emacs buffer.
|
|
90 ;; Many images may be spooled locally before printing them. To
|
|
91 ;; send the spooled images to the printer, use the command
|
|
92 ;; `ebnf-despool'.
|
|
93 ;;
|
|
94 ;; eps - The PostScript image is immediately sent to a EPS file.
|
|
95 ;;
|
|
96 ;; The spooling mechanism is the same as used by ps-print and was designed for
|
|
97 ;; printing lots of small files to save paper that would otherwise be wasted on
|
|
98 ;; banner pages, and to make it easier to find your output at the printer (it's
|
|
99 ;; easier to pick up one 50-page printout than to find 50 single-page
|
|
100 ;; printouts). As ebnf2ps and ps-print use the same Emacs buffer to spool
|
|
101 ;; images, you can intermix the spooling of ebnf2ps and ps-print images.
|
|
102 ;;
|
|
103 ;; ebnf2ps use the same hook of ps-print in the `kill-emacs-hook' so that you
|
|
104 ;; won't accidentally quit from Emacs while you have unprinted PostScript
|
|
105 ;; waiting in the spool buffer. If you do attempt to exit with spooled
|
|
106 ;; PostScript, you'll be asked if you want to print it, and if you decline,
|
|
107 ;; you'll be asked to confirm the exit; this is modeled on the confirmation that
|
|
108 ;; Emacs uses for modified buffers.
|
|
109 ;;
|
|
110 ;; The word "buffer" or "region" in the command name determines how much of the
|
|
111 ;; buffer is printed:
|
|
112 ;;
|
|
113 ;; buffer - Print the entire buffer.
|
|
114 ;;
|
|
115 ;; region - Print just the current region.
|
|
116 ;;
|
|
117 ;; Two ebnf- command examples:
|
|
118 ;;
|
|
119 ;; ebnf-print-buffer - translate and print the entire buffer, and send
|
|
120 ;; it immediately to the printer.
|
|
121 ;;
|
|
122 ;; ebnf-spool-region - translate and print just the current region, and
|
|
123 ;; spool the image in Emacs to send to the printer
|
|
124 ;; later.
|
|
125 ;;
|
|
126 ;; Note that `ebnf-eps-buffer' and `ebnf-eps-region' never spool the EPS image,
|
|
127 ;; so they don't use the ps-print spooling mechanism. See section "Actions in
|
|
128 ;; Comments" for an explanation about EPS file generation.
|
|
129 ;;
|
|
130 ;;
|
|
131 ;; Invoking Ebnf2ps
|
|
132 ;; ----------------
|
|
133 ;;
|
|
134 ;; To translate and print your buffer, type
|
|
135 ;;
|
|
136 ;; M-x ebnf-print-buffer
|
|
137 ;;
|
|
138 ;; or substitute one of the other four ebnf- commands. The command will
|
|
139 ;; generate the PostScript image and print or spool it as specified. By giving
|
|
140 ;; the command a prefix argument
|
|
141 ;;
|
|
142 ;; C-u M-x ebnf-print-buffer
|
|
143 ;;
|
|
144 ;; it will save the PostScript image to a file instead of sending it to the
|
|
145 ;; printer; you will be prompted for the name of the file to save the image to.
|
|
146 ;; The prefix argument is ignored by the commands that spool their images, but
|
|
147 ;; you may save the spooled images to a file by giving a prefix argument to
|
|
148 ;; `ebnf-despool':
|
|
149 ;;
|
|
150 ;; C-u M-x ebnf-despool
|
|
151 ;;
|
|
152 ;; When invoked this way, `ebnf-despool' will prompt you for the name of the
|
|
153 ;; file to save to.
|
|
154 ;;
|
|
155 ;; The prefix argument is also ignored by `ebnf-eps-buffer' and
|
|
156 ;; `ebnf-eps-region'.
|
|
157 ;;
|
|
158 ;; Any of the `ebnf-' commands can be bound to keys. Here are some examples:
|
|
159 ;;
|
|
160 ;; (global-set-key 'f22 'ebnf-print-buffer) ;f22 is prsc
|
|
161 ;; (global-set-key '(shift f22) 'ebnf-print-region)
|
|
162 ;; (global-set-key '(control f22) 'ebnf-despool)
|
|
163 ;;
|
|
164 ;;
|
|
165 ;; EBNF Syntax
|
|
166 ;; -----------
|
|
167 ;;
|
|
168 ;; The current EBNF that ebnf2ps accepts has the following constructions:
|
|
169 ;;
|
|
170 ;; ; comment (until end of line)
|
|
171 ;; A non-terminal
|
|
172 ;; "C" terminal
|
|
173 ;; ?C? special
|
|
174 ;; $A default non-terminal (see text below)
|
|
175 ;; $"C" default terminal (see text below)
|
|
176 ;; $?C? default special (see text below)
|
|
177 ;; A = B. production (A is the header and B the body)
|
|
178 ;; C D sequence (C occurs before D)
|
|
179 ;; C | D alternative (C or D occurs)
|
|
180 ;; A - B exception (A excluding B, B without any non-terminal)
|
|
181 ;; n * A repetition (A repeats n (integer) times)
|
|
182 ;; (C) group (expression C is grouped together)
|
|
183 ;; [C] optional (C may or not occurs)
|
|
184 ;; C+ one or more occurrences of C
|
|
185 ;; {C}+ one or more occurrences of C
|
|
186 ;; {C}* zero or more occurrences of C
|
|
187 ;; {C} zero or more occurrences of C
|
|
188 ;; C / D equivalent to: C {D C}*
|
|
189 ;; {C || D}+ equivalent to: C {D C}*
|
|
190 ;; {C || D}* equivalent to: [C {D C}*]
|
|
191 ;; {C || D} equivalent to: [C {D C}*]
|
|
192 ;;
|
|
193 ;; The EBNF syntax written using the notation above is:
|
|
194 ;;
|
|
195 ;; EBNF = {production}+.
|
|
196 ;;
|
|
197 ;; production = non_terminal "=" body ".". ;; production
|
|
198 ;;
|
|
199 ;; body = {sequence || "|"}*. ;; alternative
|
|
200 ;;
|
|
201 ;; sequence = {exception}*. ;; sequence
|
|
202 ;;
|
|
203 ;; exception = repeat [ "-" repeat]. ;; exception
|
|
204 ;;
|
|
205 ;; repeat = [ integer "*" ] term. ;; repetition
|
|
206 ;;
|
|
207 ;; term = factor
|
|
208 ;; | [factor] "+" ;; one-or-more
|
|
209 ;; | [factor] "/" [factor] ;; one-or-more
|
|
210 ;; .
|
|
211 ;;
|
|
212 ;; factor = [ "$" ] "\"" terminal "\"" ;; terminal
|
|
213 ;; | [ "$" ] non_terminal ;; non-terminal
|
|
214 ;; | [ "$" ] "?" special "?" ;; special
|
|
215 ;; | "(" body ")" ;; group
|
|
216 ;; | "[" body "]" ;; zero-or-one
|
|
217 ;; | "{" body [ "||" body ] "}+" ;; one-or-more
|
|
218 ;; | "{" body [ "||" body ] "}*" ;; zero-or-more
|
|
219 ;; | "{" body [ "||" body ] "}" ;; zero-or-more
|
|
220 ;; .
|
|
221 ;;
|
|
222 ;; non_terminal = "[A-Za-z\\240-\\377][!#%&'*-,0-:<>@-Z\\^-z~\\240-\\377]*".
|
|
223 ;;
|
|
224 ;; terminal = "\\([^\"\\]\\|\\\\[ -~\\240-\\377]\\)+".
|
|
225 ;;
|
|
226 ;; special = "[^?\\n\\000-\\010\\016-\\037\\177-\\237]*".
|
|
227 ;;
|
|
228 ;; integer = "[0-9]+".
|
|
229 ;;
|
|
230 ;; comment = ";" "[^\\n\\000-\\010\\016-\\037\\177-\\237]*" "\\n".
|
|
231 ;;
|
|
232 ;; Try to use the above EBNF to test ebnf2ps.
|
|
233 ;;
|
|
234 ;; The `default' terminal, non-terminal and special is a way to indicate a
|
|
235 ;; default path in a production. For example, the production:
|
|
236 ;;
|
|
237 ;; X = [ $A ( B | $C ) | D ].
|
|
238 ;;
|
|
239 ;; Indicates that the default meaning for "X" is "A C" if "X" is empty.
|
|
240 ;;
|
|
241 ;; The terminal name is controlled by `ebnf-terminal-regexp' and
|
|
242 ;; `ebnf-case-fold-search', so it's possible to match other kind of terminal
|
|
243 ;; name besides that enclosed by `"'.
|
|
244 ;;
|
|
245 ;; Let's see an example:
|
|
246 ;;
|
|
247 ;; (setq ebnf-terminal-regexp "[A-Z][_A-Z]*") ; upper case name
|
|
248 ;; (setq ebnf-case-fold-search nil) ; exact matching
|
|
249 ;;
|
|
250 ;; If you have the production:
|
|
251 ;;
|
|
252 ;; Logical = "(" Expression ( OR | AND | "XOR" ) Expression ")".
|
|
253 ;;
|
|
254 ;; The names are classified as:
|
|
255 ;;
|
|
256 ;; Logical Expression non-terminal
|
|
257 ;; "(" OR AND "XOR" ")" terminal
|
|
258 ;;
|
|
259 ;; The line comment is controlled by `ebnf-lex-comment-char'. The default value
|
|
260 ;; is ?\; (character `;').
|
|
261 ;;
|
|
262 ;; The end of production is controlled by `ebnf-lex-eop-char'. The default
|
|
263 ;; value is ?. (character `.').
|
|
264 ;;
|
|
265 ;; The variable `ebnf-syntax' specifies which syntax to recognize:
|
|
266 ;;
|
|
267 ;; `ebnf' ebnf2ps recognizes the syntax described above.
|
|
268 ;; The following variables *ONLY* have effect with this
|
|
269 ;; setting:
|
|
270 ;; `ebnf-terminal-regexp', `ebnf-case-fold-search',
|
|
271 ;; `ebnf-lex-comment-char' and `ebnf-lex-eop-char'.
|
|
272 ;;
|
|
273 ;; `iso-ebnf' ebnf2ps recognizes the syntax described in the URL:
|
|
274 ;; `http://www.cl.cam.ac.uk/~mgk25/iso-ebnf.html'
|
|
275 ;; ("International Standard of the ISO EBNF Notation").
|
|
276 ;; The following variables *ONLY* have effect with this
|
|
277 ;; setting:
|
|
278 ;; `ebnf-iso-alternative-p' and `ebnf-iso-normalize-p'.
|
|
279 ;;
|
|
280 ;; `yacc' ebnf2ps recognizes the Yacc/Bison syntax.
|
|
281 ;; The following variable *ONLY* has effect with this
|
|
282 ;; setting:
|
|
283 ;; `ebnf-yac-ignore-error-recovery'.
|
|
284 ;;
|
|
285 ;; Any other value is treated as `ebnf'.
|
|
286 ;;
|
|
287 ;; The default value is `ebnf'.
|
|
288 ;;
|
|
289 ;;
|
|
290 ;; Optimizations
|
|
291 ;; -------------
|
|
292 ;;
|
|
293 ;; The following EBNF optimizations are done:
|
|
294 ;;
|
|
295 ;; [ { A }* ] ==> { A }*
|
|
296 ;; [ { A }+ ] ==> { A }*
|
|
297 ;; [ A ] + ==> { A }*
|
|
298 ;; { A }* + ==> { A }*
|
|
299 ;; { A }+ + ==> { A }+
|
|
300 ;; { A }- ==> { A }+
|
|
301 ;; [ A ]- ==> A
|
|
302 ;; ( A | EMPTY )- ==> A
|
|
303 ;; ( A | B | EMPTY )- ==> A | B
|
|
304 ;; [ A | B ] ==> A | B | EMPTY
|
|
305 ;; n * EMPTY ==> EMPTY
|
|
306 ;; EMPTY + ==> EMPTY
|
|
307 ;; EMPTY / EMPTY ==> EMPTY
|
|
308 ;; EMPTY - A ==> EMPTY
|
|
309 ;;
|
|
310 ;; The following optimizations are done when `ebnf-optimize' is non-nil:
|
|
311 ;;
|
|
312 ;; left recursion:
|
|
313 ;; 1. A = B | A C. ==> A = B {C}*.
|
|
314 ;; 2. A = B | A B. ==> A = {B}+.
|
|
315 ;; 3. A = | A B. ==> A = {B}*.
|
|
316 ;; 4. A = B | A C B. ==> A = {B || C}+.
|
|
317 ;; 5. A = B | D | A C | A E. ==> A = ( B | D ) { C | E }*.
|
|
318 ;;
|
|
319 ;; optional:
|
|
320 ;; 6. A = B | . ==> A = [B].
|
|
321 ;; 7. A = | B . ==> A = [B].
|
|
322 ;;
|
|
323 ;; factoration:
|
|
324 ;; 8. A = B C | B D. ==> A = B (C | D).
|
|
325 ;; 9. A = C B | D B. ==> A = (C | D) B.
|
|
326 ;; 10. A = B C E | B D E. ==> A = B (C | D) E.
|
|
327 ;;
|
|
328 ;; The above optimizations are specially useful when `ebnf-syntax' is `yacc'.
|
|
329 ;;
|
|
330 ;;
|
|
331 ;; Form Feed
|
|
332 ;; ---------
|
|
333 ;;
|
|
334 ;; You may use form feed (^L \014) to force a production to start on a new page,
|
|
335 ;; for example:
|
|
336 ;;
|
|
337 ;; a) A = B | C.
|
|
338 ;; ^L
|
|
339 ;; X = Y | Z.
|
|
340 ;;
|
|
341 ;; b) A = B ^L | C.
|
|
342 ;; X = Y | Z.
|
|
343 ;;
|
|
344 ;; c) A = B ^L^L^L | C.^L
|
|
345 ;; ^L
|
|
346 ;; X = Y | Z.
|
|
347 ;;
|
|
348 ;; In all examples above, only the production X will start on a new page.
|
|
349 ;;
|
|
350 ;;
|
|
351 ;; Actions in Comments
|
|
352 ;; -------------------
|
|
353 ;;
|
|
354 ;; ebnf2ps accepts the following actions in comments:
|
|
355 ;;
|
|
356 ;; ;> the next production starts in the same line as the current one.
|
|
357 ;; It is useful when `ebnf-horizontal-orientation' is nil.
|
|
358 ;;
|
|
359 ;; ;< the next production starts in the next line.
|
|
360 ;; It is useful when `ebnf-horizontal-orientation' is non-nil.
|
|
361 ;;
|
|
362 ;; ;[EPS open a new EPS file. The EPS file name has the form:
|
|
363 ;; <PREFIX><NAME>.eps
|
|
364 ;; where <PREFIX> is given by variable `ebnf-eps-prefix' and <NAME>
|
|
365 ;; is the string given by ;[ action comment, this string is mapped
|
|
366 ;; to form a valid file name (see documentation for
|
|
367 ;; `ebnf-eps-buffer' or `ebnf-eps-region').
|
|
368 ;; It has effect only during `ebnf-eps-buffer' or
|
|
369 ;; `ebnf-eps-region' execution.
|
|
370 ;; It's an error to try to open an already opened EPS file.
|
|
371 ;;
|
|
372 ;; ;]EPS close an opened EPS file.
|
|
373 ;; It has effect only during `ebnf-eps-buffer' or
|
|
374 ;; `ebnf-eps-region' execution.
|
|
375 ;; It's an error to try to close a not opened EPS file.
|
|
376 ;;
|
|
377 ;; So if you have:
|
|
378 ;;
|
|
379 ;; (setq ebnf-horizontal-orientation nil)
|
|
380 ;;
|
|
381 ;; A = t.
|
|
382 ;; C = x.
|
|
383 ;; ;> C and B are drawn in the same line
|
|
384 ;; B = y.
|
|
385 ;; W = v.
|
|
386 ;;
|
|
387 ;; The graphical result is:
|
|
388 ;;
|
|
389 ;; +---+
|
|
390 ;; | A |
|
|
391 ;; +---+
|
|
392 ;;
|
|
393 ;; +---------+ +-----+
|
|
394 ;; | | | |
|
|
395 ;; | C | | |
|
|
396 ;; | | | B |
|
|
397 ;; +---------+ | |
|
|
398 ;; | |
|
|
399 ;; +-----+
|
|
400 ;;
|
|
401 ;; +-----------+
|
|
402 ;; | W |
|
|
403 ;; +-----------+
|
|
404 ;;
|
|
405 ;; Note that if ascending production sort is used, the productions A and B will
|
|
406 ;; be drawn in the same line instead of C and B.
|
|
407 ;;
|
|
408 ;; If consecutive actions occur, only the last one takes effect, so if you have:
|
|
409 ;;
|
|
410 ;; A = X.
|
|
411 ;; ;<
|
|
412 ;; ^L
|
|
413 ;; ;>
|
|
414 ;; B = Y.
|
|
415 ;;
|
|
416 ;; Only the ;> will take effect, that is, A and B will be drawn in the same
|
|
417 ;; line.
|
|
418 ;;
|
|
419 ;; In ISO EBNF the above actions are specified as (*>*), (*<*), (*[EPS*) and
|
|
420 ;; (*]EPS*). The first example above should be written:
|
|
421 ;;
|
|
422 ;; A = t;
|
|
423 ;; C = x;
|
|
424 ;; (*> C and B are drawn in the same line *)
|
|
425 ;; B = y;
|
|
426 ;; W = v;
|
|
427 ;;
|
|
428 ;; For an example of EPS action when executing `ebnf-eps-buffer' or
|
|
429 ;; `ebnf-eps-region':
|
|
430 ;;
|
|
431 ;; Z = B0.
|
|
432 ;; ;[CC
|
|
433 ;; ;[AA
|
|
434 ;; A = B1.
|
|
435 ;; ;[BB
|
|
436 ;; C = B2.
|
|
437 ;; ;]AA
|
|
438 ;; B = B3.
|
|
439 ;; ;]BB
|
|
440 ;; ;]CC
|
|
441 ;; D = B4.
|
|
442 ;; E = B5.
|
|
443 ;; ;[CC
|
|
444 ;; F = B6.
|
|
445 ;; ;]CC
|
|
446 ;; G = B7.
|
|
447 ;;
|
|
448 ;; The following table summarizes the results:
|
|
449 ;;
|
|
450 ;; EPS FILE NAME NO SORT ASCENDING SORT DESCENDING SORT
|
|
451 ;; ebnf--AA.eps A C A C C A
|
|
452 ;; ebnf--BB.eps C B B C C B
|
|
453 ;; ebnf--CC.eps A C B F A B C F F C B A
|
|
454 ;; ebnf--D.eps D D D
|
|
455 ;; ebnf--E.eps E E E
|
|
456 ;; ebnf--G.eps G G G
|
|
457 ;; ebnf--Z.eps Z Z Z
|
|
458 ;;
|
|
459 ;; As you can see if EPS actions is not used, each single production is
|
|
460 ;; generated per EPS file. To avoid overriding EPS files, use names in ;[ that
|
|
461 ;; it's not an existing production name.
|
|
462 ;;
|
|
463 ;; In the following case:
|
|
464 ;;
|
|
465 ;; A = B0.
|
|
466 ;; ;[AA
|
|
467 ;; A = B1.
|
|
468 ;; ;[BB
|
|
469 ;; A = B2.
|
|
470 ;;
|
|
471 ;; The production A is generated in both files ebnf--AA.eps and ebnf--BB.eps.
|
|
472 ;;
|
|
473 ;;
|
|
474 ;; Utilities
|
|
475 ;; ---------
|
|
476 ;;
|
|
477 ;; Some tools are provided to help you.
|
|
478 ;;
|
|
479 ;; `ebnf-setup' returns the current setup.
|
|
480 ;;
|
|
481 ;; `ebnf-syntax-buffer' does a syntatic analysis of your EBNF in the current
|
|
482 ;; buffer.
|
|
483 ;;
|
|
484 ;; `ebnf-syntax-region' does a syntatic analysis of your EBNF in the current
|
|
485 ;; region.
|
|
486 ;;
|
|
487 ;; `ebnf-customize' activates a customization buffer for ebnf2ps options.
|
|
488 ;;
|
|
489 ;; `ebnf-syntax-buffer', `ebnf-syntax-region' and `ebnf-customize' can be bound
|
|
490 ;; to keys in the same way as `ebnf-' commands.
|
|
491 ;;
|
|
492 ;;
|
|
493 ;; Hooks
|
|
494 ;; -----
|
|
495 ;;
|
|
496 ;; ebn2ps has the following hook variables:
|
|
497 ;;
|
|
498 ;; `ebnf-hook'
|
|
499 ;; It is evaluated once before any ebnf2ps process.
|
|
500 ;;
|
|
501 ;; `ebnf-production-hook'
|
|
502 ;; It is evaluated on each beginning of production.
|
|
503 ;;
|
|
504 ;; `ebnf-page-hook'
|
|
505 ;; It is evaluated on each beginning of page.
|
|
506 ;;
|
|
507 ;;
|
|
508 ;; Options
|
|
509 ;; -------
|
|
510 ;;
|
|
511 ;; Below it's shown a brief description of ebnf2ps options, please, see the
|
|
512 ;; options declaration in the code for a long documentation.
|
|
513 ;;
|
|
514 ;; `ebnf-horizontal-orientation' Non-nil means productions are drawn
|
|
515 ;; horizontally.
|
|
516 ;;
|
|
517 ;; `ebnf-horizontal-max-height' Non-nil means to use maximum production
|
|
518 ;; height in horizontal orientation.
|
|
519 ;;
|
|
520 ;; `ebnf-production-horizontal-space' Specify horizontal space in points
|
|
521 ;; between productions.
|
|
522 ;;
|
|
523 ;; `ebnf-production-vertical-space' Specify vertical space in points between
|
|
524 ;; productions.
|
|
525 ;;
|
|
526 ;; `ebnf-justify-sequence' Specify justification of terms in a
|
|
527 ;; sequence inside alternatives.
|
|
528 ;;
|
|
529 ;; `ebnf-terminal-regexp' Specify how it's a terminal name.
|
|
530 ;;
|
|
531 ;; `ebnf-case-fold-search' Non-nil means ignore case on matching.
|
|
532 ;;
|
|
533 ;; `ebnf-terminal-font' Specify terminal font.
|
|
534 ;;
|
|
535 ;; `ebnf-terminal-shape' Specify terminal box shape.
|
|
536 ;;
|
|
537 ;; `ebnf-terminal-shadow' Non-nil means terminal box will have a
|
|
538 ;; shadow.
|
|
539 ;;
|
|
540 ;; `ebnf-terminal-border-width' Specify border width for terminal box.
|
|
541 ;;
|
|
542 ;; `ebnf-terminal-border-color' Specify border color for terminal box.
|
|
543 ;;
|
|
544 ;; `ebnf-sort-production' Specify how productions are sorted.
|
|
545 ;;
|
|
546 ;; `ebnf-production-font' Specify production font.
|
|
547 ;;
|
|
548 ;; `ebnf-non-terminal-font' Specify non-terminal font.
|
|
549 ;;
|
|
550 ;; `ebnf-non-terminal-shape' Specify non-terminal box shape.
|
|
551 ;;
|
|
552 ;; `ebnf-non-terminal-shadow' Non-nil means non-terminal box will have
|
|
553 ;; a shadow.
|
|
554 ;;
|
|
555 ;; `ebnf-non-terminal-border-width' Specify border width for non-terminal
|
|
556 ;; box.
|
|
557 ;;
|
|
558 ;; `ebnf-non-terminal-border-color' Specify border color for non-terminal
|
|
559 ;; box.
|
|
560 ;;
|
|
561 ;; `ebnf-special-font' Specify special font.
|
|
562 ;;
|
|
563 ;; `ebnf-special-shape' Specify special box shape.
|
|
564 ;;
|
|
565 ;; `ebnf-special-shadow' Non-nil means special box will have a
|
|
566 ;; shadow.
|
|
567 ;;
|
|
568 ;; `ebnf-special-border-width' Specify border width for special box.
|
|
569 ;;
|
|
570 ;; `ebnf-special-border-color' Specify border color for special box.
|
|
571 ;;
|
|
572 ;; `ebnf-except-font' Specify except font.
|
|
573 ;;
|
|
574 ;; `ebnf-except-shape' Specify except box shape.
|
|
575 ;;
|
|
576 ;; `ebnf-except-shadow' Non-nil means except box will have a
|
|
577 ;; shadow.
|
|
578 ;;
|
|
579 ;; `ebnf-except-border-width' Specify border width for except box.
|
|
580 ;;
|
|
581 ;; `ebnf-except-border-color' Specify border color for except box.
|
|
582 ;;
|
|
583 ;; `ebnf-repeat-font' Specify repeat font.
|
|
584 ;;
|
|
585 ;; `ebnf-repeat-shape' Specify repeat box shape.
|
|
586 ;;
|
|
587 ;; `ebnf-repeat-shadow' Non-nil means repeat box will have a
|
|
588 ;; shadow.
|
|
589 ;;
|
|
590 ;; `ebnf-repeat-border-width' Specify border width for repeat box.
|
|
591 ;;
|
|
592 ;; `ebnf-repeat-border-color' Specify border color for repeat box.
|
|
593 ;;
|
|
594 ;; `ebnf-entry-percentage' Specify entry height on alternatives.
|
|
595 ;;
|
|
596 ;; `ebnf-arrow-shape' Specify the arrow shape.
|
|
597 ;;
|
|
598 ;; `ebnf-chart-shape' Specify chart flow shape.
|
|
599 ;;
|
|
600 ;; `ebnf-color-p' Non-nil means use color.
|
|
601 ;;
|
|
602 ;; `ebnf-line-width' Specify flow line width.
|
|
603 ;;
|
|
604 ;; `ebnf-line-color' Specify flow line color.
|
|
605 ;;
|
|
606 ;; `ebnf-user-arrow' Specify a user arrow shape (a PostScript
|
|
607 ;; code).
|
|
608 ;;
|
|
609 ;; `ebnf-debug-ps' Non-nil means to generate PostScript
|
|
610 ;; debug procedures.
|
|
611 ;;
|
|
612 ;; `ebnf-lex-comment-char' Specify the line comment character.
|
|
613 ;;
|
|
614 ;; `ebnf-lex-eop-char' Specify the end of production character.
|
|
615 ;;
|
|
616 ;; `ebnf-syntax' Specify syntax to be recognized.
|
|
617 ;;
|
|
618 ;; `ebnf-iso-alternative-p' Non-nil means use alternative ISO EBNF.
|
|
619 ;;
|
|
620 ;; `ebnf-iso-normalize-p' Non-nil means normalize ISO EBNF syntax
|
|
621 ;; names.
|
|
622 ;;
|
|
623 ;; `ebnf-default-width' Specify additional border width over
|
|
624 ;; default terminal, non-terminal or
|
|
625 ;; special.
|
|
626 ;;
|
|
627 ;; `ebnf-eps-prefix' Specify EPS prefix file name.
|
|
628 ;;
|
|
629 ;; `ebnf-use-float-format' Non-nil means use `%f' float format.
|
|
630 ;;
|
|
631 ;; `ebnf-yac-ignore-error-recovery' Non-nil means ignore error recovery.
|
|
632 ;;
|
|
633 ;; `ebnf-ignore-empty-rule' Non-nil means ignore empty rules.
|
|
634 ;;
|
|
635 ;; `ebnf-optimize' Non-nil means optimize syntatic chart of
|
|
636 ;; rules.
|
|
637 ;;
|
|
638 ;; To set the above options you may:
|
|
639 ;;
|
|
640 ;; a) insert the code in your ~/.emacs, like:
|
|
641 ;;
|
|
642 ;; (setq ebnf-terminal-shape 'bevel)
|
|
643 ;;
|
|
644 ;; This way always keep your default settings when you enter a new Emacs
|
|
645 ;; session.
|
|
646 ;;
|
|
647 ;; b) or use `set-variable' in your Emacs session, like:
|
|
648 ;;
|
|
649 ;; M-x set-variable RET ebnf-terminal-shape RET bevel RET
|
|
650 ;;
|
|
651 ;; This way keep your settings only during the current Emacs session.
|
|
652 ;;
|
|
653 ;; c) or use customization, for example:
|
|
654 ;; click on menu-bar *Help* option,
|
|
655 ;; then click on *Customize*,
|
|
656 ;; then click on *Browse Customization Groups*,
|
|
657 ;; expand *PostScript* group,
|
|
658 ;; expand *Ebnf2ps* group
|
|
659 ;; and then customize ebnf2ps options.
|
|
660 ;; Through this way, you may choose if the settings are kept or not when
|
|
661 ;; you leave out the current Emacs session.
|
|
662 ;;
|
|
663 ;; d) or see the option value:
|
|
664 ;;
|
|
665 ;; C-h v ebnf-terminal-shape RET
|
|
666 ;;
|
|
667 ;; and click the *customize* hypertext button.
|
|
668 ;; Through this way, you may choose if the settings are kept or not when
|
|
669 ;; you leave out the current Emacs session.
|
|
670 ;;
|
|
671 ;; e) or invoke:
|
|
672 ;;
|
|
673 ;; M-x ebnf-customize RET
|
|
674 ;;
|
|
675 ;; and then customize ebnf2ps options.
|
|
676 ;; Through this way, you may choose if the settings are kept or not when
|
|
677 ;; you leave out the current Emacs session.
|
|
678 ;;
|
|
679 ;;
|
|
680 ;; Styles
|
|
681 ;; ------
|
|
682 ;;
|
|
683 ;; Sometimes you need to change the EBNF style you are using, for example,
|
|
684 ;; change the shapes and colors. These changes may force you to set some
|
|
685 ;; variables and after use, set back the variables to the old values.
|
|
686 ;;
|
|
687 ;; To help to handle this situation, ebnf2ps has the following commands to
|
|
688 ;; handle styles:
|
|
689 ;;
|
|
690 ;; `ebnf-insert-style' Insert a new style NAME with inheritance INHERITS and
|
|
691 ;; values VALUES.
|
|
692 ;;
|
|
693 ;; `ebnf-merge-style' Merge values of style NAME with style VALUES.
|
|
694 ;;
|
|
695 ;; `ebnf-apply-style' Set STYLE to current style.
|
|
696 ;;
|
|
697 ;; `ebnf-reset-style' Reset current style.
|
|
698 ;;
|
|
699 ;; `ebnf-push-style' Push the current style and set STYLE to current style.
|
|
700 ;;
|
|
701 ;; `ebnf-pop-style' Pop a style and set it to current style.
|
|
702 ;;
|
|
703 ;; These commands helps to put together a lot of variable settings in a group
|
|
704 ;; and name this group. So when you wish to apply these settings it's only
|
|
705 ;; needed to give the name.
|
|
706 ;;
|
|
707 ;; There is also a notion of simple inheritance of style; so if you declare that
|
|
708 ;; a style A inherits from a style B, all settings of B is applied first and
|
|
709 ;; then the settings of A is applied. This is useful when you wish to modify
|
|
710 ;; some aspects of an existing style, but at same time wish to keep it
|
|
711 ;; unmodified.
|
|
712 ;;
|
|
713 ;; See documentation for `ebnf-style-database'.
|
|
714 ;;
|
|
715 ;;
|
|
716 ;; Layout
|
|
717 ;; ------
|
|
718 ;;
|
|
719 ;; Below it is the layout of minimum area to draw each element, and it's used
|
|
720 ;; the following terms:
|
|
721 ;;
|
|
722 ;; font height is given by:
|
|
723 ;; (terminal font height + non-terminal font height) / 2
|
|
724 ;;
|
|
725 ;; entry is the vertical position used to know where it should be
|
|
726 ;; drawn the flow line in the current element.
|
|
727 ;;
|
|
728 ;;
|
|
729 ;; * SPECIAL, TERMINAL and NON-TERMINAL
|
|
730 ;;
|
|
731 ;; +==============+...................................
|
|
732 ;; | | } font height / 2 } entry }
|
|
733 ;; | XXXXXXXX...|....... } }
|
|
734 ;; ====+ XXXXXXXX +==== } text height ...... } height
|
|
735 ;; : | XXXXXXXX...|...:... }
|
|
736 ;; : | : : | : } font height / 2 }
|
|
737 ;; : +==============+...:...............................
|
|
738 ;; : : : : : :
|
|
739 ;; : : : : : :......................
|
|
740 ;; : : : : : } font height }
|
|
741 ;; : : : : :....... }
|
|
742 ;; : : : : } font height / 2 }
|
|
743 ;; : : : :........... }
|
|
744 ;; : : : } text width } width
|
|
745 ;; : : :.................. }
|
|
746 ;; : : } font height / 2 }
|
|
747 ;; : :...................... }
|
|
748 ;; : } font height }
|
|
749 ;; :.............................................
|
|
750 ;;
|
|
751 ;;
|
|
752 ;; * OPTIONAL
|
|
753 ;;
|
|
754 ;; +==========+.....................................
|
|
755 ;; | | } } }
|
|
756 ;; | | } entry } }
|
|
757 ;; | | } } }
|
|
758 ;; ===+===+ +===+===... } element height } height
|
|
759 ;; : \ | | / : } }
|
|
760 ;; : + | | + : } }
|
|
761 ;; : | +==========+.|................. }
|
|
762 ;; : | : : | : } font height }
|
|
763 ;; : +==============+...................................
|
|
764 ;; : : : :
|
|
765 ;; : : : :......................
|
|
766 ;; : : : } font height * 2 }
|
|
767 ;; : : :.......... }
|
|
768 ;; : : } element width } width
|
|
769 ;; : :..................... }
|
|
770 ;; : } font height * 2 }
|
|
771 ;; :...............................................
|
|
772 ;;
|
|
773 ;;
|
|
774 ;; * ALTERNATIVE
|
|
775 ;;
|
|
776 ;; +===+...................................
|
|
777 ;; +==+ A +==+ } A height } }
|
|
778 ;; | +===+..|........ } entry }
|
|
779 ;; + + } font height } }
|
|
780 ;; / +===+...\....... } }
|
|
781 ;; ===+====+ B +====+=== } B height ..... } height
|
|
782 ;; : \ +===+.../....... }
|
|
783 ;; : + + : } font height }
|
|
784 ;; : | +===+..|........ }
|
|
785 ;; : +==+ C +==+ : } C height }
|
|
786 ;; : : +===+...................................
|
|
787 ;; : : : :
|
|
788 ;; : : : :......................
|
|
789 ;; : : : } font height * 2 }
|
|
790 ;; : : :......... }
|
|
791 ;; : : } max width } width
|
|
792 ;; : :................. }
|
|
793 ;; : } font height * 2 }
|
|
794 ;; :..........................................
|
|
795 ;;
|
|
796 ;; NOTES:
|
|
797 ;; 1. An empty alternative has zero of height.
|
|
798 ;;
|
|
799 ;; 2. The variable `ebnf-entry-percentage' is used to determine the
|
|
800 ;; entry point.
|
|
801 ;;
|
|
802 ;;
|
|
803 ;; * ZERO OR MORE
|
|
804 ;;
|
|
805 ;; +===========+...............................
|
|
806 ;; +=+ separator +=+ } separator height }
|
|
807 ;; / +===========+..\........ }
|
|
808 ;; + + } }
|
|
809 ;; | | } font height }
|
|
810 ;; + + } }
|
|
811 ;; \ +===========+../........ } height = entry
|
|
812 ;; +=+ element +=+ } element height }
|
|
813 ;; /: +===========+..\........ }
|
|
814 ;; + : : + } }
|
|
815 ;; + : : + } font height }
|
|
816 ;; / : : \ } }
|
|
817 ;; ==+=======================+==.......................
|
|
818 ;; : : : :
|
|
819 ;; : : : :.......................
|
|
820 ;; : : : } font height * 2 }
|
|
821 ;; : : :......... }
|
|
822 ;; : : } max width } width
|
|
823 ;; : :......................... }
|
|
824 ;; : } font height * 2 }
|
|
825 ;; :...................................................
|
|
826 ;;
|
|
827 ;;
|
|
828 ;; * ONE OR MORE
|
|
829 ;;
|
|
830 ;; +===========+......................................
|
|
831 ;; +=+ separator +=+ } separator height } }
|
|
832 ;; / +===========+..\...... } }
|
|
833 ;; + + } } entry }
|
|
834 ;; | | } font height } } height
|
|
835 ;; + + } } }
|
|
836 ;; \ +===========+../...... } }
|
|
837 ;; ===+=+ element +=+=== } element height .... }
|
|
838 ;; : : +===========+......................................
|
|
839 ;; : : : :
|
|
840 ;; : : : :........................
|
|
841 ;; : : : } font height * 2 }
|
|
842 ;; : : :....... }
|
|
843 ;; : : } max width } width
|
|
844 ;; : :....................... }
|
|
845 ;; : } font height * 2 }
|
|
846 ;; :..............................................
|
|
847 ;;
|
|
848 ;;
|
|
849 ;; * PRODUCTION
|
|
850 ;;
|
|
851 ;; XXXXXX:......................................
|
|
852 ;; XXXXXX: } production font height }
|
|
853 ;; XXXXXX:............ }
|
|
854 ;; } font height }
|
|
855 ;; +======+....... } height = entry
|
|
856 ;; | | } }
|
|
857 ;; ====+ +==== } element height }
|
|
858 ;; : | | : } }
|
|
859 ;; : +======+.................................
|
|
860 ;; : : : :
|
|
861 ;; : : : :......................
|
|
862 ;; : : : } font height * 2 }
|
|
863 ;; : : :....... }
|
|
864 ;; : : } element width } width
|
|
865 ;; : :.............. }
|
|
866 ;; : } font height * 2 }
|
|
867 ;; :.....................................
|
|
868 ;;
|
|
869 ;;
|
|
870 ;; * REPEAT
|
|
871 ;;
|
|
872 ;; +================+...................................
|
|
873 ;; | | } font height / 2 } entry }
|
|
874 ;; | +===+...|....... } }
|
|
875 ;; ====+ N * | X | +==== } X height ......... } height
|
|
876 ;; : | : : +===+...|...:... }
|
|
877 ;; : | : : : : | : } font height / 2 }
|
|
878 ;; : +================+...:...............................
|
|
879 ;; : : : : : : : :
|
|
880 ;; : : : : : : : :......................
|
|
881 ;; : : : : : : : } font height }
|
|
882 ;; : : : : : : :....... }
|
|
883 ;; : : : : : : } font height / 2 }
|
|
884 ;; : : : : : :........... }
|
|
885 ;; : : : : : } X width }
|
|
886 ;; : : : : :............... }
|
|
887 ;; : : : : } font height / 2 } width
|
|
888 ;; : : : :.................. }
|
|
889 ;; : : : } text width }
|
|
890 ;; : : :..................... }
|
|
891 ;; : : } font height / 2 }
|
|
892 ;; : :........................ }
|
|
893 ;; : } font height }
|
|
894 ;; :...............................................
|
|
895 ;;
|
|
896 ;;
|
|
897 ;; * EXCEPT
|
|
898 ;;
|
|
899 ;; +==================+...................................
|
|
900 ;; | | } font height / 2 } entry }
|
|
901 ;; | +===+ +===+...|....... } }
|
|
902 ;; ====+ | X | - | y | +==== } max height ....... } height
|
|
903 ;; : | +===+ +===+...|...:... }
|
|
904 ;; : | : : : : | : } font height / 2 }
|
|
905 ;; : +==================+...:...............................
|
|
906 ;; : : : : : : : :
|
|
907 ;; : : : : : : : :......................
|
|
908 ;; : : : : : : : } font height }
|
|
909 ;; : : : : : : :....... }
|
|
910 ;; : : : : : : } font height / 2 }
|
|
911 ;; : : : : : :........... }
|
|
912 ;; : : : : : } Y width }
|
|
913 ;; : : : : :............... }
|
|
914 ;; : : : : } font height } width
|
|
915 ;; : : : :................... }
|
|
916 ;; : : : } X width }
|
|
917 ;; : : :....................... }
|
|
918 ;; : : } font height / 2 }
|
|
919 ;; : :.......................... }
|
|
920 ;; : } font height }
|
|
921 ;; :.................................................
|
|
922 ;;
|
|
923 ;; NOTE: If Y element is empty, it's draw nothing at Y place.
|
|
924 ;;
|
|
925 ;;
|
|
926 ;; Internal Structures
|
|
927 ;; -------------------
|
|
928 ;;
|
|
929 ;; ebnf2ps has two passes. The first pass does a lexical and syntatic analysis
|
|
930 ;; of current buffer and generates an intermediate representation. The second
|
|
931 ;; pass uses the intermediate representation to generate the PostScript syntatic
|
|
932 ;; chart.
|
|
933 ;;
|
|
934 ;; The intermediate representation is a list of vectors, the vector element
|
|
935 ;; represents a syntatic chart element. Below is a vector representation for
|
|
936 ;; each syntatic chart element.
|
|
937 ;;
|
|
938 ;; [production WIDTH-FUN DIM-FUN ENTRY HEIGHT WIDTH NAME PRODUCTION ACTION]
|
|
939 ;; [alternative WIDTH-FUN DIM-FUN ENTRY HEIGHT WIDTH LIST]
|
|
940 ;; [sequence WIDTH-FUN DIM-FUN ENTRY HEIGHT WIDTH LIST]
|
|
941 ;; [terminal WIDTH-FUN DIM-FUN ENTRY HEIGHT WIDTH NAME DEFAULT]
|
|
942 ;; [non-terminal WIDTH-FUN DIM-FUN ENTRY HEIGHT WIDTH NAME DEFAULT]
|
|
943 ;; [special WIDTH-FUN DIM-FUN ENTRY HEIGHT WIDTH NAME DEFAULT]
|
|
944 ;; [empty WIDTH-FUN DIM-FUN ENTRY HEIGHT WIDTH]
|
|
945 ;; [optional WIDTH-FUN DIM-FUN ENTRY HEIGHT WIDTH ELEMENT]
|
|
946 ;; [one-or-more WIDTH-FUN DIM-FUN ENTRY HEIGHT WIDTH ELEMENT SEPARATOR]
|
|
947 ;; [zero-or-more WIDTH-FUN DIM-FUN ENTRY HEIGHT WIDTH ELEMENT SEPARATOR]
|
|
948 ;; [repeat WIDTH-FUN DIM-FUN ENTRY HEIGHT WIDTH TIMES ELEMENT]
|
|
949 ;; [except WIDTH-FUN DIM-FUN ENTRY HEIGHT WIDTH ELEMENT ELEMENT]
|
|
950 ;;
|
|
951 ;; The first vector position is a function symbol used to generate PostScript
|
|
952 ;; for this element.
|
|
953 ;; WIDTH-FUN is a function symbol called to adjust the element width.
|
|
954 ;; DIM-FUN is a function symbol called to set the element dimensions.
|
|
955 ;; ENTRY is the element entry point.
|
|
956 ;; HEIGHT and WIDTH are the element height and width, respectively.
|
|
957 ;; NAME is a string that it's the element name.
|
|
958 ;; DEFAULT is a boolean that indicates if it's a `default' element.
|
|
959 ;; PRODUCTION and ELEMENT are vectors that represents sub-elements of current
|
|
960 ;; one.
|
|
961 ;; LIST is a list of vector that represents the list part for alternatives and
|
|
962 ;; sequences.
|
|
963 ;; SEPARATOR is a vector that represents the sub-element used to separate the
|
|
964 ;; list elements.
|
|
965 ;; TIMES is a string representing the number of times that ELEMENT is repeated
|
|
966 ;; on a repeat construction.
|
|
967 ;; ACTION indicates some action that should be done before production is
|
|
968 ;; generated. The current actions are:
|
|
969 ;;
|
|
970 ;; nil no action.
|
|
971 ;;
|
|
972 ;; form-feed current production starts on a new page.
|
|
973 ;;
|
|
974 ;; newline current production starts on next line, this is useful
|
|
975 ;; when `ebnf-horizontal-orientation' is non-nil.
|
|
976 ;;
|
|
977 ;; keep-line current production continues on the current line, this
|
|
978 ;; is useful when `ebnf-horizontal-orientation' is nil.
|
|
979 ;;
|
|
980 ;;
|
|
981 ;; Things To Change
|
|
982 ;; ----------------
|
|
983 ;;
|
|
984 ;; . Handle situations when syntatic chart is out of paper.
|
|
985 ;; . Use other alphabet than ascii.
|
|
986 ;; . Optimizations...
|
|
987 ;;
|
|
988 ;;
|
|
989 ;; Acknowledgements
|
|
990 ;; ----------------
|
|
991 ;;
|
|
992 ;; Thanks to all who emailed comments.
|
|
993 ;;
|
|
994 ;;
|
|
995 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
996
|
|
997 ;;; code:
|
|
998
|
|
999
|
|
1000 (require 'ps-print)
|
|
1001
|
|
1002 (and (string< ps-print-version "3.05.1")
|
|
1003 (error "`ebnf2ps' requires `ps-print' package version 3.05.1 or later"))
|
|
1004
|
|
1005
|
|
1006 ;; temporary fix for ps-print
|
|
1007 (or (fboundp 'set-buffer-multibyte)
|
|
1008 (defun set-buffer-multibyte (arg)
|
|
1009 (setq enable-multibyte-characters arg)))
|
|
1010
|
|
1011 (or (fboundp 'string-as-unibyte)
|
|
1012 (defun string-as-unibyte (arg) arg))
|
|
1013
|
|
1014 (or (fboundp 'string-as-multibyte)
|
|
1015 (defun string-as-multibyte (arg) arg))
|
|
1016
|
|
1017 (or (fboundp 'charset-after)
|
|
1018 (defun charset-after (&optional arg)
|
|
1019 (char-charset (char-after arg))))
|
|
1020
|
|
1021
|
|
1022 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1023 ;; User Variables:
|
|
1024
|
|
1025
|
|
1026 ;;; Interface to the command system
|
|
1027
|
|
1028 (defgroup postscript nil
|
|
1029 "PostScript Group"
|
|
1030 :tag "PostScript"
|
|
1031 :group 'emacs)
|
|
1032
|
|
1033
|
|
1034 (defgroup ebnf2ps nil
|
|
1035 "Translate an EBNF to a syntatic chart on PostScript"
|
|
1036 :prefix "ebnf-"
|
|
1037 :group 'wp
|
|
1038 :group 'postscript)
|
|
1039
|
|
1040
|
|
1041 (defgroup ebnf-special nil
|
|
1042 "Special customization"
|
|
1043 :prefix "ebnf-"
|
|
1044 :tag "Special"
|
|
1045 :group 'ebnf2ps)
|
|
1046
|
|
1047
|
|
1048 (defgroup ebnf-except nil
|
|
1049 "Except customization"
|
|
1050 :prefix "ebnf-"
|
|
1051 :tag "Except"
|
|
1052 :group 'ebnf2ps)
|
|
1053
|
|
1054
|
|
1055 (defgroup ebnf-repeat nil
|
|
1056 "Repeat customization"
|
|
1057 :prefix "ebnf-"
|
|
1058 :tag "Repeat"
|
|
1059 :group 'ebnf2ps)
|
|
1060
|
|
1061
|
|
1062 (defgroup ebnf-terminal nil
|
|
1063 "Terminal customization"
|
|
1064 :prefix "ebnf-"
|
|
1065 :tag "Terminal"
|
|
1066 :group 'ebnf2ps)
|
|
1067
|
|
1068
|
|
1069 (defgroup ebnf-non-terminal nil
|
|
1070 "Non-Terminal customization"
|
|
1071 :prefix "ebnf-"
|
|
1072 :tag "Non-Terminal"
|
|
1073 :group 'ebnf2ps)
|
|
1074
|
|
1075
|
|
1076 (defgroup ebnf-production nil
|
|
1077 "Production customization"
|
|
1078 :prefix "ebnf-"
|
|
1079 :tag "Production"
|
|
1080 :group 'ebnf2ps)
|
|
1081
|
|
1082
|
|
1083 (defgroup ebnf-shape nil
|
|
1084 "Shapes customization"
|
|
1085 :prefix "ebnf-"
|
|
1086 :tag "Shape"
|
|
1087 :group 'ebnf2ps)
|
|
1088
|
|
1089
|
|
1090 (defgroup ebnf-displacement nil
|
|
1091 "Displacement customization"
|
|
1092 :prefix "ebnf-"
|
|
1093 :tag "Displacement"
|
|
1094 :group 'ebnf2ps)
|
|
1095
|
|
1096
|
|
1097 (defgroup ebnf-syntatic nil
|
|
1098 "Syntatic customization"
|
|
1099 :prefix "ebnf-"
|
|
1100 :tag "Syntatic"
|
|
1101 :group 'ebnf2ps)
|
|
1102
|
|
1103
|
|
1104 (defgroup ebnf-optimization nil
|
|
1105 "Optimization customization"
|
|
1106 :prefix "ebnf-"
|
|
1107 :tag "Optimization"
|
|
1108 :group 'ebnf2ps)
|
|
1109
|
|
1110
|
|
1111 (defcustom ebnf-horizontal-orientation nil
|
|
1112 "*Non-nil means productions are drawn horizontally."
|
|
1113 :type 'boolean
|
|
1114 :group 'ebnf-displacement)
|
|
1115
|
|
1116
|
|
1117 (defcustom ebnf-horizontal-max-height nil
|
|
1118 "*Non-nil means to use maximum production height in horizontal orientation.
|
|
1119
|
|
1120 It is only used when `ebnf-horizontal-orientation' is non-nil."
|
|
1121 :type 'boolean
|
|
1122 :group 'ebnf-displacement)
|
|
1123
|
|
1124
|
|
1125 (defcustom ebnf-production-horizontal-space 0.0 ; use ebnf2ps default value
|
|
1126 "*Specify horizontal space in points between productions.
|
|
1127
|
|
1128 Value less or equal to zero forces ebnf2ps to set a proper default value."
|
|
1129 :type 'number
|
|
1130 :group 'ebnf-displacement)
|
|
1131
|
|
1132
|
|
1133 (defcustom ebnf-production-vertical-space 0.0 ; use ebnf2ps default value
|
|
1134 "*Specify vertical space in points between productions.
|
|
1135
|
|
1136 Value less or equal to zero forces ebnf2ps to set a proper default value."
|
|
1137 :type 'number
|
|
1138 :group 'ebnf-displacement)
|
|
1139
|
|
1140
|
|
1141 (defcustom ebnf-justify-sequence 'center
|
|
1142 "*Specify justification of terms in a sequence inside alternatives.
|
|
1143
|
|
1144 Valid values are:
|
|
1145
|
|
1146 `left' left justification
|
|
1147 `right' right justification
|
|
1148 any other value centralize"
|
|
1149 :type '(radio :tag "Sequence Justification"
|
|
1150 (const left) (const right) (other :tag "center" center))
|
|
1151 :group 'ebnf-displacement)
|
|
1152
|
|
1153
|
|
1154 (defcustom ebnf-special-font '(7 Courier "Black" "Gray95" bold italic)
|
|
1155 "*Specify special font.
|
|
1156
|
|
1157 See documentation for `ebnf-production-font'."
|
|
1158 :type '(list :tag "Special Font"
|
|
1159 (number :tag "Font Size")
|
|
1160 (symbol :tag "Font Name")
|
|
1161 (choice :tag "Foreground Color"
|
|
1162 (string :tag "Name")
|
|
1163 (other :tag "Default" nil))
|
|
1164 (choice :tag "Background Color"
|
|
1165 (string :tag "Name")
|
|
1166 (other :tag "Default" nil))
|
|
1167 (repeat :tag "Font Attributes" :inline t
|
|
1168 (choice (const bold) (const italic)
|
|
1169 (const underline) (const strikeout)
|
|
1170 (const overline) (const shadow)
|
|
1171 (const box) (const outline))))
|
|
1172 :group 'ebnf-special)
|
|
1173
|
|
1174
|
|
1175 (defcustom ebnf-special-shape 'bevel
|
|
1176 "*Specify special box shape.
|
|
1177
|
|
1178 See documentation for `ebnf-non-terminal-shape'."
|
|
1179 :type '(radio :tag "Special Shape"
|
|
1180 (const miter) (const round) (const bevel))
|
|
1181 :group 'ebnf-special)
|
|
1182
|
|
1183
|
|
1184 (defcustom ebnf-special-shadow nil
|
|
1185 "*Non-nil means special box will have a shadow."
|
|
1186 :type 'boolean
|
|
1187 :group 'ebnf-special)
|
|
1188
|
|
1189
|
|
1190 (defcustom ebnf-special-border-width 0.5
|
|
1191 "*Specify border width for special box."
|
|
1192 :type 'number
|
|
1193 :group 'ebnf-special)
|
|
1194
|
|
1195
|
|
1196 (defcustom ebnf-special-border-color "Black"
|
|
1197 "*Specify border color for special box."
|
|
1198 :type 'string
|
|
1199 :group 'ebnf-special)
|
|
1200
|
|
1201
|
|
1202 (defcustom ebnf-except-font '(7 Courier "Black" "Gray90" bold italic)
|
|
1203 "*Specify except font.
|
|
1204
|
|
1205 See documentation for `ebnf-production-font'."
|
|
1206 :type '(list :tag "Except Font"
|
|
1207 (number :tag "Font Size")
|
|
1208 (symbol :tag "Font Name")
|
|
1209 (choice :tag "Foreground Color"
|
|
1210 (string :tag "Name")
|
|
1211 (other :tag "Default" nil))
|
|
1212 (choice :tag "Background Color"
|
|
1213 (string :tag "Name")
|
|
1214 (other :tag "Default" nil))
|
|
1215 (repeat :tag "Font Attributes" :inline t
|
|
1216 (choice (const bold) (const italic)
|
|
1217 (const underline) (const strikeout)
|
|
1218 (const overline) (const shadow)
|
|
1219 (const box) (const outline))))
|
|
1220 :group 'ebnf-except)
|
|
1221
|
|
1222
|
|
1223 (defcustom ebnf-except-shape 'bevel
|
|
1224 "*Specify except box shape.
|
|
1225
|
|
1226 See documentation for `ebnf-non-terminal-shape'."
|
|
1227 :type '(radio :tag "Except Shape"
|
|
1228 (const miter) (const round) (const bevel))
|
|
1229 :group 'ebnf-except)
|
|
1230
|
|
1231
|
|
1232 (defcustom ebnf-except-shadow nil
|
|
1233 "*Non-nil means except box will have a shadow."
|
|
1234 :type 'boolean
|
|
1235 :group 'ebnf-except)
|
|
1236
|
|
1237
|
|
1238 (defcustom ebnf-except-border-width 0.25
|
|
1239 "*Specify border width for except box."
|
|
1240 :type 'number
|
|
1241 :group 'ebnf-except)
|
|
1242
|
|
1243
|
|
1244 (defcustom ebnf-except-border-color "Black"
|
|
1245 "*Specify border color for except box."
|
|
1246 :type 'string
|
|
1247 :group 'ebnf-except)
|
|
1248
|
|
1249
|
|
1250 (defcustom ebnf-repeat-font '(7 Courier "Black" "Gray85" bold italic)
|
|
1251 "*Specify repeat font.
|
|
1252
|
|
1253 See documentation for `ebnf-production-font'."
|
|
1254 :type '(list :tag "Repeat Font"
|
|
1255 (number :tag "Font Size")
|
|
1256 (symbol :tag "Font Name")
|
|
1257 (choice :tag "Foreground Color"
|
|
1258 (string :tag "Name")
|
|
1259 (other :tag "Default" nil))
|
|
1260 (choice :tag "Background Color"
|
|
1261 (string :tag "Name")
|
|
1262 (other :tag "Default" nil))
|
|
1263 (repeat :tag "Font Attributes" :inline t
|
|
1264 (choice (const bold) (const italic)
|
|
1265 (const underline) (const strikeout)
|
|
1266 (const overline) (const shadow)
|
|
1267 (const box) (const outline))))
|
|
1268 :group 'ebnf-repeat)
|
|
1269
|
|
1270
|
|
1271 (defcustom ebnf-repeat-shape 'bevel
|
|
1272 "*Specify repeat box shape.
|
|
1273
|
|
1274 See documentation for `ebnf-non-terminal-shape'."
|
|
1275 :type '(radio :tag "Repeat Shape"
|
|
1276 (const miter) (const round) (const bevel))
|
|
1277 :group 'ebnf-repeat)
|
|
1278
|
|
1279
|
|
1280 (defcustom ebnf-repeat-shadow nil
|
|
1281 "*Non-nil means repeat box will have a shadow."
|
|
1282 :type 'boolean
|
|
1283 :group 'ebnf-repeat)
|
|
1284
|
|
1285
|
|
1286 (defcustom ebnf-repeat-border-width 0.0
|
|
1287 "*Specify border width for repeat box."
|
|
1288 :type 'number
|
|
1289 :group 'ebnf-repeat)
|
|
1290
|
|
1291
|
|
1292 (defcustom ebnf-repeat-border-color "Black"
|
|
1293 "*Specify border color for repeat box."
|
|
1294 :type 'string
|
|
1295 :group 'ebnf-repeat)
|
|
1296
|
|
1297
|
|
1298 (defcustom ebnf-terminal-font '(7 Courier "Black" "White")
|
|
1299 "*Specify terminal font.
|
|
1300
|
|
1301 See documentation for `ebnf-production-font'."
|
|
1302 :type '(list :tag "Terminal Font"
|
|
1303 (number :tag "Font Size")
|
|
1304 (symbol :tag "Font Name")
|
|
1305 (choice :tag "Foreground Color"
|
|
1306 (string :tag "Name")
|
|
1307 (other :tag "Default" nil))
|
|
1308 (choice :tag "Background Color"
|
|
1309 (string :tag "Name")
|
|
1310 (other :tag "Default" nil))
|
|
1311 (repeat :tag "Font Attributes" :inline t
|
|
1312 (choice (const bold) (const italic)
|
|
1313 (const underline) (const strikeout)
|
|
1314 (const overline) (const shadow)
|
|
1315 (const box) (const outline))))
|
|
1316 :group 'ebnf-terminal)
|
|
1317
|
|
1318
|
|
1319 (defcustom ebnf-terminal-shape 'miter
|
|
1320 "*Specify terminal box shape.
|
|
1321
|
|
1322 See documentation for `ebnf-non-terminal-shape'."
|
|
1323 :type '(radio :tag "Terminal Shape"
|
|
1324 (const miter) (const round) (const bevel))
|
|
1325 :group 'ebnf-terminal)
|
|
1326
|
|
1327
|
|
1328 (defcustom ebnf-terminal-shadow nil
|
|
1329 "*Non-nil means terminal box will have a shadow."
|
|
1330 :type 'boolean
|
|
1331 :group 'ebnf-terminal)
|
|
1332
|
|
1333
|
|
1334 (defcustom ebnf-terminal-border-width 1.0
|
|
1335 "*Specify border width for terminal box."
|
|
1336 :type 'number
|
|
1337 :group 'ebnf-terminal)
|
|
1338
|
|
1339
|
|
1340 (defcustom ebnf-terminal-border-color "Black"
|
|
1341 "*Specify border color for terminal box."
|
|
1342 :type 'string
|
|
1343 :group 'ebnf-terminal)
|
|
1344
|
|
1345
|
|
1346 (defcustom ebnf-sort-production nil
|
|
1347 "*Specify how productions are sorted.
|
|
1348
|
|
1349 Valid values are:
|
|
1350
|
|
1351 nil don't sort productions.
|
|
1352 `ascending' ascending sort.
|
|
1353 any other value descending sort."
|
|
1354 :type '(radio :tag "Production Sort"
|
|
1355 (const :tag "Ascending" ascending)
|
|
1356 (const :tag "Descending" descending)
|
|
1357 (other :tag "No Sort" nil))
|
|
1358 :group 'ebnf-production)
|
|
1359
|
|
1360
|
|
1361 (defcustom ebnf-production-font '(10 Helvetica "Black" "White" bold)
|
|
1362 "*Specify production header font.
|
|
1363
|
|
1364 It is a list with the following form:
|
|
1365
|
|
1366 (SIZE NAME FOREGROUND BACKGROUND ATTRIBUTE...)
|
|
1367
|
|
1368 Where:
|
|
1369 SIZE is the font size.
|
|
1370 NAME is the font name symbol.
|
|
1371 ATTRIBUTE is one of the following symbols:
|
|
1372 bold - use bold font.
|
|
1373 italic - use italic font.
|
|
1374 underline - put a line under text.
|
|
1375 strikeout - like underline, but the line is in middle of text.
|
|
1376 overline - like underline, but the line is over the text.
|
|
1377 shadow - text will have a shadow.
|
|
1378 box - text will be surrounded by a box.
|
|
1379 outline - print characters as hollow outlines.
|
|
1380 FOREGROUND is a foreground string color name; if it's nil, the default color is
|
|
1381 \"Black\".
|
|
1382 BACKGROUND is a background string color name; if it's nil, the default color is
|
|
1383 \"White\".
|
|
1384
|
|
1385 See `ps-font-info-database' for valid font name."
|
|
1386 :type '(list :tag "Production Font"
|
|
1387 (number :tag "Font Size")
|
|
1388 (symbol :tag "Font Name")
|
|
1389 (choice :tag "Foreground Color"
|
|
1390 (string :tag "Name")
|
|
1391 (other :tag "Default" nil))
|
|
1392 (choice :tag "Background Color"
|
|
1393 (string :tag "Name")
|
|
1394 (other :tag "Default" nil))
|
|
1395 (repeat :tag "Font Attributes" :inline t
|
|
1396 (choice (const bold) (const italic)
|
|
1397 (const underline) (const strikeout)
|
|
1398 (const overline) (const shadow)
|
|
1399 (const box) (const outline))))
|
|
1400 :group 'ebnf-production)
|
|
1401
|
|
1402
|
|
1403 (defcustom ebnf-non-terminal-font '(7 Helvetica "Black" "White")
|
|
1404 "*Specify non-terminal font.
|
|
1405
|
|
1406 See documentation for `ebnf-production-font'."
|
|
1407 :type '(list :tag "Non-Terminal Font"
|
|
1408 (number :tag "Font Size")
|
|
1409 (symbol :tag "Font Name")
|
|
1410 (choice :tag "Foreground Color"
|
|
1411 (string :tag "Name")
|
|
1412 (other :tag "Default" nil))
|
|
1413 (choice :tag "Background Color"
|
|
1414 (string :tag "Name")
|
|
1415 (other :tag "Default" nil))
|
|
1416 (repeat :tag "Font Attributes" :inline t
|
|
1417 (choice (const bold) (const italic)
|
|
1418 (const underline) (const strikeout)
|
|
1419 (const overline) (const shadow)
|
|
1420 (const box) (const outline))))
|
|
1421 :group 'ebnf-non-terminal)
|
|
1422
|
|
1423
|
|
1424 (defcustom ebnf-non-terminal-shape 'round
|
|
1425 "*Specify non-terminal box shape.
|
|
1426
|
|
1427 Valid values are:
|
|
1428
|
|
1429 `miter' +-------+
|
|
1430 | |
|
|
1431 +-------+
|
|
1432
|
|
1433 `round' -------
|
|
1434 ( )
|
|
1435 -------
|
|
1436
|
|
1437 `bevel' /-------\\
|
|
1438 | |
|
|
1439 \\-------/
|
|
1440
|
|
1441 Any other value is treated as `miter'."
|
|
1442 :type '(radio :tag "Non-Terminal Shape"
|
|
1443 (const miter) (const round) (const bevel))
|
|
1444 :group 'ebnf-non-terminal)
|
|
1445
|
|
1446
|
|
1447 (defcustom ebnf-non-terminal-shadow nil
|
|
1448 "*Non-nil means non-terminal box will have a shadow."
|
|
1449 :type 'boolean
|
|
1450 :group 'ebnf-non-terminal)
|
|
1451
|
|
1452
|
|
1453 (defcustom ebnf-non-terminal-border-width 1.0
|
|
1454 "*Specify border width for non-terminal box."
|
|
1455 :type 'number
|
|
1456 :group 'ebnf-non-terminal)
|
|
1457
|
|
1458
|
|
1459 (defcustom ebnf-non-terminal-border-color "Black"
|
|
1460 "*Specify border color for non-terminal box."
|
|
1461 :type 'string
|
|
1462 :group 'ebnf-non-terminal)
|
|
1463
|
|
1464
|
|
1465 (defcustom ebnf-arrow-shape 'hollow
|
|
1466 "*Specify the arrow shape.
|
|
1467
|
|
1468 Valid values are:
|
|
1469
|
|
1470 `none' ======
|
|
1471
|
|
1472 `semi-up' * `transparent' *
|
|
1473 * |*
|
|
1474 =====* | *
|
|
1475 ==+==*
|
|
1476 | *
|
|
1477 |*
|
|
1478 *
|
|
1479
|
|
1480 `semi-down' =====* `hollow' *
|
|
1481 * |*
|
|
1482 * | *
|
|
1483 ==+ *
|
|
1484 | *
|
|
1485 |*
|
|
1486 *
|
|
1487
|
|
1488 `simple' * `full' *
|
|
1489 * |*
|
|
1490 =====* |X*
|
|
1491 * ==+XX*
|
|
1492 * |X*
|
|
1493 |*
|
|
1494 *
|
|
1495
|
|
1496 `user' See also documentation for variable `ebnf-user-arrow'.
|
|
1497
|
|
1498 Any other value is treated as `none'."
|
|
1499 :type '(radio :tag "Arrow Shape"
|
|
1500 (const none) (const semi-up)
|
|
1501 (const semi-down) (const simple)
|
|
1502 (const transparent) (const hollow)
|
|
1503 (const full) (const user))
|
|
1504 :group 'ebnf-shape)
|
|
1505
|
|
1506
|
|
1507 (defcustom ebnf-chart-shape 'round
|
|
1508 "*Specify chart flow shape.
|
|
1509
|
|
1510 See documentation for `ebnf-non-terminal-shape'."
|
|
1511 :type '(radio :tag "Chart Flow Shape"
|
|
1512 (const miter) (const round) (const bevel))
|
|
1513 :group 'ebnf-shape)
|
|
1514
|
|
1515
|
|
1516 (defcustom ebnf-user-arrow nil
|
|
1517 "*Specify a user arrow shape (a PostScript code).
|
|
1518
|
|
1519 PostScript code should draw a right arrow.
|
|
1520
|
|
1521 The anatomy of a right arrow is:
|
|
1522
|
|
1523 ...... Initial position
|
|
1524 :
|
|
1525 : *.................
|
|
1526 : | * } }
|
|
1527 : | * } hT4 }
|
|
1528 v | * } }
|
|
1529 ======+======*... } hT2
|
|
1530 : | *: } }
|
|
1531 : | * : } hT4 }
|
|
1532 : | * : } }
|
|
1533 : *.................
|
|
1534 : : :
|
|
1535 : : :..........
|
|
1536 : : } hT2 }
|
|
1537 : :.......... } hT
|
|
1538 : } hT2 }
|
|
1539 :.......................
|
|
1540
|
|
1541 Where `hT', `hT2' and `hT4' are predefined PostScript variable names that can be
|
|
1542 used to generate your own arrow. As these variables are used along PostScript
|
|
1543 execution, *DON'T* modify the values of them. Instead, copy the values, if you
|
|
1544 need to modify them.
|
|
1545
|
|
1546 The relation between these variables is: hT = 2 * hT2 = 4 * hT4.
|
|
1547
|
|
1548 The variable `ebnf-user-arrow' is only used when `ebnf-arrow-shape' is set to
|
|
1549 symbol `user'.
|
|
1550
|
|
1551 See function `ebnf-user-arrow' for valid values and how values are processed."
|
|
1552 :type '(radio :tag "User Arrow Shape"
|
|
1553 (const nil)
|
|
1554 string
|
|
1555 symbol
|
|
1556 (repeat :tag "List"
|
|
1557 (radio string
|
|
1558 symbol
|
|
1559 sexp)))
|
|
1560 :group 'ebnf-shape)
|
|
1561
|
|
1562
|
|
1563 (defcustom ebnf-syntax 'ebnf
|
|
1564 "*Specify syntax to be recognized.
|
|
1565
|
|
1566 Valid values are:
|
|
1567
|
27495
|
1568 `ebnf' ebnf2ps recognizes the syntax described in ebnf2ps
|
|
1569 documentation.
|
27451
|
1570 The following variables *ONLY* have effect with this
|
|
1571 setting:
|
|
1572 `ebnf-terminal-regexp', `ebnf-case-fold-search',
|
|
1573 `ebnf-lex-comment-char' and `ebnf-lex-eop-char'.
|
|
1574
|
|
1575 `iso-ebnf' ebnf2ps recognizes the syntax described in the URL:
|
|
1576 `http://www.cl.cam.ac.uk/~mgk25/iso-ebnf.html'
|
|
1577 (\"International Standard of the ISO EBNF Notation\").
|
|
1578 The following variables *ONLY* have effect with this
|
|
1579 setting:
|
|
1580 `ebnf-iso-alternative-p' and `ebnf-iso-normalize-p'.
|
|
1581
|
|
1582 `yacc' ebnf2ps recognizes the Yacc/Bison syntax.
|
|
1583 The following variable *ONLY* has effect with this
|
|
1584 setting:
|
|
1585 `ebnf-yac-ignore-error-recovery'.
|
|
1586
|
|
1587 Any other value is treated as `ebnf'."
|
|
1588 :type '(radio :tag "Syntax"
|
|
1589 (const ebnf) (const iso-ebnf) (const yacc))
|
|
1590 :group 'ebnf-syntatic)
|
|
1591
|
|
1592
|
|
1593 (defcustom ebnf-lex-comment-char ?\;
|
|
1594 "*Specify the line comment character.
|
|
1595
|
|
1596 It's used only when `ebnf-syntax' is `ebnf'."
|
|
1597 :type 'character
|
|
1598 :group 'ebnf-syntatic)
|
|
1599
|
|
1600
|
|
1601 (defcustom ebnf-lex-eop-char ?.
|
|
1602 "*Specify the end of production character.
|
|
1603
|
|
1604 It's used only when `ebnf-syntax' is `ebnf'."
|
|
1605 :type 'character
|
|
1606 :group 'ebnf-syntatic)
|
|
1607
|
|
1608
|
|
1609 (defcustom ebnf-terminal-regexp nil
|
|
1610 "*Specify how it's a terminal name.
|
|
1611
|
|
1612 If it's nil, the terminal name must be enclosed by `\"'.
|
|
1613 If it's a string, it should be a regexp that it'll be used to determine a
|
|
1614 terminal name; terminal name may also be enclosed by `\"'.
|
|
1615
|
|
1616 It's used only when `ebnf-syntax' is `ebnf'."
|
|
1617 :type '(radio :tag "Terminal Name"
|
|
1618 (const nil) regexp)
|
|
1619 :group 'ebnf-syntatic)
|
|
1620
|
|
1621
|
|
1622 (defcustom ebnf-case-fold-search nil
|
|
1623 "*Non-nil means ignore case on matching.
|
|
1624
|
|
1625 It's only used when `ebnf-terminal-regexp' is non-nil and when `ebnf-syntax' is
|
|
1626 `ebnf'."
|
|
1627 :type 'boolean
|
|
1628 :group 'ebnf-syntatic)
|
|
1629
|
|
1630
|
|
1631 (defcustom ebnf-iso-alternative-p nil
|
|
1632 "*Non-nil means use alternative ISO EBNF.
|
|
1633
|
|
1634 It's only used when `ebnf-syntax' is `iso-ebnf'.
|
|
1635
|
|
1636 This variable affects the following symbol set:
|
|
1637
|
|
1638 STANDARD ALTERNATIVE
|
|
1639 | ==> / or !
|
|
1640 [ ==> (/
|
|
1641 ] ==> /)
|
|
1642 { ==> (:
|
|
1643 } ==> :)
|
|
1644 ; ==> ."
|
|
1645 :type 'boolean
|
|
1646 :group 'ebnf-syntatic)
|
|
1647
|
|
1648
|
|
1649 (defcustom ebnf-iso-normalize-p nil
|
|
1650 "*Non-nil means normalize ISO EBNF syntax names.
|
|
1651
|
|
1652 Normalize a name means that several contiguous spaces inside name become a
|
|
1653 single space, so \"A B C\" is normalized to \"A B C\".
|
|
1654
|
|
1655 It's only used when `ebnf-syntax' is `iso-ebnf'."
|
|
1656 :type 'boolean
|
|
1657 :group 'ebnf-syntatic)
|
|
1658
|
|
1659
|
|
1660 (defcustom ebnf-eps-prefix "ebnf--"
|
|
1661 "*Specify EPS prefix file name.
|
|
1662
|
|
1663 See `ebnf-eps-buffer' and `ebnf-eps-region' commands."
|
|
1664 :type 'string
|
|
1665 :group 'ebnf2ps)
|
|
1666
|
|
1667
|
|
1668 (defcustom ebnf-entry-percentage 0.5 ; middle
|
|
1669 "*Specify entry height on alternatives.
|
|
1670
|
|
1671 It must be a float between 0.0 (top) and 1.0 (bottom)."
|
|
1672 :type 'number
|
|
1673 :group 'ebnf2ps)
|
|
1674
|
|
1675
|
|
1676 (defcustom ebnf-default-width 0.6
|
|
1677 "*Specify additional border width over default terminal, non-terminal or
|
|
1678 special."
|
|
1679 :type 'number
|
|
1680 :group 'ebnf2ps)
|
|
1681
|
|
1682
|
|
1683 ;; Printing color requires x-color-values.
|
|
1684 (defcustom ebnf-color-p (or (fboundp 'x-color-values) ; Emacs
|
|
1685 (fboundp 'color-instance-rgb-components)) ; XEmacs
|
|
1686 "*Non-nil means use color."
|
|
1687 :type 'boolean
|
|
1688 :group 'ebnf2ps)
|
|
1689
|
|
1690
|
|
1691 (defcustom ebnf-line-width 1.0
|
|
1692 "*Specify flow line width."
|
|
1693 :type 'number
|
|
1694 :group 'ebnf2ps)
|
|
1695
|
|
1696
|
|
1697 (defcustom ebnf-line-color "Black"
|
|
1698 "*Specify flow line color."
|
|
1699 :type 'string
|
|
1700 :group 'ebnf2ps)
|
|
1701
|
|
1702
|
|
1703 (defcustom ebnf-debug-ps nil
|
|
1704 "*Non-nil means to generate PostScript debug procedures.
|
|
1705
|
|
1706 It is intended to help PostScript programmers in debugging."
|
|
1707 :type 'boolean
|
|
1708 :group 'ebnf2ps)
|
|
1709
|
|
1710
|
|
1711 (defcustom ebnf-use-float-format t
|
|
1712 "*Non-nil means use `%f' float format.
|
|
1713
|
|
1714 The advantage of using float format is that ebnf2ps generates a little short
|
|
1715 PostScript file.
|
|
1716
|
|
1717 If it occurs the error message:
|
|
1718
|
|
1719 Invalid format operation %f
|
|
1720
|
|
1721 when executing ebnf2ps, set `ebnf-use-float-format' to nil."
|
|
1722 :type 'boolean
|
|
1723 :group 'ebnf2ps)
|
|
1724
|
|
1725
|
|
1726 (defcustom ebnf-yac-ignore-error-recovery nil
|
|
1727 "*Non-nil means ignore error recovery.
|
|
1728
|
|
1729 It's only used when `ebnf-syntax' is `yacc'."
|
|
1730 :type 'boolean
|
|
1731 :group 'ebnf-syntatic)
|
|
1732
|
|
1733
|
|
1734 (defcustom ebnf-ignore-empty-rule nil
|
|
1735 "*Non-nil means ignore empty rules.
|
|
1736
|
|
1737 It's interesting to set this variable if your Yacc/Bison grammar has a lot of
|
|
1738 middle action rule."
|
|
1739 :type 'boolean
|
|
1740 :group 'ebnf-optimization)
|
|
1741
|
|
1742
|
|
1743 (defcustom ebnf-optimize nil
|
|
1744 "*Non-nil means optimize syntatic chart of rules.
|
|
1745
|
|
1746 The following optimizations are done:
|
|
1747
|
|
1748 left recursion:
|
|
1749 1. A = B | A C. ==> A = B {C}*.
|
|
1750 2. A = B | A B. ==> A = {B}+.
|
|
1751 3. A = | A B. ==> A = {B}*.
|
|
1752 4. A = B | A C B. ==> A = {B || C}+.
|
|
1753 5. A = B | D | A C | A E. ==> A = ( B | D ) { C | E }*.
|
|
1754
|
|
1755 optional:
|
|
1756 6. A = B | . ==> A = [B].
|
|
1757 7. A = | B . ==> A = [B].
|
|
1758
|
|
1759 factoration:
|
|
1760 8. A = B C | B D. ==> A = B (C | D).
|
|
1761 9. A = C B | D B. ==> A = (C | D) B.
|
|
1762 10. A = B C E | B D E. ==> A = B (C | D) E.
|
|
1763
|
|
1764 The above optimizations are specially useful when `ebnf-syntax' is `yacc'."
|
|
1765 :type 'boolean
|
|
1766 :group 'ebnf-optimization)
|
|
1767
|
|
1768
|
|
1769 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1770 ;; Customization
|
|
1771
|
|
1772
|
|
1773 ;;;###autoload
|
|
1774 (defun ebnf-customize ()
|
|
1775 "Customization for ebnf group."
|
|
1776 (interactive)
|
|
1777 (customize-group 'ebnf2ps))
|
|
1778
|
|
1779
|
|
1780 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1781 ;; User commands
|
|
1782
|
|
1783
|
|
1784 ;;;###autoload
|
|
1785 (defun ebnf-print-buffer (&optional filename)
|
|
1786 "Generate and print a PostScript syntatic chart image of the buffer.
|
|
1787
|
|
1788 When called with a numeric prefix argument (C-u), prompts the user for
|
|
1789 the name of a file to save the PostScript image in, instead of sending
|
|
1790 it to the printer.
|
|
1791
|
|
1792 More specifically, the FILENAME argument is treated as follows: if it
|
|
1793 is nil, send the image to the printer. If FILENAME is a string, save
|
|
1794 the PostScript image in a file with that name. If FILENAME is a
|
|
1795 number, prompt the user for the name of the file to save in."
|
|
1796 (interactive (list (ps-print-preprint current-prefix-arg)))
|
|
1797 (ebnf-print-region (point-min) (point-max) filename))
|
|
1798
|
|
1799
|
|
1800 ;;;###autoload
|
|
1801 (defun ebnf-print-region (from to &optional filename)
|
|
1802 "Generate and print a PostScript syntatic chart image of the region.
|
|
1803 Like `ebnf-print-buffer', but prints just the current region."
|
|
1804 (interactive (list (point) (mark) (ps-print-preprint current-prefix-arg)))
|
|
1805 (run-hooks 'ebnf-hook)
|
|
1806 (or (ebnf-spool-region from to)
|
|
1807 (ps-do-despool filename)))
|
|
1808
|
|
1809
|
|
1810 ;;;###autoload
|
|
1811 (defun ebnf-spool-buffer ()
|
|
1812 "Generate and spool a PostScript syntatic chart image of the buffer.
|
|
1813 Like `ebnf-print-buffer' except that the PostScript image is saved in a
|
|
1814 local buffer to be sent to the printer later.
|
|
1815
|
|
1816 Use the command `ebnf-despool' to send the spooled images to the printer."
|
|
1817 (interactive)
|
|
1818 (ebnf-spool-region (point-min) (point-max)))
|
|
1819
|
|
1820
|
|
1821 ;;;###autoload
|
|
1822 (defun ebnf-spool-region (from to)
|
|
1823 "Generate a PostScript syntatic chart image of the region and spool locally.
|
|
1824 Like `ebnf-spool-buffer', but spools just the current region.
|
|
1825
|
|
1826 Use the command `ebnf-despool' to send the spooled images to the printer."
|
|
1827 (interactive "r")
|
|
1828 (ebnf-generate-region from to 'ebnf-generate))
|
|
1829
|
|
1830
|
|
1831 ;;;###autoload
|
|
1832 (defun ebnf-eps-buffer ()
|
|
1833 "Generate a PostScript syntatic chart image of the buffer in a EPS file.
|
|
1834
|
|
1835 Indeed, for each production is generated a EPS file.
|
|
1836 The EPS file name has the following form:
|
|
1837
|
|
1838 <PREFIX><PRODUCTION>.eps
|
|
1839
|
|
1840 <PREFIX> is given by variable `ebnf-eps-prefix'.
|
|
1841 The default value is \"ebnf--\".
|
|
1842
|
|
1843 <PRODUCTION> is the production name.
|
|
1844 The production name is mapped to form a valid file name.
|
|
1845 For example, the production name \"A/B + C\" is mapped to
|
|
1846 \"A_B_+_C\" and the EPS file name used is \"ebnf--A_B_+_C.eps\".
|
|
1847
|
|
1848 WARNING: It's *NOT* asked any confirmation to override an existing file."
|
|
1849 (interactive)
|
|
1850 (ebnf-eps-region (point-min) (point-max)))
|
|
1851
|
|
1852
|
|
1853 ;;;###autoload
|
|
1854 (defun ebnf-eps-region (from to)
|
|
1855 "Generate a PostScript syntatic chart image of the region in a EPS file.
|
|
1856
|
|
1857 Indeed, for each production is generated a EPS file.
|
|
1858 The EPS file name has the following form:
|
|
1859
|
|
1860 <PREFIX><PRODUCTION>.eps
|
|
1861
|
|
1862 <PREFIX> is given by variable `ebnf-eps-prefix'.
|
|
1863 The default value is \"ebnf--\".
|
|
1864
|
|
1865 <PRODUCTION> is the production name.
|
|
1866 The production name is mapped to form a valid file name.
|
|
1867 For example, the production name \"A/B + C\" is mapped to
|
|
1868 \"A_B_+_C\" and the EPS file name used is \"ebnf--A_B_+_C.eps\".
|
|
1869
|
|
1870 WARNING: It's *NOT* asked any confirmation to override an existing file."
|
|
1871 (interactive "r")
|
|
1872 (let ((ebnf-eps-executing t))
|
|
1873 (ebnf-generate-region from to 'ebnf-generate-eps)))
|
|
1874
|
|
1875
|
|
1876 ;;;###autoload
|
|
1877 (defalias 'ebnf-despool 'ps-despool)
|
|
1878
|
|
1879
|
|
1880 ;;;###autoload
|
|
1881 (defun ebnf-syntax-buffer ()
|
|
1882 "Does a syntatic analysis of the current buffer."
|
|
1883 (interactive)
|
|
1884 (ebnf-syntax-region (point-min) (point-max)))
|
|
1885
|
|
1886
|
|
1887 ;;;###autoload
|
|
1888 (defun ebnf-syntax-region (from to)
|
|
1889 "Does a syntatic analysis of a region."
|
|
1890 (interactive "r")
|
|
1891 (ebnf-generate-region from to nil))
|
|
1892
|
|
1893
|
|
1894 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1895 ;; Utilities
|
|
1896
|
|
1897
|
|
1898 ;;;###autoload
|
|
1899 (defun ebnf-setup ()
|
|
1900 "Return the current ebnf2ps setup."
|
|
1901 (format
|
|
1902 "
|
|
1903 \(setq ebnf-special-font %s
|
|
1904 ebnf-special-shape %s
|
|
1905 ebnf-special-shadow %S
|
|
1906 ebnf-special-border-width %S
|
|
1907 ebnf-special-border-color %S
|
|
1908 ebnf-except-font %s
|
|
1909 ebnf-except-shape %s
|
|
1910 ebnf-except-shadow %S
|
|
1911 ebnf-except-border-width %S
|
|
1912 ebnf-except-border-color %S
|
|
1913 ebnf-repeat-font %s
|
|
1914 ebnf-repeat-shape %s
|
|
1915 ebnf-repeat-shadow %S
|
|
1916 ebnf-repeat-border-width %S
|
|
1917 ebnf-repeat-border-color %S
|
|
1918 ebnf-terminal-regexp %S
|
|
1919 ebnf-case-fold-search %S
|
|
1920 ebnf-terminal-font %s
|
|
1921 ebnf-terminal-shape %s
|
|
1922 ebnf-terminal-shadow %S
|
|
1923 ebnf-terminal-border-width %S
|
|
1924 ebnf-terminal-border-color %S
|
|
1925 ebnf-non-terminal-font %s
|
|
1926 ebnf-non-terminal-shape %s
|
|
1927 ebnf-non-terminal-shadow %S
|
|
1928 ebnf-non-terminal-border-width %S
|
|
1929 ebnf-non-terminal-border-color %S
|
|
1930 ebnf-sort-production %s
|
|
1931 ebnf-production-font %s
|
|
1932 ebnf-arrow-shape %s
|
|
1933 ebnf-chart-shape %s
|
|
1934 ebnf-user-arrow %s
|
|
1935 ebnf-horizontal-orientation %S
|
|
1936 ebnf-horizontal-max-height %S
|
|
1937 ebnf-production-horizontal-space %S
|
|
1938 ebnf-production-vertical-space %S
|
|
1939 ebnf-justify-sequence %s
|
|
1940 ebnf-lex-comment-char ?\\%03o
|
|
1941 ebnf-lex-eop-char ?\\%03o
|
|
1942 ebnf-syntax %s
|
|
1943 ebnf-iso-alternative-p %S
|
|
1944 ebnf-iso-normalize-p %S
|
|
1945 ebnf-eps-prefix %S
|
|
1946 ebnf-entry-percentage %S
|
|
1947 ebnf-color-p %S
|
|
1948 ebnf-line-width %S
|
|
1949 ebnf-line-color %S
|
|
1950 ebnf-debug-ps %S
|
|
1951 ebnf-use-float-format %S
|
|
1952 ebnf-yac-ignore-error-recovery %S
|
|
1953 ebnf-ignore-empty-rule %S
|
|
1954 ebnf-optimize %S)
|
|
1955 "
|
|
1956 (ps-print-quote ebnf-special-font)
|
|
1957 (ps-print-quote ebnf-special-shape)
|
|
1958 ebnf-special-shadow
|
|
1959 ebnf-special-border-width
|
|
1960 ebnf-special-border-color
|
|
1961 (ps-print-quote ebnf-except-font)
|
|
1962 (ps-print-quote ebnf-except-shape)
|
|
1963 ebnf-except-shadow
|
|
1964 ebnf-except-border-width
|
|
1965 ebnf-except-border-color
|
|
1966 (ps-print-quote ebnf-repeat-font)
|
|
1967 (ps-print-quote ebnf-repeat-shape)
|
|
1968 ebnf-repeat-shadow
|
|
1969 ebnf-repeat-border-width
|
|
1970 ebnf-repeat-border-color
|
|
1971 ebnf-terminal-regexp
|
|
1972 ebnf-case-fold-search
|
|
1973 (ps-print-quote ebnf-terminal-font)
|
|
1974 (ps-print-quote ebnf-terminal-shape)
|
|
1975 ebnf-terminal-shadow
|
|
1976 ebnf-terminal-border-width
|
|
1977 ebnf-terminal-border-color
|
|
1978 (ps-print-quote ebnf-non-terminal-font)
|
|
1979 (ps-print-quote ebnf-non-terminal-shape)
|
|
1980 ebnf-non-terminal-shadow
|
|
1981 ebnf-non-terminal-border-width
|
|
1982 ebnf-non-terminal-border-color
|
|
1983 (ps-print-quote ebnf-sort-production)
|
|
1984 (ps-print-quote ebnf-production-font)
|
|
1985 (ps-print-quote ebnf-arrow-shape)
|
|
1986 (ps-print-quote ebnf-chart-shape)
|
|
1987 (ps-print-quote ebnf-user-arrow)
|
|
1988 ebnf-horizontal-orientation
|
|
1989 ebnf-horizontal-max-height
|
|
1990 ebnf-production-horizontal-space
|
|
1991 ebnf-production-vertical-space
|
|
1992 (ps-print-quote ebnf-justify-sequence)
|
|
1993 ebnf-lex-comment-char
|
|
1994 ebnf-lex-eop-char
|
|
1995 (ps-print-quote ebnf-syntax)
|
|
1996 ebnf-iso-alternative-p
|
|
1997 ebnf-iso-normalize-p
|
|
1998 ebnf-eps-prefix
|
|
1999 ebnf-entry-percentage
|
|
2000 ebnf-color-p
|
|
2001 ebnf-line-width
|
|
2002 ebnf-line-color
|
|
2003 ebnf-debug-ps
|
|
2004 ebnf-use-float-format
|
|
2005 ebnf-yac-ignore-error-recovery
|
|
2006 ebnf-ignore-empty-rule
|
|
2007 ebnf-optimize))
|
|
2008
|
|
2009
|
|
2010 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
2011 ;; Style variables
|
|
2012
|
|
2013
|
|
2014 (defvar ebnf-stack-style nil
|
|
2015 "Used in functions `ebnf-reset-style', `ebnf-push-style' and
|
|
2016 `ebnf-pop-style'.")
|
|
2017
|
|
2018
|
|
2019 (defvar ebnf-current-style 'default
|
|
2020 "Used in functions `ebnf-apply-style' and `ebnf-push-style'.")
|
|
2021
|
|
2022
|
|
2023 (defconst ebnf-style-custom-list
|
|
2024 '(ebnf-special-font
|
|
2025 ebnf-special-shape
|
|
2026 ebnf-special-shadow
|
|
2027 ebnf-special-border-width
|
|
2028 ebnf-special-border-color
|
|
2029 ebnf-except-font
|
|
2030 ebnf-except-shape
|
|
2031 ebnf-except-shadow
|
|
2032 ebnf-except-border-width
|
|
2033 ebnf-except-border-color
|
|
2034 ebnf-repeat-font
|
|
2035 ebnf-repeat-shape
|
|
2036 ebnf-repeat-shadow
|
|
2037 ebnf-repeat-border-width
|
|
2038 ebnf-repeat-border-color
|
|
2039 ebnf-terminal-regexp
|
|
2040 ebnf-case-fold-search
|
|
2041 ebnf-terminal-font
|
|
2042 ebnf-terminal-shape
|
|
2043 ebnf-terminal-shadow
|
|
2044 ebnf-terminal-border-width
|
|
2045 ebnf-terminal-border-color
|
|
2046 ebnf-non-terminal-font
|
|
2047 ebnf-non-terminal-shape
|
|
2048 ebnf-non-terminal-shadow
|
|
2049 ebnf-non-terminal-border-width
|
|
2050 ebnf-non-terminal-border-color
|
|
2051 ebnf-sort-production
|
|
2052 ebnf-production-font
|
|
2053 ebnf-arrow-shape
|
|
2054 ebnf-chart-shape
|
|
2055 ebnf-user-arrow
|
|
2056 ebnf-horizontal-orientation
|
|
2057 ebnf-horizontal-max-height
|
|
2058 ebnf-production-horizontal-space
|
|
2059 ebnf-production-vertical-space
|
|
2060 ebnf-justify-sequence
|
|
2061 ebnf-lex-comment-char
|
|
2062 ebnf-lex-eop-char
|
|
2063 ebnf-syntax
|
|
2064 ebnf-iso-alternative-p
|
|
2065 ebnf-iso-normalize-p
|
|
2066 ebnf-eps-prefix
|
|
2067 ebnf-entry-percentage
|
|
2068 ebnf-color-p
|
|
2069 ebnf-line-width
|
|
2070 ebnf-line-color
|
|
2071 ebnf-debug-ps
|
|
2072 ebnf-use-float-format
|
|
2073 ebnf-yac-ignore-error-recovery
|
|
2074 ebnf-ignore-empty-rule
|
|
2075 ebnf-optimize)
|
|
2076 "List of valid symbol custom variable.")
|
|
2077
|
|
2078
|
|
2079 (defvar ebnf-style-database
|
|
2080 '(;; EBNF default
|
|
2081 (default
|
|
2082 nil
|
|
2083 (ebnf-special-font . '(7 Courier "Black" "Gray95" bold italic))
|
|
2084 (ebnf-special-shape . 'bevel)
|
|
2085 (ebnf-special-shadow . nil)
|
|
2086 (ebnf-special-border-width . 0.5)
|
|
2087 (ebnf-special-border-color . "Black")
|
|
2088 (ebnf-except-font . '(7 Courier "Black" "Gray90" bold italic))
|
|
2089 (ebnf-except-shape . 'bevel)
|
|
2090 (ebnf-except-shadow . nil)
|
|
2091 (ebnf-except-border-width . 0.25)
|
|
2092 (ebnf-except-border-color . "Black")
|
|
2093 (ebnf-repeat-font . '(7 Courier "Black" "Gray85" bold italic))
|
|
2094 (ebnf-repeat-shape . 'bevel)
|
|
2095 (ebnf-repeat-shadow . nil)
|
|
2096 (ebnf-repeat-border-width . 0.0)
|
|
2097 (ebnf-repeat-border-color . "Black")
|
|
2098 (ebnf-terminal-regexp . nil)
|
|
2099 (ebnf-case-fold-search . nil)
|
|
2100 (ebnf-terminal-font . '(7 Courier "Black" "White"))
|
|
2101 (ebnf-terminal-shape . 'miter)
|
|
2102 (ebnf-terminal-shadow . nil)
|
|
2103 (ebnf-terminal-border-width . 1.0)
|
|
2104 (ebnf-terminal-border-color . "Black")
|
|
2105 (ebnf-non-terminal-font . '(7 Helvetica "Black" "White"))
|
|
2106 (ebnf-non-terminal-shape . 'round)
|
|
2107 (ebnf-non-terminal-shadow . nil)
|
|
2108 (ebnf-non-terminal-border-width . 1.0)
|
|
2109 (ebnf-non-terminal-border-color . "Black")
|
|
2110 (ebnf-sort-production . nil)
|
|
2111 (ebnf-production-font . '(10 Helvetica "Black" "White" bold))
|
|
2112 (ebnf-arrow-shape . 'hollow)
|
|
2113 (ebnf-chart-shape . 'round)
|
|
2114 (ebnf-user-arrow . nil)
|
|
2115 (ebnf-horizontal-orientation . nil)
|
|
2116 (ebnf-horizontal-max-height . nil)
|
|
2117 (ebnf-production-horizontal-space . 0.0)
|
|
2118 (ebnf-production-vertical-space . 0.0)
|
|
2119 (ebnf-justify-sequence . 'center)
|
|
2120 (ebnf-lex-comment-char . ?\;)
|
|
2121 (ebnf-lex-eop-char . ?.)
|
|
2122 (ebnf-syntax . 'ebnf)
|
|
2123 (ebnf-iso-alternative-p . nil)
|
|
2124 (ebnf-iso-normalize-p . nil)
|
|
2125 (ebnf-eps-prefix . "ebnf--")
|
|
2126 (ebnf-entry-percentage . 0.5)
|
|
2127 (ebnf-color-p . (or (fboundp 'x-color-values) ; Emacs
|
|
2128 (fboundp 'color-instance-rgb-components))) ; XEmacs
|
|
2129 (ebnf-line-width . 1.0)
|
|
2130 (ebnf-line-color . "Black")
|
|
2131 (ebnf-debug-ps . nil)
|
|
2132 (ebnf-use-float-format . t)
|
|
2133 (ebnf-yac-ignore-error-recovery . nil)
|
|
2134 (ebnf-ignore-empty-rule . nil)
|
|
2135 (ebnf-optimize . nil))
|
|
2136 ;; Happy EBNF default
|
|
2137 (happy
|
|
2138 default
|
|
2139 (ebnf-justify-sequence . 'left)
|
|
2140 (ebnf-lex-comment-char . ?\#)
|
|
2141 (ebnf-lex-eop-char . ?\;))
|
|
2142 ;; ISO EBNF default
|
|
2143 (iso-ebnf
|
|
2144 default
|
|
2145 (ebnf-syntax . 'iso-ebnf))
|
|
2146 ;; Yacc/Bison default
|
|
2147 (yacc
|
|
2148 default
|
|
2149 (ebnf-syntax . 'yacc))
|
|
2150 )
|
|
2151 "Style database.
|
|
2152
|
|
2153 Each element has the following form:
|
|
2154
|
|
2155 (CUSTOM INHERITS (VAR . VALUE)...)
|
|
2156
|
|
2157 CUSTOM is a symbol name style.
|
|
2158 INHERITS is a symbol name style from which the current style inherits the
|
|
2159 context. If INHERITS is nil, means that there is no inheritance.
|
|
2160 VAR is a valid ebnf2ps symbol custom variable. See `ebnf-style-custom-list' for
|
|
2161 valid symbol variable.
|
|
2162 VALUE is a sexp which it'll be evaluated to set the value to VAR. So, don't
|
|
2163 forget to quote symbols and constant lists. See `default' style for an
|
|
2164 example.
|
|
2165
|
|
2166 Don't handle this variable directly. Use functions `ebnf-insert-style' and
|
|
2167 `ebnf-merge-style'.")
|
|
2168
|
|
2169
|
|
2170 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
2171 ;; Style commands
|
|
2172
|
|
2173
|
|
2174 ;;;###autoload
|
|
2175 (defun ebnf-insert-style (name inherits &rest values)
|
|
2176 "Insert a new style NAME with inheritance INHERITS and values VALUES."
|
|
2177 (interactive)
|
|
2178 (and (assoc name ebnf-style-database)
|
|
2179 (error "Style name already exists: %s" name))
|
|
2180 (or (assoc inherits ebnf-style-database)
|
|
2181 (error "Style inheritance name does'nt exist: %s" inherits))
|
|
2182 (setq ebnf-style-database
|
|
2183 (cons (cons name (cons inherits (ebnf-check-style-values values)))
|
|
2184 ebnf-style-database)))
|
|
2185
|
|
2186
|
|
2187 ;;;###autoload
|
|
2188 (defun ebnf-merge-style (name &rest values)
|
|
2189 "Merge values of style NAME with style VALUES."
|
|
2190 (interactive)
|
|
2191 (let ((style (or (assoc name ebnf-style-database)
|
|
2192 (error "Style name does'nt exist: %s" name)))
|
|
2193 (merge (ebnf-check-style-values values))
|
|
2194 val elt new check)
|
|
2195 ;; modify value of existing variables
|
|
2196 (setq val (nthcdr 2 style))
|
|
2197 (while merge
|
|
2198 (setq check (car merge)
|
|
2199 merge (cdr merge)
|
|
2200 elt (assoc (car check) val))
|
|
2201 (if elt
|
|
2202 (setcdr elt (cdr check))
|
|
2203 (setq new (cons check new))))
|
|
2204 ;; insert new variables
|
|
2205 (nconc style (nreverse new))))
|
|
2206
|
|
2207
|
|
2208 ;;;###autoload
|
|
2209 (defun ebnf-apply-style (style)
|
|
2210 "Set STYLE to current style.
|
|
2211
|
|
2212 It returns the old style symbol."
|
|
2213 (interactive)
|
|
2214 (prog1
|
|
2215 ebnf-current-style
|
|
2216 (and (ebnf-apply-style1 style)
|
|
2217 (setq ebnf-current-style style))))
|
|
2218
|
|
2219
|
|
2220 ;;;###autoload
|
|
2221 (defun ebnf-reset-style (&optional style)
|
|
2222 "Reset current style.
|
|
2223
|
|
2224 It returns the old style symbol."
|
|
2225 (interactive)
|
|
2226 (setq ebnf-stack-style nil)
|
|
2227 (ebnf-apply-style (or style 'default)))
|
|
2228
|
|
2229
|
|
2230 ;;;###autoload
|
|
2231 (defun ebnf-push-style (&optional style)
|
|
2232 "Push the current style and set STYLE to current style.
|
|
2233
|
|
2234 It returns the old style symbol."
|
|
2235 (interactive)
|
|
2236 (prog1
|
|
2237 ebnf-current-style
|
|
2238 (setq ebnf-stack-style (cons ebnf-current-style ebnf-stack-style))
|
|
2239 (and style
|
|
2240 (ebnf-apply-style style))))
|
|
2241
|
|
2242
|
|
2243 ;;;###autoload
|
|
2244 (defun ebnf-pop-style ()
|
|
2245 "Pop a style and set it to current style.
|
|
2246
|
|
2247 It returns the old style symbol."
|
|
2248 (interactive)
|
|
2249 (prog1
|
|
2250 (ebnf-apply-style (car ebnf-stack-style))
|
|
2251 (setq ebnf-stack-style (cdr ebnf-stack-style))))
|
|
2252
|
|
2253
|
|
2254 (defun ebnf-apply-style1 (style)
|
|
2255 (let ((value (cdr (assoc style ebnf-style-database))))
|
|
2256 (prog1
|
|
2257 value
|
|
2258 (and (car value) (ebnf-apply-style1 (car value)))
|
|
2259 (while (setq value (cdr value))
|
|
2260 (set (caar value) (eval (cdar value)))))))
|
|
2261
|
|
2262
|
|
2263 (defun ebnf-check-style-values (values)
|
|
2264 (let (style)
|
|
2265 (while values
|
|
2266 (and (memq (car values) ebnf-style-custom-list)
|
|
2267 (setq style (cons (car values) style)))
|
|
2268 (setq values (cdr values)))
|
|
2269 (nreverse style)))
|
|
2270
|
|
2271
|
|
2272 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
2273 ;; Internal variables
|
|
2274
|
|
2275
|
|
2276 (make-local-hook 'ebnf-hook)
|
|
2277 (make-local-hook 'ebnf-production-hook)
|
|
2278 (make-local-hook 'ebnf-page-hook)
|
|
2279
|
|
2280
|
|
2281 (defvar ebnf-eps-buffer-name " *EPS*")
|
|
2282 (defvar ebnf-parser-func nil)
|
|
2283 (defvar ebnf-eps-executing nil)
|
|
2284 (defvar ebnf-eps-upper-x 0.0)
|
|
2285 (make-variable-buffer-local 'ebnf-eps-upper-x)
|
|
2286 (defvar ebnf-eps-upper-y 0.0)
|
|
2287 (make-variable-buffer-local 'ebnf-eps-upper-y)
|
|
2288 (defvar ebnf-eps-prod-width 0.0)
|
|
2289 (make-variable-buffer-local 'ebnf-eps-prod-width)
|
|
2290 (defvar ebnf-eps-max-height 0.0)
|
|
2291 (make-variable-buffer-local 'ebnf-eps-max-height)
|
|
2292 (defvar ebnf-eps-max-width 0.0)
|
|
2293 (make-variable-buffer-local 'ebnf-eps-max-width)
|
|
2294
|
|
2295
|
|
2296 (defvar ebnf-eps-context nil
|
|
2297 "List of EPS file name during parsing.
|
|
2298
|
|
2299 See section \"Actions in Comments\" in ebnf2ps documentation.")
|
|
2300
|
|
2301
|
|
2302 (defvar ebnf-eps-production-list nil
|
|
2303 "Alist associating production name with EPS file name list.
|
|
2304
|
|
2305 Each element has the following form:
|
|
2306
|
|
2307 (PRODUCTION EPS-FILENAME...)
|
|
2308
|
|
2309 PRODUCTION is the production name.
|
|
2310 EPS-FILENAME is the EPS file name.
|
|
2311
|
|
2312 It's generated during parsing and used during EPS generation.
|
|
2313
|
|
2314 See `ebnf-eps-context' and section \"Actions in Comments\" in ebnf2ps
|
|
2315 documentation.")
|
|
2316
|
|
2317
|
|
2318 (defconst ebnf-arrow-shape-alist
|
|
2319 '((none . 0)
|
|
2320 (semi-up . 1)
|
|
2321 (semi-down . 2)
|
|
2322 (simple . 3)
|
|
2323 (transparent . 4)
|
|
2324 (hollow . 5)
|
|
2325 (full . 6)
|
|
2326 (user . 7))
|
|
2327 "Alist associating values for `ebnf-arrow-shape'.
|
|
2328
|
|
2329 See documentation for `ebnf-arrow-shape'.")
|
|
2330
|
|
2331
|
|
2332 (defconst ebnf-terminal-shape-alist
|
|
2333 '((miter . 0)
|
|
2334 (round . 1)
|
|
2335 (bevel . 2))
|
|
2336 "Alist associating values from `ebnf-terminal-shape' to a bit vector.
|
|
2337
|
|
2338 See documentation for `ebnf-terminal-shape', `ebnf-non-terminal-shape' and
|
|
2339 `ebnf-chart-shape'.")
|
|
2340
|
|
2341
|
|
2342 (defvar ebnf-limit nil)
|
|
2343 (defvar ebnf-action nil)
|
|
2344 (defvar ebnf-action-list nil)
|
|
2345
|
|
2346
|
|
2347 (defvar ebnf-default-p nil)
|
|
2348
|
|
2349
|
|
2350 (defvar ebnf-font-height-P 0)
|
|
2351 (defvar ebnf-font-height-T 0)
|
|
2352 (defvar ebnf-font-height-NT 0)
|
|
2353 (defvar ebnf-font-height-S 0)
|
|
2354 (defvar ebnf-font-height-E 0)
|
|
2355 (defvar ebnf-font-height-R 0)
|
|
2356 (defvar ebnf-font-width-P 0)
|
|
2357 (defvar ebnf-font-width-T 0)
|
|
2358 (defvar ebnf-font-width-NT 0)
|
|
2359 (defvar ebnf-font-width-S 0)
|
|
2360 (defvar ebnf-font-width-E 0)
|
|
2361 (defvar ebnf-font-width-R 0)
|
|
2362 (defvar ebnf-space-T 0)
|
|
2363 (defvar ebnf-space-NT 0)
|
|
2364 (defvar ebnf-space-S 0)
|
|
2365 (defvar ebnf-space-E 0)
|
|
2366 (defvar ebnf-space-R 0)
|
|
2367
|
|
2368
|
|
2369 (defvar ebnf-basic-width 0)
|
|
2370 (defvar ebnf-basic-height 0)
|
|
2371 (defvar ebnf-vertical-space 0)
|
|
2372 (defvar ebnf-horizontal-space 0)
|
|
2373
|
|
2374
|
|
2375 (defvar ebnf-settings nil)
|
|
2376 (defvar ebnf-fonts-required nil)
|
|
2377
|
|
2378
|
|
2379 (defconst ebnf-debug
|
|
2380 "
|
|
2381 % === begin EBNF procedures to help debugging
|
|
2382
|
|
2383 % Mark visually current point: string debug
|
|
2384 /debug
|
|
2385 {/-s- exch def
|
|
2386 currentpoint
|
|
2387 gsave -s- show grestore
|
|
2388 gsave
|
|
2389 20 20 rlineto
|
|
2390 0 -40 rlineto
|
|
2391 -40 40 rlineto
|
|
2392 0 -40 rlineto
|
|
2393 20 20 rlineto
|
|
2394 stroke
|
|
2395 grestore
|
|
2396 moveto
|
|
2397 }def
|
|
2398
|
|
2399 % Show number value: number string debug-number
|
|
2400 /debug-number
|
|
2401 {gsave
|
|
2402 20 0 rmoveto show ([) show 60 string cvs show (]) show
|
|
2403 grestore
|
|
2404 }def
|
|
2405
|
|
2406 % === end EBNF procedures to help debugging
|
|
2407
|
|
2408 "
|
|
2409 "This is intended to help debugging PostScript programming.")
|
|
2410
|
|
2411
|
|
2412 (defconst ebnf-prologue
|
|
2413 "
|
|
2414 % === begin EBNF engine
|
|
2415
|
|
2416 % --- Basic Definitions
|
|
2417
|
|
2418 /fS F
|
|
2419 /SpaceS FontHeight 0.5 mul def
|
|
2420 /HeightS FontHeight FontHeight add def
|
|
2421
|
|
2422 /fE F
|
|
2423 /SpaceE FontHeight 0.5 mul def
|
|
2424 /HeightE FontHeight FontHeight add def
|
|
2425
|
|
2426 /fR F
|
|
2427 /SpaceR FontHeight 0.5 mul def
|
|
2428 /HeightR FontHeight FontHeight add def
|
|
2429
|
|
2430 /fT F
|
|
2431 /SpaceT FontHeight 0.5 mul def
|
|
2432 /HeightT FontHeight FontHeight add def
|
|
2433
|
|
2434 /fNT F
|
|
2435 /SpaceNT FontHeight 0.5 mul def
|
|
2436 /HeightNT FontHeight FontHeight add def
|
|
2437
|
|
2438 /T HeightT HeightNT add 0.5 mul def
|
|
2439 /hT T 0.5 mul def
|
|
2440 /hT2 hT 0.5 mul def
|
|
2441 /hT4 hT 0.25 mul def
|
|
2442
|
|
2443 /Er 0.1 def % Error factor
|
|
2444
|
|
2445
|
|
2446 /c{currentpoint}bind def
|
|
2447 /xyi{/xi c /yi exch def def}bind def
|
|
2448 /xyo{/xo c /yo exch def def}bind def
|
|
2449 /xyp{/xp c /yp exch def def}bind def
|
|
2450 /xyt{/xt c /yt exch def def}bind def
|
|
2451
|
|
2452 % vertical movement: x y height vm
|
|
2453 /vm{add moveto}bind def
|
|
2454
|
|
2455 % horizontal movement: x y width hm
|
|
2456 /hm{3 -1 roll exch add exch moveto}bind def
|
|
2457
|
|
2458 % set color: [R G B] SetRGB
|
|
2459 /SetRGB{aload pop setrgbcolor}bind def
|
|
2460
|
|
2461 % filling gray area: gray-scale FillGray
|
|
2462 /FillGray{gsave setgray fill grestore}bind def
|
|
2463
|
|
2464 % filling color area: [R G B] FillRGB
|
|
2465 /FillRGB{gsave SetRGB fill grestore}bind def
|
|
2466
|
|
2467 /Stroke{LineWidth setlinewidth LineColor SetRGB stroke}bind def
|
|
2468 /StrokeShape{borderwidth setlinewidth bordercolor SetRGB stroke}bind def
|
|
2469 /Gstroke{gsave Stroke grestore}bind def
|
|
2470
|
|
2471 % Empty Line: width EL
|
|
2472 /EL{0 rlineto Gstroke}bind def
|
|
2473
|
|
2474 % --- Arrows
|
|
2475
|
|
2476 /Down{hT2 neg hT4 neg rlineto}bind def
|
|
2477
|
|
2478 /Arrow
|
|
2479 {hT2 neg hT4 rmoveto
|
|
2480 hT2 hT4 neg rlineto
|
|
2481 Down
|
|
2482 }bind def
|
|
2483
|
|
2484 /ArrowPath{c newpath moveto Arrow closepath}bind def
|
|
2485
|
|
2486 %>Right Arrow: RA
|
|
2487 % \\
|
|
2488 % *---+
|
|
2489 % /
|
|
2490 /RA-vector
|
|
2491 [{} % 0 - none
|
|
2492 {hT2 neg hT4 rlineto} % 1 - semi-up
|
|
2493 {Down} % 2 - semi-down
|
|
2494 {Arrow} % 3 - simple
|
|
2495 {Gstroke ArrowPath} % 4 - transparent
|
|
2496 {Gstroke ArrowPath 1 FillGray} % 5 - hollow
|
|
2497 {Gstroke ArrowPath LineColor FillRGB} % 6 - full
|
|
2498 {Gstroke gsave UserArrow grestore} % 7 - user
|
|
2499 ]def
|
|
2500
|
|
2501 /RA
|
|
2502 {hT 0 rlineto
|
|
2503 c
|
|
2504 RA-vector ArrowShape get exec
|
|
2505 Gstroke
|
|
2506 moveto
|
|
2507 }def
|
|
2508
|
|
2509 % rotation DrawArrow
|
|
2510 /DrawArrow
|
|
2511 {gsave
|
|
2512 0 0 translate
|
|
2513 rotate
|
|
2514 RA
|
|
2515 c
|
|
2516 grestore
|
|
2517 rmoveto
|
|
2518 }def
|
|
2519
|
|
2520 %>Left Arrow: LA
|
|
2521 % /
|
|
2522 % +---*
|
|
2523 % \\
|
|
2524 /LA{180 DrawArrow}def
|
|
2525
|
|
2526 %>Up Arrow: UA
|
|
2527 % +
|
|
2528 % /|\\
|
|
2529 % |
|
|
2530 % *
|
|
2531 /UA{90 DrawArrow}def
|
|
2532
|
|
2533 %>Down Arrow: DA
|
|
2534 % *
|
|
2535 % |
|
|
2536 % \\|/
|
|
2537 % +
|
|
2538 /DA{270 DrawArrow}def
|
|
2539
|
|
2540 % --- Corners
|
|
2541
|
|
2542 %>corner Right Descendent: height arrow corner_RD
|
|
2543 % _ | arrow
|
|
2544 % / height > 0 | 0 - none
|
|
2545 % | | 1 - right
|
|
2546 % * ---------- | 2 - left
|
|
2547 % | | 3 - vertical
|
|
2548 % \\ height < 0 |
|
|
2549 % - |
|
|
2550 /cRD0-vector
|
|
2551 [% 0 - none
|
|
2552 {0 h rlineto
|
|
2553 hT 0 rlineto}
|
|
2554 % 1 - right
|
|
2555 {0 h rlineto
|
|
2556 RA}
|
|
2557 % 2 - left
|
|
2558 {hT 0 rmoveto xyi
|
|
2559 LA
|
|
2560 0 h neg rlineto
|
|
2561 xi yi moveto}
|
|
2562 % 3 - vertical
|
|
2563 {hT h rmoveto xyi
|
|
2564 hT neg 0 rlineto
|
|
2565 h 0 gt{DA}{UA}ifelse
|
|
2566 xi yi moveto}
|
|
2567 ]def
|
|
2568
|
|
2569 /cRD-vector
|
|
2570 [{cRD0-vector arrow get exec} % 0 - miter
|
|
2571 {0 0 0 h hT h rcurveto} % 1 - rounded
|
|
2572 {hT h rlineto} % 2 - bevel
|
|
2573 ]def
|
|
2574
|
|
2575 /corner_RD
|
|
2576 {/arrow exch def /h exch def
|
|
2577 cRD-vector ChartShape get exec
|
|
2578 Gstroke
|
|
2579 }def
|
|
2580
|
|
2581 %>corner Right Ascendent: height arrow corner_RA
|
|
2582 % | arrow
|
|
2583 % | height > 0 | 0 - none
|
|
2584 % / | 1 - right
|
|
2585 % *- ---------- | 2 - left
|
|
2586 % \\ | 3 - vertical
|
|
2587 % | height < 0 |
|
|
2588 % |
|
|
2589 /cRA0-vector
|
|
2590 [% 0 - none
|
|
2591 {hT 0 rlineto
|
|
2592 0 h rlineto}
|
|
2593 % 1 - right
|
|
2594 {RA
|
|
2595 0 h rlineto}
|
|
2596 % 2 - left
|
|
2597 {hT h rmoveto xyi
|
|
2598 0 h neg rlineto
|
|
2599 LA
|
|
2600 xi yi moveto}
|
|
2601 % 3 - vertical
|
|
2602 {hT h rmoveto xyi
|
|
2603 h 0 gt{DA}{UA}ifelse
|
|
2604 hT neg 0 rlineto
|
|
2605 xi yi moveto}
|
|
2606 ]def
|
|
2607
|
|
2608 /cRA-vector
|
|
2609 [{cRA0-vector arrow get exec} % 0 - miter
|
|
2610 {0 0 hT 0 hT h rcurveto} % 1 - rounded
|
|
2611 {hT h rlineto} % 2 - bevel
|
|
2612 ]def
|
|
2613
|
|
2614 /corner_RA
|
|
2615 {/arrow exch def /h exch def
|
|
2616 cRA-vector ChartShape get exec
|
|
2617 Gstroke
|
|
2618 }def
|
|
2619
|
|
2620 %>corner Left Descendent: height arrow corner_LD
|
|
2621 % _ | arrow
|
|
2622 % \\ height > 0 | 0 - none
|
|
2623 % | | 1 - right
|
|
2624 % * ---------- | 2 - left
|
|
2625 % | | 3 - vertical
|
|
2626 % / height < 0 |
|
|
2627 % - |
|
|
2628 /cLD0-vector
|
|
2629 [% 0 - none
|
|
2630 {0 h rlineto
|
|
2631 hT neg 0 rlineto}
|
|
2632 % 1 - right
|
|
2633 {hT neg h rmoveto xyi
|
|
2634 RA
|
|
2635 0 h neg rlineto
|
|
2636 xi yi moveto}
|
|
2637 % 2 - left
|
|
2638 {0 h rlineto
|
|
2639 LA}
|
|
2640 % 3 - vertical
|
|
2641 {hT neg h rmoveto xyi
|
|
2642 hT 0 rlineto
|
|
2643 h 0 gt{DA}{UA}ifelse
|
|
2644 xi yi moveto}
|
|
2645 ]def
|
|
2646
|
|
2647 /cLD-vector
|
|
2648 [{cLD0-vector arrow get exec} % 0 - miter
|
|
2649 {0 0 0 h hT neg h rcurveto} % 1 - rounded
|
|
2650 {hT neg h rlineto} % 2 - bevel
|
|
2651 ]def
|
|
2652
|
|
2653 /corner_LD
|
|
2654 {/arrow exch def /h exch def
|
|
2655 cLD-vector ChartShape get exec
|
|
2656 Gstroke
|
|
2657 }def
|
|
2658
|
|
2659 %>corner Left Ascendent: height arrow corner_LA
|
|
2660 % | arrow
|
|
2661 % | height > 0 | 0 - none
|
|
2662 % \\ | 1 - right
|
|
2663 % -* ---------- | 2 - left
|
|
2664 % / | 3 - vertical
|
|
2665 % | height < 0 |
|
|
2666 % |
|
|
2667 /cLA0-vector
|
|
2668 [% 0 - none
|
|
2669 {hT neg 0 rlineto
|
|
2670 0 h rlineto}
|
|
2671 % 1 - right
|
|
2672 {hT neg h rmoveto xyi
|
|
2673 0 h neg rlineto
|
|
2674 RA
|
|
2675 xi yi moveto}
|
|
2676 % 2 - left
|
|
2677 {LA
|
|
2678 0 h rlineto}
|
|
2679 % 3 - vertical
|
|
2680 {hT neg h rmoveto xyi
|
|
2681 h 0 gt{DA}{UA}ifelse
|
|
2682 hT 0 rlineto
|
|
2683 xi yi moveto}
|
|
2684 ]def
|
|
2685
|
|
2686 /cLA-vector
|
|
2687 [{cLA0-vector arrow get exec} % 0 - miter
|
|
2688 {0 0 hT neg 0 hT neg h rcurveto} % 1 - rounded
|
|
2689 {hT neg h rlineto} % 2 - bevel
|
|
2690 ]def
|
|
2691
|
|
2692 /corner_LA
|
|
2693 {/arrow exch def /h exch def
|
|
2694 cLA-vector ChartShape get exec
|
|
2695 Gstroke
|
|
2696 }def
|
|
2697
|
|
2698 % --- Flow Stuff
|
|
2699
|
|
2700 % height prepare_height |- line_height corner_height corner_height
|
|
2701 /prepare_height
|
|
2702 {dup 0 gt
|
|
2703 {T sub hT}
|
|
2704 {T add hT neg}ifelse
|
|
2705 dup
|
|
2706 }def
|
|
2707
|
|
2708 %>Left Alternative: height LAlt
|
|
2709 % _
|
|
2710 % /
|
|
2711 % | height > 0
|
|
2712 % |
|
|
2713 % /
|
|
2714 % *- ----------
|
|
2715 % \\
|
|
2716 % |
|
|
2717 % | height < 0
|
|
2718 % \\
|
|
2719 % -
|
|
2720 /LAlt
|
|
2721 {dup 0 eq
|
|
2722 {T exch rlineto}
|
|
2723 {dup abs T lt
|
|
2724 {0.5 mul dup
|
|
2725 1 corner_RA
|
|
2726 0 corner_RD}
|
|
2727 {prepare_height
|
|
2728 1 corner_RA
|
|
2729 exch 0 exch rlineto
|
|
2730 0 corner_RD
|
|
2731 }ifelse
|
|
2732 }ifelse
|
|
2733 }def
|
|
2734
|
|
2735 %>Left Loop: height LLoop
|
|
2736 % _
|
|
2737 % /
|
|
2738 % | height > 0
|
|
2739 % |
|
|
2740 % \\
|
|
2741 % -* ----------
|
|
2742 % /
|
|
2743 % |
|
|
2744 % | height < 0
|
|
2745 % \\
|
|
2746 % -
|
|
2747 /LLoop
|
|
2748 {prepare_height
|
|
2749 3 corner_LA
|
|
2750 exch 0 exch rlineto
|
|
2751 0 corner_RD
|
|
2752 }def
|
|
2753
|
|
2754 %>Right Alternative: height RAlt
|
|
2755 % _
|
|
2756 % \\
|
|
2757 % | height > 0
|
|
2758 % |
|
|
2759 % \\
|
|
2760 % -* ----------
|
|
2761 % /
|
|
2762 % |
|
|
2763 % | height < 0
|
|
2764 % /
|
|
2765 % -
|
|
2766 /RAlt
|
|
2767 {dup 0 eq
|
|
2768 {T neg exch rlineto}
|
|
2769 {dup abs T lt
|
|
2770 {0.5 mul dup
|
|
2771 1 corner_LA
|
|
2772 0 corner_LD}
|
|
2773 {prepare_height
|
|
2774 1 corner_LA
|
|
2775 exch 0 exch rlineto
|
|
2776 0 corner_LD
|
|
2777 }ifelse
|
|
2778 }ifelse
|
|
2779 }def
|
|
2780
|
|
2781 %>Right Loop: height RLoop
|
|
2782 % _
|
|
2783 % \\
|
|
2784 % | height > 0
|
|
2785 % |
|
|
2786 % /
|
|
2787 % *- ----------
|
|
2788 % \\
|
|
2789 % |
|
|
2790 % | height < 0
|
|
2791 % /
|
|
2792 % -
|
|
2793 /RLoop
|
|
2794 {prepare_height
|
|
2795 1 corner_RA
|
|
2796 exch 0 exch rlineto
|
|
2797 0 corner_LD
|
|
2798 }def
|
|
2799
|
|
2800 % --- Terminal, Non-terminal and Special Basics
|
|
2801
|
|
2802 % string width prepare-width |- string
|
|
2803 /prepare-width
|
|
2804 {/width exch def
|
|
2805 dup stringwidth pop space add space add width exch sub 0.5 mul
|
|
2806 /w exch def
|
|
2807 }def
|
|
2808
|
|
2809 % string width begin-right
|
|
2810 /begin-right
|
|
2811 {xyo
|
|
2812 prepare-width
|
|
2813 w hT sub EL
|
|
2814 RA
|
|
2815 }def
|
|
2816
|
|
2817 % end-right
|
|
2818 /end-right
|
|
2819 {xo width add Er add yo moveto
|
|
2820 w Er add neg EL
|
|
2821 xo yo moveto
|
|
2822 }def
|
|
2823
|
|
2824 % string width begin-left
|
|
2825 /begin-left
|
|
2826 {xyo
|
|
2827 prepare-width
|
|
2828 w EL
|
|
2829 }def
|
|
2830
|
|
2831 % end-left
|
|
2832 /end-left
|
|
2833 {xo width add Er add yo moveto
|
|
2834 hT w sub Er add EL
|
|
2835 LA
|
|
2836 xo yo moveto
|
|
2837 }def
|
|
2838
|
|
2839 /ShapePath-vector
|
|
2840 [% 0 - miter
|
|
2841 {xx yy moveto
|
|
2842 xx YY lineto
|
|
2843 XX YY lineto
|
|
2844 XX yy lineto}
|
|
2845 % 1 - rounded
|
|
2846 {/half YY yy sub 0.5 mul abs def
|
|
2847 xx half add YY moveto
|
|
2848 0 0 half neg 0 half neg half neg rcurveto
|
|
2849 0 0 0 half neg half half neg rcurveto
|
|
2850 XX xx sub abs half sub half sub 0 rlineto
|
|
2851 0 0 half 0 half half rcurveto
|
|
2852 0 0 0 half half neg half rcurveto}
|
|
2853 % 2 - bevel
|
|
2854 {/quarter YY yy sub 0.25 mul abs def
|
|
2855 xx quarter add YY moveto
|
|
2856 quarter neg quarter neg rlineto
|
|
2857 0 quarter quarter add neg rlineto
|
|
2858 quarter quarter neg rlineto
|
|
2859 XX xx sub abs quarter sub quarter sub 0 rlineto
|
|
2860 quarter quarter rlineto
|
|
2861 0 quarter quarter add rlineto
|
|
2862 quarter neg quarter rlineto}
|
|
2863 ]def
|
|
2864
|
|
2865 /doShapePath
|
|
2866 {newpath
|
|
2867 ShapePath-vector shape get exec
|
|
2868 closepath
|
|
2869 }def
|
|
2870
|
|
2871 /doShapeShadow
|
|
2872 {gsave
|
|
2873 Xshadow Xshadow add Xshadow add
|
|
2874 Yshadow Yshadow add Yshadow add translate
|
|
2875 doShapePath
|
|
2876 0.9 FillGray
|
|
2877 grestore
|
|
2878 }def
|
|
2879
|
|
2880 /doShape
|
|
2881 {gsave
|
|
2882 doShapePath
|
|
2883 shapecolor FillRGB
|
|
2884 StrokeShape
|
|
2885 grestore
|
|
2886 }def
|
|
2887
|
|
2888 % string SBound |- string
|
|
2889 /SBound
|
|
2890 {/xx c dup /yy exch def
|
|
2891 FontHeight add /YY exch def def
|
|
2892 dup stringwidth pop xx add /XX exch def
|
|
2893 Effect 8 and 0 ne
|
|
2894 {/yy yy YShadow add def
|
|
2895 /XX XX XShadow add def
|
|
2896 }if
|
|
2897 }def
|
|
2898
|
|
2899 % string SBox
|
|
2900 /SBox
|
|
2901 {gsave
|
|
2902 c space sub moveto
|
|
2903 SBound
|
|
2904 /XX XX space add space add def
|
|
2905 /YY YY space add def
|
|
2906 /yy yy space sub def
|
|
2907 shadow{doShapeShadow}if
|
|
2908 doShape
|
|
2909 space Descent abs rmoveto
|
|
2910 foreground SetRGB S
|
|
2911 grestore
|
|
2912 }def
|
|
2913
|
|
2914 % --- Terminal
|
|
2915
|
|
2916 % TeRminal: string TR
|
|
2917 /TR
|
|
2918 {/Effect EffectT def
|
|
2919 /shape ShapeT def
|
|
2920 /shapecolor BackgroundT def
|
|
2921 /borderwidth BorderWidthT def
|
|
2922 /bordercolor BorderColorT def
|
|
2923 /foreground ForegroundT def
|
|
2924 /shadow ShadowT def
|
|
2925 SBox
|
|
2926 }def
|
|
2927
|
|
2928 %>Right Terminal: string width RT |- x y
|
|
2929 /RT
|
|
2930 {xyt
|
|
2931 /fT F
|
|
2932 /space SpaceT def
|
|
2933 begin-right
|
|
2934 TR
|
|
2935 end-right
|
|
2936 xt yt
|
|
2937 }def
|
|
2938
|
|
2939 %>Left Terminal: string width LT |- x y
|
|
2940 /LT
|
|
2941 {xyt
|
|
2942 /fT F
|
|
2943 /space SpaceT def
|
|
2944 begin-left
|
|
2945 TR
|
|
2946 end-left
|
|
2947 xt yt
|
|
2948 }def
|
|
2949
|
|
2950 %>Right Terminal Default: string width RTD |- x y
|
|
2951 /RTD
|
|
2952 {/-save- BorderWidthT def
|
|
2953 /BorderWidthT BorderWidthT DefaultWidth add def
|
|
2954 RT
|
|
2955 /BorderWidthT -save- def
|
|
2956 }def
|
|
2957
|
|
2958 %>Left Terminal Default: string width LTD |- x y
|
|
2959 /LTD
|
|
2960 {/-save- BorderWidthT def
|
|
2961 /BorderWidthT BorderWidthT DefaultWidth add def
|
|
2962 LT
|
|
2963 /BorderWidthT -save- def
|
|
2964 }def
|
|
2965
|
|
2966 % --- Non-Terminal
|
|
2967
|
|
2968 % Non-Terminal: string NT
|
|
2969 /NT
|
|
2970 {/Effect EffectNT def
|
|
2971 /shape ShapeNT def
|
|
2972 /shapecolor BackgroundNT def
|
|
2973 /borderwidth BorderWidthNT def
|
|
2974 /bordercolor BorderColorNT def
|
|
2975 /foreground ForegroundNT def
|
|
2976 /shadow ShadowNT def
|
|
2977 SBox
|
|
2978 }def
|
|
2979
|
|
2980 %>Right Non-Terminal: string width RNT |- x y
|
|
2981 /RNT
|
|
2982 {xyt
|
|
2983 /fNT F
|
|
2984 /space SpaceNT def
|
|
2985 begin-right
|
|
2986 NT
|
|
2987 end-right
|
|
2988 xt yt
|
|
2989 }def
|
|
2990
|
|
2991 %>Left Non-Terminal: string width LNT |- x y
|
|
2992 /LNT
|
|
2993 {xyt
|
|
2994 /fNT F
|
|
2995 /space SpaceNT def
|
|
2996 begin-left
|
|
2997 NT
|
|
2998 end-left
|
|
2999 xt yt
|
|
3000 }def
|
|
3001
|
|
3002 %>Right Non-Terminal Default: string width RNTD |- x y
|
|
3003 /RNTD
|
|
3004 {/-save- BorderWidthNT def
|
|
3005 /BorderWidthNT BorderWidthNT DefaultWidth add def
|
|
3006 RNT
|
|
3007 /BorderWidthNT -save- def
|
|
3008 }def
|
|
3009
|
|
3010 %>Left Non-Terminal Default: string width LNTD |- x y
|
|
3011 /LNTD
|
|
3012 {/-save- BorderWidthNT def
|
|
3013 /BorderWidthNT BorderWidthNT DefaultWidth add def
|
|
3014 LNT
|
|
3015 /BorderWidthNT -save- def
|
|
3016 }def
|
|
3017
|
|
3018 % --- Special
|
|
3019
|
|
3020 % SPecial: string SP
|
|
3021 /SP
|
|
3022 {/Effect EffectS def
|
|
3023 /shape ShapeS def
|
|
3024 /shapecolor BackgroundS def
|
|
3025 /borderwidth BorderWidthS def
|
|
3026 /bordercolor BorderColorS def
|
|
3027 /foreground ForegroundS def
|
|
3028 /shadow ShadowS def
|
|
3029 SBox
|
|
3030 }def
|
|
3031
|
|
3032 %>Right SPecial: string width RSP |- x y
|
|
3033 /RSP
|
|
3034 {xyt
|
|
3035 /fS F
|
|
3036 /space SpaceS def
|
|
3037 begin-right
|
|
3038 SP
|
|
3039 end-right
|
|
3040 xt yt
|
|
3041 }def
|
|
3042
|
|
3043 %>Left SPecial: string width LSP |- x y
|
|
3044 /LSP
|
|
3045 {xyt
|
|
3046 /fS F
|
|
3047 /space SpaceS def
|
|
3048 begin-left
|
|
3049 SP
|
|
3050 end-left
|
|
3051 xt yt
|
|
3052 }def
|
|
3053
|
|
3054 %>Right SPecial Default: string width RSPD |- x y
|
|
3055 /RSPD
|
|
3056 {/-save- BorderWidthS def
|
|
3057 /BorderWidthS BorderWidthS DefaultWidth add def
|
|
3058 RSP
|
|
3059 /BorderWidthS -save- def
|
|
3060 }def
|
|
3061
|
|
3062 %>Left SPecial Default: string width LSPD |- x y
|
|
3063 /LSPD
|
|
3064 {/-save- BorderWidthS def
|
|
3065 /BorderWidthS BorderWidthS DefaultWidth add def
|
|
3066 LSP
|
|
3067 /BorderWidthS -save- def
|
|
3068 }def
|
|
3069
|
|
3070 % --- Repeat and Except basics
|
|
3071
|
|
3072 /begin-direction
|
|
3073 {/w width rwidth sub 0.5 mul def
|
|
3074 width 0 rmoveto}def
|
|
3075
|
|
3076 /end-direction
|
|
3077 {gsave
|
|
3078 /xx c entry add /YY exch def def
|
|
3079 /yy YY height sub def
|
|
3080 /XX xx rwidth add def
|
|
3081 shadow{doShapeShadow}if
|
|
3082 doShape
|
|
3083 grestore
|
|
3084 }def
|
|
3085
|
|
3086 /right-direction
|
|
3087 {begin-direction
|
|
3088 w neg EL
|
|
3089 xt yt moveto
|
|
3090 w hT sub EL RA
|
|
3091 end-direction
|
|
3092 }def
|
|
3093
|
|
3094 /left-direction
|
|
3095 {begin-direction
|
|
3096 hT w sub EL LA
|
|
3097 xt yt moveto
|
|
3098 w EL
|
|
3099 end-direction
|
|
3100 }def
|
|
3101
|
|
3102 % --- Repeat
|
|
3103
|
|
3104 % entry height width rwidth begin-repeat
|
|
3105 /begin-repeat
|
|
3106 {/rwidth exch def
|
|
3107 /width exch def
|
|
3108 /height exch def
|
|
3109 /entry exch def
|
|
3110 /fR F
|
|
3111 /space SpaceR def
|
|
3112 /Effect EffectR def
|
|
3113 /shape ShapeR def
|
|
3114 /shapecolor BackgroundR def
|
|
3115 /borderwidth BorderWidthR def
|
|
3116 /bordercolor BorderColorR def
|
|
3117 /foreground ForegroundR def
|
|
3118 /shadow ShadowR def
|
|
3119 xyt
|
|
3120 }def
|
|
3121
|
|
3122 % string end-repeat |- x y
|
|
3123 /end-repeat
|
|
3124 {gsave
|
|
3125 space Descent rmoveto
|
|
3126 foreground SetRGB S
|
|
3127 c Descent sub
|
|
3128 grestore
|
|
3129 exch space add exch moveto
|
|
3130 xt yt
|
|
3131 }def
|
|
3132
|
|
3133 %>Right RePeat: string entry height width rwidth RRP |- x y
|
|
3134 /RRP{begin-repeat right-direction end-repeat}def
|
|
3135
|
|
3136 %>Left RePeat: string entry height width rwidth LRP |- x y
|
|
3137 /LRP{begin-repeat left-direction end-repeat}def
|
|
3138
|
|
3139 % --- Except
|
|
3140
|
|
3141 % entry height width rwidth begin-except
|
|
3142 /begin-except
|
|
3143 {/rwidth exch def
|
|
3144 /width exch def
|
|
3145 /height exch def
|
|
3146 /entry exch def
|
|
3147 /fE F
|
|
3148 /space SpaceE def
|
|
3149 /Effect EffectE def
|
|
3150 /shape ShapeE def
|
|
3151 /shapecolor BackgroundE def
|
|
3152 /borderwidth BorderWidthE def
|
|
3153 /bordercolor BorderColorE def
|
|
3154 /foreground ForegroundE def
|
|
3155 /shadow ShadowE def
|
|
3156 xyt
|
|
3157 }def
|
|
3158
|
|
3159 % x-width end-except |- x y
|
|
3160 /end-except
|
|
3161 {gsave
|
|
3162 space space add add Descent rmoveto
|
|
3163 (-) foreground SetRGB S
|
|
3164 grestore
|
|
3165 space 0 rmoveto
|
|
3166 xt yt
|
|
3167 }def
|
|
3168
|
|
3169 %>Right EXcept: x-width entry height width rwidth REX |- x y
|
|
3170 /REX{begin-except right-direction end-except}def
|
|
3171
|
|
3172 %>Left EXcept: x-width entry height width rwidth LEX |- x y
|
|
3173 /LEX{begin-except left-direction end-except}def
|
|
3174
|
|
3175 % --- Sequence
|
|
3176
|
|
3177 %>Beginning Of Sequence: BOS |- x y
|
|
3178 /BOS{currentpoint}bind def
|
|
3179
|
|
3180 %>End Of Sequence: x y x1 y1 EOS |- x y
|
|
3181 /EOS{pop pop}bind def
|
|
3182
|
|
3183 % --- Production
|
|
3184
|
|
3185 %>Beginning Of Production: string width height BOP |- y x
|
|
3186 /BOP
|
|
3187 {xyp
|
|
3188 neg yp add /yw exch def
|
|
3189 xp add T sub /xw exch def
|
|
3190 /Effect EffectP def
|
|
3191 /fP F ForegroundP SetRGB BackgroundP aload pop true BG S
|
|
3192 /Effect 0 def
|
|
3193 ( :) S false BG
|
|
3194 xw yw moveto
|
|
3195 hT EL RA
|
|
3196 xp yw moveto
|
|
3197 T EL
|
|
3198 yp xp
|
|
3199 }def
|
|
3200
|
|
3201 %>End Of Production: y x delta EOP
|
|
3202 /EOPH{add exch moveto}bind def % horizontal
|
|
3203 /EOPV{exch pop sub 0 exch moveto}bind def % vertical
|
|
3204
|
|
3205 % --- Empty Alternative
|
|
3206
|
|
3207 %>Empty Alternative: width EA |- x y
|
|
3208 /EA
|
|
3209 {gsave
|
|
3210 Er add 0 rlineto
|
|
3211 Stroke
|
|
3212 grestore
|
|
3213 c
|
|
3214 }def
|
|
3215
|
|
3216 % --- Alternative
|
|
3217
|
|
3218 %>AlTernative: h1 h2 ... hn n width AT |- x y
|
|
3219 /AT
|
|
3220 {xyo xo add /xw exch def
|
|
3221 xw yo moveto
|
|
3222 Er EL
|
|
3223 {xw yo moveto
|
|
3224 dup RAlt
|
|
3225 xo yo moveto
|
|
3226 LAlt}repeat
|
|
3227 xo yo
|
|
3228 }def
|
|
3229
|
|
3230 % --- Optional
|
|
3231
|
|
3232 %>OPtional: height width OP |- x y
|
|
3233 /OP
|
|
3234 {xyo
|
|
3235 T sub /ow exch def
|
|
3236 ow Er sub 0 rmoveto
|
|
3237 T Er add EL
|
|
3238 neg dup RAlt
|
|
3239 ow T sub neg EL
|
|
3240 xo yo moveto
|
|
3241 LAlt
|
|
3242 xo yo moveto
|
|
3243 T EL
|
|
3244 xo yo
|
|
3245 }def
|
|
3246
|
|
3247 % --- List Flow
|
|
3248
|
|
3249 %>One or More: height width OM |- x y
|
|
3250 /OM
|
|
3251 {xyo
|
|
3252 /ow exch def
|
|
3253 ow Er add 0 rmoveto
|
|
3254 T Er add neg EL
|
|
3255 dup RLoop
|
|
3256 xo T add yo moveto
|
|
3257 LLoop
|
|
3258 xo yo moveto
|
|
3259 T EL
|
|
3260 xo yo
|
|
3261 }def
|
|
3262
|
|
3263 %>Zero or More: h2 h1 width ZM |- x y
|
|
3264 /ZM
|
|
3265 {xyo
|
|
3266 Er add EL
|
|
3267 Er neg 0 rmoveto
|
|
3268 dup RAlt
|
|
3269 exch dup RLoop
|
|
3270 xo yo moveto
|
|
3271 exch dup LAlt
|
|
3272 exch LLoop
|
|
3273 yo add xo T add exch moveto
|
|
3274 xo yo
|
|
3275 }def
|
|
3276
|
|
3277 % === end EBNF engine
|
|
3278
|
|
3279 "
|
|
3280 "EBNF PostScript prologue")
|
|
3281
|
|
3282
|
|
3283 (defconst ebnf-eps-prologue
|
|
3284 "
|
|
3285 /#ebnf2ps#dict 230 dict def
|
|
3286 #ebnf2ps#dict begin
|
|
3287
|
|
3288 % Initiliaze variables to avoid name-conflicting with document variables.
|
|
3289 % This is the case when using `bind' operator.
|
|
3290 /-fillp- 0 def /h 0 def
|
|
3291 /-ox- 0 def /half 0 def
|
|
3292 /-oy- 0 def /height 0 def
|
|
3293 /-save- 0 def /ow 0 def
|
|
3294 /Ascent 0 def /quarter 0 def
|
|
3295 /Descent 0 def /rXX 0 def
|
|
3296 /Effect 0 def /rYY 0 def
|
|
3297 /FontHeight 0 def /rwidth 0 def
|
|
3298 /LineThickness 0 def /rxx 0 def
|
|
3299 /OverlinePosition 0 def /ryy 0 def
|
|
3300 /SpaceBackground 0 def /shadow 0 def
|
|
3301 /StrikeoutPosition 0 def /shape 0 def
|
|
3302 /UnderlinePosition 0 def /shapecolor 0 def
|
|
3303 /XBox 0 def /space 0 def
|
|
3304 /XX 0 def /st 1 string def
|
|
3305 /Xshadow 0 def /w 0 def
|
|
3306 /YBox 0 def /width 0 def
|
|
3307 /YY 0 def /xi 0 def
|
|
3308 /Yshadow 0 def /xo 0 def
|
|
3309 /arrow 0 def /xp 0 def
|
|
3310 /bg false def /xt 0 def
|
|
3311 /bgcolor 0 def /xw 0 def
|
|
3312 /bordercolor 0 def /xx 0 def
|
|
3313 /borderwidth 0 def /yi 0 def
|
|
3314 /dd 0 def /yo 0 def
|
|
3315 /entry 0 def /yp 0 def
|
|
3316 /foreground 0 def /yt 0 def
|
|
3317 /yy 0 def
|
|
3318
|
|
3319
|
|
3320 % ISOLatin1Encoding stolen from ps_init.ps in GhostScript 2.6.1.4:
|
|
3321 /ISOLatin1Encoding where
|
|
3322 {pop}
|
|
3323 {% -- The ISO Latin-1 encoding vector isn't known, so define it.
|
|
3324 % -- The first half is the same as the standard encoding,
|
|
3325 % -- except for minus instead of hyphen at code 055.
|
|
3326 /ISOLatin1Encoding
|
|
3327 StandardEncoding 0 45 getinterval aload pop
|
|
3328 /minus
|
|
3329 StandardEncoding 46 82 getinterval aload pop
|
|
3330 %*** NOTE: the following are missing in the Adobe documentation,
|
|
3331 %*** but appear in the displayed table:
|
|
3332 %*** macron at 0225, dieresis at 0230, cedilla at 0233, space at 0240.
|
|
3333 % 0200 (128)
|
|
3334 /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
|
|
3335 /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef /.notdef
|
|
3336 /dotlessi /grave /acute /circumflex /tilde /macron /breve /dotaccent
|
|
3337 /dieresis /.notdef /ring /cedilla /.notdef /hungarumlaut /ogonek /caron
|
|
3338 % 0240 (160)
|
|
3339 /space /exclamdown /cent /sterling
|
|
3340 /currency /yen /brokenbar /section
|
|
3341 /dieresis /copyright /ordfeminine /guillemotleft
|
|
3342 /logicalnot /hyphen /registered /macron
|
|
3343 /degree /plusminus /twosuperior /threesuperior
|
|
3344 /acute /mu /paragraph /periodcentered
|
|
3345 /cedilla /onesuperior /ordmasculine /guillemotright
|
|
3346 /onequarter /onehalf /threequarters /questiondown
|
|
3347 % 0300 (192)
|
|
3348 /Agrave /Aacute /Acircumflex /Atilde
|
|
3349 /Adieresis /Aring /AE /Ccedilla
|
|
3350 /Egrave /Eacute /Ecircumflex /Edieresis
|
|
3351 /Igrave /Iacute /Icircumflex /Idieresis
|
|
3352 /Eth /Ntilde /Ograve /Oacute
|
|
3353 /Ocircumflex /Otilde /Odieresis /multiply
|
|
3354 /Oslash /Ugrave /Uacute /Ucircumflex
|
|
3355 /Udieresis /Yacute /Thorn /germandbls
|
|
3356 % 0340 (224)
|
|
3357 /agrave /aacute /acircumflex /atilde
|
|
3358 /adieresis /aring /ae /ccedilla
|
|
3359 /egrave /eacute /ecircumflex /edieresis
|
|
3360 /igrave /iacute /icircumflex /idieresis
|
|
3361 /eth /ntilde /ograve /oacute
|
|
3362 /ocircumflex /otilde /odieresis /divide
|
|
3363 /oslash /ugrave /uacute /ucircumflex
|
|
3364 /udieresis /yacute /thorn /ydieresis
|
|
3365 256 packedarray def
|
|
3366 }ifelse
|
|
3367
|
|
3368 /reencodeFontISO %def
|
|
3369 {dup
|
|
3370 length 12 add dict % Make a new font (a new dict the same size
|
|
3371 % as the old one) with room for our new symbols.
|
|
3372
|
|
3373 begin % Make the new font the current dictionary.
|
|
3374 {1 index /FID ne
|
|
3375 {def}{pop pop}ifelse
|
|
3376 }forall % Copy each of the symbols from the old dictionary
|
|
3377 % to the new one except for the font ID.
|
|
3378
|
|
3379 currentdict /FontType get 0 ne
|
|
3380 {/Encoding ISOLatin1Encoding def}if % Override the encoding with
|
|
3381 % the ISOLatin1 encoding.
|
|
3382
|
|
3383 % Use the font's bounding box to determine the ascent, descent,
|
|
3384 % and overall height; don't forget that these values have to be
|
|
3385 % transformed using the font's matrix.
|
|
3386
|
|
3387 % ^ (x2 y2)
|
|
3388 % | |
|
|
3389 % | v
|
|
3390 % | +----+ - -
|
|
3391 % | | | ^
|
|
3392 % | | | | Ascent (usually > 0)
|
|
3393 % | | | |
|
|
3394 % (0 0) -> +--+----+-------->
|
|
3395 % | | |
|
|
3396 % | | v Descent (usually < 0)
|
|
3397 % (x1 y1) --> +----+ - -
|
|
3398
|
|
3399 currentdict /FontType get 0 ne
|
|
3400 {/FontBBox load aload pop % -- x1 y1 x2 y2
|
|
3401 FontMatrix transform /Ascent exch def pop
|
|
3402 FontMatrix transform /Descent exch def pop}
|
|
3403 {/PrimaryFont FDepVector 0 get def
|
|
3404 PrimaryFont /FontBBox get aload pop
|
|
3405 PrimaryFont /FontMatrix get transform /Ascent exch def pop
|
|
3406 PrimaryFont /FontMatrix get transform /Descent exch def pop
|
|
3407 }ifelse
|
|
3408
|
|
3409 /FontHeight Ascent Descent sub def % use `sub' because descent < 0
|
|
3410
|
|
3411 % Define these in case they're not in the FontInfo
|
|
3412 % (also, here they're easier to get to).
|
|
3413 /UnderlinePosition Descent 0.70 mul def
|
|
3414 /OverlinePosition Descent UnderlinePosition sub Ascent add def
|
|
3415 /StrikeoutPosition Ascent 0.30 mul def
|
|
3416 /LineThickness FontHeight 0.05 mul def
|
|
3417 /Xshadow FontHeight 0.08 mul def
|
|
3418 /Yshadow FontHeight -0.09 mul def
|
|
3419 /SpaceBackground Descent neg UnderlinePosition add def
|
|
3420 /XBox Descent neg def
|
|
3421 /YBox LineThickness 0.7 mul def
|
|
3422
|
|
3423 currentdict % Leave the new font on the stack
|
|
3424 end % Stop using the font as the current dictionary
|
|
3425 definefont % Put the font into the font dictionary
|
|
3426 pop % Discard the returned font
|
|
3427 }bind def
|
|
3428
|
|
3429 % Font definition
|
|
3430 /DefFont{findfont exch scalefont reencodeFontISO}def
|
|
3431
|
|
3432 % Font selection
|
|
3433 /F
|
|
3434 {findfont
|
|
3435 dup /Ascent get /Ascent exch def
|
|
3436 dup /Descent get /Descent exch def
|
|
3437 dup /FontHeight get /FontHeight exch def
|
|
3438 dup /UnderlinePosition get /UnderlinePosition exch def
|
|
3439 dup /OverlinePosition get /OverlinePosition exch def
|
|
3440 dup /StrikeoutPosition get /StrikeoutPosition exch def
|
|
3441 dup /LineThickness get /LineThickness exch def
|
|
3442 dup /Xshadow get /Xshadow exch def
|
|
3443 dup /Yshadow get /Yshadow exch def
|
|
3444 dup /SpaceBackground get /SpaceBackground exch def
|
|
3445 dup /XBox get /XBox exch def
|
|
3446 dup /YBox get /YBox exch def
|
|
3447 setfont
|
|
3448 }def
|
|
3449
|
|
3450 /BG
|
|
3451 {dup /bg exch def
|
|
3452 {mark 4 1 roll ]}
|
|
3453 {[ 1.0 1.0 1.0 ]}
|
|
3454 ifelse
|
|
3455 /bgcolor exch def
|
|
3456 }def
|
|
3457
|
|
3458 % stack: --
|
|
3459 /FillBgColor{bgcolor aload pop setrgbcolor fill}bind def
|
|
3460
|
|
3461 % stack: fill-or-not lower-x lower-y upper-x upper-y |- --
|
|
3462 /doRect
|
|
3463 {/rYY exch def
|
|
3464 /rXX exch def
|
|
3465 /ryy exch def
|
|
3466 /rxx exch def
|
|
3467 gsave
|
|
3468 newpath
|
|
3469 rXX rYY moveto
|
|
3470 rxx rYY lineto
|
|
3471 rxx ryy lineto
|
|
3472 rXX ryy lineto
|
|
3473 closepath
|
|
3474 % top of stack: fill-or-not
|
|
3475 {FillBgColor}
|
|
3476 {LineThickness setlinewidth stroke}
|
|
3477 ifelse
|
|
3478 grestore
|
|
3479 }bind def
|
|
3480
|
|
3481 % stack: string fill-or-not |- --
|
|
3482 /doOutline
|
|
3483 {/-fillp- exch def
|
|
3484 /-ox- currentpoint /-oy- exch def def
|
|
3485 gsave
|
|
3486 LineThickness setlinewidth
|
|
3487 {st 0 3 -1 roll put
|
|
3488 st dup true charpath
|
|
3489 -fillp- {gsave FillBgColor grestore}if
|
|
3490 stroke stringwidth
|
|
3491 -oy- add /-oy- exch def
|
|
3492 -ox- add /-ox- exch def
|
|
3493 -ox- -oy- moveto
|
|
3494 }forall
|
|
3495 grestore
|
|
3496 -ox- -oy- moveto
|
|
3497 }bind def
|
|
3498
|
|
3499 % stack: fill-or-not delta |- --
|
|
3500 /doBox
|
|
3501 {/dd exch def
|
|
3502 xx XBox sub dd sub yy YBox sub dd sub
|
|
3503 XX XBox add dd add YY YBox add dd add
|
|
3504 doRect
|
|
3505 }bind def
|
|
3506
|
|
3507 % stack: string |- --
|
|
3508 /doShadow
|
|
3509 {gsave
|
|
3510 Xshadow Yshadow rmoveto
|
|
3511 false doOutline
|
|
3512 grestore
|
|
3513 }bind def
|
|
3514
|
|
3515 % stack: position |- --
|
|
3516 /Hline
|
|
3517 {currentpoint exch pop add dup
|
|
3518 gsave
|
|
3519 newpath
|
|
3520 xx exch moveto
|
|
3521 XX exch lineto
|
|
3522 closepath
|
|
3523 LineThickness setlinewidth stroke
|
|
3524 grestore
|
|
3525 }bind def
|
|
3526
|
|
3527 % stack: string |- --
|
|
3528 % effect: 1 - underline 2 - strikeout 4 - overline
|
|
3529 % 8 - shadow 16 - box 32 - outline
|
|
3530 /S
|
|
3531 {/xx currentpoint dup Descent add /yy exch def
|
|
3532 Ascent add /YY exch def def
|
|
3533 dup stringwidth pop xx add /XX exch def
|
|
3534 Effect 8 and 0 ne
|
|
3535 {/yy yy Yshadow add def
|
|
3536 /XX XX Xshadow add def
|
|
3537 }if
|
|
3538 bg
|
|
3539 {true
|
|
3540 Effect 16 and 0 ne
|
|
3541 {SpaceBackground doBox}
|
|
3542 {xx yy XX YY doRect}
|
|
3543 ifelse
|
|
3544 }if % background
|
|
3545 Effect 16 and 0 ne{false 0 doBox}if % box
|
|
3546 Effect 8 and 0 ne{dup doShadow}if % shadow
|
|
3547 Effect 32 and 0 ne
|
|
3548 {true doOutline} % outline
|
|
3549 {show} % normal text
|
|
3550 ifelse
|
|
3551 Effect 1 and 0 ne{UnderlinePosition Hline}if % underline
|
|
3552 Effect 2 and 0 ne{StrikeoutPosition Hline}if % strikeout
|
|
3553 Effect 4 and 0 ne{OverlinePosition Hline}if % overline
|
|
3554 }bind def
|
|
3555
|
|
3556 "
|
|
3557 "EBNF EPS prologue")
|
|
3558
|
|
3559
|
|
3560 (defconst ebnf-eps-begin
|
|
3561 "
|
|
3562 end
|
|
3563
|
|
3564 % x y #ebnf2ps#begin
|
|
3565 /#ebnf2ps#begin
|
|
3566 {#ebnf2ps#dict begin /#ebnf2ps#save save def
|
|
3567 moveto false BG 0.0 0.0 0.0 setrgbcolor}def
|
|
3568
|
|
3569 /#ebnf2ps#end{showpage #ebnf2ps#save restore end}def
|
|
3570
|
|
3571 %%EndPrologue
|
|
3572 "
|
|
3573 "EBNF EPS begin")
|
|
3574
|
|
3575
|
|
3576 (defconst ebnf-eps-end
|
|
3577 "#ebnf2ps#end
|
|
3578 %%EOF
|
|
3579 "
|
|
3580 "EBNF EPS end")
|
|
3581
|
|
3582
|
|
3583 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
3584 ;; Formatting
|
|
3585
|
|
3586
|
|
3587 (defvar ebnf-format-float "%1.3f")
|
|
3588
|
|
3589
|
|
3590 (defun ebnf-format-float (&rest floats)
|
|
3591 (mapconcat
|
|
3592 #'(lambda (float)
|
|
3593 (format ebnf-format-float float))
|
|
3594 floats
|
|
3595 " "))
|
|
3596
|
|
3597
|
|
3598 (defun ebnf-format-color (format-str color default)
|
|
3599 (let* ((the-color (or color default))
|
|
3600 (rgb (mapcar 'ps-color-value (ps-color-values the-color))))
|
|
3601 (format format-str
|
|
3602 (concat "["
|
|
3603 (ebnf-format-float (nth 0 rgb) (nth 1 rgb) (nth 2 rgb))
|
|
3604 "]")
|
|
3605 the-color)))
|
|
3606
|
|
3607
|
|
3608 (defvar ebnf-message-float "%3.2f")
|
|
3609
|
|
3610
|
|
3611 (defsubst ebnf-message-float (format-str value)
|
|
3612 (message format-str
|
|
3613 (format ebnf-message-float value)))
|
|
3614
|
|
3615
|
|
3616 (defsubst ebnf-message-info (messag)
|
|
3617 (message "%s...%3d%%"
|
|
3618 messag
|
|
3619 (round (/ (* (setq ebnf-nprod (1+ ebnf-nprod)) 100.0) ebnf-total))))
|
|
3620
|
|
3621
|
|
3622 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
3623 ;; Macros
|
|
3624
|
|
3625
|
|
3626 (defmacro ebnf-node-kind (vec &optional value)
|
|
3627 (if value
|
|
3628 `(aset ,vec 0 ,value)
|
|
3629 `(aref ,vec 0)))
|
|
3630
|
|
3631
|
|
3632 (defmacro ebnf-node-width-func (node width)
|
|
3633 `(funcall (aref ,node 1) ,node ,width))
|
|
3634
|
|
3635
|
|
3636 (defmacro ebnf-node-dimension-func (node &optional value)
|
|
3637 (if value
|
|
3638 `(aset ,node 2 ,value)
|
|
3639 `(funcall (aref ,node 2) ,node)))
|
|
3640
|
|
3641
|
|
3642 (defmacro ebnf-node-entry (vec &optional value)
|
|
3643 (if value
|
|
3644 `(aset ,vec 3 ,value)
|
|
3645 `(aref ,vec 3)))
|
|
3646
|
|
3647
|
|
3648 (defmacro ebnf-node-height (vec &optional value)
|
|
3649 (if value
|
|
3650 `(aset ,vec 4 ,value)
|
|
3651 `(aref ,vec 4)))
|
|
3652
|
|
3653
|
|
3654 (defmacro ebnf-node-width (vec &optional value)
|
|
3655 (if value
|
|
3656 `(aset ,vec 5 ,value)
|
|
3657 `(aref ,vec 5)))
|
|
3658
|
|
3659
|
|
3660 (defmacro ebnf-node-name (vec)
|
|
3661 `(aref ,vec 6))
|
|
3662
|
|
3663
|
|
3664 (defmacro ebnf-node-list (vec &optional value)
|
|
3665 (if value
|
|
3666 `(aset ,vec 6 ,value)
|
|
3667 `(aref ,vec 6)))
|
|
3668
|
|
3669
|
|
3670 (defmacro ebnf-node-default (vec)
|
|
3671 `(aref ,vec 7))
|
|
3672
|
|
3673
|
|
3674 (defmacro ebnf-node-production (vec &optional value)
|
|
3675 (if value
|
|
3676 `(aset ,vec 7 ,value)
|
|
3677 `(aref ,vec 7)))
|
|
3678
|
|
3679
|
|
3680 (defmacro ebnf-node-separator (vec &optional value)
|
|
3681 (if value
|
|
3682 `(aset ,vec 7 ,value)
|
|
3683 `(aref ,vec 7)))
|
|
3684
|
|
3685
|
|
3686 (defmacro ebnf-node-action (vec &optional value)
|
|
3687 (if value
|
|
3688 `(aset ,vec 8 ,value)
|
|
3689 `(aref ,vec 8)))
|
|
3690
|
|
3691
|
|
3692 (defmacro ebnf-node-generation (node)
|
|
3693 `(funcall (ebnf-node-kind ,node) ,node))
|
|
3694
|
|
3695
|
|
3696 (defmacro ebnf-max-width (prod)
|
|
3697 `(max (ebnf-node-width ,prod)
|
|
3698 (+ (* (length (ebnf-node-name ,prod))
|
|
3699 ebnf-font-width-P)
|
|
3700 ebnf-production-horizontal-space)))
|
|
3701
|
|
3702
|
|
3703 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
3704 ;; PostScript generation
|
|
3705
|
|
3706
|
|
3707 (defun ebnf-generate-eps (ebnf-tree)
|
|
3708 (let* ((ps-color-p (and ebnf-color-p (ps-color-device)))
|
|
3709 (ps-print-color-scale (if ps-color-p
|
|
3710 (float (car (ps-color-values "white")))
|
|
3711 1.0))
|
|
3712 (ebnf-total (length ebnf-tree))
|
|
3713 (ebnf-nprod 0)
|
|
3714 (old-ps-output (symbol-function 'ps-output))
|
|
3715 (old-ps-output-string (symbol-function 'ps-output-string))
|
|
3716 (eps-buffer (get-buffer-create ebnf-eps-buffer-name))
|
|
3717 ebnf-debug-ps error-msg horizontal
|
|
3718 prod prod-name prod-width prod-height prod-list file-list)
|
|
3719 ;; redefines `ps-output' and `ps-output-string'
|
|
3720 (defalias 'ps-output 'ebnf-eps-output)
|
|
3721 (defalias 'ps-output-string 'ps-output-string-prim)
|
|
3722 ;; generate EPS file
|
|
3723 (save-excursion
|
|
3724 (condition-case data
|
|
3725 (progn
|
|
3726 (while ebnf-tree
|
|
3727 (setq prod (car ebnf-tree)
|
|
3728 prod-name (ebnf-node-name prod)
|
|
3729 prod-width (ebnf-max-width prod)
|
|
3730 prod-height (ebnf-node-height prod)
|
|
3731 horizontal (memq (ebnf-node-action prod) ebnf-action-list))
|
|
3732 ;; generate production in EPS buffer
|
|
3733 (save-excursion
|
|
3734 (set-buffer eps-buffer)
|
|
3735 (setq ebnf-eps-upper-x 0.0
|
|
3736 ebnf-eps-upper-y 0.0
|
|
3737 ebnf-eps-max-width prod-width
|
|
3738 ebnf-eps-max-height prod-height)
|
|
3739 (ebnf-generate-production prod))
|
|
3740 (if (setq prod-list (cdr (assoc prod-name
|
|
3741 ebnf-eps-production-list)))
|
|
3742 ;; insert EPS buffer in all buffer associated with production
|
|
3743 (ebnf-eps-production-list prod-list 'file-list horizontal
|
|
3744 prod-width prod-height eps-buffer)
|
|
3745 ;; write EPS file for production
|
|
3746 (ebnf-eps-finish-and-write eps-buffer
|
|
3747 (ebnf-eps-filename prod-name)))
|
|
3748 ;; prepare for next loop
|
|
3749 (save-excursion
|
|
3750 (set-buffer eps-buffer)
|
|
3751 (erase-buffer))
|
|
3752 (setq ebnf-tree (cdr ebnf-tree)))
|
|
3753 ;; write and kill temporary buffers
|
|
3754 (ebnf-eps-write-kill-temp file-list t)
|
|
3755 (setq file-list nil))
|
|
3756 ;; handler
|
|
3757 ((quit error)
|
|
3758 (setq error-msg (error-message-string data)))))
|
|
3759 ;; restore `ps-output' and `ps-output-string'
|
|
3760 (defalias 'ps-output old-ps-output)
|
|
3761 (defalias 'ps-output-string old-ps-output-string)
|
|
3762 ;; kill temporary buffers
|
|
3763 (kill-buffer eps-buffer)
|
|
3764 (ebnf-eps-write-kill-temp file-list nil)
|
|
3765 (and error-msg (error error-msg))
|
|
3766 (message " ")))
|
|
3767
|
|
3768
|
|
3769 ;; write and kill temporary buffers
|
|
3770 (defun ebnf-eps-write-kill-temp (file-list write-p)
|
|
3771 (while file-list
|
|
3772 (let ((buffer (get-buffer (concat " *" (car file-list) "*"))))
|
|
3773 (when buffer
|
|
3774 (and write-p
|
|
3775 (ebnf-eps-finish-and-write buffer (car file-list)))
|
|
3776 (kill-buffer buffer)))
|
|
3777 (setq file-list (cdr file-list))))
|
|
3778
|
|
3779
|
|
3780 ;; insert EPS buffer in all buffer associated with production
|
|
3781 (defun ebnf-eps-production-list (prod-list file-list-sym horizontal
|
|
3782 prod-width prod-height eps-buffer)
|
|
3783 (while prod-list
|
|
3784 (add-to-list file-list-sym (car prod-list))
|
|
3785 (save-excursion
|
|
3786 (set-buffer (get-buffer-create (concat " *" (car prod-list) "*")))
|
|
3787 (goto-char (point-max))
|
|
3788 (cond
|
|
3789 ;; first production
|
|
3790 ((zerop (buffer-size))
|
|
3791 (setq ebnf-eps-upper-x 0.0
|
|
3792 ebnf-eps-upper-y 0.0
|
|
3793 ebnf-eps-max-width prod-width
|
|
3794 ebnf-eps-max-height prod-height))
|
|
3795 ;; horizontal
|
|
3796 (horizontal
|
|
3797 (ebnf-eop-horizontal ebnf-eps-prod-width)
|
|
3798 (setq ebnf-eps-max-width (+ ebnf-eps-max-width
|
|
3799 ebnf-production-horizontal-space
|
|
3800 prod-width)
|
|
3801 ebnf-eps-max-height (max ebnf-eps-max-height prod-height)))
|
|
3802 ;; vertical
|
|
3803 (t
|
|
3804 (ebnf-eop-vertical ebnf-eps-max-height)
|
|
3805 (setq ebnf-eps-upper-x (max ebnf-eps-upper-x ebnf-eps-max-width)
|
|
3806 ebnf-eps-upper-y (if (zerop ebnf-eps-upper-y)
|
|
3807 ebnf-eps-max-height
|
|
3808 (+ ebnf-eps-upper-y
|
|
3809 ebnf-production-vertical-space
|
|
3810 ebnf-eps-max-height))
|
|
3811 ebnf-eps-max-width prod-width
|
|
3812 ebnf-eps-max-height prod-height))
|
|
3813 )
|
|
3814 (setq ebnf-eps-prod-width prod-width)
|
|
3815 (insert-buffer eps-buffer))
|
|
3816 (setq prod-list (cdr prod-list))))
|
|
3817
|
|
3818
|
|
3819 (defun ebnf-generate (ebnf-tree)
|
|
3820 (let* ((ps-color-p (and ebnf-color-p (ps-color-device)))
|
|
3821 (ps-print-color-scale (if ps-color-p
|
|
3822 (float (car (ps-color-values "white")))
|
|
3823 1.0))
|
|
3824 ps-zebra-stripes ps-line-number ps-razzle-dazzle
|
|
3825 ps-print-hook
|
|
3826 ps-print-begin-sheet-hook
|
|
3827 ps-print-begin-page-hook
|
|
3828 ps-print-begin-column-hook)
|
|
3829 (ps-generate (current-buffer) (point-min) (point-max)
|
|
3830 'ebnf-generate-postscript)))
|
|
3831
|
|
3832
|
|
3833 (defvar ebnf-tree nil)
|
|
3834 (defvar ebnf-direction "R")
|
|
3835 (defvar ebnf-total 0)
|
|
3836 (defvar ebnf-nprod 0)
|
|
3837
|
|
3838
|
|
3839 (defun ebnf-generate-postscript (from to)
|
|
3840 (ebnf-begin-file)
|
|
3841 (if ebnf-horizontal-max-height
|
|
3842 (ebnf-generate-with-max-height)
|
|
3843 (ebnf-generate-without-max-height))
|
|
3844 (message " "))
|
|
3845
|
|
3846
|
|
3847 (defun ebnf-generate-with-max-height ()
|
|
3848 (let ((ebnf-total (length ebnf-tree))
|
|
3849 (ebnf-nprod 0)
|
|
3850 next-line max-height prod the-width)
|
|
3851 (while ebnf-tree
|
|
3852 ;; find next line point
|
|
3853 (setq next-line ebnf-tree
|
|
3854 prod (car ebnf-tree)
|
|
3855 max-height (ebnf-node-height prod))
|
|
3856 (ebnf-begin-line prod (ebnf-max-width prod))
|
|
3857 (while (and (setq next-line (cdr next-line))
|
|
3858 (setq prod (car next-line))
|
|
3859 (memq (ebnf-node-action prod) ebnf-action-list)
|
|
3860 (setq the-width (ebnf-max-width prod))
|
|
3861 (<= the-width ps-width-remaining))
|
|
3862 (setq max-height (max max-height (ebnf-node-height prod))
|
|
3863 ps-width-remaining (- ps-width-remaining
|
|
3864 (+ the-width
|
|
3865 ebnf-production-horizontal-space))))
|
|
3866 ;; generate current line
|
|
3867 (ebnf-newline max-height)
|
|
3868 (setq prod (car ebnf-tree))
|
|
3869 (ebnf-generate-production prod)
|
|
3870 (while (not (eq (setq ebnf-tree (cdr ebnf-tree)) next-line))
|
|
3871 (ebnf-eop-horizontal (ebnf-max-width prod))
|
|
3872 (setq prod (car ebnf-tree))
|
|
3873 (ebnf-generate-production prod))
|
|
3874 (ebnf-eop-vertical max-height))))
|
|
3875
|
|
3876
|
|
3877 (defun ebnf-generate-without-max-height ()
|
|
3878 (let ((ebnf-total (length ebnf-tree))
|
|
3879 (ebnf-nprod 0)
|
|
3880 max-height prod bef-width cur-width)
|
|
3881 (while ebnf-tree
|
|
3882 ;; generate current line
|
|
3883 (setq prod (car ebnf-tree)
|
|
3884 max-height (ebnf-node-height prod)
|
|
3885 bef-width (ebnf-max-width prod))
|
|
3886 (ebnf-begin-line prod bef-width)
|
|
3887 (ebnf-generate-production prod)
|
|
3888 (while (and (setq ebnf-tree (cdr ebnf-tree))
|
|
3889 (setq prod (car ebnf-tree))
|
|
3890 (memq (ebnf-node-action prod) ebnf-action-list)
|
|
3891 (setq cur-width (ebnf-max-width prod))
|
|
3892 (<= cur-width ps-width-remaining)
|
|
3893 (<= (ebnf-node-height prod) ps-height-remaining))
|
|
3894 (ebnf-eop-horizontal bef-width)
|
|
3895 (ebnf-generate-production prod)
|
|
3896 (setq bef-width cur-width
|
|
3897 max-height (max max-height (ebnf-node-height prod))
|
|
3898 ps-width-remaining (- ps-width-remaining
|
|
3899 (+ cur-width
|
|
3900 ebnf-production-horizontal-space))))
|
|
3901 (ebnf-eop-vertical max-height)
|
|
3902 ;; prepare next line
|
|
3903 (ebnf-newline max-height))))
|
|
3904
|
|
3905
|
|
3906 (defun ebnf-begin-line (prod width)
|
|
3907 (and (or (eq (ebnf-node-action prod) 'form-feed)
|
|
3908 (> (ebnf-node-height prod) ps-height-remaining))
|
|
3909 (ebnf-new-page))
|
|
3910 (setq ps-width-remaining (- ps-width-remaining
|
|
3911 (+ width
|
|
3912 ebnf-production-horizontal-space))))
|
|
3913
|
|
3914
|
|
3915 (defun ebnf-newline (height)
|
|
3916 (and (> height ps-height-remaining)
|
|
3917 (ebnf-new-page))
|
|
3918 (setq ps-width-remaining ps-print-width
|
|
3919 ps-height-remaining (- ps-height-remaining
|
|
3920 (+ height
|
|
3921 ebnf-production-vertical-space))))
|
|
3922
|
|
3923
|
|
3924 ;; [production width-fun dim-fun entry height width name production action]
|
|
3925 (defun ebnf-generate-production (production)
|
|
3926 (ebnf-message-info "Generating")
|
|
3927 (run-hooks 'ebnf-production-hook)
|
|
3928 (ps-output-string (ebnf-node-name production))
|
|
3929 (ps-output " "
|
|
3930 (ebnf-format-float
|
|
3931 (ebnf-node-width production)
|
|
3932 (+ ebnf-basic-height
|
|
3933 (ebnf-node-entry (ebnf-node-production production))))
|
|
3934 " BOP\n")
|
|
3935 (ebnf-node-generation (ebnf-node-production production))
|
|
3936 (ps-output "EOS\n"))
|
|
3937
|
|
3938
|
|
3939 ;; [alternative width-fun dim-fun entry height width list]
|
|
3940 (defun ebnf-generate-alternative (alternative)
|
|
3941 (let ((alt (ebnf-node-list alternative))
|
|
3942 (entry (ebnf-node-entry alternative))
|
|
3943 (nlist 0)
|
|
3944 alt-height alt-entry)
|
|
3945 (while alt
|
|
3946 (ps-output (ebnf-format-float (- entry (ebnf-node-entry (car alt))))
|
|
3947 " ")
|
|
3948 (setq entry (- entry (ebnf-node-height (car alt)) ebnf-vertical-space)
|
|
3949 nlist (1+ nlist)
|
|
3950 alt (cdr alt)))
|
|
3951 (ps-output (format "%d " nlist)
|
|
3952 (ebnf-format-float (ebnf-node-width alternative))
|
|
3953 " AT\n")
|
|
3954 (setq alt (ebnf-node-list alternative))
|
|
3955 (when alt
|
|
3956 (ebnf-node-generation (car alt))
|
|
3957 (setq alt-height (- (ebnf-node-height (car alt))
|
|
3958 (ebnf-node-entry (car alt)))))
|
|
3959 (while (setq alt (cdr alt))
|
|
3960 (setq alt-entry (ebnf-node-entry (car alt)))
|
|
3961 (ebnf-vertical-movement
|
|
3962 (- (+ alt-height ebnf-vertical-space alt-entry)))
|
|
3963 (ebnf-node-generation (car alt))
|
|
3964 (setq alt-height (- (ebnf-node-height (car alt)) alt-entry))))
|
|
3965 (ps-output "EOS\n"))
|
|
3966
|
|
3967
|
|
3968 ;; [sequence width-fun dim-fun entry height width list]
|
|
3969 (defun ebnf-generate-sequence (sequence)
|
|
3970 (ps-output "BOS\n")
|
|
3971 (let ((seq (ebnf-node-list sequence))
|
|
3972 seq-width)
|
|
3973 (when seq
|
|
3974 (ebnf-node-generation (car seq))
|
|
3975 (setq seq-width (ebnf-node-width (car seq))))
|
|
3976 (while (setq seq (cdr seq))
|
|
3977 (ebnf-horizontal-movement seq-width)
|
|
3978 (ebnf-node-generation (car seq))
|
|
3979 (setq seq-width (ebnf-node-width (car seq)))))
|
|
3980 (ps-output "EOS\n"))
|
|
3981
|
|
3982
|
|
3983 ;; [terminal width-fun dim-fun entry height width name]
|
|
3984 (defun ebnf-generate-terminal (terminal)
|
|
3985 (ebnf-gen-terminal terminal "T"))
|
|
3986
|
|
3987
|
|
3988 ;; [non-terminal width-fun dim-fun entry height width name]
|
|
3989 (defun ebnf-generate-non-terminal (non-terminal)
|
|
3990 (ebnf-gen-terminal non-terminal "NT"))
|
|
3991
|
|
3992
|
|
3993 ;; [empty width-fun dim-fun entry height width]
|
|
3994 (defun ebnf-generate-empty (empty)
|
|
3995 (ebnf-empty-alternative (ebnf-node-width empty)))
|
|
3996
|
|
3997
|
|
3998 ;; [optional width-fun dim-fun entry height width element]
|
|
3999 (defun ebnf-generate-optional (optional)
|
|
4000 (let ((the-optional (ebnf-node-list optional)))
|
|
4001 (ps-output (ebnf-format-float
|
|
4002 (+ (- (ebnf-node-height the-optional)
|
|
4003 (ebnf-node-entry optional))
|
|
4004 ebnf-vertical-space)
|
|
4005 (ebnf-node-width optional))
|
|
4006 " OP\n")
|
|
4007 (ebnf-node-generation the-optional)
|
|
4008 (ps-output "EOS\n")))
|
|
4009
|
|
4010
|
|
4011 ;; [one-or-more width-fun dim-fun entry height width element separator]
|
|
4012 (defun ebnf-generate-one-or-more (one-or-more)
|
|
4013 (let* ((width (ebnf-node-width one-or-more))
|
|
4014 (sep (ebnf-node-separator one-or-more))
|
|
4015 (entry (- (ebnf-node-entry one-or-more)
|
|
4016 (if sep
|
|
4017 (ebnf-node-entry sep)
|
|
4018 0))))
|
|
4019 (ps-output (ebnf-format-float entry width)
|
|
4020 " OM\n")
|
|
4021 (ebnf-node-generation (ebnf-node-list one-or-more))
|
|
4022 (ebnf-vertical-movement entry)
|
|
4023 (if sep
|
|
4024 (let ((ebnf-direction "L"))
|
|
4025 (ebnf-node-generation sep))
|
|
4026 (ebnf-empty-alternative (- width ebnf-horizontal-space))))
|
|
4027 (ps-output "EOS\n"))
|
|
4028
|
|
4029
|
|
4030 ;; [zero-or-more width-fun dim-fun entry height width element separator]
|
|
4031 (defun ebnf-generate-zero-or-more (zero-or-more)
|
|
4032 (let* ((width (ebnf-node-width zero-or-more))
|
|
4033 (node-list (ebnf-node-list zero-or-more))
|
|
4034 (list-entry (ebnf-node-entry node-list))
|
|
4035 (node-sep (ebnf-node-separator zero-or-more))
|
|
4036 (entry (+ list-entry
|
|
4037 ebnf-vertical-space
|
|
4038 (if node-sep
|
|
4039 (- (ebnf-node-height node-sep)
|
|
4040 (ebnf-node-entry node-sep))
|
|
4041 0))))
|
|
4042 (ps-output (ebnf-format-float entry
|
|
4043 (+ (- (ebnf-node-height node-list)
|
|
4044 list-entry)
|
|
4045 ebnf-vertical-space)
|
|
4046 width)
|
|
4047 " ZM\n")
|
|
4048 (ebnf-node-generation (ebnf-node-list zero-or-more))
|
|
4049 (ebnf-vertical-movement entry)
|
|
4050 (if (ebnf-node-separator zero-or-more)
|
|
4051 (let ((ebnf-direction "L"))
|
|
4052 (ebnf-node-generation (ebnf-node-separator zero-or-more)))
|
|
4053 (ebnf-empty-alternative (- width ebnf-horizontal-space))))
|
|
4054 (ps-output "EOS\n"))
|
|
4055
|
|
4056
|
|
4057 ;; [special width-fun dim-fun entry height width name]
|
|
4058 (defun ebnf-generate-special (special)
|
|
4059 (ebnf-gen-terminal special "SP"))
|
|
4060
|
|
4061
|
|
4062 ;; [repeat width-fun dim-fun entry height width times element]
|
|
4063 (defun ebnf-generate-repeat (repeat)
|
|
4064 (let ((times (ebnf-node-name repeat))
|
|
4065 (element (ebnf-node-separator repeat)))
|
|
4066 (ps-output-string times)
|
|
4067 (ps-output " "
|
|
4068 (ebnf-format-float
|
|
4069 (ebnf-node-entry repeat)
|
|
4070 (ebnf-node-height repeat)
|
|
4071 (ebnf-node-width repeat)
|
|
4072 (if element
|
|
4073 (+ (ebnf-node-width element)
|
|
4074 ebnf-space-R ebnf-space-R ebnf-space-R
|
|
4075 (* (length times) ebnf-font-width-R))
|
|
4076 0.0))
|
|
4077 " " ebnf-direction "RP\n")
|
|
4078 (and element
|
|
4079 (ebnf-node-generation element)))
|
|
4080 (ps-output "EOS\n"))
|
|
4081
|
|
4082
|
|
4083 ;; [except width-fun dim-fun entry height width element element]
|
|
4084 (defun ebnf-generate-except (except)
|
|
4085 (let* ((element (ebnf-node-list except))
|
|
4086 (exception (ebnf-node-separator except))
|
|
4087 (width (ebnf-node-width element)))
|
|
4088 (ps-output (ebnf-format-float
|
|
4089 width
|
|
4090 (ebnf-node-entry except)
|
|
4091 (ebnf-node-height except)
|
|
4092 (ebnf-node-width except)
|
|
4093 (+ width
|
|
4094 ebnf-space-E ebnf-space-E ebnf-space-E
|
|
4095 ebnf-font-width-E
|
|
4096 (if exception
|
|
4097 (+ (ebnf-node-width exception) ebnf-space-E)
|
|
4098 0.0)))
|
|
4099 " " ebnf-direction "EX\n")
|
|
4100 (ebnf-node-generation (ebnf-node-list except))
|
|
4101 (when exception
|
|
4102 (ebnf-horizontal-movement (+ width ebnf-space-E
|
|
4103 ebnf-font-width-E ebnf-space-E))
|
|
4104 (ebnf-node-generation exception)))
|
|
4105 (ps-output "EOS\n"))
|
|
4106
|
|
4107
|
|
4108 (defun ebnf-gen-terminal (node code)
|
|
4109 (ps-output-string (ebnf-node-name node))
|
|
4110 (ps-output " " (ebnf-format-float (ebnf-node-width node))
|
|
4111 " " ebnf-direction code
|
|
4112 (if (ebnf-node-default node)
|
|
4113 "D\n"
|
|
4114 "\n")))
|
|
4115
|
|
4116
|
|
4117 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
4118 ;; Internal functions
|
|
4119
|
|
4120
|
|
4121 (defvar ebnf-map-name
|
|
4122 (let ((map (make-vector 256 ?\_)))
|
|
4123 (mapcar #'(lambda (char)
|
|
4124 (aset map char char))
|
|
4125 (concat "#$%&+-.0123456789=?@~"
|
|
4126 "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
|
4127 "abcdefghijklmnopqrstuvwxyz"))
|
|
4128 map))
|
|
4129
|
|
4130
|
|
4131 (defun ebnf-eps-filename (str)
|
|
4132 (let* ((len (length str))
|
|
4133 (stri 0)
|
|
4134 (new (make-string len ?\ )))
|
|
4135 (while (< stri len)
|
|
4136 (aset new stri (aref ebnf-map-name (aref str stri)))
|
|
4137 (setq stri (1+ stri)))
|
|
4138 (concat ebnf-eps-prefix new ".eps")))
|
|
4139
|
|
4140
|
|
4141 (defun ebnf-eps-output (&rest args)
|
|
4142 (while args
|
|
4143 (insert (car args))
|
|
4144 (setq args (cdr args))))
|
|
4145
|
|
4146
|
|
4147 (defun ebnf-generate-region (from to gen-func)
|
|
4148 (run-hooks 'ebnf-hook)
|
|
4149 (let ((ebnf-limit (max from to))
|
|
4150 the-point)
|
|
4151 (save-excursion
|
|
4152 (save-restriction
|
|
4153 (save-match-data
|
|
4154 (condition-case data
|
|
4155 (let ((tree (ebnf-parse-and-sort (min from to))))
|
|
4156 (when gen-func
|
|
4157 (funcall gen-func
|
|
4158 (ebnf-dimensions
|
|
4159 (ebnf-optimize
|
|
4160 (ebnf-eliminate-empty-rules tree))))))
|
|
4161 ;; handler
|
|
4162 ((quit error)
|
|
4163 (ding)
|
|
4164 (setq the-point (max (1- (point)) (point-min)))
|
|
4165 (message (error-message-string data)))))))
|
|
4166 (cond
|
|
4167 (the-point
|
|
4168 (goto-char the-point))
|
|
4169 (gen-func
|
|
4170 nil)
|
|
4171 (t
|
|
4172 (message "EBNF syntatic analysis: NO ERRORS.")))))
|
|
4173
|
|
4174
|
|
4175 (defun ebnf-parse-and-sort (start)
|
|
4176 (ebnf-begin-job)
|
|
4177 (let ((tree (funcall ebnf-parser-func start)))
|
|
4178 (if ebnf-sort-production
|
|
4179 (progn
|
|
4180 (message "Sorting...")
|
|
4181 (sort tree
|
|
4182 (if (eq ebnf-sort-production 'ascending)
|
|
4183 'ebnf-sorter-ascending
|
|
4184 'ebnf-sorter-descending)))
|
|
4185 (nreverse tree))))
|
|
4186
|
|
4187
|
|
4188 (defun ebnf-sorter-ascending (first second)
|
|
4189 (string< (ebnf-node-name first)
|
|
4190 (ebnf-node-name second)))
|
|
4191
|
|
4192
|
|
4193 (defun ebnf-sorter-descending (first second)
|
|
4194 (string< (ebnf-node-name second)
|
|
4195 (ebnf-node-name first)))
|
|
4196
|
|
4197
|
|
4198 (defun ebnf-empty-alternative (width)
|
|
4199 (ps-output (ebnf-format-float width) " EA\n"))
|
|
4200
|
|
4201
|
|
4202 (defun ebnf-vertical-movement (height)
|
|
4203 (ps-output (ebnf-format-float height) " vm\n"))
|
|
4204
|
|
4205
|
|
4206 (defun ebnf-horizontal-movement (width)
|
|
4207 (ps-output (ebnf-format-float width) " hm\n"))
|
|
4208
|
|
4209
|
|
4210 (defun ebnf-entry (height)
|
|
4211 (* height ebnf-entry-percentage))
|
|
4212
|
|
4213
|
|
4214 (defun ebnf-eop-vertical (height)
|
|
4215 (ps-output (ebnf-format-float (+ height ebnf-production-vertical-space))
|
|
4216 " EOPV\n\n"))
|
|
4217
|
|
4218
|
|
4219 (defun ebnf-eop-horizontal (width)
|
|
4220 (ps-output (ebnf-format-float (+ width ebnf-production-horizontal-space))
|
|
4221 " EOPH\n\n"))
|
|
4222
|
|
4223
|
|
4224 (defun ebnf-new-page ()
|
|
4225 (when (< ps-height-remaining ps-print-height)
|
|
4226 (run-hooks 'ebnf-page-hook)
|
|
4227 (ps-next-page)
|
|
4228 (ps-output "\n")))
|
|
4229
|
|
4230
|
|
4231 (defsubst ebnf-font-size (font) (nth 0 font))
|
|
4232 (defsubst ebnf-font-name (font) (nth 1 font))
|
|
4233 (defsubst ebnf-font-foreground (font) (nth 2 font))
|
|
4234 (defsubst ebnf-font-background (font) (nth 3 font))
|
|
4235 (defsubst ebnf-font-list (font) (nthcdr 4 font))
|
|
4236 (defsubst ebnf-font-attributes (font)
|
|
4237 (lsh (ps-extension-bit (cdr font)) -2))
|
|
4238
|
|
4239
|
|
4240 (defconst ebnf-font-name-select
|
|
4241 (vector 'normal 'bold 'italic 'bold-italic))
|
|
4242
|
|
4243
|
|
4244 (defun ebnf-font-name-select (font)
|
|
4245 (let* ((font-list (ebnf-font-list font))
|
|
4246 (font-index (+ (if (memq 'bold font-list) 1 0)
|
|
4247 (if (memq 'italic font-list) 2 0)))
|
|
4248 (name (ebnf-font-name font))
|
|
4249 (database (cdr (assoc name ps-font-info-database)))
|
|
4250 (info-list (or (cdr (assoc 'fonts database))
|
|
4251 (error "Invalid font: %s" name))))
|
|
4252 (or (cdr (assoc (aref ebnf-font-name-select font-index)
|
|
4253 info-list))
|
|
4254 (error "Invalid attributes for font %s" name))))
|
|
4255
|
|
4256
|
|
4257 (defun ebnf-font-select (font select)
|
|
4258 (let* ((name (ebnf-font-name font))
|
|
4259 (database (cdr (assoc name ps-font-info-database)))
|
|
4260 (size (cdr (assoc 'size database)))
|
|
4261 (base (cdr (assoc select database))))
|
|
4262 (if (and size base)
|
|
4263 (/ (* (ebnf-font-size font) base)
|
|
4264 size)
|
|
4265 (error "Invalid font: %s" name))))
|
|
4266
|
|
4267
|
|
4268 (defsubst ebnf-font-width (font)
|
|
4269 (ebnf-font-select font 'avg-char-width))
|
|
4270 (defsubst ebnf-font-height (font)
|
|
4271 (ebnf-font-select font 'line-height))
|
|
4272
|
|
4273
|
|
4274 (defun ebnf-begin-job ()
|
|
4275 (ps-printing-region nil)
|
|
4276 (if ebnf-use-float-format
|
|
4277 (setq ebnf-format-float "%1.3f"
|
|
4278 ebnf-message-float "%3.2f")
|
|
4279 (setq ebnf-format-float "%s"
|
|
4280 ebnf-message-float "%s"))
|
|
4281 (ebnf-otz-initialize)
|
|
4282 ;; to avoid compilation gripes when calling autoloaded functions
|
|
4283 (funcall (cond ((eq ebnf-syntax 'iso-ebnf)
|
|
4284 (setq ebnf-parser-func 'ebnf-iso-parser)
|
|
4285 'ebnf-iso-initialize)
|
|
4286 ((eq ebnf-syntax 'yacc)
|
|
4287 (setq ebnf-parser-func 'ebnf-yac-parser)
|
|
4288 'ebnf-yac-initialize)
|
|
4289 (t
|
|
4290 (setq ebnf-parser-func 'ebnf-bnf-parser)
|
|
4291 'ebnf-bnf-initialize)))
|
|
4292 (and ebnf-terminal-regexp ; ensures that it's a string or nil
|
|
4293 (not (stringp ebnf-terminal-regexp))
|
|
4294 (setq ebnf-terminal-regexp nil))
|
|
4295 (or (and ebnf-eps-prefix ; ensures that it's a string
|
|
4296 (stringp ebnf-eps-prefix))
|
|
4297 (setq ebnf-eps-prefix "ebnf--"))
|
|
4298 (setq ebnf-entry-percentage ; ensures value between 0.0 and 1.0
|
|
4299 (min (max ebnf-entry-percentage 0.0) 1.0)
|
|
4300 ebnf-action-list (if ebnf-horizontal-orientation
|
|
4301 '(nil keep-line)
|
|
4302 '(keep-line))
|
|
4303 ebnf-settings nil
|
|
4304 ebnf-fonts-required nil
|
|
4305 ebnf-action nil
|
|
4306 ebnf-default-p nil
|
|
4307 ebnf-eps-context nil
|
|
4308 ebnf-eps-production-list nil
|
|
4309 ebnf-eps-upper-x 0.0
|
|
4310 ebnf-eps-upper-y 0.0
|
|
4311 ebnf-font-height-P (ebnf-font-height ebnf-production-font)
|
|
4312 ebnf-font-height-T (ebnf-font-height ebnf-terminal-font)
|
|
4313 ebnf-font-height-NT (ebnf-font-height ebnf-non-terminal-font)
|
|
4314 ebnf-font-height-S (ebnf-font-height ebnf-special-font)
|
|
4315 ebnf-font-height-E (ebnf-font-height ebnf-except-font)
|
|
4316 ebnf-font-height-R (ebnf-font-height ebnf-repeat-font)
|
|
4317 ebnf-font-width-P (ebnf-font-width ebnf-production-font)
|
|
4318 ebnf-font-width-T (ebnf-font-width ebnf-terminal-font)
|
|
4319 ebnf-font-width-NT (ebnf-font-width ebnf-non-terminal-font)
|
|
4320 ebnf-font-width-S (ebnf-font-width ebnf-special-font)
|
|
4321 ebnf-font-width-E (ebnf-font-width ebnf-except-font)
|
|
4322 ebnf-font-width-R (ebnf-font-width ebnf-repeat-font)
|
|
4323 ebnf-space-T (* ebnf-font-height-T 0.5)
|
|
4324 ebnf-space-NT (* ebnf-font-height-NT 0.5)
|
|
4325 ebnf-space-S (* ebnf-font-height-S 0.5)
|
|
4326 ebnf-space-E (* ebnf-font-height-E 0.5)
|
|
4327 ebnf-space-R (* ebnf-font-height-R 0.5))
|
|
4328 (let ((basic (+ ebnf-font-height-T ebnf-font-height-NT)))
|
|
4329 (setq ebnf-basic-width (* basic 0.5)
|
|
4330 ebnf-horizontal-space (+ basic basic)
|
|
4331 ebnf-basic-height ebnf-basic-width
|
|
4332 ebnf-vertical-space ebnf-basic-width)
|
|
4333 ;; ensures value is greater than zero
|
|
4334 (or (and (numberp ebnf-production-horizontal-space)
|
|
4335 (> ebnf-production-horizontal-space 0.0))
|
|
4336 (setq ebnf-production-horizontal-space basic))
|
|
4337 ;; ensures value is greater than zero
|
|
4338 (or (and (numberp ebnf-production-vertical-space)
|
|
4339 (> ebnf-production-vertical-space 0.0))
|
|
4340 (setq ebnf-production-vertical-space basic))))
|
|
4341
|
|
4342
|
|
4343 (defsubst ebnf-shape-value (sym alist)
|
|
4344 (or (cdr (assq sym alist)) 0))
|
|
4345
|
|
4346
|
|
4347 (defsubst ebnf-boolean (value)
|
|
4348 (if value "true" "false"))
|
|
4349
|
|
4350
|
|
4351 (defun ebnf-begin-file ()
|
|
4352 (ps-flush-output)
|
|
4353 (save-excursion
|
|
4354 (set-buffer ps-spool-buffer)
|
|
4355 (goto-char (point-min))
|
|
4356 (and (search-forward "%%Creator: " nil t)
|
|
4357 (not (search-forward "& ebnf2ps v"
|
|
4358 (save-excursion (end-of-line) (point))
|
|
4359 t))
|
|
4360 (progn
|
|
4361 ;; adjust creator comment
|
|
4362 (end-of-line)
|
|
4363 (backward-char)
|
|
4364 (insert " & ebnf2ps v" ebnf-version)
|
|
4365 ;; insert ebnf settings & engine
|
|
4366 (goto-char (point-max))
|
|
4367 (search-backward "\n%%EndPrologue\n")
|
|
4368 (ebnf-insert-ebnf-prologue)
|
|
4369 (ps-output "\n")))))
|
|
4370
|
|
4371
|
|
4372 (defun ebnf-eps-finish-and-write (buffer filename)
|
|
4373 (save-excursion
|
|
4374 (set-buffer buffer)
|
|
4375 (setq ebnf-eps-upper-x (max ebnf-eps-upper-x ebnf-eps-max-width)
|
|
4376 ebnf-eps-upper-y (if (zerop ebnf-eps-upper-y)
|
|
4377 ebnf-eps-max-height
|
|
4378 (+ ebnf-eps-upper-y
|
|
4379 ebnf-production-vertical-space
|
|
4380 ebnf-eps-max-height)))
|
|
4381 ;; prologue
|
|
4382 (goto-char (point-min))
|
|
4383 (insert
|
|
4384 "%!PS-Adobe-3.0 EPSF-3.0"
|
|
4385 "\n%%BoundingBox: 0 0 "
|
|
4386 (format "%d %d" (1+ ebnf-eps-upper-x) (1+ ebnf-eps-upper-y))
|
|
4387 "\n%%Title: " filename
|
|
4388 "\n%%CreationDate: " (time-stamp-hh:mm:ss) " " (time-stamp-mon-dd-yyyy)
|
|
4389 "\n%%Creator: " (user-full-name) " (using ebnf2ps v" ebnf-version ")"
|
|
4390 "\n%%DocumentNeededResources: font "
|
|
4391 (or ebnf-fonts-required
|
|
4392 (setq ebnf-fonts-required
|
|
4393 (let ((fonts (ps-remove-duplicates
|
|
4394 (mapcar 'ebnf-font-name-select
|
|
4395 (list ebnf-production-font
|
|
4396 ebnf-terminal-font
|
|
4397 ebnf-non-terminal-font
|
|
4398 ebnf-special-font
|
|
4399 ebnf-except-font
|
|
4400 ebnf-repeat-font)))))
|
|
4401 (concat (car fonts)
|
|
4402 (and (cdr fonts) "\n%%+ font ")
|
|
4403 (mapconcat 'identity (cdr fonts) "\n%%+ font ")))))
|
|
4404 "\n%%Pages: 0\n%%EndComments\n\n%%BeginPrologue\n"
|
|
4405 ebnf-eps-prologue)
|
|
4406 (ebnf-insert-ebnf-prologue)
|
|
4407 (insert ebnf-eps-begin
|
|
4408 "\n0 " (ebnf-format-float
|
|
4409 (- ebnf-eps-upper-y (* ebnf-font-height-P 0.7)))
|
|
4410 " #ebnf2ps#begin\n")
|
|
4411 ;; epilogue
|
|
4412 (goto-char (point-max))
|
|
4413 (insert ebnf-eps-end)
|
|
4414 ;; write file
|
|
4415 (message "Saving...")
|
|
4416 (setq filename (expand-file-name filename))
|
|
4417 (let ((coding-system-for-write 'raw-text-unix))
|
|
4418 (write-region (point-min) (point-max) filename))
|
|
4419 (message "Wrote %s" filename)))
|
|
4420
|
|
4421
|
|
4422 (defun ebnf-insert-ebnf-prologue ()
|
|
4423 (insert
|
|
4424 (or ebnf-settings
|
|
4425 (setq ebnf-settings
|
|
4426 (concat
|
|
4427 "\n\n% === begin EBNF settings\n\n"
|
|
4428 ;; production
|
|
4429 (format "/fP %s /%s DefFont\n"
|
|
4430 (ebnf-format-float (ebnf-font-size ebnf-production-font))
|
|
4431 (ebnf-font-name-select ebnf-production-font))
|
|
4432 (ebnf-format-color "/ForegroundP %s def %% %s\n"
|
|
4433 (ebnf-font-foreground ebnf-production-font)
|
|
4434 "Black")
|
|
4435 (ebnf-format-color "/BackgroundP %s def %% %s\n"
|
|
4436 (ebnf-font-background ebnf-production-font)
|
|
4437 "White")
|
|
4438 (format "/EffectP %d def\n"
|
|
4439 (ebnf-font-attributes ebnf-production-font))
|
|
4440 ;; terminal
|
|
4441 (format "/fT %s /%s DefFont\n"
|
|
4442 (ebnf-format-float (ebnf-font-size ebnf-terminal-font))
|
|
4443 (ebnf-font-name-select ebnf-terminal-font))
|
|
4444 (ebnf-format-color "/ForegroundT %s def %% %s\n"
|
|
4445 (ebnf-font-foreground ebnf-terminal-font)
|
|
4446 "Black")
|
|
4447 (ebnf-format-color "/BackgroundT %s def %% %s\n"
|
|
4448 (ebnf-font-background ebnf-terminal-font)
|
|
4449 "White")
|
|
4450 (format "/EffectT %d def\n"
|
|
4451 (ebnf-font-attributes ebnf-terminal-font))
|
|
4452 (format "/BorderWidthT %s def\n"
|
|
4453 (ebnf-format-float ebnf-terminal-border-width))
|
|
4454 (ebnf-format-color "/BorderColorT %s def %% %s\n"
|
|
4455 ebnf-terminal-border-color
|
|
4456 "Black")
|
|
4457 (format "/ShapeT %d def\n"
|
|
4458 (ebnf-shape-value ebnf-terminal-shape
|
|
4459 ebnf-terminal-shape-alist))
|
|
4460 (format "/ShadowT %s def\n"
|
|
4461 (ebnf-boolean ebnf-terminal-shadow))
|
|
4462 ;; non-terminal
|
|
4463 (format "/fNT %s /%s DefFont\n"
|
|
4464 (ebnf-format-float
|
|
4465 (ebnf-font-size ebnf-non-terminal-font))
|
|
4466 (ebnf-font-name-select ebnf-non-terminal-font))
|
|
4467 (ebnf-format-color "/ForegroundNT %s def %% %s\n"
|
|
4468 (ebnf-font-foreground ebnf-non-terminal-font)
|
|
4469 "Black")
|
|
4470 (ebnf-format-color "/BackgroundNT %s def %% %s\n"
|
|
4471 (ebnf-font-background ebnf-non-terminal-font)
|
|
4472 "White")
|
|
4473 (format "/EffectNT %d def\n"
|
|
4474 (ebnf-font-attributes ebnf-non-terminal-font))
|
|
4475 (format "/BorderWidthNT %s def\n"
|
|
4476 (ebnf-format-float ebnf-non-terminal-border-width))
|
|
4477 (ebnf-format-color "/BorderColorNT %s def %% %s\n"
|
|
4478 ebnf-non-terminal-border-color
|
|
4479 "Black")
|
|
4480 (format "/ShapeNT %d def\n"
|
|
4481 (ebnf-shape-value ebnf-non-terminal-shape
|
|
4482 ebnf-terminal-shape-alist))
|
|
4483 (format "/ShadowNT %s def\n"
|
|
4484 (ebnf-boolean ebnf-non-terminal-shadow))
|
|
4485 ;; special
|
|
4486 (format "/fS %s /%s DefFont\n"
|
|
4487 (ebnf-format-float (ebnf-font-size ebnf-special-font))
|
|
4488 (ebnf-font-name-select ebnf-special-font))
|
|
4489 (ebnf-format-color "/ForegroundS %s def %% %s\n"
|
|
4490 (ebnf-font-foreground ebnf-special-font)
|
|
4491 "Black")
|
|
4492 (ebnf-format-color "/BackgroundS %s def %% %s\n"
|
|
4493 (ebnf-font-background ebnf-special-font)
|
|
4494 "Gray95")
|
|
4495 (format "/EffectS %d def\n"
|
|
4496 (ebnf-font-attributes ebnf-special-font))
|
|
4497 (format "/BorderWidthS %s def\n"
|
|
4498 (ebnf-format-float ebnf-special-border-width))
|
|
4499 (ebnf-format-color "/BorderColorS %s def %% %s\n"
|
|
4500 ebnf-special-border-color
|
|
4501 "Black")
|
|
4502 (format "/ShapeS %d def\n"
|
|
4503 (ebnf-shape-value ebnf-special-shape
|
|
4504 ebnf-terminal-shape-alist))
|
|
4505 (format "/ShadowS %s def\n"
|
|
4506 (ebnf-boolean ebnf-special-shadow))
|
|
4507 ;; except
|
|
4508 (format "/fE %s /%s DefFont\n"
|
|
4509 (ebnf-format-float (ebnf-font-size ebnf-except-font))
|
|
4510 (ebnf-font-name-select ebnf-except-font))
|
|
4511 (ebnf-format-color "/ForegroundE %s def %% %s\n"
|
|
4512 (ebnf-font-foreground ebnf-except-font)
|
|
4513 "Black")
|
|
4514 (ebnf-format-color "/BackgroundE %s def %% %s\n"
|
|
4515 (ebnf-font-background ebnf-except-font)
|
|
4516 "Gray90")
|
|
4517 (format "/EffectE %d def\n"
|
|
4518 (ebnf-font-attributes ebnf-except-font))
|
|
4519 (format "/BorderWidthE %s def\n"
|
|
4520 (ebnf-format-float ebnf-except-border-width))
|
|
4521 (ebnf-format-color "/BorderColorE %s def %% %s\n"
|
|
4522 ebnf-except-border-color
|
|
4523 "Black")
|
|
4524 (format "/ShapeE %d def\n"
|
|
4525 (ebnf-shape-value ebnf-except-shape
|
|
4526 ebnf-terminal-shape-alist))
|
|
4527 (format "/ShadowE %s def\n"
|
|
4528 (ebnf-boolean ebnf-except-shadow))
|
|
4529 ;; repeat
|
|
4530 (format "/fR %s /%s DefFont\n"
|
|
4531 (ebnf-format-float (ebnf-font-size ebnf-repeat-font))
|
|
4532 (ebnf-font-name-select ebnf-repeat-font))
|
|
4533 (ebnf-format-color "/ForegroundR %s def %% %s\n"
|
|
4534 (ebnf-font-foreground ebnf-repeat-font)
|
|
4535 "Black")
|
|
4536 (ebnf-format-color "/BackgroundR %s def %% %s\n"
|
|
4537 (ebnf-font-background ebnf-repeat-font)
|
|
4538 "Gray85")
|
|
4539 (format "/EffectR %d def\n"
|
|
4540 (ebnf-font-attributes ebnf-repeat-font))
|
|
4541 (format "/BorderWidthR %s def\n"
|
|
4542 (ebnf-format-float ebnf-repeat-border-width))
|
|
4543 (ebnf-format-color "/BorderColorR %s def %% %s\n"
|
|
4544 ebnf-repeat-border-color
|
|
4545 "Black")
|
|
4546 (format "/ShapeR %d def\n"
|
|
4547 (ebnf-shape-value ebnf-repeat-shape
|
|
4548 ebnf-terminal-shape-alist))
|
|
4549 (format "/ShadowR %s def\n"
|
|
4550 (ebnf-boolean ebnf-repeat-shadow))
|
|
4551 ;; miscellaneous
|
|
4552 (format "/DefaultWidth %s def\n"
|
|
4553 (ebnf-format-float ebnf-default-width))
|
|
4554 (format "/LineWidth %s def\n"
|
|
4555 (ebnf-format-float ebnf-line-width))
|
|
4556 (ebnf-format-color "/LineColor %s def %% %s\n"
|
|
4557 ebnf-line-color
|
|
4558 "Black")
|
|
4559 (format "/ArrowShape %d def\n"
|
|
4560 (ebnf-shape-value ebnf-arrow-shape
|
|
4561 ebnf-arrow-shape-alist))
|
|
4562 (format "/ChartShape %d def\n"
|
|
4563 (ebnf-shape-value ebnf-chart-shape
|
|
4564 ebnf-terminal-shape-alist))
|
|
4565 (format "/UserArrow{%s}def\n"
|
|
4566 (ebnf-user-arrow ebnf-user-arrow))
|
|
4567 "\n% === end EBNF settings\n\n"
|
|
4568 (and ebnf-debug-ps ebnf-debug))))
|
|
4569 ebnf-prologue))
|
|
4570
|
|
4571
|
|
4572 (defun ebnf-user-arrow (user-arrow)
|
|
4573 "Return a user arrow shape from USER-ARROW (a PostScript code).
|
|
4574
|
|
4575 This function is only called when `ebnf-arrow-shape' is set to symbol `user'.
|
|
4576
|
|
4577 If is a string, should be a PostScript procedure body.
|
|
4578 If is a variable symbol, should contain a string.
|
|
4579 If is a function symbol, it is called and the result is applied recursively.
|
|
4580 If is a cons and car is a function symbol, it is called as:
|
|
4581 (funcall (car cons) (cdr cons))
|
|
4582 and the result is applied recursively.
|
|
4583 If is a cons and car is not a function symbol, it is applied recursively on
|
|
4584 car and cdr, and the results are concatened as:
|
|
4585 (concat RESULT-FROM-CAR \" \" RESULT-FROM-CDR)
|
|
4586 If is a list and car is a function symbol, it is called as:
|
|
4587 (apply (car list) (cdr list))
|
|
4588 and the result is applied recursively.
|
|
4589 If is a list and car is not a function symbol, it is applied recursively on
|
|
4590 each element and the resulting list is concatened as:
|
|
4591 (mapconcat 'identity RESULTING-LIST \" \")
|
|
4592 Otherwise, it is treated as an empty string."
|
|
4593 (cond
|
|
4594 ((null user-arrow)
|
|
4595 "")
|
|
4596 ((stringp user-arrow)
|
|
4597 user-arrow)
|
|
4598 ((and (symbolp user-arrow) (fboundp user-arrow))
|
|
4599 (ebnf-user-arrow (funcall user-arrow)))
|
|
4600 ((and (symbolp user-arrow) (boundp user-arrow))
|
|
4601 (ebnf-user-arrow (symbol-value user-arrow)))
|
|
4602 ((consp user-arrow)
|
|
4603 (if (and (symbolp (car user-arrow)) (fboundp (car user-arrow)))
|
|
4604 (ebnf-user-arrow (funcall (car user-arrow) (cdr user-arrow)))
|
|
4605 (concat (ebnf-user-arrow (car user-arrow))
|
|
4606 " "
|
|
4607 (ebnf-user-arrow (cdr user-arrow)))))
|
|
4608 ((listp user-arrow)
|
|
4609 (if (and (symbolp (car user-arrow))
|
|
4610 (fboundp (car user-arrow)))
|
|
4611 (ebnf-user-arrow (apply (car user-arrow) (cdr user-arrow)))
|
|
4612 (mapconcat 'ebnf-user-arrow user-arrow " ")))
|
|
4613 (t
|
|
4614 "")
|
|
4615 ))
|
|
4616
|
|
4617
|
|
4618 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
4619 ;; Adjusting dimensions
|
|
4620
|
|
4621
|
|
4622 (defun ebnf-dimensions (tree)
|
|
4623 (let ((ebnf-total (length tree))
|
|
4624 (ebnf-nprod 0))
|
|
4625 (mapcar 'ebnf-production-dimension tree))
|
|
4626 tree)
|
|
4627
|
|
4628
|
|
4629 ;; [empty width-fun dim-fun entry height width]
|
|
4630 ;;(defun ebnf-empty-dimension (empty)
|
|
4631 ;; )
|
|
4632
|
|
4633
|
|
4634 ;; [production width-fun dim-fun entry height width name production action]
|
|
4635 (defun ebnf-production-dimension (production)
|
|
4636 (ebnf-message-info "Calculating dimensions")
|
|
4637 (ebnf-node-dimension-func (ebnf-node-production production))
|
|
4638 (let* ((prod (ebnf-node-production production))
|
|
4639 (height (+ ebnf-font-height-P
|
|
4640 ebnf-basic-height
|
|
4641 (ebnf-node-height prod))))
|
|
4642 (ebnf-node-entry production height)
|
|
4643 (ebnf-node-height production height)
|
|
4644 (ebnf-node-width production (+ (ebnf-node-width prod)
|
|
4645 ebnf-horizontal-space))))
|
|
4646
|
|
4647
|
|
4648 ;; [terminal width-fun dim-fun entry height width name]
|
|
4649 (defun ebnf-terminal-dimension (terminal)
|
|
4650 (ebnf-terminal-dimension1 terminal
|
|
4651 ebnf-font-height-T
|
|
4652 ebnf-font-width-T
|
|
4653 ebnf-space-T))
|
|
4654
|
|
4655
|
|
4656 ;; [non-terminal width-fun dim-fun entry height width name]
|
|
4657 (defun ebnf-non-terminal-dimension (non-terminal)
|
|
4658 (ebnf-terminal-dimension1 non-terminal
|
|
4659 ebnf-font-height-NT
|
|
4660 ebnf-font-width-NT
|
|
4661 ebnf-space-NT))
|
|
4662
|
|
4663
|
|
4664 ;; [special width-fun dim-fun entry height width name]
|
|
4665 (defun ebnf-special-dimension (special)
|
|
4666 (ebnf-terminal-dimension1 special
|
|
4667 ebnf-font-height-S
|
|
4668 ebnf-font-width-S
|
|
4669 ebnf-space-S))
|
|
4670
|
|
4671
|
|
4672 (defun ebnf-terminal-dimension1 (node font-height font-width space)
|
|
4673 (let ((height (+ space font-height space))
|
|
4674 (len (length (ebnf-node-name node))))
|
|
4675 (ebnf-node-entry node (* height 0.5))
|
|
4676 (ebnf-node-height node height)
|
|
4677 (ebnf-node-width node (+ ebnf-basic-width space
|
|
4678 (* len font-width)
|
|
4679 space ebnf-basic-width))))
|
|
4680
|
|
4681
|
|
4682 (defconst ebnf-null-vector (vector t t t 0.0 0.0 0.0))
|
|
4683
|
|
4684
|
|
4685 ;; [repeat width-fun dim-fun entry height width times element]
|
|
4686 (defun ebnf-repeat-dimension (repeat)
|
|
4687 (let ((times (ebnf-node-name repeat))
|
|
4688 (element (ebnf-node-separator repeat)))
|
|
4689 (if element
|
|
4690 (ebnf-node-dimension-func element)
|
|
4691 (setq element ebnf-null-vector))
|
|
4692 (ebnf-node-entry repeat (+ (ebnf-node-entry element)
|
|
4693 ebnf-space-R))
|
|
4694 (ebnf-node-height repeat (+ (max (ebnf-node-height element)
|
|
4695 ebnf-font-height-S)
|
|
4696 ebnf-space-R ebnf-space-R))
|
|
4697 (ebnf-node-width repeat (+ (ebnf-node-width element)
|
|
4698 ebnf-space-R ebnf-space-R ebnf-space-R
|
|
4699 ebnf-horizontal-space
|
|
4700 (* (length times) ebnf-font-width-R)))))
|
|
4701
|
|
4702
|
|
4703 ;; [except width-fun dim-fun entry height width element element]
|
|
4704 (defun ebnf-except-dimension (except)
|
|
4705 (let ((factor (ebnf-node-list except))
|
|
4706 (element (ebnf-node-separator except)))
|
|
4707 (ebnf-node-dimension-func factor)
|
|
4708 (if element
|
|
4709 (ebnf-node-dimension-func element)
|
|
4710 (setq element ebnf-null-vector))
|
|
4711 (ebnf-node-entry except (+ (max (ebnf-node-entry factor)
|
|
4712 (ebnf-node-entry element))
|
|
4713 ebnf-space-E))
|
|
4714 (ebnf-node-height except (+ (max (ebnf-node-height factor)
|
|
4715 (ebnf-node-height element))
|
|
4716 ebnf-space-E ebnf-space-E))
|
|
4717 (ebnf-node-width except (+ (ebnf-node-width factor)
|
|
4718 (ebnf-node-width element)
|
|
4719 ebnf-space-E ebnf-space-E
|
|
4720 ebnf-space-E ebnf-space-E
|
|
4721 ebnf-font-width-E
|
|
4722 ebnf-horizontal-space))))
|
|
4723
|
|
4724
|
|
4725 ;; [alternative width-fun dim-fun entry height width list]
|
|
4726 (defun ebnf-alternative-dimension (alternative)
|
|
4727 (let ((body (ebnf-node-list alternative))
|
|
4728 (lis (ebnf-node-list alternative)))
|
|
4729 (while lis
|
|
4730 (ebnf-node-dimension-func (car lis))
|
|
4731 (setq lis (cdr lis)))
|
|
4732 (let ((height 0.0)
|
|
4733 (width 0.0)
|
|
4734 (alt body)
|
|
4735 (tail (car (last body)))
|
|
4736 (entry (ebnf-node-entry (car body)))
|
|
4737 node)
|
|
4738 (while alt
|
|
4739 (setq node (car alt)
|
|
4740 alt (cdr alt)
|
|
4741 height (+ (ebnf-node-height node) height)
|
|
4742 width (max (ebnf-node-width node) width)))
|
|
4743 (ebnf-adjust-width body width)
|
|
4744 (setq height (+ height (* (1- (length body)) ebnf-vertical-space)))
|
|
4745 (ebnf-node-entry alternative (+ entry
|
|
4746 (ebnf-entry
|
|
4747 (- height entry
|
|
4748 (- (ebnf-node-height tail)
|
|
4749 (ebnf-node-entry tail))))))
|
|
4750 (ebnf-node-height alternative height)
|
|
4751 (ebnf-node-width alternative (+ width ebnf-horizontal-space))
|
|
4752 (ebnf-node-list alternative body))))
|
|
4753
|
|
4754
|
|
4755 ;; [optional width-fun dim-fun entry height width element]
|
|
4756 (defun ebnf-optional-dimension (optional)
|
|
4757 (let ((body (ebnf-node-list optional)))
|
|
4758 (ebnf-node-dimension-func body)
|
|
4759 (ebnf-node-entry optional (ebnf-node-entry body))
|
|
4760 (ebnf-node-height optional (+ (ebnf-node-height body)
|
|
4761 ebnf-vertical-space))
|
|
4762 (ebnf-node-width optional (+ (ebnf-node-width body)
|
|
4763 ebnf-horizontal-space))))
|
|
4764
|
|
4765
|
|
4766 ;; [one-or-more width-fun dim-fun entry height width element separator]
|
|
4767 (defun ebnf-one-or-more-dimension (or-more)
|
|
4768 (let ((list-part (ebnf-node-list or-more))
|
|
4769 (sep-part (ebnf-node-separator or-more)))
|
|
4770 (ebnf-node-dimension-func list-part)
|
|
4771 (and sep-part
|
|
4772 (ebnf-node-dimension-func sep-part))
|
|
4773 (let ((height (+ (if sep-part
|
|
4774 (ebnf-node-height sep-part)
|
|
4775 0.0)
|
|
4776 ebnf-vertical-space
|
|
4777 (ebnf-node-height list-part)))
|
|
4778 (width (max (if sep-part
|
|
4779 (ebnf-node-width sep-part)
|
|
4780 0.0)
|
|
4781 (ebnf-node-width list-part))))
|
|
4782 (when sep-part
|
|
4783 (ebnf-adjust-width list-part width)
|
|
4784 (ebnf-adjust-width sep-part width))
|
|
4785 (ebnf-node-entry or-more (+ (- height (ebnf-node-height list-part))
|
|
4786 (ebnf-node-entry list-part)))
|
|
4787 (ebnf-node-height or-more height)
|
|
4788 (ebnf-node-width or-more (+ width ebnf-horizontal-space)))))
|
|
4789
|
|
4790
|
|
4791 ;; [zero-or-more width-fun dim-fun entry height width element separator]
|
|
4792 (defun ebnf-zero-or-more-dimension (or-more)
|
|
4793 (let ((list-part (ebnf-node-list or-more))
|
|
4794 (sep-part (ebnf-node-separator or-more)))
|
|
4795 (ebnf-node-dimension-func list-part)
|
|
4796 (and sep-part
|
|
4797 (ebnf-node-dimension-func sep-part))
|
|
4798 (let ((height (+ (if sep-part
|
|
4799 (ebnf-node-height sep-part)
|
|
4800 0.0)
|
|
4801 ebnf-vertical-space
|
|
4802 (ebnf-node-height list-part)
|
|
4803 ebnf-vertical-space))
|
|
4804 (width (max (if sep-part
|
|
4805 (ebnf-node-width sep-part)
|
|
4806 0.0)
|
|
4807 (ebnf-node-width list-part))))
|
|
4808 (when sep-part
|
|
4809 (ebnf-adjust-width list-part width)
|
|
4810 (ebnf-adjust-width sep-part width))
|
|
4811 (ebnf-node-entry or-more height)
|
|
4812 (ebnf-node-height or-more height)
|
|
4813 (ebnf-node-width or-more (+ width ebnf-horizontal-space)))))
|
|
4814
|
|
4815
|
|
4816 ;; [sequence width-fun dim-fun entry height width list]
|
|
4817 (defun ebnf-sequence-dimension (sequence)
|
|
4818 (let ((above 0.0)
|
|
4819 (below 0.0)
|
|
4820 (width 0.0)
|
|
4821 (lis (ebnf-node-list sequence))
|
|
4822 entry node)
|
|
4823 (while lis
|
|
4824 (setq node (car lis)
|
|
4825 lis (cdr lis))
|
|
4826 (ebnf-node-dimension-func node)
|
|
4827 (setq entry (ebnf-node-entry node)
|
|
4828 above (max above entry)
|
|
4829 below (max below (- (ebnf-node-height node) entry))
|
|
4830 width (+ width (ebnf-node-width node))))
|
|
4831 (ebnf-node-entry sequence above)
|
|
4832 (ebnf-node-height sequence (+ above below))
|
|
4833 (ebnf-node-width sequence width)))
|
|
4834
|
|
4835
|
|
4836 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
4837 ;; Adjusting width
|
|
4838
|
|
4839
|
|
4840 (defun ebnf-adjust-width (node width)
|
|
4841 (cond
|
|
4842 ((listp node)
|
|
4843 (prog1
|
|
4844 node
|
|
4845 (while node
|
|
4846 (setcar node (ebnf-adjust-width (car node) width))
|
|
4847 (setq node (cdr node)))))
|
|
4848 ((vectorp node)
|
|
4849 (cond
|
|
4850 ;; nothing to be done
|
|
4851 ((= width (ebnf-node-width node))
|
|
4852 node)
|
|
4853 ;; left justify term
|
|
4854 ((eq ebnf-justify-sequence 'left)
|
|
4855 (ebnf-adjust-empty node width nil))
|
|
4856 ;; right justify terms
|
|
4857 ((eq ebnf-justify-sequence 'right)
|
|
4858 (ebnf-adjust-empty node width t))
|
|
4859 ;; centralize terms
|
|
4860 (t
|
|
4861 (ebnf-node-width-func node width)
|
|
4862 (ebnf-node-width node width)
|
|
4863 node)
|
|
4864 ))
|
|
4865 (t
|
|
4866 node)
|
|
4867 ))
|
|
4868
|
|
4869
|
|
4870 (defun ebnf-adjust-empty (node width last-p)
|
|
4871 (if (eq (ebnf-node-kind node) 'ebnf-generate-empty)
|
|
4872 (progn
|
|
4873 (ebnf-node-width node width)
|
|
4874 node)
|
|
4875 (let ((empty (ebnf-make-empty (- width (ebnf-node-width node)))))
|
|
4876 (ebnf-make-dup-sequence node
|
|
4877 (if last-p
|
|
4878 (list empty node)
|
|
4879 (list node empty))))))
|
|
4880
|
|
4881
|
|
4882 ;; [terminal width-fun dim-fun entry height width name]
|
|
4883 ;; [non-terminal width-fun dim-fun entry height width name]
|
|
4884 ;; [empty width-fun dim-fun entry height width]
|
|
4885 ;; [special width-fun dim-fun entry height width name]
|
|
4886 ;; [repeat width-fun dim-fun entry height width times element]
|
|
4887 ;; [except width-fun dim-fun entry height width element element]
|
|
4888 ;;(defun ebnf-terminal-width (terminal width)
|
|
4889 ;; )
|
|
4890
|
|
4891
|
|
4892 ;; [alternative width-fun dim-fun entry height width list]
|
|
4893 ;; [optional width-fun dim-fun entry height width element]
|
|
4894 (defun ebnf-alternative-width (alternative width)
|
|
4895 (ebnf-adjust-width (ebnf-node-list alternative)
|
|
4896 (- width ebnf-horizontal-space)))
|
|
4897
|
|
4898
|
|
4899 ;; [one-or-more width-fun dim-fun entry height width element separator]
|
|
4900 ;; [zero-or-more width-fun dim-fun entry height width element separator]
|
|
4901 (defun ebnf-list-width (or-more width)
|
|
4902 (setq width (- width ebnf-horizontal-space))
|
|
4903 (ebnf-node-list or-more
|
|
4904 (ebnf-justify-list or-more
|
|
4905 (ebnf-node-list or-more)
|
|
4906 width))
|
|
4907 (ebnf-node-separator or-more
|
|
4908 (ebnf-justify-list or-more
|
|
4909 (ebnf-node-separator or-more)
|
|
4910 width)))
|
|
4911
|
|
4912
|
|
4913 ;; [sequence width-fun dim-fun entry height width list]
|
|
4914 (defun ebnf-sequence-width (sequence width)
|
|
4915 (ebnf-node-list sequence
|
|
4916 (ebnf-justify-list sequence (ebnf-node-list sequence) width)))
|
|
4917
|
|
4918
|
|
4919 (defun ebnf-justify-list (node seq width)
|
|
4920 (let ((seq-width (ebnf-node-width node)))
|
|
4921 (if (= width seq-width)
|
|
4922 seq
|
|
4923 (cond
|
|
4924 ;; left justify terms
|
|
4925 ((eq ebnf-justify-sequence 'left)
|
|
4926 (ebnf-justify node seq seq-width width t))
|
|
4927 ;; right justify terms
|
|
4928 ((eq ebnf-justify-sequence 'right)
|
|
4929 (ebnf-justify node seq seq-width width nil))
|
|
4930 ;; centralize terms
|
|
4931 (t
|
|
4932 (let ((the-width (/ (- width seq-width) (length seq)))
|
|
4933 (lis seq))
|
|
4934 (while lis
|
|
4935 (ebnf-adjust-width (car lis)
|
|
4936 (+ (ebnf-node-width (car lis))
|
|
4937 the-width))
|
|
4938 (setq lis (cdr lis)))
|
|
4939 seq))
|
|
4940 ))))
|
|
4941
|
|
4942
|
|
4943 (defun ebnf-justify (node seq seq-width width last-p)
|
|
4944 (let ((term (car (if last-p (last seq) seq))))
|
|
4945 (cond
|
|
4946 ;; adjust empty term
|
|
4947 ((eq (ebnf-node-kind term) 'ebnf-generate-empty)
|
|
4948 (ebnf-node-width term (+ (- width seq-width)
|
|
4949 (ebnf-node-width term)))
|
|
4950 seq)
|
|
4951 ;; insert empty at end ==> left justify
|
|
4952 (last-p
|
|
4953 (nconc seq
|
|
4954 (list (ebnf-make-empty (- width seq-width)))))
|
|
4955 ;; insert empty at beginning ==> right justify
|
|
4956 (t
|
|
4957 (cons (ebnf-make-empty (- width seq-width))
|
|
4958 seq))
|
|
4959 )))
|
|
4960
|
|
4961
|
|
4962 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
4963 ;; Functions used by parsers
|
|
4964
|
|
4965
|
|
4966 (defun ebnf-eps-add-context (name)
|
|
4967 (let ((filename (ebnf-eps-filename name)))
|
|
4968 (if (member filename ebnf-eps-context)
|
|
4969 (error "Try to open an already opened EPS file: %s" filename)
|
|
4970 (setq ebnf-eps-context (cons filename ebnf-eps-context)))))
|
|
4971
|
|
4972
|
|
4973 (defun ebnf-eps-remove-context (name)
|
|
4974 (let ((filename (ebnf-eps-filename name)))
|
|
4975 (if (member filename ebnf-eps-context)
|
|
4976 (setq ebnf-eps-context (delete filename ebnf-eps-context))
|
|
4977 (error "Try to close a not opened EPS file: %s" filename))))
|
|
4978
|
|
4979
|
|
4980 (defun ebnf-eps-add-production (header)
|
|
4981 (and ebnf-eps-executing
|
|
4982 ebnf-eps-context
|
|
4983 (let ((prod (assoc header ebnf-eps-production-list)))
|
|
4984 (if prod
|
|
4985 (setcdr prod (append ebnf-eps-context (cdr prod)))
|
|
4986 (setq ebnf-eps-production-list
|
|
4987 (cons (cons header (ebnf-dup-list ebnf-eps-context))
|
|
4988 ebnf-eps-production-list))))))
|
|
4989
|
|
4990
|
|
4991 (defun ebnf-dup-list (old)
|
|
4992 (let (new)
|
|
4993 (while old
|
|
4994 (setq new (cons (car old) new)
|
|
4995 old (cdr old)))
|
|
4996 (nreverse new)))
|
|
4997
|
|
4998
|
|
4999 (defun ebnf-buffer-substring (chars)
|
|
5000 (buffer-substring-no-properties
|
|
5001 (point)
|
|
5002 (progn
|
|
5003 (skip-chars-forward chars ebnf-limit)
|
|
5004 (point))))
|
|
5005
|
|
5006
|
|
5007 (defun ebnf-string (chars eos-char kind)
|
|
5008 (forward-char)
|
|
5009 (buffer-substring-no-properties
|
|
5010 (point)
|
|
5011 (progn
|
|
5012 (skip-chars-forward (concat chars "\240-\377") ebnf-limit)
|
|
5013 (if (or (eobp) (/= (following-char) eos-char))
|
|
5014 (error "Illegal %s: missing `%c'." kind eos-char)
|
|
5015 (forward-char)
|
|
5016 (1- (point))))))
|
|
5017
|
|
5018
|
|
5019 (defun ebnf-get-string ()
|
|
5020 (forward-char)
|
|
5021 (buffer-substring-no-properties (point) (ebnf-end-of-string)))
|
|
5022
|
|
5023
|
|
5024 (defun ebnf-end-of-string ()
|
|
5025 (let ((n 1))
|
|
5026 (while (> (logand n 1) 0)
|
|
5027 (skip-chars-forward "^\"" ebnf-limit)
|
|
5028 (setq n (- (skip-chars-backward "\\\\")))
|
|
5029 (goto-char (+ (point) n 1))))
|
|
5030 (if (= (preceding-char) ?\")
|
|
5031 (1- (point))
|
|
5032 (error "Missing `\"'.")))
|
|
5033
|
|
5034
|
|
5035 (defun ebnf-trim-right (str)
|
|
5036 (let* ((len (1- (length str)))
|
|
5037 (index len))
|
|
5038 (while (and (> index 0) (= (aref str index) ?\ ))
|
|
5039 (setq index (1- index)))
|
|
5040 (if (= index len)
|
|
5041 str
|
|
5042 (substring str 0 (1+ index)))))
|
|
5043
|
|
5044
|
|
5045 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
5046 ;; Vector creation
|
|
5047
|
|
5048
|
|
5049 (defun ebnf-make-empty (&optional width)
|
|
5050 (vector 'ebnf-generate-empty
|
|
5051 'ignore
|
|
5052 'ignore
|
|
5053 0.0
|
|
5054 0.0
|
|
5055 (or width ebnf-horizontal-space)))
|
|
5056
|
|
5057
|
|
5058 (defun ebnf-make-terminal (name)
|
|
5059 (ebnf-make-terminal1 name
|
|
5060 'ebnf-generate-terminal
|
|
5061 'ebnf-terminal-dimension))
|
|
5062
|
|
5063
|
|
5064 (defun ebnf-make-non-terminal (name)
|
|
5065 (ebnf-make-terminal1 name
|
|
5066 'ebnf-generate-non-terminal
|
|
5067 'ebnf-non-terminal-dimension))
|
|
5068
|
|
5069
|
|
5070 (defun ebnf-make-special (name)
|
|
5071 (ebnf-make-terminal1 name
|
|
5072 'ebnf-generate-special
|
|
5073 'ebnf-special-dimension))
|
|
5074
|
|
5075
|
|
5076 (defun ebnf-make-terminal1 (name gen-func dim-func)
|
|
5077 (vector gen-func
|
|
5078 'ignore
|
|
5079 dim-func
|
|
5080 0.0
|
|
5081 0.0
|
|
5082 0.0
|
|
5083 (let ((len (length name)))
|
|
5084 (cond ((> len 2) name)
|
|
5085 ((= len 2) (concat " " name))
|
|
5086 ((= len 1) (concat " " name " "))
|
|
5087 (t " ")))
|
|
5088 ebnf-default-p))
|
|
5089
|
|
5090
|
|
5091 (defun ebnf-make-one-or-more (list-part &optional sep-part)
|
|
5092 (ebnf-make-or-more1 'ebnf-generate-one-or-more
|
|
5093 'ebnf-one-or-more-dimension
|
|
5094 list-part
|
|
5095 sep-part))
|
|
5096
|
|
5097
|
|
5098 (defun ebnf-make-zero-or-more (list-part &optional sep-part)
|
|
5099 (ebnf-make-or-more1 'ebnf-generate-zero-or-more
|
|
5100 'ebnf-zero-or-more-dimension
|
|
5101 list-part
|
|
5102 sep-part))
|
|
5103
|
|
5104
|
|
5105 (defun ebnf-make-or-more1 (gen-func dim-func list-part sep-part)
|
|
5106 (vector gen-func
|
|
5107 'ebnf-list-width
|
|
5108 dim-func
|
|
5109 0.0
|
|
5110 0.0
|
|
5111 0.0
|
|
5112 (if (listp list-part)
|
|
5113 (ebnf-make-sequence list-part)
|
|
5114 list-part)
|
|
5115 (if (and sep-part (listp sep-part))
|
|
5116 (ebnf-make-sequence sep-part)
|
|
5117 sep-part)))
|
|
5118
|
|
5119
|
|
5120 (defun ebnf-make-production (name prod action)
|
|
5121 (vector 'ebnf-generate-production
|
|
5122 'ignore
|
|
5123 'ebnf-production-dimension
|
|
5124 0.0
|
|
5125 0.0
|
|
5126 0.0
|
|
5127 name
|
|
5128 prod
|
|
5129 action))
|
|
5130
|
|
5131
|
|
5132 (defun ebnf-make-alternative (body)
|
|
5133 (vector 'ebnf-generate-alternative
|
|
5134 'ebnf-alternative-width
|
|
5135 'ebnf-alternative-dimension
|
|
5136 0.0
|
|
5137 0.0
|
|
5138 0.0
|
|
5139 body))
|
|
5140
|
|
5141
|
|
5142 (defun ebnf-make-optional (body)
|
|
5143 (vector 'ebnf-generate-optional
|
|
5144 'ebnf-alternative-width
|
|
5145 'ebnf-optional-dimension
|
|
5146 0.0
|
|
5147 0.0
|
|
5148 0.0
|
|
5149 body))
|
|
5150
|
|
5151
|
|
5152 (defun ebnf-make-except (factor exception)
|
|
5153 (vector 'ebnf-generate-except
|
|
5154 'ignore
|
|
5155 'ebnf-except-dimension
|
|
5156 0.0
|
|
5157 0.0
|
|
5158 0.0
|
|
5159 factor
|
|
5160 exception))
|
|
5161
|
|
5162
|
|
5163 (defun ebnf-make-repeat (times primary)
|
|
5164 (vector 'ebnf-generate-repeat
|
|
5165 'ignore
|
|
5166 'ebnf-repeat-dimension
|
|
5167 0.0
|
|
5168 0.0
|
|
5169 0.0
|
|
5170 (concat times " *")
|
|
5171 primary))
|
|
5172
|
|
5173
|
|
5174 (defun ebnf-make-sequence (seq)
|
|
5175 (vector 'ebnf-generate-sequence
|
|
5176 'ebnf-sequence-width
|
|
5177 'ebnf-sequence-dimension
|
|
5178 0.0
|
|
5179 0.0
|
|
5180 0.0
|
|
5181 seq))
|
|
5182
|
|
5183
|
|
5184 (defun ebnf-make-dup-sequence (node seq)
|
|
5185 (vector 'ebnf-generate-sequence
|
|
5186 'ebnf-sequence-width
|
|
5187 'ebnf-sequence-dimension
|
|
5188 (ebnf-node-entry node)
|
|
5189 (ebnf-node-height node)
|
|
5190 (ebnf-node-width node)
|
|
5191 seq))
|
|
5192
|
|
5193
|
|
5194 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
5195 ;; Optimizers used by parsers
|
|
5196
|
|
5197
|
|
5198 (defun ebnf-token-except (element exception)
|
|
5199 (cons (prog1
|
|
5200 (car exception)
|
|
5201 (setq exception (cdr exception)))
|
|
5202 (and element ; EMPTY - A ==> EMPTY
|
|
5203 (let ((kind (ebnf-node-kind element)))
|
|
5204 (cond
|
|
5205 ;; [ A ]- ==> A
|
|
5206 ((and (null exception)
|
|
5207 (eq kind 'ebnf-generate-optional))
|
|
5208 (ebnf-node-list element))
|
|
5209 ;; { A }- ==> { A }+
|
|
5210 ((and (null exception)
|
|
5211 (eq kind 'ebnf-generate-zero-or-more))
|
|
5212 (ebnf-node-kind element 'ebnf-generate-one-or-more)
|
|
5213 (ebnf-node-dimension-func element 'ebnf-one-or-more-dimension)
|
|
5214 element)
|
|
5215 ;; ( A | EMPTY )- ==> A
|
|
5216 ;; ( A | B | EMPTY )- ==> A | B
|
|
5217 ((and (null exception)
|
|
5218 (eq kind 'ebnf-generate-alternative)
|
|
5219 (eq (ebnf-node-kind (car (last (ebnf-node-list element))))
|
|
5220 'ebnf-generate-empty))
|
|
5221 (let ((elt (ebnf-node-list element))
|
|
5222 bef)
|
|
5223 (while (cdr elt)
|
|
5224 (setq bef elt
|
|
5225 elt (cdr elt)))
|
|
5226 (if (null bef)
|
|
5227 ;; this should not happen!!?!
|
|
5228 (setq element (ebnf-make-empty
|
|
5229 (ebnf-node-width element)))
|
|
5230 (setcdr bef nil)
|
|
5231 (setq elt (ebnf-node-list element))
|
|
5232 (and (= (length elt) 1)
|
|
5233 (setq element (car elt))))
|
|
5234 element))
|
|
5235 ;; A - B
|
|
5236 (t
|
|
5237 (ebnf-make-except element exception))
|
|
5238 )))))
|
|
5239
|
|
5240
|
|
5241 (defun ebnf-token-repeat (times repeat)
|
|
5242 (if (null (cdr repeat))
|
|
5243 ;; n * EMPTY ==> EMPTY
|
|
5244 repeat
|
|
5245 ;; n * term
|
|
5246 (cons (car repeat)
|
|
5247 (ebnf-make-repeat times (cdr repeat)))))
|
|
5248
|
|
5249
|
|
5250 (defun ebnf-token-optional (body)
|
|
5251 (let ((kind (ebnf-node-kind body)))
|
|
5252 (cond
|
|
5253 ;; [ EMPTY ] ==> EMPTY
|
|
5254 ((eq kind 'ebnf-generate-empty)
|
|
5255 nil)
|
|
5256 ;; [ { A }* ] ==> { A }*
|
|
5257 ((eq kind 'ebnf-generate-zero-or-more)
|
|
5258 body)
|
|
5259 ;; [ { A }+ ] ==> { A }*
|
|
5260 ((eq kind 'ebnf-generate-one-or-more)
|
|
5261 (ebnf-node-kind body 'ebnf-generate-zero-or-more)
|
|
5262 body)
|
|
5263 ;; [ A | B ] ==> A | B | EMPTY
|
|
5264 ((eq kind 'ebnf-generate-alternative)
|
|
5265 (ebnf-node-list body (nconc (ebnf-node-list body)
|
|
5266 (list (ebnf-make-empty))))
|
|
5267 body)
|
|
5268 ;; [ A ]
|
|
5269 (t
|
|
5270 (ebnf-make-optional body))
|
|
5271 )))
|
|
5272
|
|
5273
|
|
5274 (defun ebnf-token-alternative (body sequence)
|
|
5275 (if (null body)
|
|
5276 (if (cdr sequence)
|
|
5277 sequence
|
|
5278 (cons (car sequence)
|
|
5279 (ebnf-make-empty)))
|
|
5280 (cons (car sequence)
|
|
5281 (let ((seq (cdr sequence)))
|
|
5282 (if (and (= (length body) 1) (null seq))
|
|
5283 (car body)
|
|
5284 (ebnf-make-alternative (nreverse (if seq
|
|
5285 (cons seq body)
|
|
5286 body))))))))
|
|
5287
|
|
5288
|
|
5289 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
5290 ;; Variables used by parsers
|
|
5291
|
|
5292
|
|
5293 (defconst ebnf-comment-table
|
|
5294 (let ((table (make-vector 256 nil)))
|
|
5295 ;; Override special comment character:
|
|
5296 (aset table ?< 'newline)
|
|
5297 (aset table ?> 'keep-line)
|
|
5298 table)
|
|
5299 "Vector used to map characters to a special comment token.")
|
|
5300
|
|
5301
|
|
5302 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
5303 ;; To make this file smaller, some commands go in a separate file.
|
|
5304 ;; But autoload them here to make the separation invisible.
|
|
5305
|
|
5306 (autoload 'ebnf-bnf-parser "ebnf-bnf"
|
|
5307 "EBNF parser.")
|
|
5308
|
|
5309 (autoload 'ebnf-bnf-initialize "ebnf-bnf"
|
|
5310 "Initialize EBNF token table.")
|
|
5311
|
|
5312 (autoload 'ebnf-iso-parser "ebnf-iso"
|
|
5313 "ISO EBNF parser.")
|
|
5314
|
|
5315 (autoload 'ebnf-iso-initialize "ebnf-iso"
|
|
5316 "Initialize ISO EBNF token table.")
|
|
5317
|
|
5318 (autoload 'ebnf-yac-parser "ebnf-yac"
|
|
5319 "Yacc/Bison parser.")
|
|
5320
|
|
5321 (autoload 'ebnf-yac-initialize "ebnf-yac"
|
|
5322 "Initializations for Yacc/Bison parser.")
|
|
5323
|
|
5324 (autoload 'ebnf-eliminate-empty-rules "ebnf-otz"
|
|
5325 "Eliminate empty rules.")
|
|
5326
|
|
5327 (autoload 'ebnf-optimize "ebnf-otz"
|
|
5328 "Syntatic chart optimizer.")
|
|
5329
|
|
5330 (autoload 'ebnf-otz-initialize "ebnf-otz"
|
|
5331 "Initialize optimizer.")
|
|
5332
|
|
5333
|
|
5334 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
5335
|
|
5336
|
|
5337 (provide 'ebnf2ps)
|
|
5338
|
|
5339
|
|
5340 ;;; ebnf2ps.el ends here
|