1 |
;;; ebnf-otz.el --- syntatic chart OpTimiZer |
;;; ebnf-otz.el --- syntactic chart OpTimiZer |
2 |
|
|
3 |
;; Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. |
;; Copyright (C) 1999, 2000, 2001 Free Software Foundation, Inc. |
4 |
|
|
5 |
;; Author: Vinicius Jose Latorre <vinicius@cpqd.com.br> |
;; Author: Vinicius Jose Latorre <vinicius@cpqd.com.br> |
6 |
;; Maintainer: Vinicius Jose Latorre <vinicius@cpqd.com.br> |
;; Maintainer: Vinicius Jose Latorre <vinicius@cpqd.com.br> |
7 |
;; Keywords: wp, ebnf, PostScript |
;; Keywords: wp, ebnf, PostScript |
8 |
;; Time-stamp: <2001/08/15 17:13:25 vinicius> |
;; Time-stamp: <2003-02-10 10:46:51 jbarranquero> |
9 |
;; Version: 1.0 |
;; Version: 1.0 |
10 |
|
|
11 |
;; This file is part of GNU Emacs. |
;; This file is part of GNU Emacs. |
196 |
;; A = B | C A D. ==> A = B | C A D. |
;; A = B | C A D. ==> A = B | C A D. |
197 |
|
|
198 |
(defun ebnf-optimize (syntax-list) |
(defun ebnf-optimize (syntax-list) |
199 |
"Syntatic chart optimizer." |
"Syntactic chart optimizer." |
200 |
(if (not ebnf-optimize) |
(if (not ebnf-optimize) |
201 |
syntax-list |
syntax-list |
202 |
(let ((ebnf-total (length syntax-list)) |
(let ((ebnf-total (length syntax-list)) |
225 |
;; 10. A = B C E | B D E. ==> A = B (C | D) E. |
;; 10. A = B C E | B D E. ==> A = B (C | D) E. |
226 |
|
|
227 |
(defun ebnf-optimize1 (prod) |
(defun ebnf-optimize1 (prod) |
228 |
(ebnf-message-info "Optimizing syntatic chart") |
(ebnf-message-info "Optimizing syntactic chart") |
229 |
(let ((production (ebnf-node-production prod))) |
(let ((production (ebnf-node-production prod))) |
230 |
(and (eq (ebnf-node-kind production) 'ebnf-generate-alternative) |
(and (eq (ebnf-node-kind production) 'ebnf-generate-alternative) |
231 |
(let* ((hlist (ebnf-split-header-prefix |
(let* ((hlist (ebnf-split-header-prefix |