-;;; ebnf2ps --- Translate an EBNF to a syntatic chart on PostScript
+;;; ebnf2ps.el --- translate an EBNF to a syntactic chart on PostScript
-;; Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+;; Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc.
-;; Author: Vinicius Jose Latorre <vinicius@cpqd.com.br>
+;; Author: Vinicius Jose Latorre <vinicius@cpqd.com.br>
;; Maintainer: Vinicius Jose Latorre <vinicius@cpqd.com.br>
-;; Keywords: wp, ebnf, PostScript
-;; Time-stamp: <2000/08/27 14:24:32 vinicius>
-;; Version: 3.3
-;; X-URL: http://www.cpqd.com.br/~vinicius/emacs/Emacs.html
+;; Keywords: wp, ebnf, PostScript
+;; Time-stamp: <2003/08/08 23:09:36 vinicius>
+;; Version: 3.6.1
+;; X-URL: http://www.cpqd.com.br/~vinicius/emacs/
;; This file is part of GNU Emacs.
;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
;; Boston, MA 02111-1307, USA.
-(defconst ebnf-version "3.3"
- "ebnf2ps.el, v 3.2 <2000/08/27 vinicius>
+(defconst ebnf-version "3.6.1"
+ "ebnf2ps.el, v 3.6.1 <2001/09/24 vinicius>
Vinicius's last change version. When reporting bugs, please also
report the version of Emacs, if any, that ebnf2ps was running with.
;; Introduction
;; ------------
;;
-;; This package translates an EBNF to a syntatic chart on PostScript.
+;; This package translates an EBNF to a syntactic chart on PostScript.
;;
;; To use ebnf2ps, insert in your ~/.emacs:
;;
;; Using ebnf2ps
;; -------------
;;
-;; ebnf2ps provides six commands for generating PostScript syntatic chart
+;; ebnf2ps provides six commands for generating PostScript syntactic chart
;; images of Emacs buffers:
;;
;; ebnf-print-buffer
;; ebnf-eps-region
;;
;; These commands all perform essentially the same function: they generate
-;; PostScript syntatic chart images suitable for printing on a PostScript
+;; PostScript syntactic chart images suitable for printing on a PostScript
;; printer or displaying with GhostScript. These commands are collectively
;; referred to as "ebnf- commands".
;;
;; | "{" body [ "||" body ] "}" ;; zero-or-more
;; .
;;
-;; non_terminal = "[A-Za-z\\240-\\377][!#%&'*-,0-:<>@-Z\\^-z~\\240-\\377]*".
+;; non_terminal = "[!#%&'*-,0-:<>@-Z\\\\^-z~\\240-\\377]+".
;;
;; terminal = "\\([^\"\\]\\|\\\\[ -~\\240-\\377]\\)+".
;;
;;
;; `ebnf-setup' returns the current setup.
;;
-;; `ebnf-syntax-buffer' does a syntatic analysis of your EBNF in the current
+;; `ebnf-syntax-buffer' does a syntactic analysis of your EBNF in the current
;; buffer.
;;
-;; `ebnf-syntax-region' does a syntatic analysis of your EBNF in the current
+;; `ebnf-syntax-region' does a syntactic analysis of your EBNF in the current
;; region.
;;
;; `ebnf-customize' activates a customization buffer for ebnf2ps options.
;;
;; `ebnf-ignore-empty-rule' Non-nil means ignore empty rules.
;;
-;; `ebnf-optimize' Non-nil means optimize syntatic chart
+;; `ebnf-optimize' Non-nil means optimize syntactic chart
;; of rules.
;;
;; To set the above options you may:
;; Internal Structures
;; -------------------
;;
-;; ebnf2ps has two passes. The first pass does a lexical and syntatic analysis
+;; ebnf2ps has two passes. The first pass does a lexical and syntactic analysis
;; of current buffer and generates an intermediate representation. The second
;; pass uses the intermediate representation to generate the PostScript
-;; syntatic chart.
+;; syntactic chart.
;;
;; The intermediate representation is a list of vectors, the vector element
-;; represents a syntatic chart element. Below is a vector representation for
-;; each syntatic chart element.
+;; represents a syntactic chart element. Below is a vector representation for
+;; each syntactic chart element.
;;
;; [production WIDTH-FUN DIM-FUN ENTRY HEIGHT WIDTH NAME PRODUCTION ACTION]
;; [alternative WIDTH-FUN DIM-FUN ENTRY HEIGHT WIDTH LIST]
;; Things To Change
;; ----------------
;;
-;; . Handle situations when syntatic chart is out of paper.
+;; . Handle situations when syntactic chart is out of paper.
;; . Use other alphabet than ascii.
;; . Optimizations...
;;
;;
;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
-;;; code:
+;;; Code:
(require 'ps-print)
(defgroup ebnf2ps nil
- "Translate an EBNF to a syntatic chart on PostScript"
+ "Translate an EBNF to a syntactic chart on PostScript"
:prefix "ebnf-"
:group 'wp
:group 'postscript)
:group 'ebnf2ps)
-(defgroup ebnf-syntatic nil
- "Syntatic customization"
+(defgroup ebnf-syntactic nil
+ "Syntactic customization"
:prefix "ebnf-"
- :tag "Syntatic"
+ :tag "Syntactic"
:group 'ebnf2ps)
Any other value is treated as `ebnf'."
:type '(radio :tag "Syntax"
(const ebnf) (const iso-ebnf) (const yacc))
- :group 'ebnf-syntatic)
+ :group 'ebnf-syntactic)
(defcustom ebnf-lex-comment-char ?\;
It's used only when `ebnf-syntax' is `ebnf'."
:type 'character
- :group 'ebnf-syntatic)
+ :group 'ebnf-syntactic)
(defcustom ebnf-lex-eop-char ?.
It's used only when `ebnf-syntax' is `ebnf'."
:type 'character
- :group 'ebnf-syntatic)
+ :group 'ebnf-syntactic)
(defcustom ebnf-terminal-regexp nil
It's used only when `ebnf-syntax' is `ebnf'."
:type '(radio :tag "Terminal Name"
(const nil) regexp)
- :group 'ebnf-syntatic)
+ :group 'ebnf-syntactic)
(defcustom ebnf-case-fold-search nil
It's only used when `ebnf-terminal-regexp' is non-nil and when `ebnf-syntax' is
`ebnf'."
:type 'boolean
- :group 'ebnf-syntatic)
+ :group 'ebnf-syntactic)
(defcustom ebnf-iso-alternative-p nil
} ==> :)
; ==> ."
:type 'boolean
- :group 'ebnf-syntatic)
+ :group 'ebnf-syntactic)
(defcustom ebnf-iso-normalize-p nil
It's only used when `ebnf-syntax' is `iso-ebnf'."
:type 'boolean
- :group 'ebnf-syntatic)
+ :group 'ebnf-syntactic)
(defcustom ebnf-eps-prefix "ebnf--"
It's only used when `ebnf-syntax' is `yacc'."
:type 'boolean
- :group 'ebnf-syntatic)
+ :group 'ebnf-syntactic)
(defcustom ebnf-ignore-empty-rule nil
(defcustom ebnf-optimize nil
- "*Non-nil means optimize syntatic chart of rules.
+ "*Non-nil means optimize syntactic chart of rules.
The following optimizations are done:
;;;###autoload
(defun ebnf-print-buffer (&optional filename)
- "Generate and print a PostScript syntatic chart image of the buffer.
+ "Generate and print a PostScript syntactic chart image of the buffer.
When called with a numeric prefix argument (C-u), prompts the user for
the name of a file to save the PostScript image in, instead of sending
;;;###autoload
(defun ebnf-print-region (from to &optional filename)
- "Generate and print a PostScript syntatic chart image of the region.
+ "Generate and print a PostScript syntactic chart image of the region.
Like `ebnf-print-buffer', but prints just the current region."
(interactive (list (point) (mark) (ps-print-preprint current-prefix-arg)))
(run-hooks 'ebnf-hook)
;;;###autoload
(defun ebnf-spool-buffer ()
- "Generate and spool a PostScript syntatic chart image of the buffer.
+ "Generate and spool a PostScript syntactic chart image of the buffer.
Like `ebnf-print-buffer' except that the PostScript image is saved in a
local buffer to be sent to the printer later.
;;;###autoload
(defun ebnf-spool-region (from to)
- "Generate a PostScript syntatic chart image of the region and spool locally.
+ "Generate a PostScript syntactic chart image of the region and spool locally.
Like `ebnf-spool-buffer', but spools just the current region.
Use the command `ebnf-despool' to send the spooled images to the printer."
;;;###autoload
(defun ebnf-eps-buffer ()
- "Generate a PostScript syntatic chart image of the buffer in a EPS file.
+ "Generate a PostScript syntactic chart image of the buffer in a EPS file.
Indeed, for each production is generated a EPS file.
The EPS file name has the following form:
;;;###autoload
(defun ebnf-eps-region (from to)
- "Generate a PostScript syntatic chart image of the region in a EPS file.
+ "Generate a PostScript syntactic chart image of the region in a EPS file.
Indeed, for each production is generated a EPS file.
The EPS file name has the following form:
;;;###autoload
(defun ebnf-syntax-buffer ()
- "Does a syntatic analysis of the current buffer."
+ "Does a syntactic analysis of the current buffer."
(interactive)
(ebnf-syntax-region (point-min) (point-max)))
;;;###autoload
(defun ebnf-syntax-region (from to)
- "Does a syntatic analysis of a region."
+ "Does a syntactic analysis of a region."
(interactive "r")
(ebnf-generate-region from to nil))
"Return the current ebnf2ps setup."
(format
"
+;;; ebnf2ps.el version %s
+
\(setq ebnf-special-font %s
ebnf-special-shape %s
ebnf-special-shadow %S
ebnf-yac-ignore-error-recovery %S
ebnf-ignore-empty-rule %S
ebnf-optimize %S)
+
+;;; ebnf2ps.el - end of settings
"
+ ebnf-version
(ps-print-quote ebnf-special-font)
(ps-print-quote ebnf-special-shape)
ebnf-special-shadow
;; Internal variables
-(make-local-hook 'ebnf-hook)
-(make-local-hook 'ebnf-production-hook)
-(make-local-hook 'ebnf-page-hook)
-
-
(defvar ebnf-eps-buffer-name " *EPS*")
(defvar ebnf-parser-func nil)
(defvar ebnf-eps-executing nil)
/#ebnf2ps#end{showpage #ebnf2ps#save restore end}def
-%%EndPrologue
+%%EndProlog
"
"EBNF EPS begin")
(format ebnf-message-float value)))
+(defvar ebnf-total 0)
+(defvar ebnf-nprod 0)
+
+
(defsubst ebnf-message-info (messag)
(message "%s...%3d%%"
messag
(defvar ebnf-tree nil)
(defvar ebnf-direction "R")
-(defvar ebnf-total 0)
-(defvar ebnf-nprod 0)
(defun ebnf-generate-postscript (from to)
;; Internal functions
+;; function `ebnf-range-regexp' is used to avoid a bug of `skip-chars-forward'
+;; on version 20.4.1, that is, it doesn't accept ranges like "\240-\377" (or
+;; "\177-\237"), but it accepts the character sequence from \240 to \377 (or
+;; from \177 to \237). It seems that version 20.7 has the same problem.
+(defun ebnf-range-regexp (prefix from to)
+ (let (str)
+ (while (<= from to)
+ (setq str (concat str (char-to-string from))
+ from (1+ from)))
+ (concat prefix str)))
+
+
(defvar ebnf-map-name
(let ((map (make-vector 256 ?\_)))
(mapcar #'(lambda (char)
(gen-func
nil)
(t
- (message "EBNF syntatic analysis: NO ERRORS.")))))
+ (message "EBNF syntactic analysis: NO ERRORS.")))))
(defun ebnf-parse-and-sort (start)
(defun ebnf-begin-job ()
- (ps-printing-region nil nil)
+ (ps-printing-region nil nil nil)
(if ebnf-use-float-format
(setq ebnf-format-float "%1.3f"
ebnf-message-float "%3.2f")
(insert " & ebnf2ps v" ebnf-version)
;; insert ebnf settings & engine
(goto-char (point-max))
- (search-backward "\n%%EndPrologue\n")
+ (search-backward "\n%%EndProlog\n")
(ebnf-insert-ebnf-prologue)
(ps-output "\n")))))
"\n%%BoundingBox: 0 0 "
(format "%d %d" (1+ ebnf-eps-upper-x) (1+ ebnf-eps-upper-y))
"\n%%Title: " filename
- "\n%%CreationDate: " (time-stamp-hh:mm:ss) " " (time-stamp-mon-dd-yyyy)
+ "\n%%CreationDate: " (format-time-string "%T %b %d %Y")
"\n%%Creator: " (user-full-name) " (using ebnf2ps v" ebnf-version ")"
"\n%%DocumentNeededResources: font "
(or ebnf-fonts-required
ebnf-except-font
ebnf-repeat-font)))
"\n%%+ font ")))
- "\n%%Pages: 0\n%%EndComments\n\n%%BeginPrologue\n"
+ "\n%%Pages: 0\n%%EndComments\n\n%%BeginProlog\n"
ebnf-eps-prologue)
(ebnf-insert-ebnf-prologue)
(insert ebnf-eps-begin
(point))))
-;; to avoid a bug of `skip-chars-forward' on version 20.4.1, that is, it
-;; doesn't accept the range "\240-\377", but it accepts the character sequence
-;; from \240 to \377. It seems that version 20.7 has the same problem.
-(defconst ebnf-8-bit-chars
- (let ((char ?\240)
- str)
- (while (<= char ?\377)
- (setq str (concat str (char-to-string char))
- char (1+ char)))
- str))
+;; replace the range "\240-\377" (see `ebnf-range-regexp').
+(defconst ebnf-8-bit-chars (ebnf-range-regexp "" ?\240 ?\377))
(defun ebnf-string (chars eos-char kind)
;;(skip-chars-forward (concat chars "\240-\377") ebnf-limit)
(skip-chars-forward (concat chars ebnf-8-bit-chars) ebnf-limit)
(if (or (eobp) (/= (following-char) eos-char))
- (error "Illegal %s: missing `%c'." kind eos-char)
+ (error "Illegal %s: missing `%c'" kind eos-char)
(forward-char)
(1- (point))))))
(goto-char (+ (point) n 1))))
(if (= (preceding-char) ?\")
(1- (point))
- (error "Missing `\"'.")))
+ (error "Missing `\"'")))
(defun ebnf-trim-right (str)
"Eliminate empty rules.")
(autoload 'ebnf-optimize "ebnf-otz"
- "Syntatic chart optimizer.")
+ "Syntactic chart optimizer.")
(autoload 'ebnf-otz-initialize "ebnf-otz"
"Initialize optimizer.")
(provide 'ebnf2ps)
-
+;;; arch-tag: 148bc8af-5398-468b-b922-eeb7afef3e4f
;;; ebnf2ps.el ends here