Mercurial > emacs
comparison lisp/progmodes/ebnf2ps.el @ 30552:a7498193b035
Update ps-print functions call. Indentation fix. Doc
fix.
(ebnf-version): New version number (3.2).
(ebnf-format-color, ebnf-begin-job): Code fix.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Tue, 01 Aug 2000 19:56:12 +0000 |
parents | 9299c470e566 |
children | f0463edb8518 |
comparison
equal
deleted
inserted
replaced
30551:56f69311c3a0 | 30552:a7498193b035 |
---|---|
3 ;; Copyright (C) 1999, 2000 Free Software Foundation, Inc. | 3 ;; Copyright (C) 1999, 2000 Free Software Foundation, Inc. |
4 | 4 |
5 ;; Author: Vinicius Jose Latorre <vinicius@cpqd.com.br> | 5 ;; Author: Vinicius Jose Latorre <vinicius@cpqd.com.br> |
6 ;; Maintainer: Vinicius Jose Latorre <vinicius@cpqd.com.br> | 6 ;; Maintainer: Vinicius Jose Latorre <vinicius@cpqd.com.br> |
7 ;; Keywords: wp, ebnf, PostScript | 7 ;; Keywords: wp, ebnf, PostScript |
8 ;; Time-stamp: <99/12/11 21:41:24 vinicius> | 8 ;; Time-stamp: <2000/07/29 13:09:47 vinicius> |
9 ;; Version: 3.1 | 9 ;; Version: 3.2 |
10 ;; X-URL: http://www.cpqd.com.br/~vinicius/emacs/Emacs.html | |
10 | 11 |
11 ;; This file is part of GNU Emacs. | 12 ;; This file is part of GNU Emacs. |
12 | 13 |
13 ;; GNU Emacs is free software; you can redistribute it and/or modify | 14 ;; GNU Emacs is free software; you can redistribute it and/or modify |
14 ;; it under the terms of the GNU General Public License as published by | 15 ;; it under the terms of the GNU General Public License as published by |
23 ;; You should have received a copy of the GNU General Public License | 24 ;; You should have received a copy of the GNU General Public License |
24 ;; along with GNU Emacs; see the file COPYING. If not, write to the | 25 ;; along with GNU Emacs; see the file COPYING. If not, write to the |
25 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 26 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
26 ;; Boston, MA 02111-1307, USA. | 27 ;; Boston, MA 02111-1307, USA. |
27 | 28 |
28 (defconst ebnf-version "3.1" | 29 (defconst ebnf-version "3.2" |
29 "ebnf2ps.el, v 3.1 <99/12/11 vinicius> | 30 "ebnf2ps.el, v 3.2 <2000/07/29 vinicius> |
30 | 31 |
31 Vinicius's last change version. When reporting bugs, please also | 32 Vinicius's last change version. When reporting bugs, please also |
32 report the version of Emacs, if any, that ebnf2ps was running with. | 33 report the version of Emacs, if any, that ebnf2ps was running with. |
33 | 34 |
34 Please send all bug fixes and enhancements to | 35 Please send all bug fixes and enhancements to |
47 ;; | 48 ;; |
48 ;; To use ebnf2ps, insert in your ~/.emacs: | 49 ;; To use ebnf2ps, insert in your ~/.emacs: |
49 ;; | 50 ;; |
50 ;; (require 'ebnf2ps) | 51 ;; (require 'ebnf2ps) |
51 ;; | 52 ;; |
52 ;; ebnf2ps uses ps-print package (version 3.05.1 or later), so see ps-print to | 53 ;; ebnf2ps uses ps-print package (version 5.2.3 or later), so see ps-print to |
53 ;; know how to set options like landscape printing, page headings, margins, etc. | 54 ;; know how to set options like landscape printing, page headings, margins, |
55 ;; etc. | |
54 ;; | 56 ;; |
55 ;; NOTE: ps-print zebra stripes and line number options doesn't have effect on | 57 ;; NOTE: ps-print zebra stripes and line number options doesn't have effect on |
56 ;; ebnf2ps, they behave as it's turned off. | 58 ;; ebnf2ps, they behave as it's turned off. |
57 ;; | 59 ;; |
58 ;; For good performance, be sure to byte-compile ebnf2ps.el, e.g. | 60 ;; For good performance, be sure to byte-compile ebnf2ps.el, e.g. |
65 ;; | 67 ;; |
66 ;; | 68 ;; |
67 ;; Using ebnf2ps | 69 ;; Using ebnf2ps |
68 ;; ------------- | 70 ;; ------------- |
69 ;; | 71 ;; |
70 ;; ebnf2ps provides six commands for generating PostScript syntatic chart images | 72 ;; ebnf2ps provides six commands for generating PostScript syntatic chart |
71 ;; of Emacs buffers: | 73 ;; images of Emacs buffers: |
72 ;; | 74 ;; |
73 ;; ebnf-print-buffer | 75 ;; ebnf-print-buffer |
74 ;; ebnf-print-region | 76 ;; ebnf-print-region |
75 ;; ebnf-spool-buffer | 77 ;; ebnf-spool-buffer |
76 ;; ebnf-spool-region | 78 ;; ebnf-spool-region |
77 ;; ebnf-eps-buffer | 79 ;; ebnf-eps-buffer |
78 ;; ebnf-eps-region | 80 ;; ebnf-eps-region |
79 ;; | 81 ;; |
80 ;; These commands all perform essentially the same function: they generate | 82 ;; These commands all perform essentially the same function: they generate |
81 ;; PostScript syntatic chart images suitable for printing on a PostScript | 83 ;; PostScript syntatic chart images suitable for printing on a PostScript |
82 ;; printer or displaying with GhostScript. These commands are collectively | 84 ;; printer or displaying with GhostScript. These commands are collectively |
83 ;; referred to as "ebnf- commands". | 85 ;; referred to as "ebnf- commands". |
84 ;; | 86 ;; |
85 ;; The word "print", "spool" and "eps" in the command name determines when the | 87 ;; The word "print", "spool" and "eps" in the command name determines when the |
86 ;; PostScript image is sent to the printer (or file): | 88 ;; PostScript image is sent to the printer (or file): |
87 ;; | 89 ;; |
88 ;; print - The PostScript image is immediately sent to the printer; | 90 ;; print - The PostScript image is immediately sent to the printer; |
89 ;; | 91 ;; |
90 ;; spool - The PostScript image is saved temporarily in an Emacs buffer. | 92 ;; spool - The PostScript image is saved temporarily in an Emacs buffer. |
91 ;; Many images may be spooled locally before printing them. To | 93 ;; Many images may be spooled locally before printing them. To |
92 ;; send the spooled images to the printer, use the command | 94 ;; send the spooled images to the printer, use the command |
93 ;; `ebnf-despool'. | 95 ;; `ebnf-despool'. |
94 ;; | 96 ;; |
95 ;; eps - The PostScript image is immediately sent to a EPS file. | 97 ;; eps - The PostScript image is immediately sent to a EPS file. |
96 ;; | 98 ;; |
97 ;; The spooling mechanism is the same as used by ps-print and was designed for | 99 ;; The spooling mechanism is the same as used by ps-print and was designed for |
98 ;; printing lots of small files to save paper that would otherwise be wasted on | 100 ;; printing lots of small files to save paper that would otherwise be wasted on |
99 ;; banner pages, and to make it easier to find your output at the printer (it's | 101 ;; banner pages, and to make it easier to find your output at the printer (it's |
100 ;; easier to pick up one 50-page printout than to find 50 single-page | 102 ;; easier to pick up one 50-page printout than to find 50 single-page |
103 ;; | 105 ;; |
104 ;; ebnf2ps use the same hook of ps-print in the `kill-emacs-hook' so that you | 106 ;; ebnf2ps use the same hook of ps-print in the `kill-emacs-hook' so that you |
105 ;; won't accidentally quit from Emacs while you have unprinted PostScript | 107 ;; won't accidentally quit from Emacs while you have unprinted PostScript |
106 ;; waiting in the spool buffer. If you do attempt to exit with spooled | 108 ;; waiting in the spool buffer. If you do attempt to exit with spooled |
107 ;; PostScript, you'll be asked if you want to print it, and if you decline, | 109 ;; PostScript, you'll be asked if you want to print it, and if you decline, |
108 ;; you'll be asked to confirm the exit; this is modeled on the confirmation that | 110 ;; you'll be asked to confirm the exit; this is modeled on the confirmation |
109 ;; Emacs uses for modified buffers. | 111 ;; that Emacs uses for modified buffers. |
110 ;; | 112 ;; |
111 ;; The word "buffer" or "region" in the command name determines how much of the | 113 ;; The word "buffer" or "region" in the command name determines how much of the |
112 ;; buffer is printed: | 114 ;; buffer is printed: |
113 ;; | 115 ;; |
114 ;; buffer - Print the entire buffer. | 116 ;; buffer - Print the entire buffer. |
115 ;; | 117 ;; |
116 ;; region - Print just the current region. | 118 ;; region - Print just the current region. |
117 ;; | 119 ;; |
118 ;; Two ebnf- command examples: | 120 ;; Two ebnf- command examples: |
119 ;; | 121 ;; |
120 ;; ebnf-print-buffer - translate and print the entire buffer, and send | 122 ;; ebnf-print-buffer - translate and print the entire buffer, and send it |
121 ;; it immediately to the printer. | 123 ;; immediately to the printer. |
122 ;; | 124 ;; |
123 ;; ebnf-spool-region - translate and print just the current region, and | 125 ;; ebnf-spool-region - translate and print just the current region, and |
124 ;; spool the image in Emacs to send to the printer | 126 ;; spool the image in Emacs to send to the printer |
125 ;; later. | 127 ;; later. |
126 ;; | 128 ;; |
127 ;; Note that `ebnf-eps-buffer' and `ebnf-eps-region' never spool the EPS image, | 129 ;; Note that `ebnf-eps-buffer' and `ebnf-eps-region' never spool the EPS image, |
128 ;; so they don't use the ps-print spooling mechanism. See section "Actions in | 130 ;; so they don't use the ps-print spooling mechanism. See section "Actions in |
129 ;; Comments" for an explanation about EPS file generation. | 131 ;; Comments" for an explanation about EPS file generation. |
130 ;; | 132 ;; |
255 ;; The names are classified as: | 257 ;; The names are classified as: |
256 ;; | 258 ;; |
257 ;; Logical Expression non-terminal | 259 ;; Logical Expression non-terminal |
258 ;; "(" OR AND "XOR" ")" terminal | 260 ;; "(" OR AND "XOR" ")" terminal |
259 ;; | 261 ;; |
260 ;; The line comment is controlled by `ebnf-lex-comment-char'. The default value | 262 ;; The line comment is controlled by `ebnf-lex-comment-char'. The default |
261 ;; is ?\; (character `;'). | 263 ;; value is ?\; (character `;'). |
262 ;; | 264 ;; |
263 ;; The end of production is controlled by `ebnf-lex-eop-char'. The default | 265 ;; The end of production is controlled by `ebnf-lex-eop-char'. The default |
264 ;; value is ?. (character `.'). | 266 ;; value is ?. (character `.'). |
265 ;; | 267 ;; |
266 ;; The variable `ebnf-syntax' specifies which syntax to recognize: | 268 ;; The variable `ebnf-syntax' specifies which syntax to recognize: |
330 ;; | 332 ;; |
331 ;; | 333 ;; |
332 ;; Form Feed | 334 ;; Form Feed |
333 ;; --------- | 335 ;; --------- |
334 ;; | 336 ;; |
335 ;; You may use form feed (^L \014) to force a production to start on a new page, | 337 ;; You may use form feed (^L \014) to force a production to start on a new |
336 ;; for example: | 338 ;; page, for example: |
337 ;; | 339 ;; |
338 ;; a) A = B | C. | 340 ;; a) A = B | C. |
339 ;; ^L | 341 ;; ^L |
340 ;; X = Y | Z. | 342 ;; X = Y | Z. |
341 ;; | 343 ;; |
360 ;; ;< the next production starts in the next line. | 362 ;; ;< the next production starts in the next line. |
361 ;; It is useful when `ebnf-horizontal-orientation' is non-nil. | 363 ;; It is useful when `ebnf-horizontal-orientation' is non-nil. |
362 ;; | 364 ;; |
363 ;; ;[EPS open a new EPS file. The EPS file name has the form: | 365 ;; ;[EPS open a new EPS file. The EPS file name has the form: |
364 ;; <PREFIX><NAME>.eps | 366 ;; <PREFIX><NAME>.eps |
365 ;; where <PREFIX> is given by variable `ebnf-eps-prefix' and <NAME> | 367 ;; where <PREFIX> is given by variable `ebnf-eps-prefix' and |
366 ;; is the string given by ;[ action comment, this string is mapped | 368 ;; <NAME> is the string given by ;[ action comment, this string is |
367 ;; to form a valid file name (see documentation for | 369 ;; mapped to form a valid file name (see documentation for |
368 ;; `ebnf-eps-buffer' or `ebnf-eps-region'). | 370 ;; `ebnf-eps-buffer' or `ebnf-eps-region'). |
369 ;; It has effect only during `ebnf-eps-buffer' or | 371 ;; It has effect only during `ebnf-eps-buffer' or |
370 ;; `ebnf-eps-region' execution. | 372 ;; `ebnf-eps-region' execution. |
371 ;; It's an error to try to open an already opened EPS file. | 373 ;; It's an error to try to open an already opened EPS file. |
372 ;; | 374 ;; |
404 ;; +-----------+ | 406 ;; +-----------+ |
405 ;; | 407 ;; |
406 ;; Note that if ascending production sort is used, the productions A and B will | 408 ;; Note that if ascending production sort is used, the productions A and B will |
407 ;; be drawn in the same line instead of C and B. | 409 ;; be drawn in the same line instead of C and B. |
408 ;; | 410 ;; |
409 ;; If consecutive actions occur, only the last one takes effect, so if you have: | 411 ;; If consecutive actions occur, only the last one takes effect, so if you |
412 ;; have: | |
410 ;; | 413 ;; |
411 ;; A = X. | 414 ;; A = X. |
412 ;; ;< | 415 ;; ;< |
413 ;; ^L | 416 ;; ^L |
414 ;; ;> | 417 ;; ;> |
519 ;; height in horizontal orientation. | 522 ;; height in horizontal orientation. |
520 ;; | 523 ;; |
521 ;; `ebnf-production-horizontal-space' Specify horizontal space in points | 524 ;; `ebnf-production-horizontal-space' Specify horizontal space in points |
522 ;; between productions. | 525 ;; between productions. |
523 ;; | 526 ;; |
524 ;; `ebnf-production-vertical-space' Specify vertical space in points between | 527 ;; `ebnf-production-vertical-space' Specify vertical space in points |
525 ;; productions. | 528 ;; between productions. |
526 ;; | 529 ;; |
527 ;; `ebnf-justify-sequence' Specify justification of terms in a | 530 ;; `ebnf-justify-sequence' Specify justification of terms in a |
528 ;; sequence inside alternatives. | 531 ;; sequence inside alternatives. |
529 ;; | 532 ;; |
530 ;; `ebnf-terminal-regexp' Specify how it's a terminal name. | 533 ;; `ebnf-terminal-regexp' Specify how it's a terminal name. |
548 ;; | 551 ;; |
549 ;; `ebnf-non-terminal-font' Specify non-terminal font. | 552 ;; `ebnf-non-terminal-font' Specify non-terminal font. |
550 ;; | 553 ;; |
551 ;; `ebnf-non-terminal-shape' Specify non-terminal box shape. | 554 ;; `ebnf-non-terminal-shape' Specify non-terminal box shape. |
552 ;; | 555 ;; |
553 ;; `ebnf-non-terminal-shadow' Non-nil means non-terminal box will have | 556 ;; `ebnf-non-terminal-shadow' Non-nil means non-terminal box will |
554 ;; a shadow. | 557 ;; have a shadow. |
555 ;; | 558 ;; |
556 ;; `ebnf-non-terminal-border-width' Specify border width for non-terminal | 559 ;; `ebnf-non-terminal-border-width' Specify border width for non-terminal |
557 ;; box. | 560 ;; box. |
558 ;; | 561 ;; |
559 ;; `ebnf-non-terminal-border-color' Specify border color for non-terminal | 562 ;; `ebnf-non-terminal-border-color' Specify border color for non-terminal |
602 ;; | 605 ;; |
603 ;; `ebnf-line-width' Specify flow line width. | 606 ;; `ebnf-line-width' Specify flow line width. |
604 ;; | 607 ;; |
605 ;; `ebnf-line-color' Specify flow line color. | 608 ;; `ebnf-line-color' Specify flow line color. |
606 ;; | 609 ;; |
607 ;; `ebnf-user-arrow' Specify a user arrow shape (a PostScript | 610 ;; `ebnf-user-arrow' Specify a user arrow shape (a |
608 ;; code). | 611 ;; PostScript code). |
609 ;; | 612 ;; |
610 ;; `ebnf-debug-ps' Non-nil means to generate PostScript | 613 ;; `ebnf-debug-ps' Non-nil means to generate PostScript |
611 ;; debug procedures. | 614 ;; debug procedures. |
612 ;; | 615 ;; |
613 ;; `ebnf-lex-comment-char' Specify the line comment character. | 616 ;; `ebnf-lex-comment-char' Specify the line comment character. |
614 ;; | 617 ;; |
615 ;; `ebnf-lex-eop-char' Specify the end of production character. | 618 ;; `ebnf-lex-eop-char' Specify the end of production |
619 ;; character. | |
616 ;; | 620 ;; |
617 ;; `ebnf-syntax' Specify syntax to be recognized. | 621 ;; `ebnf-syntax' Specify syntax to be recognized. |
618 ;; | 622 ;; |
619 ;; `ebnf-iso-alternative-p' Non-nil means use alternative ISO EBNF. | 623 ;; `ebnf-iso-alternative-p' Non-nil means use alternative ISO EBNF. |
620 ;; | 624 ;; |
631 ;; | 635 ;; |
632 ;; `ebnf-yac-ignore-error-recovery' Non-nil means ignore error recovery. | 636 ;; `ebnf-yac-ignore-error-recovery' Non-nil means ignore error recovery. |
633 ;; | 637 ;; |
634 ;; `ebnf-ignore-empty-rule' Non-nil means ignore empty rules. | 638 ;; `ebnf-ignore-empty-rule' Non-nil means ignore empty rules. |
635 ;; | 639 ;; |
636 ;; `ebnf-optimize' Non-nil means optimize syntatic chart of | 640 ;; `ebnf-optimize' Non-nil means optimize syntatic chart |
637 ;; rules. | 641 ;; of rules. |
638 ;; | 642 ;; |
639 ;; To set the above options you may: | 643 ;; To set the above options you may: |
640 ;; | 644 ;; |
641 ;; a) insert the code in your ~/.emacs, like: | 645 ;; a) insert the code in your ~/.emacs, like: |
642 ;; | 646 ;; |
703 ;; | 707 ;; |
704 ;; These commands helps to put together a lot of variable settings in a group | 708 ;; These commands helps to put together a lot of variable settings in a group |
705 ;; and name this group. So when you wish to apply these settings it's only | 709 ;; and name this group. So when you wish to apply these settings it's only |
706 ;; needed to give the name. | 710 ;; needed to give the name. |
707 ;; | 711 ;; |
708 ;; There is also a notion of simple inheritance of style; so if you declare that | 712 ;; There is also a notion of simple inheritance of style; so if you declare |
709 ;; a style A inherits from a style B, all settings of B is applied first and | 713 ;; that a style A inherits from a style B, all settings of B is applied first |
710 ;; then the settings of A is applied. This is useful when you wish to modify | 714 ;; and then the settings of A is applied. This is useful when you wish to |
711 ;; some aspects of an existing style, but at same time wish to keep it | 715 ;; modify some aspects of an existing style, but at same time wish to keep it |
712 ;; unmodified. | 716 ;; unmodified. |
713 ;; | 717 ;; |
714 ;; See documentation for `ebnf-style-database'. | 718 ;; See documentation for `ebnf-style-database'. |
715 ;; | 719 ;; |
716 ;; | 720 ;; |
721 ;; the following terms: | 725 ;; the following terms: |
722 ;; | 726 ;; |
723 ;; font height is given by: | 727 ;; font height is given by: |
724 ;; (terminal font height + non-terminal font height) / 2 | 728 ;; (terminal font height + non-terminal font height) / 2 |
725 ;; | 729 ;; |
726 ;; entry is the vertical position used to know where it should be | 730 ;; entry is the vertical position used to know where it should |
727 ;; drawn the flow line in the current element. | 731 ;; be drawn the flow line in the current element. |
728 ;; | 732 ;; |
729 ;; | 733 ;; |
730 ;; * SPECIAL, TERMINAL and NON-TERMINAL | 734 ;; * SPECIAL, TERMINAL and NON-TERMINAL |
731 ;; | 735 ;; |
732 ;; +==============+................................... | 736 ;; +==============+................................... |
927 ;; Internal Structures | 931 ;; Internal Structures |
928 ;; ------------------- | 932 ;; ------------------- |
929 ;; | 933 ;; |
930 ;; ebnf2ps has two passes. The first pass does a lexical and syntatic analysis | 934 ;; ebnf2ps has two passes. The first pass does a lexical and syntatic analysis |
931 ;; of current buffer and generates an intermediate representation. The second | 935 ;; of current buffer and generates an intermediate representation. The second |
932 ;; pass uses the intermediate representation to generate the PostScript syntatic | 936 ;; pass uses the intermediate representation to generate the PostScript |
933 ;; chart. | 937 ;; syntatic chart. |
934 ;; | 938 ;; |
935 ;; The intermediate representation is a list of vectors, the vector element | 939 ;; The intermediate representation is a list of vectors, the vector element |
936 ;; represents a syntatic chart element. Below is a vector representation for | 940 ;; represents a syntatic chart element. Below is a vector representation for |
937 ;; each syntatic chart element. | 941 ;; each syntatic chart element. |
938 ;; | 942 ;; |
939 ;; [production WIDTH-FUN DIM-FUN ENTRY HEIGHT WIDTH NAME PRODUCTION ACTION] | 943 ;; [production WIDTH-FUN DIM-FUN ENTRY HEIGHT WIDTH NAME PRODUCTION ACTION] |
940 ;; [alternative WIDTH-FUN DIM-FUN ENTRY HEIGHT WIDTH LIST] | 944 ;; [alternative WIDTH-FUN DIM-FUN ENTRY HEIGHT WIDTH LIST] |
941 ;; [sequence WIDTH-FUN DIM-FUN ENTRY HEIGHT WIDTH LIST] | 945 ;; [sequence WIDTH-FUN DIM-FUN ENTRY HEIGHT WIDTH LIST] |
942 ;; [terminal WIDTH-FUN DIM-FUN ENTRY HEIGHT WIDTH NAME DEFAULT] | 946 ;; [terminal WIDTH-FUN DIM-FUN ENTRY HEIGHT WIDTH NAME DEFAULT] |
943 ;; [non-terminal WIDTH-FUN DIM-FUN ENTRY HEIGHT WIDTH NAME DEFAULT] | 947 ;; [non-terminal WIDTH-FUN DIM-FUN ENTRY HEIGHT WIDTH NAME DEFAULT] |
944 ;; [special WIDTH-FUN DIM-FUN ENTRY HEIGHT WIDTH NAME DEFAULT] | 948 ;; [special WIDTH-FUN DIM-FUN ENTRY HEIGHT WIDTH NAME DEFAULT] |
998 ;;; code: | 1002 ;;; code: |
999 | 1003 |
1000 | 1004 |
1001 (require 'ps-print) | 1005 (require 'ps-print) |
1002 | 1006 |
1003 (and (string< ps-print-version "3.05.1") | 1007 (and (string< ps-print-version "5.2.3") |
1004 (error "`ebnf2ps' requires `ps-print' package version 3.05.1 or later")) | 1008 (error "`ebnf2ps' requires `ps-print' package version 5.2.3 or later")) |
1005 | |
1006 | |
1007 ;; temporary fix for ps-print | |
1008 (or (fboundp 'set-buffer-multibyte) | |
1009 (defun set-buffer-multibyte (arg) | |
1010 (setq enable-multibyte-characters arg))) | |
1011 | |
1012 (or (fboundp 'string-as-unibyte) | |
1013 (defun string-as-unibyte (arg) arg)) | |
1014 | |
1015 (or (fboundp 'string-as-multibyte) | |
1016 (defun string-as-multibyte (arg) arg)) | |
1017 | |
1018 (or (fboundp 'charset-after) | |
1019 (defun charset-after (&optional arg) | |
1020 (char-charset (char-after arg)))) | |
1021 | 1009 |
1022 | 1010 |
1023 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | 1011 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; |
1024 ;; User Variables: | 1012 ;; User Variables: |
1025 | 1013 |
1537 : : } hT2 } | 1525 : : } hT2 } |
1538 : :.......... } hT | 1526 : :.......... } hT |
1539 : } hT2 } | 1527 : } hT2 } |
1540 :....................... | 1528 :....................... |
1541 | 1529 |
1542 Where `hT', `hT2' and `hT4' are predefined PostScript variable names that can be | 1530 Where `hT', `hT2' and `hT4' are predefined PostScript variable names that can |
1543 used to generate your own arrow. As these variables are used along PostScript | 1531 be used to generate your own arrow. As these variables are used along |
1544 execution, *DON'T* modify the values of them. Instead, copy the values, if you | 1532 PostScript execution, *DON'T* modify the values of them. Instead, copy the |
1545 need to modify them. | 1533 values, if you need to modify them. |
1546 | 1534 |
1547 The relation between these variables is: hT = 2 * hT2 = 4 * hT4. | 1535 The relation between these variables is: hT = 2 * hT2 = 4 * hT4. |
1548 | 1536 |
1549 The variable `ebnf-user-arrow' is only used when `ebnf-arrow-shape' is set to | 1537 The variable `ebnf-user-arrow' is only used when `ebnf-arrow-shape' is set to |
1550 symbol `user'. | 1538 symbol `user'. |
2156 (CUSTOM INHERITS (VAR . VALUE)...) | 2144 (CUSTOM INHERITS (VAR . VALUE)...) |
2157 | 2145 |
2158 CUSTOM is a symbol name style. | 2146 CUSTOM is a symbol name style. |
2159 INHERITS is a symbol name style from which the current style inherits the | 2147 INHERITS is a symbol name style from which the current style inherits the |
2160 context. If INHERITS is nil, means that there is no inheritance. | 2148 context. If INHERITS is nil, means that there is no inheritance. |
2161 VAR is a valid ebnf2ps symbol custom variable. See `ebnf-style-custom-list' for | 2149 VAR is a valid ebnf2ps symbol custom variable. See `ebnf-style-custom-list' |
2162 valid symbol variable. | 2150 for valid symbol variable. |
2163 VALUE is a sexp which it'll be evaluated to set the value to VAR. So, don't | 2151 VALUE is a sexp which it'll be evaluated to set the value to VAR. So, don't |
2164 forget to quote symbols and constant lists. See `default' style for an | 2152 forget to quote symbols and constant lists. See `default' style for an |
2165 example. | 2153 example. |
2166 | 2154 |
2167 Don't handle this variable directly. Use functions `ebnf-insert-style' and | 2155 Don't handle this variable directly. Use functions `ebnf-insert-style' and |
3596 " ")) | 3584 " ")) |
3597 | 3585 |
3598 | 3586 |
3599 (defun ebnf-format-color (format-str color default) | 3587 (defun ebnf-format-color (format-str color default) |
3600 (let* ((the-color (or color default)) | 3588 (let* ((the-color (or color default)) |
3601 (rgb (mapcar 'ps-color-value (ps-color-values the-color)))) | 3589 (rgb (ps-color-scale the-color))) |
3602 (format format-str | 3590 (format format-str |
3603 (concat "[" | 3591 (concat "[" |
3604 (ebnf-format-float (nth 0 rgb) (nth 1 rgb) (nth 2 rgb)) | 3592 (ebnf-format-float (nth 0 rgb) (nth 1 rgb) (nth 2 rgb)) |
3605 "]") | 3593 "]") |
3606 the-color))) | 3594 the-color))) |
3727 (while ebnf-tree | 3715 (while ebnf-tree |
3728 (setq prod (car ebnf-tree) | 3716 (setq prod (car ebnf-tree) |
3729 prod-name (ebnf-node-name prod) | 3717 prod-name (ebnf-node-name prod) |
3730 prod-width (ebnf-max-width prod) | 3718 prod-width (ebnf-max-width prod) |
3731 prod-height (ebnf-node-height prod) | 3719 prod-height (ebnf-node-height prod) |
3732 horizontal (memq (ebnf-node-action prod) ebnf-action-list)) | 3720 horizontal (memq (ebnf-node-action prod) |
3721 ebnf-action-list)) | |
3733 ;; generate production in EPS buffer | 3722 ;; generate production in EPS buffer |
3734 (save-excursion | 3723 (save-excursion |
3735 (set-buffer eps-buffer) | 3724 (set-buffer eps-buffer) |
3736 (setq ebnf-eps-upper-x 0.0 | 3725 (setq ebnf-eps-upper-x 0.0 |
3737 ebnf-eps-upper-y 0.0 | 3726 ebnf-eps-upper-y 0.0 |
4271 (defsubst ebnf-font-height (font) | 4260 (defsubst ebnf-font-height (font) |
4272 (ebnf-font-select font 'line-height)) | 4261 (ebnf-font-select font 'line-height)) |
4273 | 4262 |
4274 | 4263 |
4275 (defun ebnf-begin-job () | 4264 (defun ebnf-begin-job () |
4276 (ps-printing-region nil) | 4265 (ps-printing-region nil nil) |
4277 (if ebnf-use-float-format | 4266 (if ebnf-use-float-format |
4278 (setq ebnf-format-float "%1.3f" | 4267 (setq ebnf-format-float "%1.3f" |
4279 ebnf-message-float "%3.2f") | 4268 ebnf-message-float "%3.2f") |
4280 (setq ebnf-format-float "%s" | 4269 (setq ebnf-format-float "%s" |
4281 ebnf-message-float "%s")) | 4270 ebnf-message-float "%s")) |
4912 | 4901 |
4913 | 4902 |
4914 ;; [sequence width-fun dim-fun entry height width list] | 4903 ;; [sequence width-fun dim-fun entry height width list] |
4915 (defun ebnf-sequence-width (sequence width) | 4904 (defun ebnf-sequence-width (sequence width) |
4916 (ebnf-node-list sequence | 4905 (ebnf-node-list sequence |
4917 (ebnf-justify-list sequence (ebnf-node-list sequence) width))) | 4906 (ebnf-justify-list sequence |
4907 (ebnf-node-list sequence) | |
4908 width))) | |
4918 | 4909 |
4919 | 4910 |
4920 (defun ebnf-justify-list (node seq width) | 4911 (defun ebnf-justify-list (node seq width) |
4921 (let ((seq-width (ebnf-node-width node))) | 4912 (let ((seq-width (ebnf-node-width node))) |
4922 (if (= width seq-width) | 4913 (if (= width seq-width) |
5215 element) | 5206 element) |
5216 ;; ( A | EMPTY )- ==> A | 5207 ;; ( A | EMPTY )- ==> A |
5217 ;; ( A | B | EMPTY )- ==> A | B | 5208 ;; ( A | B | EMPTY )- ==> A | B |
5218 ((and (null exception) | 5209 ((and (null exception) |
5219 (eq kind 'ebnf-generate-alternative) | 5210 (eq kind 'ebnf-generate-alternative) |
5220 (eq (ebnf-node-kind (car (last (ebnf-node-list element)))) | 5211 (eq (ebnf-node-kind |
5212 (car (last (ebnf-node-list element)))) | |
5221 'ebnf-generate-empty)) | 5213 'ebnf-generate-empty)) |
5222 (let ((elt (ebnf-node-list element)) | 5214 (let ((elt (ebnf-node-list element)) |
5223 bef) | 5215 bef) |
5224 (while (cdr elt) | 5216 (while (cdr elt) |
5225 (setq bef elt | 5217 (setq bef elt |