Function: bovine--make-parser-1
bovine--make-parser-1 is a byte-compiled function defined in
grammar.el.gz.
Signature
(bovine--make-parser-1 INFILE &optional OUTDIR)
Source Code
;; Defined in /usr/src/emacs/lisp/cedet/semantic/bovine/grammar.el.gz
(defun bovine--make-parser-1 (infile &optional outdir)
(if outdir (setq outdir (file-name-directory (expand-file-name outdir))))
;; It would be nicer to use a temp-buffer rather than find-file-noselect.
;; The only thing stopping us is bovine's semantic-grammar-setupcode-builder's
;; use of (buffer-name). Perhaps that could be changed to
;; (file-name-nondirectory (buffer-file-name)) ?
;; (with-temp-buffer
;; (insert-file-contents infile)
;; (bovine-grammar-mode)
;; (setq buffer-file-name (expand-file-name infile))
;; (if outdir (setq default-directory outdir))
(let ((packagename
;; This is with-demoted-errors.
(condition-case err
(with-current-buffer (find-file-noselect infile)
(setq infile buffer-file-name)
(if outdir (setq default-directory outdir))
(semantic-grammar-create-package t t))
(error (message "%s" (error-message-string err)) nil)))
lang filename copyright-end)
(when (and packagename
(string-match "^.*/\\(.*\\)-by\\.el\\'" packagename))
(setq lang (match-string 1 packagename))
(setq filename (expand-file-name (concat lang "-by.el") outdir))
(with-temp-file filename
(insert-file-contents filename)
;; Fix copyright header:
(goto-char (point-min))
(re-search-forward "^;; Author:")
(setq copyright-end (match-beginning 0))
(re-search-forward "^;;; Code:\n")
(delete-region copyright-end (match-end 0))
(goto-char copyright-end)
(insert ";; This file is part of GNU Emacs.
;; GNU Emacs is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.
;; GNU Emacs is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
;; GNU General Public License for more details.
;; You should have received a copy of the GNU General Public License
;; along with GNU Emacs. If not, see <https://www.gnu.org/licenses/>.
;;; Commentary:
;;
;; This file was generated from "
(if (string-match "\\(admin/grammars/.*\\.by\\)\\'" infile)
(match-string 1 infile)
(concat "admin/grammars/"
(if (string-equal lang "scm") "scheme" lang) ".by"))
".
;;; Code:
")
(goto-char (point-min))
(delete-region (point-min) (line-end-position))
(insert ";;; " packagename
" --- Generated parser support file "
"-*- lexical-binding:t -*-")
(delete-trailing-whitespace)
(re-search-forward ";;; \\(.*\\) ends here")
(replace-match packagename nil nil nil 1)))))