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