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