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