• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /macosx-10.10.1/emacs-93/emacs/lisp/progmodes/

Lines Matching +refs:ebnf +refs:file

8 ;; Keywords: wp, ebnf, PostScript
12 ;; This file is part of GNU Emacs.
25 ;; along with GNU Emacs; see the file COPYING. If not, write to the
29 (defconst ebnf-version "4.3"
62 ;; M-x byte-compile-file <give the path to ebnf2ps.el when prompted>
75 ;; ebnf-print-directory
76 ;; ebnf-print-file
77 ;; ebnf-print-buffer
78 ;; ebnf-print-region
79 ;; ebnf-spool-directory
80 ;; ebnf-spool-file
81 ;; ebnf-spool-buffer
82 ;; ebnf-spool-region
83 ;; ebnf-eps-directory
84 ;; ebnf-eps-file
85 ;; ebnf-eps-buffer
86 ;; ebnf-eps-region
91 ;; referred to as "ebnf- commands".
94 ;; PostScript image is sent to the printer (or file):
101 ;; `ebnf-despool'.
103 ;; eps - The PostScript image is immediately sent to an EPS file.
119 ;; The word "directory", "file", "buffer" or "region" in the command name
124 ;; file - Read file and print it.
130 ;; Two ebnf- command examples:
132 ;; ebnf-print-buffer - translate and print the entire buffer, and send it
135 ;; ebnf-spool-region - translate and print just the current region, and
139 ;; Note that `ebnf-eps-directory', `ebnf-eps-file', `ebnf-eps-buffer' and
140 ;; `ebnf-eps-region' never spool the EPS image, so they don't use the ps-print
142 ;; about EPS file generation.
150 ;; M-x ebnf-print-buffer
152 ;; or substitute one of the other four ebnf- commands. The command will
156 ;; C-u M-x ebnf-print-buffer
158 ;; it will save the PostScript image to a file instead of sending it to the
159 ;; printer; you will be prompted for the name of the file to save the image to.
161 ;; you may save the spooled images to a file by giving a prefix argument to
162 ;; `ebnf-despool':
164 ;; C-u M-x ebnf-despool
166 ;; When invoked this way, `ebnf-despool' will prompt you for the name of the
167 ;; file to save to.
169 ;; The prefix argument is also ignored by `ebnf-eps-buffer' and
170 ;; `ebnf-eps-region'.
172 ;; Any of the `ebnf-' commands can be bound to keys. Here are some examples:
174 ;; (global-set-key 'f22 'ebnf-print-buffer) ;f22 is prsc
175 ;; (global-set-key '(shift f22) 'ebnf-print-region)
176 ;; (global-set-key '(control f22) 'ebnf-despool)
188 ;; emacs -batch -l setup-ebnf2ps.el -f ebnf-eps-directory
190 ;; Where setup-ebnf2ps.el should be a file containing:
196 ;; (setq ebnf-terminal-shape 'bevel)
207 ;; `ebnf-syntax' documentation below in this section.
301 ;; The terminal name is controlled by `ebnf-terminal-regexp' and
302 ;; `ebnf-case-fold-search', so it's possible to match other kind of terminal
307 ;; (setq ebnf-terminal-regexp "[A-Z][_A-Z]*") ; upper case name
308 ;; (setq ebnf-case-fold-search nil) ; exact matching
319 ;; The line comment is controlled by `ebnf-lex-comment-char'. The default
322 ;; The end of production is controlled by `ebnf-lex-eop-char'. The default
325 ;; The variable `ebnf-syntax' specifies which syntax to recognize:
327 ;; `ebnf' ebnf2ps recognizes the syntax described above.
330 ;; `ebnf-terminal-regexp', `ebnf-case-fold-search',
331 ;; `ebnf-lex-comment-char' and `ebnf-lex-eop-char'.
337 ;; `iso-ebnf' ebnf2ps recognizes the syntax described in the URL:
338 ;; `http://www.cl.cam.ac.uk/~mgk25/iso-ebnf.html'
342 ;; `ebnf-iso-alternative-p' and `ebnf-iso-normalize-p'.
347 ;; `ebnf-yac-ignore-error-recovery'.
357 ;; Any other value is treated as `ebnf'.
359 ;; The default value is `ebnf'.
382 ;; The following optimizations are done when `ebnf-optimize' is non-nil:
400 ;; The above optimizations are specially useful when `ebnf-syntax' is `yacc'.
431 ;; It is useful when `ebnf-horizontal-orientation' is nil.
434 ;; It is useful when `ebnf-horizontal-orientation' is non-nil.
436 ;; ;[EPS open a new EPS file. The EPS file name has the form:
438 ;; where <PREFIX> is given by variable `ebnf-eps-prefix' and
440 ;; mapped to form a valid file name (see documentation for
441 ;; `ebnf-eps-buffer' or `ebnf-eps-region').
442 ;; It has effect only during `ebnf-eps-buffer' or
443 ;; `ebnf-eps-region' execution.
444 ;; It's an error to try to open an already opened EPS file.
446 ;; ;]EPS close an opened EPS file.
447 ;; It has effect only during `ebnf-eps-buffer' or
448 ;; `ebnf-eps-region' execution.
449 ;; It's an error to try to close a not opened EPS file.
453 ;; (setq ebnf-horizontal-orientation nil)
503 ;; For an example of EPS action when executing `ebnf-eps-buffer' or
504 ;; `ebnf-eps-region':
526 ;; ebnf--AA.eps A C A C C A
527 ;; ebnf--BB.eps C B B C C B
528 ;; ebnf--CC.eps A C B F A B C F F C B A
529 ;; ebnf--D.eps D D D
530 ;; ebnf--E.eps E E E
531 ;; ebnf--G.eps G G G
532 ;; ebnf--Z.eps Z Z Z
535 ;; generated per EPS file. To avoid overriding EPS files, use names in ;[ that
546 ;; The production A is generated in both files ebnf--AA.eps and ebnf--BB.eps.
554 ;; `ebnf-setup' returns the current setup.
556 ;; `ebnf-syntax-directory' does a syntactic analysis of your EBNF files in the
559 ;; `ebnf-syntax-file' does a syntactic analysis of your EBNF in the given
560 ;; file.
562 ;; `ebnf-syntax-buffer' does a syntactic analysis of your EBNF in the current
565 ;; `ebnf-syntax-region' does a syntactic analysis of your EBNF in the current
568 ;; `ebnf-customize' activates a customization buffer for ebnf2ps options.
570 ;; `ebnf-syntax-directory', `ebnf-syntax-file', `ebnf-syntax-buffer',
571 ;; `ebnf-syntax-region' and `ebnf-customize' can be bound to keys in the same
572 ;; way as `ebnf-' commands.
580 ;; `ebnf-hook'
583 ;; `ebnf-production-hook'
586 ;; `ebnf-page-hook'
596 ;; `ebnf-horizontal-orientation' Non-nil means productions are drawn
599 ;; `ebnf-horizontal-max-height' Non-nil means to use maximum production
602 ;; `ebnf-production-horizontal-space' Specify horizontal space in points
605 ;; `ebnf-production-vertical-space' Specify vertical space in points
608 ;; `ebnf-justify-sequence' Specify justification of terms in a
611 ;; `ebnf-terminal-regexp' Specify how it's a terminal name.
613 ;; `ebnf-case-fold-search' Non-nil means ignore case on matching.
615 ;; `ebnf-terminal-font' Specify terminal font.
617 ;; `ebnf-terminal-shape' Specify terminal box shape.
619 ;; `ebnf-terminal-shadow' Non-nil means terminal box will have a
622 ;; `ebnf-terminal-border-width' Specify border width for terminal box.
624 ;; `ebnf-terminal-border-color' Specify border color for terminal box.
626 ;; `ebnf-production-name-p' Non-nil means production name will be
629 ;; `ebnf-sort-production' Specify how productions are sorted.
631 ;; `ebnf-production-font' Specify production font.
633 ;; `ebnf-non-terminal-font' Specify non-terminal font.
635 ;; `ebnf-non-terminal-shape' Specify non-terminal box shape.
637 ;; `ebnf-non-terminal-shadow' Non-nil means non-terminal box will
640 ;; `ebnf-non-terminal-border-width' Specify border width for non-terminal
643 ;; `ebnf-non-terminal-border-color' Specify border color for non-terminal
646 ;; `ebnf-special-show-delimiter' Non-nil means special delimiter
649 ;; `ebnf-special-font' Specify special font.
651 ;; `ebnf-special-shape' Specify special box shape.
653 ;; `ebnf-special-shadow' Non-nil means special box will have a
656 ;; `ebnf-special-border-width' Specify border width for special box.
658 ;; `ebnf-special-border-color' Specify border color for special box.
660 ;; `ebnf-except-font' Specify except font.
662 ;; `ebnf-except-shape' Specify except box shape.
664 ;; `ebnf-except-shadow' Non-nil means except box will have a
667 ;; `ebnf-except-border-width' Specify border width for except box.
669 ;; `ebnf-except-border-color' Specify border color for except box.
671 ;; `ebnf-repeat-font' Specify repeat font.
673 ;; `ebnf-repeat-shape' Specify repeat box shape.
675 ;; `ebnf-repeat-shadow' Non-nil means repeat box will have a
678 ;; `ebnf-repeat-border-width' Specify border width for repeat box.
680 ;; `ebnf-repeat-border-color' Specify border color for repeat box.
682 ;; `ebnf-entry-percentage' Specify entry height on alternatives.
684 ;; `ebnf-arrow-shape' Specify the arrow shape.
686 ;; `ebnf-chart-shape' Specify chart flow shape.
688 ;; `ebnf-color-p' Non-nil means use color.
690 ;; `ebnf-line-width' Specify flow line width.
692 ;; `ebnf-line-color' Specify flow line color.
694 ;; `ebnf-arrow-extra-width' Specify extra width for arrow shape
697 ;; `ebnf-arrow-scale' Specify the arrow scale.
699 ;; `ebnf-user-arrow' Specify a sexp for user arrow shape (a
702 ;; `ebnf-debug-ps' Non-nil means to generate PostScript
705 ;; `ebnf-lex-comment-char' Specify the line comment character.
707 ;; `ebnf-lex-eop-char' Specify the end of production
710 ;; `ebnf-syntax' Specify syntax to be recognized.
712 ;; `ebnf-iso-alternative-p' Non-nil means use alternative ISO EBNF.
714 ;; `ebnf-iso-normalize-p' Non-nil means normalize ISO EBNF syntax
717 ;; `ebnf-default-width' Specify additional border width over
721 ;; `ebnf-file-suffix-regexp' Specify file name suffix that contains
724 ;; `ebnf-eps-prefix' Specify EPS prefix file name.
726 ;; `ebnf-use-float-format' Non-nil means use `%f' float format.
728 ;; `ebnf-stop-on-error' Non-nil means signal error and stop.
731 ;; `ebnf-yac-ignore-error-recovery' Non-nil means ignore error recovery.
733 ;; `ebnf-ignore-empty-rule' Non-nil means ignore empty rules.
735 ;; `ebnf-optimize' Non-nil means optimize syntactic chart
742 ;; (setq ebnf-terminal-shape 'bevel)
749 ;; M-x set-variable RET ebnf-terminal-shape RET bevel RET
765 ;; C-h v ebnf-terminal-shape RET
773 ;; M-x ebnf-customize RET
790 ;; `ebnf-insert-style' Insert a new style NAME with inheritance INHERITS and
793 ;; `ebnf-delete-style' Delete style NAME.
795 ;; `ebnf-merge-style' Merge values of style NAME with style VALUES.
797 ;; `ebnf-apply-style' Set STYLE as the current style.
799 ;; `ebnf-reset-style' Reset current style.
801 ;; `ebnf-push-style' Push the current style and set STYLE as the current
804 ;; `ebnf-pop-style' Pop a style and set it as the current style.
815 ;; See documentation for `ebnf-style-database'.
830 ;; extra is given by `ebnf-arrow-extra-width'.
903 ;; 2. The variable `ebnf-entry-percentage' is used to determine the
1079 ;; when `ebnf-horizontal-orientation' is non-nil.
1082 ;; is useful when `ebnf-horizontal-orientation' is nil.
1099 ;; - `ebnf-arrow-extra-width', `ebnf-arrow-scale',
1100 ;; `ebnf-production-name-p', `ebnf-stop-on-error',
1101 ;; `ebnf-file-suffix-regexp'and `ebnf-special-show-delimiter' variables.
1102 ;; - `ebnf-delete-style', `ebnf-eps-file' and `ebnf-eps-directory'
1155 :prefix "ebnf-"
1161 (defgroup ebnf-special nil
1163 :prefix "ebnf-"
1169 (defgroup ebnf-except nil
1171 :prefix "ebnf-"
1177 (defgroup ebnf-repeat nil
1179 :prefix "ebnf-"
1185 (defgroup ebnf-terminal nil
1187 :prefix "ebnf-"
1193 (defgroup ebnf-non-terminal nil
1195 :prefix "ebnf-"
1201 (defgroup ebnf-production nil
1203 :prefix "ebnf-"
1209 (defgroup ebnf-shape nil
1211 :prefix "ebnf-"
1217 (defgroup ebnf-displacement nil
1219 :prefix "ebnf-"
1225 (defgroup ebnf-syntactic nil
1227 :prefix "ebnf-"
1233 (defgroup ebnf-optimization nil
1235 :prefix "ebnf-"
1241 (defcustom ebnf-horizontal-orientation nil
1245 :group 'ebnf-displacement)
1248 (defcustom ebnf-horizontal-max-height nil
1251 It is only used when `ebnf-horizontal-orientation' is non-nil."
1254 :group 'ebnf-displacement)
1257 (defcustom ebnf-production-horizontal-space 0.0 ; use ebnf2ps default value
1263 :group 'ebnf-displacement)
1266 (defcustom ebnf-production-vertical-space 0.0 ; use ebnf2ps default value
1272 :group 'ebnf-displacement)
1275 (defcustom ebnf-justify-sequence 'center
1286 :group 'ebnf-displacement)
1289 (defcustom ebnf-special-show-delimiter t
1293 :group 'ebnf-special)
1296 (defcustom ebnf-special-font '(7 Courier "Black" "Gray95" bold italic)
1299 See documentation for `ebnf-production-font'."
1315 :group 'ebnf-special)
1318 (defcustom ebnf-special-shape 'bevel
1321 See documentation for `ebnf-non-terminal-shape'."
1325 :group 'ebnf-special)
1328 (defcustom ebnf-special-shadow nil
1332 :group 'ebnf-special)
1335 (defcustom ebnf-special-border-width 0.5
1339 :group 'ebnf-special)
1342 (defcustom ebnf-special-border-color "Black"
1346 :group 'ebnf-special)
1349 (defcustom ebnf-except-font '(7 Courier "Black" "Gray90" bold italic)
1352 See documentation for `ebnf-production-font'."
1368 :group 'ebnf-except)
1371 (defcustom ebnf-except-shape 'bevel
1374 See documentation for `ebnf-non-terminal-shape'."
1378 :group 'ebnf-except)
1381 (defcustom ebnf-except-shadow nil
1385 :group 'ebnf-except)
1388 (defcustom ebnf-except-border-width 0.25
1392 :group 'ebnf-except)
1395 (defcustom ebnf-except-border-color "Black"
1399 :group 'ebnf-except)
1402 (defcustom ebnf-repeat-font '(7 Courier "Black" "Gray85" bold italic)
1405 See documentation for `ebnf-production-font'."
1421 :group 'ebnf-repeat)
1424 (defcustom ebnf-repeat-shape 'bevel
1427 See documentation for `ebnf-non-terminal-shape'."
1431 :group 'ebnf-repeat)
1434 (defcustom ebnf-repeat-shadow nil
1438 :group 'ebnf-repeat)
1441 (defcustom ebnf-repeat-border-width 0.0
1445 :group 'ebnf-repeat)
1448 (defcustom ebnf-repeat-border-color "Black"
1452 :group 'ebnf-repeat)
1455 (defcustom ebnf-terminal-font '(7 Courier "Black" "White")
1458 See documentation for `ebnf-production-font'."
1474 :group 'ebnf-terminal)
1477 (defcustom ebnf-terminal-shape 'miter
1480 See documentation for `ebnf-non-terminal-shape'."
1484 :group 'ebnf-terminal)
1487 (defcustom ebnf-terminal-shadow nil
1491 :group 'ebnf-terminal)
1494 (defcustom ebnf-terminal-border-width 1.0
1498 :group 'ebnf-terminal)
1501 (defcustom ebnf-terminal-border-color "Black"
1505 :group 'ebnf-terminal)
1508 (defcustom ebnf-production-name-p t
1512 :group 'ebnf-production)
1515 (defcustom ebnf-sort-production nil
1528 :group 'ebnf-production)
1531 (defcustom ebnf-production-font '(10 Helvetica "Black" "White" bold)
1571 :group 'ebnf-production)
1574 (defcustom ebnf-non-terminal-font '(7 Helvetica "Black" "White")
1577 See documentation for `ebnf-production-font'."
1593 :group 'ebnf-non-terminal)
1596 (defcustom ebnf-non-terminal-shape 'round
1617 :group 'ebnf-non-terminal)
1620 (defcustom ebnf-non-terminal-shadow nil
1624 :group 'ebnf-non-terminal)
1627 (defcustom ebnf-non-terminal-border-width 1.0
1631 :group 'ebnf-non-terminal)
1634 (defcustom ebnf-non-terminal-border-color "Black"
1638 :group 'ebnf-non-terminal)
1641 (defcustom ebnf-arrow-shape 'hollow
1684 `user' See also documentation for variable `ebnf-user-arrow'.
1695 :group 'ebnf-shape)
1698 (defcustom ebnf-chart-shape 'round
1701 See documentation for `ebnf-non-terminal-shape'."
1705 :group 'ebnf-shape)
1708 (defcustom ebnf-user-arrow nil
1741 The variable `ebnf-user-arrow' is only used when `ebnf-arrow-shape' is set to
1745 :group 'ebnf-shape)
1748 (defcustom ebnf-syntax 'ebnf
1753 `ebnf' ebnf2ps recognizes the syntax described in ebnf2ps
1757 `ebnf-terminal-regexp', `ebnf-case-fold-search',
1758 `ebnf-lex-comment-char' and `ebnf-lex-eop-char'.
1764 `iso-ebnf' ebnf2ps recognizes the syntax described in the URL:
1765 `http://www.cl.cam.ac.uk/~mgk25/iso-ebnf.html'
1769 `ebnf-iso-alternative-p' and `ebnf-iso-normalize-p'.
1774 `ebnf-yac-ignore-error-recovery'.
1784 Any other value is treated as `ebnf'."
1786 (const ebnf) (const abnf) (const iso-ebnf)
1789 :group 'ebnf-syntactic)
1792 (defcustom ebnf-lex-comment-char ?\;
1795 It's used only when `ebnf-syntax' is `ebnf'."
1798 :group 'ebnf-syntactic)
1801 (defcustom ebnf-lex-eop-char ?.
1804 It's used only when `ebnf-syntax' is `ebnf'."
1807 :group 'ebnf-syntactic)
1810 (defcustom ebnf-terminal-regexp nil
1817 It's used only when `ebnf-syntax' is `ebnf'."
1821 :group 'ebnf-syntactic)
1824 (defcustom ebnf-case-fold-search nil
1827 It's only used when `ebnf-terminal-regexp' is non-nil and when `ebnf-syntax' is
1828 `ebnf'."
1831 :group 'ebnf-syntactic)
1834 (defcustom ebnf-iso-alternative-p nil
1837 It's only used when `ebnf-syntax' is `iso-ebnf'.
1850 :group 'ebnf-syntactic)
1853 (defcustom ebnf-iso-normalize-p nil
1859 It's only used when `ebnf-syntax' is `iso-ebnf'."
1862 :group 'ebnf-syntactic)
1865 (defcustom ebnf-file-suffix-regexp "\.[Bb][Nn][Ff]$"
1866 "*Specify file name suffix that contains EBNF.
1868 See `ebnf-eps-directory' command."
1874 (defcustom ebnf-eps-prefix "ebnf--"
1875 "*Specify EPS prefix file name.
1877 See `ebnf-eps-buffer' and `ebnf-eps-region' commands."
1883 (defcustom ebnf-entry-percentage 0.5 ; middle
1892 (defcustom ebnf-default-width 0.6
1901 (defcustom ebnf-color-p (or (fboundp 'x-color-values) ; Emacs
1909 (defcustom ebnf-line-width 1.0
1916 (defcustom ebnf-line-color "Black"
1923 (defcustom ebnf-arrow-extra-width
1924 (if (eq ebnf-arrow-shape 'none)
1926 (* (sqrt 5.0) 0.65 ebnf-line-width))
1930 overlap. It depens on `ebnf-arrow-shape' and `ebnf-line-width'."
1933 :group 'ebnf-shape)
1936 (defcustom ebnf-arrow-scale 1.0
1943 :group 'ebnf-shape)
1946 (defcustom ebnf-debug-ps nil
1955 (defcustom ebnf-use-float-format t
1959 PostScript file.
1965 when executing ebnf2ps, set `ebnf-use-float-format' to nil."
1971 (defcustom ebnf-stop-on-error nil
1978 (defcustom ebnf-yac-ignore-error-recovery nil
1981 It's only used when `ebnf-syntax' is `yacc'."
1984 :group 'ebnf-syntactic)
1987 (defcustom ebnf-ignore-empty-rule nil
1994 :group 'ebnf-optimization)
1997 (defcustom ebnf-optimize nil
2018 The above optimizations are specially useful when `ebnf-syntax' is `yacc'."
2021 :group 'ebnf-optimization)
2026 ;; To make this file smaller, some commands go in a separate file.
2030 (autoload 'ebnf-eliminate-empty-rules "ebnf-otz"
2033 (autoload 'ebnf-optimize "ebnf-otz"
2036 (autoload 'ebnf-otz-initialize "ebnf-otz"
2046 (defun ebnf-customize ()
2047 "Customization for ebnf group."
2058 (defun ebnf-print-directory (&optional directory)
2063 The files in DIRECTORY that matches `ebnf-file-suffix-regexp' (which see) are
2066 See also `ebnf-print-buffer'."
2068 (list (read-file-name "Directory containing EBNF files (print): "
2070 (ebnf-directory 'ebnf-print-buffer directory))
2074 (defun ebnf-print-file (file &optional do-not-kill-buffer-when-done)
2075 "Generate and print a PostScript syntactic chart image of the file FILE.
2080 See also `ebnf-print-buffer'."
2081 (interactive "fEBNF file to generate PostScript and print from: ")
2082 (ebnf-file 'ebnf-print-buffer file do-not-kill-buffer-when-done))
2086 (defun ebnf-print-buffer (&optional filename)
2090 the name of a file to save the PostScript image in, instead of sending
2095 the PostScript image in a file with that name. If FILENAME is a
2096 number, prompt the user for the name of the file to save in."
2098 (ebnf-print-region (point-min) (point-max) filename))
2102 (defun ebnf-print-region (from to &optional filename)
2104 Like `ebnf-print-buffer', but prints just the current region."
2106 (run-hooks 'ebnf-hook)
2107 (or (ebnf-spool-region from to)
2112 (defun ebnf-spool-directory (&optional directory)
2117 The files in DIRECTORY that matches `ebnf-file-suffix-regexp' (which see) are
2120 See also `ebnf-spool-buffer'."
2122 (list (read-file-name "Directory containing EBNF files (spool): "
2124 (ebnf-directory 'ebnf-spool-buffer directory))
2128 (defun ebnf-spool-file (file &optional do-not-kill-buffer-when-done)
2129 "Generate and spool a PostScript syntactic chart image of the file FILE.
2134 See also `ebnf-spool-buffer'."
2135 (interactive "fEBNF file to generate PostScript and spool from: ")
2136 (ebnf-file 'ebnf-spool-buffer file do-not-kill-buffer-when-done))
2140 (defun ebnf-spool-buffer ()
2142 Like `ebnf-print-buffer' except that the PostScript image is saved in a
2145 Use the command `ebnf-despool' to send the spooled images to the printer."
2147 (ebnf-spool-region (point-min) (point-max)))
2151 (defun ebnf-spool-region (from to)
2153 Like `ebnf-spool-buffer', but spools just the current region.
2155 Use the command `ebnf-despool' to send the spooled images to the printer."
2157 (ebnf-generate-region from to 'ebnf-generate))
2161 (defun ebnf-eps-directory (&optional directory)
2166 The files in DIRECTORY that matches `ebnf-file-suffix-regexp' (which see) are
2169 See also `ebnf-eps-buffer'."
2171 (list (read-file-name "Directory containing EBNF files (EPS): "
2173 (ebnf-directory 'ebnf-eps-buffer directory))
2177 (defun ebnf-eps-file (file &optional do-not-kill-buffer-when-done)
2178 "Generate an EPS file from EBNF file FILE.
2183 See also `ebnf-eps-buffer'."
2184 (interactive "fEBNF file to generate EPS file from: ")
2185 (ebnf-file 'ebnf-eps-buffer file do-not-kill-buffer-when-done))
2189 (defun ebnf-eps-buffer ()
2190 "Generate a PostScript syntactic chart image of the buffer in an EPS file.
2192 Generate an EPS file for each production in the buffer.
2193 The EPS file name has the following form:
2197 <PREFIX> is given by variable `ebnf-eps-prefix'.
2198 The default value is \"ebnf--\".
2201 Some characters in the production file name are replaced to
2202 produce a valid file name. For example, the production name
2204 file name used in this case will be \"ebnf--A_B_+_C.eps\".
2209 (ebnf-eps-region (point-min) (point-max)))
2213 (defun ebnf-eps-region (from to)
2214 "Generate a PostScript syntactic chart image of the region in an EPS file.
2216 Generate an EPS file for each production in the region.
2217 The EPS file name has the following form:
2221 <PREFIX> is given by variable `ebnf-eps-prefix'.
2222 The default value is \"ebnf--\".
2225 Some characters in the production file name are replaced to
2226 produce a valid file name. For example, the production name
2228 file name used in this case will be \"ebnf--A_B_+_C.eps\".
2233 (let ((ebnf-eps-executing t))
2234 (ebnf-generate-region from to 'ebnf-generate-eps)))
2238 (defalias 'ebnf-despool 'ps-despool)
2242 (defun ebnf-syntax-directory (&optional directory)
2247 Only the files in DIRECTORY that match `ebnf-file-suffix-regexp' (which see)
2250 See also `ebnf-syntax-buffer'."
2252 (list (read-file-name "Directory containing EBNF files (syntax): "
2254 (ebnf-directory 'ebnf-syntax-buffer directory))
2258 (defun ebnf-syntax-file (file &optional do-not-kill-buffer-when-done)
2264 See also `ebnf-syntax-buffer'."
2265 (interactive "fEBNF file to check syntax: ")
2266 (ebnf-file 'ebnf-syntax-buffer file do-not-kill-buffer-when-done))
2270 (defun ebnf-syntax-buffer ()
2273 (ebnf-syntax-region (point-min) (point-max)))
2277 (defun ebnf-syntax-region (from to)
2280 (ebnf-generate-region from to nil))
2289 (defun ebnf-setup ()
2295 \(setq ebnf-special-show-delimiter %S
2296 ebnf-special-font %s
2297 ebnf-special-shape %s
2298 ebnf-special-shadow %S
2299 ebnf-special-border-width %S
2300 ebnf-special-border-color %S
2301 ebnf-except-font %s
2302 ebnf-except-shape %s
2303 ebnf-except-shadow %S
2304 ebnf-except-border-width %S
2305 ebnf-except-border-color %S
2306 ebnf-repeat-font %s
2307 ebnf-repeat-shape %s
2308 ebnf-repeat-shadow %S
2309 ebnf-repeat-border-width %S
2310 ebnf-repeat-border-color %S
2311 ebnf-terminal-regexp %S
2312 ebnf-case-fold-search %S
2313 ebnf-terminal-font %s
2314 ebnf-terminal-shape %s
2315 ebnf-terminal-shadow %S
2316 ebnf-terminal-border-width %S
2317 ebnf-terminal-border-color %S
2318 ebnf-non-terminal-font %s
2319 ebnf-non-terminal-shape %s
2320 ebnf-non-terminal-shadow %S
2321 ebnf-non-terminal-border-width %S
2322 ebnf-non-terminal-border-color %S
2323 ebnf-production-name-p %S
2324 ebnf-sort-production %s
2325 ebnf-production-font %s
2326 ebnf-arrow-shape %s
2327 ebnf-chart-shape %s
2328 ebnf-user-arrow %s
2329 ebnf-horizontal-orientation %S
2330 ebnf-horizontal-max-height %S
2331 ebnf-production-horizontal-space %S
2332 ebnf-production-vertical-space %S
2333 ebnf-justify-sequence %s
2334 ebnf-lex-comment-char ?\\%03o
2335 ebnf-lex-eop-char ?\\%03o
2336 ebnf-syntax %s
2337 ebnf-iso-alternative-p %S
2338 ebnf-iso-normalize-p %S
2339 ebnf-file-suffix-regexp %S
2340 ebnf-eps-prefix %S
2341 ebnf-entry-percentage %S
2342 ebnf-color-p %S
2343 ebnf-line-width %S
2344 ebnf-line-color %S
2345 ebnf-debug-ps %S
2346 ebnf-use-float-format %S
2347 ebnf-stop-on-error %S
2348 ebnf-yac-ignore-error-recovery %S
2349 ebnf-ignore-empty-rule %S
2350 ebnf-optimize %S)
2354 ebnf-version
2355 ebnf-special-show-delimiter
2356 (ps-print-quote ebnf-special-font)
2357 (ps-print-quote ebnf-special-shape)
2358 ebnf-special-shadow
2359 ebnf-special-border-width
2360 ebnf-special-border-color
2361 (ps-print-quote ebnf-except-font)
2362 (ps-print-quote ebnf-except-shape)
2363 ebnf-except-shadow
2364 ebnf-except-border-width
2365 ebnf-except-border-color
2366 (ps-print-quote ebnf-repeat-font)
2367 (ps-print-quote ebnf-repeat-shape)
2368 ebnf-repeat-shadow
2369 ebnf-repeat-border-width
2370 ebnf-repeat-border-color
2371 ebnf-terminal-regexp
2372 ebnf-case-fold-search
2373 (ps-print-quote ebnf-terminal-font)
2374 (ps-print-quote ebnf-terminal-shape)
2375 ebnf-terminal-shadow
2376 ebnf-terminal-border-width
2377 ebnf-terminal-border-color
2378 (ps-print-quote ebnf-non-terminal-font)
2379 (ps-print-quote ebnf-non-terminal-shape)
2380 ebnf-non-terminal-shadow
2381 ebnf-non-terminal-border-width
2382 ebnf-non-terminal-border-color
2383 ebnf-production-name-p
2384 (ps-print-quote ebnf-sort-production)
2385 (ps-print-quote ebnf-production-font)
2386 (ps-print-quote ebnf-arrow-shape)
2387 (ps-print-quote ebnf-chart-shape)
2388 (ps-print-quote ebnf-user-arrow)
2389 ebnf-horizontal-orientation
2390 ebnf-horizontal-max-height
2391 ebnf-production-horizontal-space
2392 ebnf-production-vertical-space
2393 (ps-print-quote ebnf-justify-sequence)
2394 ebnf-lex-comment-char
2395 ebnf-lex-eop-char
2396 (ps-print-quote ebnf-syntax)
2397 ebnf-iso-alternative-p
2398 ebnf-iso-normalize-p
2399 ebnf-file-suffix-regexp
2400 ebnf-eps-prefix
2401 ebnf-entry-percentage
2402 ebnf-color-p
2403 ebnf-line-width
2404 ebnf-line-color
2405 ebnf-debug-ps
2406 ebnf-use-float-format
2407 ebnf-stop-on-error
2408 ebnf-yac-ignore-error-recovery
2409 ebnf-ignore-empty-rule
2410 ebnf-optimize))
2418 (defvar ebnf-stack-style nil
2419 "Used in functions `ebnf-reset-style', `ebnf-push-style' and
2420 `ebnf-pop-style'.")
2423 (defvar ebnf-current-style 'default
2424 "Used in functions `ebnf-apply-style' and `ebnf-push-style'.")
2427 (defconst ebnf-style-custom-list
2428 '(ebnf-special-show-delimiter
2429 ebnf-special-font
2430 ebnf-special-shape
2431 ebnf-special-shadow
2432 ebnf-special-border-width
2433 ebnf-special-border-color
2434 ebnf-except-font
2435 ebnf-except-shape
2436 ebnf-except-shadow
2437 ebnf-except-border-width
2438 ebnf-except-border-color
2439 ebnf-repeat-font
2440 ebnf-repeat-shape
2441 ebnf-repeat-shadow
2442 ebnf-repeat-border-width
2443 ebnf-repeat-border-color
2444 ebnf-terminal-regexp
2445 ebnf-case-fold-search
2446 ebnf-terminal-font
2447 ebnf-terminal-shape
2448 ebnf-terminal-shadow
2449 ebnf-terminal-border-width
2450 ebnf-terminal-border-color
2451 ebnf-non-terminal-font
2452 ebnf-non-terminal-shape
2453 ebnf-non-terminal-shadow
2454 ebnf-non-terminal-border-width
2455 ebnf-non-terminal-border-color
2456 ebnf-production-name-p
2457 ebnf-sort-production
2458 ebnf-production-font
2459 ebnf-arrow-shape
2460 ebnf-chart-shape
2461 ebnf-user-arrow
2462 ebnf-horizontal-orientation
2463 ebnf-horizontal-max-height
2464 ebnf-production-horizontal-space
2465 ebnf-production-vertical-space
2466 ebnf-justify-sequence
2467 ebnf-lex-comment-char
2468 ebnf-lex-eop-char
2469 ebnf-syntax
2470 ebnf-iso-alternative-p
2471 ebnf-iso-normalize-p
2472 ebnf-file-suffix-regexp
2473 ebnf-eps-prefix
2474 ebnf-entry-percentage
2475 ebnf-color-p
2476 ebnf-line-width
2477 ebnf-line-color
2478 ebnf-debug-ps
2479 ebnf-use-float-format
2480 ebnf-stop-on-error
2481 ebnf-yac-ignore-error-recovery
2482 ebnf-ignore-empty-rule
2483 ebnf-optimize)
2487 (defvar ebnf-style-database
2491 (ebnf-special-show-delimiter . t)
2492 (ebnf-special-font . '(7 Courier "Black" "Gray95" bold italic))
2493 (ebnf-special-shape . 'bevel)
2494 (ebnf-special-shadow . nil)
2495 (ebnf-special-border-width . 0.5)
2496 (ebnf-special-border-color . "Black")
2497 (ebnf-except-font . '(7 Courier "Black" "Gray90" bold italic))
2498 (ebnf-except-shape . 'bevel)
2499 (ebnf-except-shadow . nil)
2500 (ebnf-except-border-width . 0.25)
2501 (ebnf-except-border-color . "Black")
2502 (ebnf-repeat-font . '(7 Courier "Black" "Gray85" bold italic))
2503 (ebnf-repeat-shape . 'bevel)
2504 (ebnf-repeat-shadow . nil)
2505 (ebnf-repeat-border-width . 0.0)
2506 (ebnf-repeat-border-color . "Black")
2507 (ebnf-terminal-regexp . nil)
2508 (ebnf-case-fold-search . nil)
2509 (ebnf-terminal-font . '(7 Courier "Black" "White"))
2510 (ebnf-terminal-shape . 'miter)
2511 (ebnf-terminal-shadow . nil)
2512 (ebnf-terminal-border-width . 1.0)
2513 (ebnf-terminal-border-color . "Black")
2514 (ebnf-non-terminal-font . '(7 Helvetica "Black" "White"))
2515 (ebnf-non-terminal-shape . 'round)
2516 (ebnf-non-terminal-shadow . nil)
2517 (ebnf-non-terminal-border-width . 1.0)
2518 (ebnf-non-terminal-border-color . "Black")
2519 (ebnf-production-name-p . t)
2520 (ebnf-sort-production . nil)
2521 (ebnf-production-font . '(10 Helvetica "Black" "White" bold))
2522 (ebnf-arrow-shape . 'hollow)
2523 (ebnf-chart-shape . 'round)
2524 (ebnf-user-arrow . nil)
2525 (ebnf-horizontal-orientation . nil)
2526 (ebnf-horizontal-max-height . nil)
2527 (ebnf-production-horizontal-space . 0.0)
2528 (ebnf-production-vertical-space . 0.0)
2529 (ebnf-justify-sequence . 'center)
2530 (ebnf-lex-comment-char . ?\;)
2531 (ebnf-lex-eop-char . ?.)
2532 (ebnf-syntax . 'ebnf)
2533 (ebnf-iso-alternative-p . nil)
2534 (ebnf-iso-normalize-p . nil)
2535 (ebnf-file-suffix-regexp . "\.[Bb][Nn][Ff]$")
2536 (ebnf-eps-prefix . "ebnf--")
2537 (ebnf-entry-percentage . 0.5)
2538 (ebnf-color-p . (or (fboundp 'x-color-values) ; Emacs
2540 (ebnf-line-width . 1.0)
2541 (ebnf-line-color . "Black")
2542 (ebnf-debug-ps . nil)
2543 (ebnf-use-float-format . t)
2544 (ebnf-stop-on-error . nil)
2545 (ebnf-yac-ignore-error-recovery . nil)
2546 (ebnf-ignore-empty-rule . nil)
2547 (ebnf-optimize . nil))
2551 (ebnf-justify-sequence . 'left)
2552 (ebnf-lex-comment-char . ?\#)
2553 (ebnf-lex-eop-char . ?\;))
2557 (ebnf-syntax . 'abnf))
2559 (iso-ebnf
2561 (ebnf-syntax . 'iso-ebnf))
2565 (ebnf-syntax . 'yacc))
2569 (ebnf-syntax . 'ebnfx))
2573 (ebnf-syntax . 'dtd))
2595 See `ebnf-style-custom-list' for valid symbol variables.
2601 Don't use this variable directly. Use functions `ebnf-insert-style',
2602 `ebnf-delete-style' and `ebnf-merge-style'.")
2611 (defun ebnf-insert-style (name inherits &rest values)
2614 See `ebnf-style-database' documentation."
2616 (and (assoc name ebnf-style-database)
2618 (or (assoc inherits ebnf-style-database)
2620 (setq ebnf-style-database
2621 (cons (cons name (cons inherits (ebnf-check-style-values values)))
2622 ebnf-style-database)))
2626 (defun ebnf-delete-style (name)
2629 See `ebnf-style-database' documentation."
2631 (or (assoc name ebnf-style-database)
2633 (let ((db ebnf-style-database))
2639 (setq ebnf-style-database (assq-delete-all name ebnf-style-database)))
2643 (defun ebnf-merge-style (name &rest values)
2646 See `ebnf-style-database' documentation."
2648 (let ((style (or (assoc name ebnf-style-database)
2650 (merge (ebnf-check-style-values values))
2666 (defun ebnf-apply-style (style)
2671 See `ebnf-style-database' documentation."
2674 ebnf-current-style
2675 (and (ebnf-apply-style1 style)
2676 (setq ebnf-current-style style))))
2680 (defun ebnf-reset-style (&optional style)
2685 See `ebnf-style-database' documentation."
2687 (setq ebnf-stack-style nil)
2688 (ebnf-apply-style (or style 'default)))
2692 (defun ebnf-push-style (&optional style)
2697 See also `ebnf-pop-style'.
2699 See `ebnf-style-database' documentation."
2702 ebnf-current-style
2703 (setq ebnf-stack-style (cons ebnf-current-style ebnf-stack-style))
2705 (ebnf-apply-style style))))
2709 (defun ebnf-pop-style ()
2714 See also `ebnf-push-style'.
2716 See `ebnf-style-database' documentation."
2719 (ebnf-apply-style (car ebnf-stack-style))
2720 (setq ebnf-stack-style (cdr ebnf-stack-style))))
2723 (defun ebnf-apply-style1 (style)
2724 (let ((value (cdr (assoc style ebnf-style-database))))
2727 (and (car value) (ebnf-apply-style1 (car value)))
2732 (defun ebnf-check-style-values (values)
2735 (and (memq (caar values) ebnf-style-custom-list)
2746 (defvar ebnf-eps-buffer-name " *EPS*")
2747 (defvar ebnf-parser-func nil)
2748 (defvar ebnf-eps-executing nil)
2749 (defvar ebnf-eps-upper-x 0.0)
2750 (make-variable-buffer-local 'ebnf-eps-upper-x)
2751 (defvar ebnf-eps-upper-y 0.0)
2752 (make-variable-buffer-local 'ebnf-eps-upper-y)
2753 (defvar ebnf-eps-prod-width 0.0)
2754 (make-variable-buffer-local 'ebnf-eps-prod-width)
2755 (defvar ebnf-eps-max-height 0.0)
2756 (make-variable-buffer-local 'ebnf-eps-max-height)
2757 (defvar ebnf-eps-max-width 0.0)
2758 (make-variable-buffer-local 'ebnf-eps-max-width)
2761 (defvar ebnf-eps-context nil
2762 "List of EPS file name during parsing.
2767 (defvar ebnf-eps-production-list nil
2768 "Alist associating production name with EPS file name list.
2775 EPS-FILENAME is the EPS file name.
2779 See `ebnf-eps-context' and section \"Actions in Comments\" in ebnf2ps
2783 (defconst ebnf-arrow-shape-alist
2796 "Alist associating values for `ebnf-arrow-shape'.
2798 See documentation for `ebnf-arrow-shape'.")
2801 (defconst ebnf-terminal-shape-alist
2805 "Alist associating values from `ebnf-terminal-shape' to a bit vector.
2807 See documentation for `ebnf-terminal-shape', `ebnf-non-terminal-shape' and
2808 `ebnf-chart-shape'.")
2811 (defvar ebnf-limit nil)
2812 (defvar ebnf-action nil)
2813 (defvar ebnf-action-list nil)
2816 (defvar ebnf-default-p nil)
2819 (defvar ebnf-font-height-P 0)
2820 (defvar ebnf-font-height-T 0)
2821 (defvar ebnf-font-height-NT 0)
2822 (defvar ebnf-font-height-S 0)
2823 (defvar ebnf-font-height-E 0)
2824 (defvar ebnf-font-height-R 0)
2825 (defvar ebnf-font-width-P 0)
2826 (defvar ebnf-font-width-T 0)
2827 (defvar ebnf-font-width-NT 0)
2828 (defvar ebnf-font-width-S 0)
2829 (defvar ebnf-font-width-E 0)
2830 (defvar ebnf-font-width-R 0)
2831 (defvar ebnf-space-T 0)
2832 (defvar ebnf-space-NT 0)
2833 (defvar ebnf-space-S 0)
2834 (defvar ebnf-space-E 0)
2835 (defvar ebnf-space-R 0)
2838 (defvar ebnf-basic-width 0)
2839 (defvar ebnf-basic-height 0)
2840 (defvar ebnf-vertical-space 0)
2841 (defvar ebnf-horizontal-space 0)
2844 (defvar ebnf-settings nil)
2845 (defvar ebnf-fonts-required nil)
2848 (defconst ebnf-debug
2881 (defconst ebnf-prologue
3774 (defconst ebnf-eps-prologue
4051 (defconst ebnf-eps-begin
4067 (defconst ebnf-eps-end
4079 (defvar ebnf-format-float "%1.3f")
4082 (defun ebnf-format-float (&rest floats)
4085 (format ebnf-format-float float))
4090 (defun ebnf-format-color (format-str color default)
4095 (ebnf-format-float (nth 0 rgb) (nth 1 rgb) (nth 2 rgb))
4100 (defvar ebnf-message-float "%3.2f")
4103 (defsubst ebnf-message-float (format-str value)
4105 (format ebnf-message-float value)))
4108 (defvar ebnf-total 0)
4109 (defvar ebnf-nprod 0)
4112 (defsubst ebnf-message-info (messag)
4115 (round (/ (* (setq ebnf-nprod (1+ ebnf-nprod)) 100.0) ebnf-total))))
4123 (defmacro ebnf-node-kind (vec &optional value)
4129 (defmacro ebnf-node-width-func (node width)
4133 (defmacro ebnf-node-dimension-func (node &optional value)
4139 (defmacro ebnf-node-entry (vec &optional value)
4145 (defmacro ebnf-node-height (vec &optional value)
4151 (defmacro ebnf-node-width (vec &optional value)
4157 (defmacro ebnf-node-name (vec)
4161 (defmacro ebnf-node-list (vec &optional value)
4167 (defmacro ebnf-node-default (vec)
4171 (defmacro ebnf-node-production (vec &optional value)
4177 (defmacro ebnf-node-separator (vec &optional value)
4183 (defmacro ebnf-node-action (vec &optional value)
4189 (defmacro ebnf-node-generation (node)
4190 `(funcall (ebnf-node-kind ,node) ,node))
4193 (defmacro ebnf-max-width (prod)
4194 `(max (ebnf-node-width ,prod)
4195 (+ (* (length (ebnf-node-name ,prod))
4196 ebnf-font-width-P)
4197 ebnf-production-horizontal-space)))
4205 (defun ebnf-generate-eps (ebnf-tree)
4206 (let* ((ps-color-p (and ebnf-color-p (ps-color-device)))
4210 (ebnf-total (length ebnf-tree))
4211 (ebnf-nprod 0)
4214 (eps-buffer (get-buffer-create ebnf-eps-buffer-name))
4215 ebnf-debug-ps error-msg horizontal
4216 prod prod-name prod-width prod-height prod-list file-list)
4218 (defalias 'ps-output 'ebnf-eps-output)
4220 ;; generate EPS file
4224 (while ebnf-tree
4225 (setq prod (car ebnf-tree)
4226 prod-name (ebnf-node-name prod)
4227 prod-width (ebnf-max-width prod)
4228 prod-height (ebnf-node-height prod)
4229 horizontal (memq (ebnf-node-action prod)
4230 ebnf-action-list))
4234 (setq ebnf-eps-upper-x 0.0
4235 ebnf-eps-upper-y 0.0
4236 ebnf-eps-max-width prod-width
4237 ebnf-eps-max-height prod-height)
4238 (ebnf-generate-production prod))
4240 ebnf-eps-production-list)))
4242 (ebnf-eps-production-list prod-list 'file-list horizontal
4244 ;; write EPS file for production
4245 (ebnf-eps-finish-and-write eps-buffer
4246 (ebnf-eps-filename prod-name)))
4251 (setq ebnf-tree (cdr ebnf-tree)))
4253 (ebnf-eps-write-kill-temp file-list t)
4254 (setq file-list nil))
4263 (ebnf-eps-write-kill-temp file-list nil)
4269 (defun ebnf-eps-write-kill-temp (file-list write-p)
4270 (while file-list
4271 (let ((buffer (get-buffer (concat " *" (car file-list) "*"))))
4274 (ebnf-eps-finish-and-write buffer (car file-list)))
4276 (setq file-list (cdr file-list))))
4280 (defun ebnf-eps-production-list (prod-list file-list-sym horizontal
4283 (add-to-list file-list-sym (car prod-list))
4290 (setq ebnf-eps-upper-x 0.0
4291 ebnf-eps-upper-y 0.0
4292 ebnf-eps-max-width prod-width
4293 ebnf-eps-max-height prod-height))
4296 (ebnf-eop-horizontal ebnf-eps-prod-width)
4297 (setq ebnf-eps-max-width (+ ebnf-eps-max-width
4298 ebnf-production-horizontal-space
4300 ebnf-eps-max-height (max ebnf-eps-max-height prod-height)))
4303 (ebnf-eop-vertical ebnf-eps-max-height)
4304 (setq ebnf-eps-upper-x (max ebnf-eps-upper-x ebnf-eps-max-width)
4305 ebnf-eps-upper-y (if (zerop ebnf-eps-upper-y)
4306 ebnf-eps-max-height
4307 (+ ebnf-eps-upper-y
4308 ebnf-production-vertical-space
4309 ebnf-eps-max-height))
4310 ebnf-eps-max-width prod-width
4311 ebnf-eps-max-height prod-height))
4313 (setq ebnf-eps-prod-width prod-width)
4318 (defun ebnf-generate (ebnf-tree)
4319 (let* ((ps-color-p (and ebnf-color-p (ps-color-device)))
4329 'ebnf-generate-postscript)))
4332 (defvar ebnf-tree nil)
4333 (defvar ebnf-direction "R")
4336 (defun ebnf-generate-postscript (from to)
4337 (ebnf-begin-file)
4338 (if ebnf-horizontal-max-height
4339 (ebnf-generate-with-max-height)
4340 (ebnf-generate-without-max-height))
4344 (defun ebnf-generate-with-max-height ()
4345 (let ((ebnf-total (length ebnf-tree))
4346 (ebnf-nprod 0)
4348 (while ebnf-tree
4350 (setq next-line ebnf-tree
4351 prod (car ebnf-tree)
4352 max-height (ebnf-node-height prod))
4353 (ebnf-begin-line prod (ebnf-max-width prod))
4356 (memq (ebnf-node-action prod) ebnf-action-list)
4357 (setq the-width (ebnf-max-width prod))
4359 (setq max-height (max max-height (ebnf-node-height prod))
4362 ebnf-production-horizontal-space))))
4364 (ebnf-newline max-height)
4365 (setq prod (car ebnf-tree))
4366 (ebnf-generate-production prod)
4367 (while (not (eq (setq ebnf-tree (cdr ebnf-tree)) next-line))
4368 (ebnf-eop-horizontal (ebnf-max-width prod))
4369 (setq prod (car ebnf-tree))
4370 (ebnf-generate-production prod))
4371 (ebnf-eop-vertical max-height))))
4374 (defun ebnf-generate-without-max-height ()
4375 (let ((ebnf-total (length ebnf-tree))
4376 (ebnf-nprod 0)
4378 (while ebnf-tree
4380 (setq prod (car ebnf-tree)
4381 max-height (ebnf-node-height prod)
4382 bef-width (ebnf-max-width prod))
4383 (ebnf-begin-line prod bef-width)
4384 (ebnf-generate-production prod)
4385 (while (and (setq ebnf-tree (cdr ebnf-tree))
4386 (setq prod (car ebnf-tree))
4387 (memq (ebnf-node-action prod) ebnf-action-list)
4388 (setq cur-width (ebnf-max-width prod))
4390 (<= (ebnf-node-height prod) ps-height-remaining))
4391 (ebnf-eop-horizontal bef-width)
4392 (ebnf-generate-production prod)
4394 max-height (max max-height (ebnf-node-height prod))
4397 ebnf-production-horizontal-space))))
4398 (ebnf-eop-vertical max-height)
4400 (ebnf-newline max-height))))
4403 (defun ebnf-begin-line (prod width)
4404 (and (or (eq (ebnf-node-action prod) 'form-feed)
4405 (> (ebnf-node-height prod) ps-height-remaining))
4406 (ebnf-new-page))
4409 ebnf-production-horizontal-space))))
4412 (defun ebnf-newline (height)
4414 (ebnf-new-page))
4418 ebnf-production-vertical-space))))
4422 (defun ebnf-generate-production (production)
4423 (ebnf-message-info "Generating")
4424 (run-hooks 'ebnf-production-hook)
4425 (ps-output-string (if ebnf-production-name-p
4426 (ebnf-node-name production)
4429 (ebnf-format-float
4430 (ebnf-node-width production)
4431 (+ (if ebnf-production-name-p
4432 ebnf-basic-height
4434 (ebnf-node-entry (ebnf-node-production production))))
4436 (ebnf-node-generation (ebnf-node-production production))
4441 (defun ebnf-generate-alternative (alternative)
4442 (let ((alt (ebnf-node-list alternative))
4443 (entry (ebnf-node-entry alternative))
4447 (ps-output (ebnf-format-float (- entry (ebnf-node-entry (car alt))))
4449 (setq entry (- entry (ebnf-node-height (car alt)) ebnf-vertical-space)
4453 (ebnf-format-float (ebnf-node-width alternative))
4455 (setq alt (ebnf-node-list alternative))
4457 (ebnf-node-generation (car alt))
4458 (setq alt-height (- (ebnf-node-height (car alt))
4459 (ebnf-node-entry (car alt)))))
4461 (setq alt-entry (ebnf-node-entry (car alt)))
4462 (ebnf-vertical-movement
4463 (- (+ alt-height ebnf-vertical-space alt-entry)))
4464 (ebnf-node-generation (car alt))
4465 (setq alt-height (- (ebnf-node-height (car alt)) alt-entry))))
4470 (defun ebnf-generate-sequence (sequence)
4472 (let ((seq (ebnf-node-list sequence))
4475 (ebnf-node-generation (car seq))
4476 (setq seq-width (ebnf-node-width (car seq))))
4478 (ebnf-horizontal-movement seq-width)
4479 (ebnf-node-generation (car seq))
4480 (setq seq-width (ebnf-node-width (car seq)))))
4485 (defun ebnf-generate-terminal (terminal)
4486 (ebnf-gen-terminal terminal "T"))
4490 (defun ebnf-generate-non-terminal (non-terminal)
4491 (ebnf-gen-terminal non-terminal "NT"))
4495 (defun ebnf-generate-empty (empty)
4496 (ebnf-empty-alternative (ebnf-node-width empty)))
4500 (defun ebnf-generate-optional (optional)
4501 (let ((the-optional (ebnf-node-list optional)))
4502 (ps-output (ebnf-format-float
4503 (+ (- (ebnf-node-height the-optional)
4504 (ebnf-node-entry optional))
4505 ebnf-vertical-space)
4506 (ebnf-node-width optional))
4508 (ebnf-node-generation the-optional)
4513 (defun ebnf-generate-one-or-more (one-or-more)
4514 (let* ((width (ebnf-node-width one-or-more))
4515 (sep (ebnf-node-separator one-or-more))
4516 (entry (- (ebnf-node-entry one-or-more)
4518 (ebnf-node-entry sep)
4520 (ps-output (ebnf-format-float entry width)
4522 (ebnf-node-generation (ebnf-node-list one-or-more))
4523 (ebnf-vertical-movement entry)
4525 (let ((ebnf-direction "L"))
4526 (ebnf-node-generation sep))
4527 (ebnf-empty-alternative (- width ebnf-horizontal-space))))
4532 (defun ebnf-generate-zero-or-more (zero-or-more)
4533 (let* ((width (ebnf-node-width zero-or-more))
4534 (node-list (ebnf-node-list zero-or-more))
4535 (list-entry (ebnf-node-entry node-list))
4536 (node-sep (ebnf-node-separator zero-or-more))
4538 ebnf-vertical-space
4540 (- (ebnf-node-height node-sep)
4541 (ebnf-node-entry node-sep))
4543 (ps-output (ebnf-format-float entry
4544 (+ (- (ebnf-node-height node-list)
4546 ebnf-vertical-space)
4549 (ebnf-node-generation (ebnf-node-list zero-or-more))
4550 (ebnf-vertical-movement entry)
4551 (if (ebnf-node-separator zero-or-more)
4552 (let ((ebnf-direction "L"))
4553 (ebnf-node-generation (ebnf-node-separator zero-or-more)))
4554 (ebnf-empty-alternative (- width ebnf-horizontal-space))))
4559 (defun ebnf-generate-special (special)
4560 (ebnf-gen-terminal special "SP"))
4564 (defun ebnf-generate-repeat (repeat)
4565 (let ((times (ebnf-node-name repeat))
4566 (element (ebnf-node-separator repeat)))
4569 (ebnf-format-float
4570 (ebnf-node-entry repeat)
4571 (ebnf-node-height repeat)
4572 (ebnf-node-width repeat)
4574 (+ (ebnf-node-width element)
4575 ebnf-space-R ebnf-space-R ebnf-space-R
4576 (* (length times) ebnf-font-width-R))
4578 " " ebnf-direction "RP\n")
4580 (ebnf-node-generation element)))
4585 (defun ebnf-generate-except (except)
4586 (let* ((element (ebnf-node-list except))
4587 (exception (ebnf-node-separator except))
4588 (width (ebnf-node-width element)))
4589 (ps-output (ebnf-format-float
4591 (ebnf-node-entry except)
4592 (ebnf-node-height except)
4593 (ebnf-node-width except)
4595 ebnf-space-E ebnf-space-E ebnf-space-E
4596 ebnf-font-width-E
4598 (+ (ebnf-node-width exception) ebnf-space-E)
4600 " " ebnf-direction "EX\n")
4601 (ebnf-node-generation (ebnf-node-list except))
4603 (ebnf-horizontal-movement (+ width ebnf-space-E
4604 ebnf-font-width-E ebnf-space-E))
4605 (ebnf-node-generation exception)))
4609 (defun ebnf-gen-terminal (node code)
4610 (ps-output-string (ebnf-node-name node))
4611 (ps-output " " (ebnf-format-float (ebnf-node-width node))
4612 " " ebnf-direction code
4613 (if (ebnf-node-default node)
4623 (defun ebnf-directory (fun &optional directory)
4624 "Process files in DIRECTORY applying function FUN on each file.
4628 Only files in DIRECTORY that match `ebnf-file-suffix-regexp' (which see) are
4631 t ebnf-file-suffix-regexp)))
4633 (set-buffer (find-file-noselect (car files)))
4641 (defun ebnf-file (fun file &optional do-not-kill-buffer-when-done)
4646 (set-buffer (find-file-noselect file))
4652 ;; function `ebnf-range-regexp' is used to avoid a bug of `skip-chars-forward'
4656 (defun ebnf-range-regexp (prefix from to)
4664 (defvar ebnf-map-name
4674 (defun ebnf-eps-filename (str)
4679 (aset new stri (aref ebnf-map-name (aref str stri)))
4681 (concat ebnf-eps-prefix new ".eps")))
4684 (defun ebnf-eps-output (&rest args)
4690 (defun ebnf-generate-region (from to gen-func)
4691 (run-hooks 'ebnf-hook)
4692 (let ((ebnf-limit (max from to))
4699 (let ((tree (ebnf-parse-and-sort (min from to))))
4702 tree (ebnf-eliminate-empty-rules tree))
4704 tree (ebnf-optimize tree))
4706 tree (ebnf-dimensions tree))
4726 (if ebnf-stop-on-error
4737 (defun ebnf-parse-and-sort (start)
4738 (ebnf-begin-job)
4739 (let ((tree (funcall ebnf-parser-func start)))
4740 (if ebnf-sort-production
4744 (if (eq ebnf-sort-production 'ascending)
4745 'ebnf-sorter-ascending
4746 'ebnf-sorter-descending)))
4750 (defun ebnf-sorter-ascending (first second)
4751 (string< (ebnf-node-name first)
4752 (ebnf-node-name second)))
4755 (defun ebnf-sorter-descending (first second)
4756 (string< (ebnf-node-name second)
4757 (ebnf-node-name first)))
4760 (defun ebnf-empty-alternative (width)
4761 (ps-output (ebnf-format-float width) " EA\n"))
4764 (defun ebnf-vertical-movement (height)
4765 (ps-output (ebnf-format-float height) " vm\n"))
4768 (defun ebnf-horizontal-movement (width)
4769 (ps-output (ebnf-format-float width) " hm\n"))
4772 (defun ebnf-entry (height)
4773 (* height ebnf-entry-percentage))
4776 (defun ebnf-eop-vertical (height)
4777 (ps-output (ebnf-format-float (+ height ebnf-production-vertical-space))
4781 (defun ebnf-eop-horizontal (width)
4782 (ps-output (ebnf-format-float (+ width ebnf-production-horizontal-space))
4786 (defun ebnf-new-page ()
4788 (run-hooks 'ebnf-page-hook)
4793 (defsubst ebnf-font-size (font) (nth 0 font))
4794 (defsubst ebnf-font-name (font) (nth 1 font))
4795 (defsubst ebnf-font-foreground (font) (nth 2 font))
4796 (defsubst ebnf-font-background (font) (nth 3 font))
4797 (defsubst ebnf-font-list (font) (nthcdr 4 font))
4798 (defsubst ebnf-font-attributes (font)
4802 (defconst ebnf-font-name-select
4806 (defun ebnf-font-name-select (font)
4807 (let* ((font-list (ebnf-font-list font))
4810 (name (ebnf-font-name font))
4814 (or (cdr (assoc (aref ebnf-font-name-select font-index)
4819 (defun ebnf-font-select (font select)
4820 (let* ((name (ebnf-font-name font))
4825 (/ (* (ebnf-font-size font) base)
4830 (defsubst ebnf-font-width (font)
4831 (ebnf-font-select font 'avg-char-width))
4832 (defsubst ebnf-font-height (font)
4833 (ebnf-font-select font 'line-height))
4836 (defconst ebnf-syntax-alist
4838 '((iso-ebnf ebnf-iso-parser ebnf-iso-initialize)
4839 (yacc ebnf-yac-parser ebnf-yac-initialize)
4840 (abnf ebnf-abn-parser ebnf-abn-initialize)
4841 (ebnf ebnf-bnf-parser ebnf-bnf-initialize)
4842 (ebnfx ebnf-ebx-parser ebnf-ebx-initialize)
4843 (dtd ebnf-dtd-parser ebnf-dtd-initialize))
4847 (defun ebnf-begin-job ()
4849 (if ebnf-use-float-format
4850 (setq ebnf-format-float "%1.3f"
4851 ebnf-message-float "%3.2f")
4852 (setq ebnf-format-float "%s"
4853 ebnf-message-float "%s"))
4854 (ebnf-otz-initialize)
4856 (let ((init (or (assoc ebnf-syntax ebnf-syntax-alist)
4857 (assoc 'ebnf ebnf-syntax-alist))))
4858 (setq ebnf-parser-func (nth 1 init))
4860 (and ebnf-terminal-regexp ; ensures that it's a string or nil
4861 (not (stringp ebnf-terminal-regexp))
4862 (setq ebnf-terminal-regexp nil))
4863 (or (and ebnf-eps-prefix ; ensures that it's a string
4864 (stringp ebnf-eps-prefix))
4865 (setq ebnf-eps-prefix "ebnf--"))
4866 (setq ebnf-entry-percentage ; ensures value between 0.0 and 1.0
4867 (min (max ebnf-entry-percentage 0.0) 1.0)
4868 ebnf-action-list (if ebnf-horizontal-orientation
4871 ebnf-settings nil
4872 ebnf-fonts-required nil
4873 ebnf-action nil
4874 ebnf-default-p nil
4875 ebnf-eps-context nil
4876 ebnf-eps-production-list nil
4877 ebnf-eps-upper-x 0.0
4878 ebnf-eps-upper-y 0.0
4879 ebnf-font-height-P (ebnf-font-height ebnf-production-font)
4880 ebnf-font-height-T (ebnf-font-height ebnf-terminal-font)
4881 ebnf-font-height-NT (ebnf-font-height ebnf-non-terminal-font)
4882 ebnf-font-height-S (ebnf-font-height ebnf-special-font)
4883 ebnf-font-height-E (ebnf-font-height ebnf-except-font)
4884 ebnf-font-height-R (ebnf-font-height ebnf-repeat-font)
4885 ebnf-font-width-P (ebnf-font-width ebnf-production-font)
4886 ebnf-font-width-T (ebnf-font-width ebnf-terminal-font)
4887 ebnf-font-width-NT (ebnf-font-width ebnf-non-terminal-font)
4888 ebnf-font-width-S (ebnf-font-width ebnf-special-font)
4889 ebnf-font-width-E (ebnf-font-width ebnf-except-font)
4890 ebnf-font-width-R (ebnf-font-width ebnf-repeat-font)
4891 ebnf-space-T (* ebnf-font-height-T 0.5)
4892 ebnf-space-NT (* ebnf-font-height-NT 0.5)
4893 ebnf-space-S (* ebnf-font-height-S 0.5)
4894 ebnf-space-E (* ebnf-font-height-E 0.5)
4895 ebnf-space-R (* ebnf-font-height-R 0.5))
4896 (let ((basic (+ ebnf-font-height-T ebnf-font-height-NT)))
4897 (setq ebnf-basic-width (* basic 0.5)
4898 ebnf-horizontal-space (+ basic basic)
4899 ebnf-basic-height ebnf-basic-width
4900 ebnf-vertical-space ebnf-basic-width)
4902 (or (and (numberp ebnf-production-horizontal-space)
4903 (> ebnf-production-horizontal-space 0.0))
4904 (setq ebnf-production-horizontal-space basic))
4906 (or (and (numberp ebnf-production-vertical-space)
4907 (> ebnf-production-vertical-space 0.0))
4908 (setq ebnf-production-vertical-space basic))))
4911 (defsubst ebnf-shape-value (sym alist)
4915 (defsubst ebnf-boolean (value)
4919 (defun ebnf-begin-file ()
4931 (insert " & ebnf2ps v" ebnf-version)
4932 ;; insert ebnf settings & engine
4935 (ebnf-insert-ebnf-prologue)
4939 (defun ebnf-eps-finish-and-write (buffer filename)
4943 (setq ebnf-eps-upper-x (max ebnf-eps-upper-x ebnf-eps-max-width)
4944 ebnf-eps-upper-y (if (zerop ebnf-eps-upper-y)
4945 ebnf-eps-max-height
4946 (+ ebnf-eps-upper-y
4947 ebnf-production-vertical-space
4948 ebnf-eps-max-height)))
4954 (format "%d %d" (1+ ebnf-eps-upper-x) (1+ ebnf-eps-upper-y))
4957 "\n%%Creator: " (user-full-name) " (using ebnf2ps v" ebnf-version ")"
4959 (or ebnf-fonts-required
4960 (setq ebnf-fonts-required
4963 (mapcar 'ebnf-font-name-select
4964 (list ebnf-production-font
4965 ebnf-terminal-font
4966 ebnf-non-terminal-font
4967 ebnf-special-font
4968 ebnf-except-font
4969 ebnf-repeat-font)))
4972 ebnf-eps-prologue)
4973 (ebnf-insert-ebnf-prologue)
4974 (insert ebnf-eps-begin
4975 "\n0 " (ebnf-format-float
4976 (- ebnf-eps-upper-y (* ebnf-font-height-P 0.7)))
4980 (insert ebnf-eps-end)
4981 ;; write file
4983 (setq filename (expand-file-name filename))
4989 (defun ebnf-insert-ebnf-prologue ()
4991 (or ebnf-settings
4992 (setq ebnf-settings
4997 (ebnf-format-float (ebnf-font-size ebnf-production-font))
4998 (ebnf-font-name-select ebnf-production-font))
4999 (ebnf-format-color "/ForegroundP %s def %% %s\n"
5000 (ebnf-font-foreground ebnf-production-font)
5002 (ebnf-format-color "/BackgroundP %s def %% %s\n"
5003 (ebnf-font-background ebnf-production-font)
5006 (ebnf-font-attributes ebnf-production-font))
5009 (ebnf-format-float (ebnf-font-size ebnf-terminal-font))
5010 (ebnf-font-name-select ebnf-terminal-font))
5011 (ebnf-format-color "/ForegroundT %s def %% %s\n"
5012 (ebnf-font-foreground ebnf-terminal-font)
5014 (ebnf-format-color "/BackgroundT %s def %% %s\n"
5015 (ebnf-font-background ebnf-terminal-font)
5018 (ebnf-font-attributes ebnf-terminal-font))
5020 (ebnf-format-float ebnf-terminal-border-width))
5021 (ebnf-format-color "/BorderColorT %s def %% %s\n"
5022 ebnf-terminal-border-color
5025 (ebnf-shape-value ebnf-terminal-shape
5026 ebnf-terminal-shape-alist))
5028 (ebnf-boolean ebnf-terminal-shadow))
5031 (ebnf-format-float
5032 (ebnf-font-size ebnf-non-terminal-font))
5033 (ebnf-font-name-select ebnf-non-terminal-font))
5034 (ebnf-format-color "/ForegroundNT %s def %% %s\n"
5035 (ebnf-font-foreground ebnf-non-terminal-font)
5037 (ebnf-format-color "/BackgroundNT %s def %% %s\n"
5038 (ebnf-font-background ebnf-non-terminal-font)
5041 (ebnf-font-attributes ebnf-non-terminal-font))
5043 (ebnf-format-float ebnf-non-terminal-border-width))
5044 (ebnf-format-color "/BorderColorNT %s def %% %s\n"
5045 ebnf-non-terminal-border-color
5048 (ebnf-shape-value ebnf-non-terminal-shape
5049 ebnf-terminal-shape-alist))
5051 (ebnf-boolean ebnf-non-terminal-shadow))
5054 (ebnf-format-float (ebnf-font-size ebnf-special-font))
5055 (ebnf-font-name-select ebnf-special-font))
5056 (ebnf-format-color "/ForegroundS %s def %% %s\n"
5057 (ebnf-font-foreground ebnf-special-font)
5059 (ebnf-format-color "/BackgroundS %s def %% %s\n"
5060 (ebnf-font-background ebnf-special-font)
5063 (ebnf-font-attributes ebnf-special-font))
5065 (ebnf-format-float ebnf-special-border-width))
5066 (ebnf-format-color "/BorderColorS %s def %% %s\n"
5067 ebnf-special-border-color
5070 (ebnf-shape-value ebnf-special-shape
5071 ebnf-terminal-shape-alist))
5073 (ebnf-boolean ebnf-special-shadow))
5076 (ebnf-format-float (ebnf-font-size ebnf-except-font))
5077 (ebnf-font-name-select ebnf-except-font))
5078 (ebnf-format-color "/ForegroundE %s def %% %s\n"
5079 (ebnf-font-foreground ebnf-except-font)
5081 (ebnf-format-color "/BackgroundE %s def %% %s\n"
5082 (ebnf-font-background ebnf-except-font)
5085 (ebnf-font-attributes ebnf-except-font))
5087 (ebnf-format-float ebnf-except-border-width))
5088 (ebnf-format-color "/BorderColorE %s def %% %s\n"
5089 ebnf-except-border-color
5092 (ebnf-shape-value ebnf-except-shape
5093 ebnf-terminal-shape-alist))
5095 (ebnf-boolean ebnf-except-shadow))
5098 (ebnf-format-float (ebnf-font-size ebnf-repeat-font))
5099 (ebnf-font-name-select ebnf-repeat-font))
5100 (ebnf-format-color "/ForegroundR %s def %% %s\n"
5101 (ebnf-font-foreground ebnf-repeat-font)
5103 (ebnf-format-color "/BackgroundR %s def %% %s\n"
5104 (ebnf-font-background ebnf-repeat-font)
5107 (ebnf-font-attributes ebnf-repeat-font))
5109 (ebnf-format-float ebnf-repeat-border-width))
5110 (ebnf-format-color "/BorderColorR %s def %% %s\n"
5111 ebnf-repeat-border-color
5114 (ebnf-shape-value ebnf-repeat-shape
5115 ebnf-terminal-shape-alist))
5117 (ebnf-boolean ebnf-repeat-shadow))
5120 (ebnf-format-float ebnf-arrow-extra-width))
5122 (ebnf-format-float ebnf-arrow-scale))
5124 (ebnf-format-float ebnf-default-width))
5126 (ebnf-format-float ebnf-line-width))
5127 (ebnf-format-color "/LineColor %s def %% %s\n"
5128 ebnf-line-color
5131 (ebnf-shape-value ebnf-arrow-shape
5132 ebnf-arrow-shape-alist))
5134 (ebnf-shape-value ebnf-chart-shape
5135 ebnf-terminal-shape-alist))
5137 (let ((arrow (eval ebnf-user-arrow)))
5142 (and ebnf-debug-ps ebnf-debug))))
5143 ebnf-prologue))
5151 (defun ebnf-dimensions (tree)
5152 (let ((ebnf-total (length tree))
5153 (ebnf-nprod 0))
5154 (mapcar 'ebnf-production-dimension tree))
5159 ;;(defun ebnf-empty-dimension (empty)
5164 (defun ebnf-production-dimension (production)
5165 (ebnf-message-info "Calculating dimensions")
5166 (ebnf-node-dimension-func (ebnf-node-production production))
5167 (let* ((prod (ebnf-node-production production))
5168 (height (+ (if ebnf-production-name-p
5169 ebnf-font-height-P
5171 ebnf-line-width ebnf-line-width
5172 ebnf-basic-height
5173 (ebnf-node-height prod))))
5174 (ebnf-node-entry production height)
5175 (ebnf-node-height production height)
5176 (ebnf-node-width production (+ (ebnf-node-width prod)
5177 ebnf-line-width
5178 ebnf-horizontal-space))))
5182 (defun ebnf-terminal-dimension (terminal)
5183 (ebnf-terminal-dimension1 terminal
5184 ebnf-font-height-T
5185 ebnf-font-width-T
5186 ebnf-space-T))
5190 (defun ebnf-non-terminal-dimension (non-terminal)
5191 (ebnf-terminal-dimension1 non-terminal
5192 ebnf-font-height-NT
5193 ebnf-font-width-NT
5194 ebnf-space-NT))
5198 (defun ebnf-special-dimension (special)
5199 (ebnf-terminal-dimension1 special
5200 ebnf-font-height-S
5201 ebnf-font-width-S
5202 ebnf-space-S))
5205 (defun ebnf-terminal-dimension1 (node font-height font-width space)
5207 (len (length (ebnf-node-name node))))
5208 (ebnf-node-entry node (* height 0.5))
5209 (ebnf-node-height node height)
5210 (ebnf-node-width node (+ ebnf-basic-width ebnf-arrow-extra-width space
5212 space ebnf-basic-width))))
5215 (defconst ebnf-null-vector (vector t t t 0.0 0.0 0.0))
5219 (defun ebnf-repeat-dimension (repeat)
5220 (let ((times (ebnf-node-name repeat))
5221 (element (ebnf-node-separator repeat)))
5223 (ebnf-node-dimension-func element)
5224 (setq element ebnf-null-vector))
5225 (ebnf-node-entry repeat (+ (ebnf-node-entry element)
5226 ebnf-space-R))
5227 (ebnf-node-height repeat (+ (max (ebnf-node-height element)
5228 ebnf-font-height-S)
5229 ebnf-space-R ebnf-space-R))
5230 (ebnf-node-width repeat (+ (ebnf-node-width element)
5231 ebnf-arrow-extra-width
5232 ebnf-space-R ebnf-space-R ebnf-space-R
5233 ebnf-horizontal-space
5234 (* (length times) ebnf-font-width-R)))))
5238 (defun ebnf-except-dimension (except)
5239 (let ((factor (ebnf-node-list except))
5240 (element (ebnf-node-separator except)))
5241 (ebnf-node-dimension-func factor)
5243 (ebnf-node-dimension-func element)
5244 (setq element ebnf-null-vector))
5245 (ebnf-node-entry except (+ (max (ebnf-node-entry factor)
5246 (ebnf-node-entry element))
5247 ebnf-space-E))
5248 (ebnf-node-height except (+ (max (ebnf-node-height factor)
5249 (ebnf-node-height element))
5250 ebnf-space-E ebnf-space-E))
5251 (ebnf-node-width except (+ (ebnf-node-width factor)
5252 (ebnf-node-width element)
5253 ebnf-arrow-extra-width
5254 ebnf-space-E ebnf-space-E
5255 ebnf-space-E ebnf-space-E
5256 ebnf-font-width-E
5257 ebnf-horizontal-space))))
5261 (defun ebnf-alternative-dimension (alternative)
5262 (let ((body (ebnf-node-list alternative))
5263 (lis (ebnf-node-list alternative)))
5265 (ebnf-node-dimension-func (car lis))
5271 (entry (ebnf-node-entry (car body)))
5276 height (+ (ebnf-node-height node) height)
5277 width (max (ebnf-node-width node) width)))
5278 (ebnf-adjust-width body width)
5279 (setq height (+ height (* (1- (length body)) ebnf-vertical-space)))
5280 (ebnf-node-entry alternative (+ entry
5281 (ebnf-entry
5283 (- (ebnf-node-height tail)
5284 (ebnf-node-entry tail))))))
5285 (ebnf-node-height alternative height)
5286 (ebnf-node-width alternative (+ width ebnf-horizontal-space))
5287 (ebnf-node-list alternative body))))
5291 (defun ebnf-optional-dimension (optional)
5292 (let ((body (ebnf-node-list optional)))
5293 (ebnf-node-dimension-func body)
5294 (ebnf-node-entry optional (ebnf-node-entry body))
5295 (ebnf-node-height optional (+ (ebnf-node-height body)
5296 ebnf-vertical-space))
5297 (ebnf-node-width optional (+ (ebnf-node-width body)
5298 ebnf-horizontal-space))))
5302 (defun ebnf-one-or-more-dimension (or-more)
5303 (let ((list-part (ebnf-node-list or-more))
5304 (sep-part (ebnf-node-separator or-more)))
5305 (ebnf-node-dimension-func list-part)
5307 (ebnf-node-dimension-func sep-part))
5309 (ebnf-node-height sep-part)
5311 ebnf-vertical-space
5312 (ebnf-node-height list-part)))
5314 (ebnf-node-width sep-part)
5316 (ebnf-node-width list-part))))
5318 (ebnf-adjust-width list-part width)
5319 (ebnf-adjust-width sep-part width))
5320 (ebnf-node-entry or-more (+ (- height (ebnf-node-height list-part))
5321 (ebnf-node-entry list-part)))
5322 (ebnf-node-height or-more height)
5323 (ebnf-node-width or-more (+ width ebnf-horizontal-space)))))
5327 (defun ebnf-zero-or-more-dimension (or-more)
5328 (let ((list-part (ebnf-node-list or-more))
5329 (sep-part (ebnf-node-separator or-more)))
5330 (ebnf-node-dimension-func list-part)
5332 (ebnf-node-dimension-func sep-part))
5334 (ebnf-node-height sep-part)
5336 ebnf-vertical-space
5337 (ebnf-node-height list-part)
5338 ebnf-vertical-space))
5340 (ebnf-node-width sep-part)
5342 (ebnf-node-width list-part))))
5344 (ebnf-adjust-width list-part width)
5345 (ebnf-adjust-width sep-part width))
5346 (ebnf-node-entry or-more height)
5347 (ebnf-node-height or-more height)
5348 (ebnf-node-width or-more (+ width ebnf-horizontal-space)))))
5352 (defun ebnf-sequence-dimension (sequence)
5356 (lis (ebnf-node-list sequence))
5361 (ebnf-node-dimension-func node)
5362 (setq entry (ebnf-node-entry node)
5364 below (max below (- (ebnf-node-height node) entry))
5365 width (+ width (ebnf-node-width node))))
5366 (ebnf-node-entry sequence above)
5367 (ebnf-node-height sequence (+ above below))
5368 (ebnf-node-width sequence width)))
5376 (defun ebnf-adjust-width (node width)
5382 (setcar node (ebnf-adjust-width (car node) width))
5387 ((= width (ebnf-node-width node))
5390 ((eq ebnf-justify-sequence 'left)
5391 (ebnf-adjust-empty node width nil))
5393 ((eq ebnf-justify-sequence 'right)
5394 (ebnf-adjust-empty node width t))
5397 (ebnf-node-width-func node width)
5398 (ebnf-node-width node width)
5406 (defun ebnf-adjust-empty (node width last-p)
5407 (if (eq (ebnf-node-kind node) 'ebnf-generate-empty)
5409 (ebnf-node-width node width)
5411 (let ((empty (ebnf-make-empty (- width (ebnf-node-width node)))))
5412 (ebnf-make-dup-sequence node
5424 ;;(defun ebnf-terminal-width (terminal width)
5430 (defun ebnf-alternative-width (alternative width)
5431 (ebnf-adjust-width (ebnf-node-list alternative)
5432 (- width ebnf-horizontal-space)))
5437 (defun ebnf-element-width (or-more width)
5438 (setq width (- width ebnf-horizontal-space))
5439 (ebnf-node-list or-more
5440 (ebnf-justify-list or-more
5441 (ebnf-node-list or-more)
5443 (ebnf-node-separator or-more
5444 (ebnf-justify-list or-more
5445 (ebnf-node-separator or-more)
5450 (defun ebnf-sequence-width (sequence width)
5451 (ebnf-node-list sequence
5452 (ebnf-justify-list sequence
5453 (ebnf-node-list sequence)
5457 (defun ebnf-justify-list (node seq width)
5458 (let ((seq-width (ebnf-node-width node)))
5463 ((eq ebnf-justify-sequence 'left)
5464 (ebnf-justify node seq seq-width width t))
5466 ((eq ebnf-justify-sequence 'right)
5467 (ebnf-justify node seq seq-width width nil))
5470 (ebnf-adjust-width seq width))
5476 (ebnf-adjust-width (car lis)
5477 (+ (ebnf-node-width (car lis))
5484 (defun ebnf-justify (node seq seq-width width last-p)
5488 ((eq (ebnf-node-kind term) 'ebnf-generate-empty)
5489 (ebnf-node-width term (+ (- width seq-width)
5490 (ebnf-node-width term)))
5495 (list (ebnf-make-empty (- width seq-width)))))
5498 (cons (ebnf-make-empty (- width seq-width))
5508 (defun ebnf-eps-add-context (name)
5509 (let ((filename (ebnf-eps-filename name)))
5510 (if (member filename ebnf-eps-context)
5511 (error "Try to open an already opened EPS file: %s" filename)
5512 (setq ebnf-eps-context (cons filename ebnf-eps-context)))))
5515 (defun ebnf-eps-remove-context (name)
5516 (let ((filename (ebnf-eps-filename name)))
5517 (if (member filename ebnf-eps-context)
5518 (setq ebnf-eps-context (delete filename ebnf-eps-context))
5519 (error "Try to close a not opened EPS file: %s" filename))))
5522 (defun ebnf-eps-add-production (header)
5523 (and ebnf-eps-executing
5524 ebnf-eps-context
5525 (let ((prod (assoc header ebnf-eps-production-list)))
5527 (setcdr prod (append ebnf-eps-context (cdr prod)))
5528 (setq ebnf-eps-production-list
5529 (cons (cons header (ebnf-dup-list ebnf-eps-context))
5530 ebnf-eps-production-list))))))
5533 (defun ebnf-dup-list (old)
5541 (defun ebnf-buffer-substring (chars)
5545 (skip-chars-forward chars ebnf-limit)
5549 ;; replace the range "\240-\377" (see `ebnf-range-regexp').
5550 (defconst ebnf-8-bit-chars (ebnf-range-regexp "" ?\240 ?\377))
5553 (defun ebnf-string (chars eos-char kind)
5558 ;;(skip-chars-forward (concat chars "\240-\377") ebnf-limit)
5559 (skip-chars-forward (concat chars ebnf-8-bit-chars) ebnf-limit)
5566 (defun ebnf-get-string ()
5568 (buffer-substring-no-properties (point) (ebnf-end-of-string)))
5571 (defun ebnf-end-of-string ()
5574 (skip-chars-forward "^\"" ebnf-limit)
5582 (defun ebnf-trim-right (str)
5597 (defun ebnf-make-empty (&optional width)
5598 (vector 'ebnf-generate-empty
5603 (or width ebnf-horizontal-space)))
5606 (defun ebnf-make-terminal (name)
5607 (ebnf-make-terminal1 name
5608 'ebnf-generate-terminal
5609 'ebnf-terminal-dimension))
5612 (defun ebnf-make-non-terminal (name)
5613 (ebnf-make-terminal1 name
5614 'ebnf-generate-non-terminal
5615 'ebnf-non-terminal-dimension))
5618 (defun ebnf-make-special (name)
5619 (ebnf-make-terminal1 name
5620 'ebnf-generate-special
5621 'ebnf-special-dimension))
5624 (defun ebnf-make-terminal1 (name gen-func dim-func)
5637 ebnf-default-p))
5640 (defun ebnf-make-one-or-more (list-part &optional sep-part)
5641 (ebnf-make-or-more1 'ebnf-generate-one-or-more
5642 'ebnf-one-or-more-dimension
5647 (defun ebnf-make-zero-or-more (list-part &optional sep-part)
5648 (ebnf-make-or-more1 'ebnf-generate-zero-or-more
5649 'ebnf-zero-or-more-dimension
5654 (defun ebnf-make-or-more1 (gen-func dim-func list-part sep-part)
5656 'ebnf-element-width
5662 (ebnf-make-sequence list-part)
5665 (ebnf-make-sequence sep-part)
5669 (defun ebnf-make-production (name prod action)
5670 (vector 'ebnf-generate-production
5672 'ebnf-production-dimension
5681 (defun ebnf-make-alternative (body)
5682 (vector 'ebnf-generate-alternative
5683 'ebnf-alternative-width
5684 'ebnf-alternative-dimension
5691 (defun ebnf-make-optional (body)
5692 (vector 'ebnf-generate-optional
5693 'ebnf-alternative-width
5694 'ebnf-optional-dimension
5701 (defun ebnf-make-except (factor exception)
5702 (vector 'ebnf-generate-except
5704 'ebnf-except-dimension
5712 (defun ebnf-make-repeat (times primary &optional upper)
5713 (vector 'ebnf-generate-repeat
5715 'ebnf-repeat-dimension
5734 (defun ebnf-make-sequence (seq)
5735 (vector 'ebnf-generate-sequence
5736 'ebnf-sequence-width
5737 'ebnf-sequence-dimension
5744 (defun ebnf-make-dup-sequence (node seq)
5745 (vector 'ebnf-generate-sequence
5746 'ebnf-sequence-width
5747 'ebnf-sequence-dimension
5748 (ebnf-node-entry node)
5749 (ebnf-node-height node)
5750 (ebnf-node-width node)
5759 (defun ebnf-token-except (element exception)
5764 (let ((kind (ebnf-node-kind element)))
5768 (eq kind 'ebnf-generate-optional))
5769 (ebnf-node-list element))
5772 (eq kind 'ebnf-generate-zero-or-more))
5773 (ebnf-node-kind element 'ebnf-generate-one-or-more)
5774 (ebnf-node-dimension-func element 'ebnf-one-or-more-dimension)
5779 (eq kind 'ebnf-generate-alternative)
5780 (eq (ebnf-node-kind
5781 (car (last (ebnf-node-list element))))
5782 'ebnf-generate-empty))
5783 (let ((elt (ebnf-node-list element))
5790 (setq element (ebnf-make-empty
5791 (ebnf-node-width element)))
5793 (setq elt (ebnf-node-list element))
5799 (ebnf-make-except element exception))
5803 (defun ebnf-token-repeat (times repeat &optional upper)
5809 (ebnf-make-repeat times (cdr repeat) upper))))
5812 (defun ebnf-token-optional (body)
5813 (let ((kind (ebnf-node-kind body)))
5816 ((eq kind 'ebnf-generate-empty)
5819 ((eq kind 'ebnf-generate-zero-or-more)
5822 ((eq kind 'ebnf-generate-one-or-more)
5823 (ebnf-node-kind body 'ebnf-generate-zero-or-more)
5826 ((eq kind 'ebnf-generate-alternative)
5827 (ebnf-node-list body (nconc (ebnf-node-list body)
5828 (list (ebnf-make-empty))))
5832 (ebnf-make-optional body))
5836 (defun ebnf-token-alternative (body sequence)
5841 (ebnf-make-empty)))
5846 (ebnf-make-alternative (nreverse (if seq
5851 (defun ebnf-token-sequence (sequence)
5855 (ebnf-make-empty))
5861 (ebnf-make-sequence (nreverse sequence)))
5870 (defconst ebnf-comment-table
5882 ;; To make this file smaller, some commands go in a separate file.
5885 (autoload 'ebnf-abn-parser "ebnf-abn"
5888 (autoload 'ebnf-abn-initialize "ebnf-abn"
5891 (autoload 'ebnf-bnf-parser "ebnf-bnf"
5894 (autoload 'ebnf-bnf-initialize "ebnf-bnf"
5897 (autoload 'ebnf-iso-parser "ebnf-iso"
5900 (autoload 'ebnf-iso-initialize "ebnf-iso"
5903 (autoload 'ebnf-yac-parser "ebnf-yac"
5906 (autoload 'ebnf-yac-initialize "ebnf-yac"
5909 (autoload 'ebnf-ebx-parser "ebnf-ebx"
5912 (autoload 'ebnf-ebx-initialize "ebnf-ebx"
5915 (autoload 'ebnf-dtd-parser "ebnf-dtd"
5918 (autoload 'ebnf-dtd-initialize "ebnf-dtd"