X-Git-Url: https://code.delx.au/gnu-emacs/blobdiff_plain/984ae001715c945ef1e81fba2d80607f486332f2..c94d5f81aaef23672bf1be040c9388f8fe9f88e5:/lisp/progmodes/ebnf-otz.el diff --git a/lisp/progmodes/ebnf-otz.el b/lisp/progmodes/ebnf-otz.el index 5af9ef6925..c4f9fdcd8c 100644 --- a/lisp/progmodes/ebnf-otz.el +++ b/lisp/progmodes/ebnf-otz.el @@ -1,29 +1,29 @@ -;;; ebnf-otz --- Syntatic chart OpTimiZer +;;; ebnf-otz.el --- syntactic chart OpTimiZer -;; Copyright (C) 1999 Vinicius Jose Latorre +;; Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 +;; Free Software Foundation, Inc. -;; Author: Vinicius Jose Latorre -;; Maintainer: Vinicius Jose Latorre -;; Keywords: wp, ebnf, PostScript -;; Time-stamp: <99/11/20 18:03:10 vinicius> -;; Version: 1.0 +;; Author: Vinicius Jose Latorre +;; Maintainer: Vinicius Jose Latorre +;; Keywords: wp, ebnf, PostScript +;; Version: 1.0 -;; This file is *NOT* (yet?) part of GNU Emacs. +;; This file is part of GNU Emacs. -;; This program is free software; you can redistribute it and/or modify +;; 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 2, or (at your option) +;; the Free Software Foundation; either version 3, or (at your option) ;; any later version. -;; This program is distributed in the hope that it will be useful, +;; 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; see the file COPYING. If not, write to the -;; Free Software Foundation, Inc., 59 Temple Place - Suite 330, -;; Boston, MA 02111-1307, USA. +;; Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, +;; Boston, MA 02110-1301, USA. ;;; Commentary: @@ -37,9 +37,49 @@ ;; See ebnf2ps.el for documentation. ;; ;; +;; Optimizations +;; ------------- +;; +;; +;; *To be implemented*: +;; left recursion: +;; A = B | A C B | A C D. ==> A = B {C (B | D)}*. +;; +;; right recursion: +;; A = B | C A. ==> A = {C}* B. +;; A = B | D | C A | E A. ==> A = { C | E }* ( B | D ). +;; +;; optional: +;; A = B | C B. ==> A = [C] B. +;; A = B | B C. ==> A = B [C]. +;; A = D | B D | B C D. ==> A = [B [C]] D. +;; +;; +;; *Already implemented*: +;; left recursion: +;; A = B | A C. ==> A = B {C}*. +;; A = B | A B. ==> A = {B}+. +;; A = | A B. ==> A = {B}*. +;; A = B | A C B. ==> A = {B || C}+. +;; A = B | D | A C | A E. ==> A = ( B | D ) { C | E }*. +;; +;; optional: +;; A = B | . ==> A = [B]. +;; A = | B . ==> A = [B]. +;; +;; factorization: +;; A = B C | B D. ==> A = B (C | D). +;; A = C B | D B. ==> A = (C | D) B. +;; A = B C E | B D E. ==> A = B (C | D) E. +;; +;; none: +;; A = B | C | . ==> A = B | C | . +;; A = B | C A D. ==> A = B | C A D. +;; +;; ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; -;;; code: +;;; Code: (require 'ebnf2ps) @@ -186,7 +226,7 @@ ;; A = B | . ==> A = [B]. ;; A = | B . ==> A = [B]. -;; factoration: +;; factorization: ;; A = B C | B D. ==> A = B (C | D). ;; A = C B | D B. ==> A = (C | D) B. ;; A = B C E | B D E. ==> A = B (C | D) E. @@ -196,7 +236,7 @@ ;; A = B | C A D. ==> A = B | C A D. (defun ebnf-optimize (syntax-list) - "Syntatic chart optimizer." + "Syntactic chart optimizer." (if (not ebnf-optimize) syntax-list (let ((ebnf-total (length syntax-list)) @@ -219,13 +259,13 @@ ;; 6. A = B | . ==> A = [B]. ;; 7. A = | B . ==> A = [B]. -;; factoration: +;; factorization: ;; 8. A = B C | B D. ==> A = B (C | D). ;; 9. A = C B | D B. ==> A = (C | D) B. ;; 10. A = B C E | B D E. ==> A = B (C | D) E. (defun ebnf-optimize1 (prod) - (ebnf-message-info "Optimizing syntatic chart") + (ebnf-message-info "Optimizing syntactic chart") (let ((production (ebnf-node-production prod))) (and (eq (ebnf-node-kind production) 'ebnf-generate-alternative) (let* ((hlist (ebnf-split-header-prefix @@ -658,4 +698,5 @@ (provide 'ebnf-otz) +;;; arch-tag: 7ef2249d-9e8b-4bc1-999f-95d784690636 ;;; ebnf-otz.el ends here