annotate lisp/progmodes/ebnf-otz.el @ 31473:055accd6bf1d

(obtain, relinquish, relinquish, r_alloc_size_in_use) (get_bloc, relocate_blocs, update_heap_bloc_correspondence) (resize_bloc, r_alloc_sbrk, r_alloc_init): Add casts to `char *' where necessary, in case POINTER_TYPE is `void'.
author Gerd Moellmann <gerd@gnu.org>
date Thu, 07 Sep 2000 19:24:24 +0000
parents 9299c470e566
children 891b73bae2ff
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
27451
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
1 ;;; ebnf-otz --- Syntatic chart OpTimiZer
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
2
27539
9299c470e566 Update copyright.
Gerd Moellmann <gerd@gnu.org>
parents: 27451
diff changeset
3 ;; Copyright (C) 1999, 2000 Free Software Foundation, Inc.
27451
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
4
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
5 ;; Author: Vinicius Jose Latorre <vinicius@cpqd.com.br>
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
6 ;; Maintainer: Vinicius Jose Latorre <vinicius@cpqd.com.br>
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
7 ;; Keywords: wp, ebnf, PostScript
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
8 ;; Time-stamp: <99/11/20 18:03:10 vinicius>
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
9 ;; Version: 1.0
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
10
27539
9299c470e566 Update copyright.
Gerd Moellmann <gerd@gnu.org>
parents: 27451
diff changeset
11 ;; This file is part of GNU Emacs.
27451
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
12
27539
9299c470e566 Update copyright.
Gerd Moellmann <gerd@gnu.org>
parents: 27451
diff changeset
13 ;; GNU Emacs is free software; you can redistribute it and/or modify
27451
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
14 ;; it under the terms of the GNU General Public License as published by
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
15 ;; the Free Software Foundation; either version 2, or (at your option)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
16 ;; any later version.
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
17
27539
9299c470e566 Update copyright.
Gerd Moellmann <gerd@gnu.org>
parents: 27451
diff changeset
18 ;; GNU Emacs is distributed in the hope that it will be useful,
27451
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
19 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
20 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
21 ;; GNU General Public License for more details.
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
22
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
23 ;; You should have received a copy of the GNU General Public License
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
24 ;; along with GNU Emacs; see the file COPYING. If not, write to the
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
25 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
26 ;; Boston, MA 02111-1307, USA.
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
27
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
28 ;;; Commentary:
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
29
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
30 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
31 ;;
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
32 ;;
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
33 ;; This is part of ebnf2ps package.
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
34 ;;
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
35 ;; This package defines an optimizer for ebnf2ps.
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
36 ;;
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
37 ;; See ebnf2ps.el for documentation.
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
38 ;;
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
39 ;;
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
40 ;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
41
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
42 ;;; code:
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
43
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
44
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
45 (require 'ebnf2ps)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
46
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
47
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
48 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
49
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
50
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
51 (defvar ebnf-empty-rule-list nil
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
52 "List of empty rule name.")
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
53
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
54
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
55 (defun ebnf-add-empty-rule-list (rule)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
56 "Add empty RULE in `ebnf-empty-rule-list'."
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
57 (and ebnf-ignore-empty-rule
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
58 (eq (ebnf-node-kind (ebnf-node-production rule))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
59 'ebnf-generate-empty)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
60 (setq ebnf-empty-rule-list (cons (ebnf-node-name rule)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
61 ebnf-empty-rule-list))))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
62
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
63
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
64 (defun ebnf-otz-initialize ()
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
65 "Initialize optimizer."
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
66 (setq ebnf-empty-rule-list nil))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
67
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
68
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
69 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
70 ;; Eliminate empty rules
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
71
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
72
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
73 (defun ebnf-eliminate-empty-rules (syntax-list)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
74 "Eliminate empty rules."
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
75 (while ebnf-empty-rule-list
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
76 (let ((ebnf-total (length syntax-list))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
77 (ebnf-nprod 0)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
78 (prod-list syntax-list)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
79 new-list before)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
80 (while prod-list
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
81 (ebnf-message-info "Eliminating empty rules")
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
82 (let ((rule (car prod-list)))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
83 ;; if any non-terminal pertains to ebnf-empty-rule-list
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
84 ;; then eliminate non-terminal from rule
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
85 (if (ebnf-eliminate-empty rule)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
86 (setq before prod-list)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
87 ;; eliminate empty rule from syntax-list
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
88 (setq new-list (cons (ebnf-node-name rule) new-list))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
89 (if before
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
90 (setcdr before (cdr prod-list))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
91 (setq syntax-list (cdr syntax-list)))))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
92 (setq prod-list (cdr prod-list)))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
93 (setq ebnf-empty-rule-list new-list)))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
94 syntax-list)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
95
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
96
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
97 ;; [production width-func entry height width name production action]
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
98 ;; [sequence width-func entry height width list]
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
99 ;; [alternative width-func entry height width list]
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
100 ;; [non-terminal width-func entry height width name default]
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
101 ;; [empty width-func entry height width]
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
102 ;; [terminal width-func entry height width name default]
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
103 ;; [special width-func entry height width name default]
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
104
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
105 (defun ebnf-eliminate-empty (rule)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
106 (let ((kind (ebnf-node-kind rule)))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
107 (cond
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
108 ;; non-terminal
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
109 ((eq kind 'ebnf-generate-non-terminal)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
110 (if (member (ebnf-node-name rule) ebnf-empty-rule-list)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
111 nil
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
112 rule))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
113 ;; sequence
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
114 ((eq kind 'ebnf-generate-sequence)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
115 (let ((seq (ebnf-node-list rule))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
116 (header (ebnf-node-list rule))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
117 before elt)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
118 (while seq
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
119 (setq elt (car seq))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
120 (if (ebnf-eliminate-empty elt)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
121 (setq before seq)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
122 (if before
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
123 (setcdr before (cdr seq))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
124 (setq header (cdr header))))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
125 (setq seq (cdr seq)))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
126 (when header
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
127 (ebnf-node-list rule header)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
128 rule)))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
129 ;; alternative
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
130 ((eq kind 'ebnf-generate-alternative)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
131 (let ((seq (ebnf-node-list rule))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
132 (header (ebnf-node-list rule))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
133 before elt)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
134 (while seq
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
135 (setq elt (car seq))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
136 (if (ebnf-eliminate-empty elt)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
137 (setq before seq)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
138 (if before
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
139 (setcdr before (cdr seq))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
140 (setq header (cdr header))))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
141 (setq seq (cdr seq)))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
142 (when header
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
143 (if (= (length header) 1)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
144 (car header)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
145 (ebnf-node-list rule header)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
146 rule))))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
147 ;; production
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
148 ((eq kind 'ebnf-generate-production)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
149 (let ((prod (ebnf-eliminate-empty (ebnf-node-production rule))))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
150 (when prod
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
151 (ebnf-node-production rule prod)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
152 rule)))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
153 ;; terminal, special and empty
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
154 (t
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
155 rule)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
156 )))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
157
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
158
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
159 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
160 ;; Optimizations
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
161
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
162
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
163 ;; *To be implemented*:
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
164 ;; left recursion:
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
165 ;; A = B | A C B | A C D. ==> A = B {C (B | D)}*.
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
166
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
167 ;; right recursion:
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
168 ;; A = B | C A. ==> A = {C}* B.
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
169 ;; A = B | D | C A | E A. ==> A = { C | E }* ( B | D ).
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
170
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
171 ;; optional:
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
172 ;; A = B | C B. ==> A = [C] B.
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
173 ;; A = B | B C. ==> A = B [C].
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
174 ;; A = D | B D | B C D. ==> A = [B [C]] D.
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
175
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
176
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
177 ;; *Already implemented*:
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
178 ;; left recursion:
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
179 ;; A = B | A C. ==> A = B {C}*.
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
180 ;; A = B | A B. ==> A = {B}+.
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
181 ;; A = | A B. ==> A = {B}*.
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
182 ;; A = B | A C B. ==> A = {B || C}+.
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
183 ;; A = B | D | A C | A E. ==> A = ( B | D ) { C | E }*.
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
184
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
185 ;; optional:
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
186 ;; A = B | . ==> A = [B].
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
187 ;; A = | B . ==> A = [B].
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
188
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
189 ;; factoration:
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
190 ;; A = B C | B D. ==> A = B (C | D).
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
191 ;; A = C B | D B. ==> A = (C | D) B.
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
192 ;; A = B C E | B D E. ==> A = B (C | D) E.
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
193
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
194 ;; none:
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
195 ;; A = B | C | . ==> A = B | C | .
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
196 ;; A = B | C A D. ==> A = B | C A D.
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
197
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
198 (defun ebnf-optimize (syntax-list)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
199 "Syntatic chart optimizer."
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
200 (if (not ebnf-optimize)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
201 syntax-list
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
202 (let ((ebnf-total (length syntax-list))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
203 (ebnf-nprod 0)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
204 new)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
205 (while syntax-list
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
206 (setq new (cons (ebnf-optimize1 (car syntax-list)) new)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
207 syntax-list (cdr syntax-list)))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
208 (nreverse new))))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
209
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
210
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
211 ;; left recursion:
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
212 ;; 1. A = B | A C. ==> A = B {C}*.
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
213 ;; 2. A = B | A B. ==> A = {B}+.
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
214 ;; 3. A = | A B. ==> A = {B}*.
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
215 ;; 4. A = B | A C B. ==> A = {B || C}+.
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
216 ;; 5. A = B | D | A C | A E. ==> A = ( B | D ) { C | E }*.
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
217
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
218 ;; optional:
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
219 ;; 6. A = B | . ==> A = [B].
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
220 ;; 7. A = | B . ==> A = [B].
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
221
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
222 ;; factoration:
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
223 ;; 8. A = B C | B D. ==> A = B (C | D).
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
224 ;; 9. A = C B | D B. ==> A = (C | D) B.
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
225 ;; 10. A = B C E | B D E. ==> A = B (C | D) E.
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
226
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
227 (defun ebnf-optimize1 (prod)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
228 (ebnf-message-info "Optimizing syntatic chart")
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
229 (let ((production (ebnf-node-production prod)))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
230 (and (eq (ebnf-node-kind production) 'ebnf-generate-alternative)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
231 (let* ((hlist (ebnf-split-header-prefix
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
232 (ebnf-node-list production)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
233 (ebnf-node-name prod)))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
234 (nlist (car hlist))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
235 (zlist (cdr hlist))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
236 (elist (ebnf-split-header-suffix nlist zlist)))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
237 (ebnf-node-production
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
238 prod
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
239 (cond
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
240 ;; cases 2., 4.
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
241 (elist
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
242 (and (eq elist t)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
243 (setq elist nil))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
244 (setq elist (or (ebnf-prefix-suffix elist)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
245 elist))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
246 (let* ((nl (ebnf-extract-empty nlist))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
247 (el (or (ebnf-prefix-suffix (cdr nl))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
248 (ebnf-create-alternative (cdr nl)))))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
249 (if (car nl)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
250 (ebnf-make-zero-or-more el elist)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
251 (ebnf-make-one-or-more el elist))))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
252 ;; cases 1., 3., 5.
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
253 (zlist
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
254 (let* ((xlist (cdr (ebnf-extract-empty zlist)))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
255 (znode (ebnf-make-zero-or-more
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
256 (or (ebnf-prefix-suffix xlist)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
257 (ebnf-create-alternative xlist))))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
258 (nnode (ebnf-map-list-to-optional nlist)))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
259 (and nnode
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
260 (setq nlist (list nnode)))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
261 (if (or (null nlist)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
262 (and (= (length nlist) 1)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
263 (eq (ebnf-node-kind (car nlist))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
264 'ebnf-generate-empty)))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
265 znode
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
266 (ebnf-make-sequence
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
267 (list (or (ebnf-prefix-suffix nlist)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
268 (ebnf-create-alternative nlist))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
269 znode)))))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
270 ;; cases 6., 7.
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
271 ((ebnf-map-node-to-optional production)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
272 )
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
273 ;; cases 8., 9., 10.
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
274 ((ebnf-prefix-suffix nlist)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
275 )
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
276 ;; none
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
277 (t
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
278 production)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
279 ))))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
280 prod))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
281
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
282
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
283 (defun ebnf-split-header-prefix (node-list header)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
284 (let* ((hlist (ebnf-split-header-prefix1 node-list header))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
285 (nlist (car hlist))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
286 zlist empty-p)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
287 (while (setq hlist (cdr hlist))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
288 (let ((elt (car hlist)))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
289 (if (eq (ebnf-node-kind elt) 'ebnf-generate-sequence)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
290 (setq zlist (cons
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
291 (let ((seq (cdr (ebnf-node-list elt))))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
292 (if (= (length seq) 1)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
293 (car seq)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
294 (ebnf-node-list elt seq)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
295 elt))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
296 zlist))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
297 (setq empty-p t))))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
298 (and empty-p
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
299 (setq zlist (cons (ebnf-make-empty)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
300 zlist)))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
301 (cons nlist (nreverse zlist))))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
302
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
303
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
304 (defun ebnf-split-header-prefix1 (node-list header)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
305 (let (hlist nlist)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
306 (while node-list
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
307 (if (ebnf-node-equal-header (car node-list) header)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
308 (setq hlist (cons (car node-list) hlist))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
309 (setq nlist (cons (car node-list) nlist)))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
310 (setq node-list (cdr node-list)))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
311 (cons (nreverse nlist) (nreverse hlist))))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
312
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
313
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
314 (defun ebnf-node-equal-header (node header)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
315 (let ((kind (ebnf-node-kind node)))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
316 (cond
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
317 ((eq kind 'ebnf-generate-sequence)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
318 (ebnf-node-equal-header (car (ebnf-node-list node)) header))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
319 ((eq kind 'ebnf-generate-non-terminal)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
320 (string= (ebnf-node-name node) header))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
321 (t
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
322 nil)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
323 )))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
324
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
325
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
326 (defun ebnf-map-node-to-optional (node)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
327 (and (eq (ebnf-node-kind node) 'ebnf-generate-alternative)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
328 (ebnf-map-list-to-optional (ebnf-node-list node))))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
329
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
330
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
331 (defun ebnf-map-list-to-optional (nlist)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
332 (and (= (length nlist) 2)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
333 (let ((first (nth 0 nlist))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
334 (second (nth 1 nlist)))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
335 (cond
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
336 ;; empty second
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
337 ((eq (ebnf-node-kind first) 'ebnf-generate-empty)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
338 (ebnf-make-optional second))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
339 ;; first empty
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
340 ((eq (ebnf-node-kind second) 'ebnf-generate-empty)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
341 (ebnf-make-optional first))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
342 ;; first second
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
343 (t
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
344 nil)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
345 ))))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
346
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
347
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
348 (defun ebnf-extract-empty (elist)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
349 (let ((now elist)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
350 before empty-p)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
351 (while now
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
352 (if (not (eq (ebnf-node-kind (car now)) 'ebnf-generate-empty))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
353 (setq before now)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
354 (setq empty-p t)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
355 (if before
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
356 (setcdr before (cdr now))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
357 (setq elist (cdr elist))))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
358 (setq now (cdr now)))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
359 (cons empty-p elist)))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
360
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
361
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
362 (defun ebnf-split-header-suffix (nlist zlist)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
363 (let (new empty-p)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
364 (and (cond
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
365 ((= (length nlist) 1)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
366 (let ((ok t)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
367 (elt (car nlist)))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
368 (while (and ok zlist)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
369 (setq ok (ebnf-split-header-suffix1 elt (car zlist))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
370 zlist (cdr zlist))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
371 (if (eq ok t)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
372 (setq empty-p t)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
373 (setq new (cons ok new))))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
374 ok))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
375 ((= (length nlist) (length zlist))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
376 (let ((ok t))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
377 (while (and ok zlist)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
378 (setq ok (ebnf-split-header-suffix1 (car nlist) (car zlist))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
379 nlist (cdr nlist)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
380 zlist (cdr zlist))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
381 (if (eq ok t)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
382 (setq empty-p t)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
383 (setq new (cons ok new))))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
384 ok))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
385 (t
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
386 nil)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
387 )
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
388 (let* ((lis (ebnf-unique-list new))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
389 (len (length lis)))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
390 (cond
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
391 ((zerop len)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
392 t)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
393 ((= len 1)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
394 (setq lis (car lis))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
395 (if empty-p
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
396 (ebnf-make-optional lis)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
397 lis))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
398 (t
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
399 (and empty-p
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
400 (setq lis (cons (ebnf-make-empty) lis)))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
401 (ebnf-create-alternative (nreverse lis)))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
402 )))))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
403
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
404
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
405 (defun ebnf-split-header-suffix1 (ne ze)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
406 (cond
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
407 ((eq (ebnf-node-kind ne) 'ebnf-generate-sequence)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
408 (and (eq (ebnf-node-kind ze) 'ebnf-generate-sequence)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
409 (let ((nl (ebnf-node-list ne))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
410 (zl (ebnf-node-list ze))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
411 len z)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
412 (and (>= (length zl) (length nl))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
413 (let ((ok t))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
414 (setq len (- (length zl) (length nl))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
415 z (nthcdr len zl))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
416 (while (and ok z)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
417 (setq ok (ebnf-node-equal (car z) (car nl))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
418 z (cdr z)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
419 nl (cdr nl)))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
420 ok)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
421 (if (zerop len)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
422 t
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
423 (setcdr (nthcdr (1- len) zl) nil)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
424 ze)))))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
425 ((eq (ebnf-node-kind ze) 'ebnf-generate-sequence)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
426 (let* ((zl (ebnf-node-list ze))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
427 (len (length zl)))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
428 (and (ebnf-node-equal ne (car (nthcdr (1- len) zl)))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
429 (cond
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
430 ((= len 1)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
431 t)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
432 ((= len 2)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
433 (car zl))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
434 (t
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
435 (setcdr (nthcdr (- len 2) zl) nil)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
436 ze)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
437 ))))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
438 (t
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
439 (ebnf-node-equal ne ze))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
440 ))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
441
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
442
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
443 (defun ebnf-prefix-suffix (lis)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
444 (and lis (listp lis)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
445 (let* ((prefix (ebnf-split-prefix lis))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
446 (suffix (ebnf-split-suffix (cdr prefix)))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
447 (middle (cdr suffix)))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
448 (setq prefix (car prefix)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
449 suffix (car suffix))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
450 (and (or prefix suffix)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
451 (ebnf-make-sequence
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
452 (nconc prefix
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
453 (and middle
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
454 (list (or (ebnf-map-list-to-optional middle)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
455 (ebnf-create-alternative middle))))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
456 suffix))))))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
457
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
458
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
459 (defun ebnf-split-prefix (lis)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
460 (let* ((len (length lis))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
461 (tail lis)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
462 (head (if (eq (ebnf-node-kind (car lis)) 'ebnf-generate-sequence)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
463 (ebnf-node-list (car lis))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
464 (list (car lis))))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
465 (ipre (1+ len)))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
466 ;; determine prefix length
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
467 (while (and (> ipre 0) (setq tail (cdr tail)))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
468 (let ((cur head)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
469 (this (if (eq (ebnf-node-kind (car tail)) 'ebnf-generate-sequence)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
470 (ebnf-node-list (car tail))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
471 (list (car tail))))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
472 (i 0))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
473 (while (and cur this
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
474 (ebnf-node-equal (car cur) (car this)))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
475 (setq cur (cdr cur)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
476 this (cdr this)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
477 i (1+ i)))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
478 (setq ipre (min ipre i))))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
479 (if (or (zerop ipre) (> ipre len))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
480 ;; no prefix at all
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
481 (cons nil lis)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
482 (let* ((tail (nthcdr ipre head))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
483 ;; get prefix
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
484 (prefix (progn
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
485 (and tail
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
486 (setcdr (nthcdr (1- ipre) head) nil))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
487 head))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
488 empty-p before)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
489 ;; adjust first element
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
490 (if (or (not (eq (ebnf-node-kind (car lis)) 'ebnf-generate-sequence))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
491 (null tail))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
492 (setq lis (cdr lis)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
493 tail lis
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
494 empty-p t)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
495 (if (= (length tail) 1)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
496 (setcar lis (car tail))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
497 (ebnf-node-list (car lis) tail))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
498 (setq tail (cdr lis)))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
499 ;; eliminate prefix from lis based on ipre
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
500 (while tail
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
501 (let ((elt (car tail))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
502 rest)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
503 (if (and (eq (ebnf-node-kind elt) 'ebnf-generate-sequence)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
504 (setq rest (nthcdr ipre (ebnf-node-list elt))))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
505 (progn
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
506 (if (= (length rest) 1)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
507 (setcar tail (car rest))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
508 (ebnf-node-list elt rest))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
509 (setq before tail))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
510 (setq empty-p t)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
511 (if before
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
512 (setcdr before (cdr tail))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
513 (setq lis (cdr lis))))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
514 (setq tail (cdr tail))))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
515 (cons prefix (ebnf-unique-list
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
516 (if empty-p
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
517 (nconc lis (list (ebnf-make-empty)))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
518 lis)))))))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
519
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
520
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
521 (defun ebnf-split-suffix (lis)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
522 (let* ((len (length lis))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
523 (tail lis)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
524 (head (nreverse
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
525 (if (eq (ebnf-node-kind (car lis)) 'ebnf-generate-sequence)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
526 (ebnf-node-list (car lis))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
527 (list (car lis)))))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
528 (isuf (1+ len)))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
529 ;; determine suffix length
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
530 (while (and (> isuf 0) (setq tail (cdr tail)))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
531 (let* ((cur head)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
532 (tlis (nreverse
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
533 (if (eq (ebnf-node-kind (car tail)) 'ebnf-generate-sequence)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
534 (ebnf-node-list (car tail))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
535 (list (car tail)))))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
536 (this tlis)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
537 (i 0))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
538 (while (and cur this
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
539 (ebnf-node-equal (car cur) (car this)))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
540 (setq cur (cdr cur)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
541 this (cdr this)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
542 i (1+ i)))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
543 (nreverse tlis)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
544 (setq isuf (min isuf i))))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
545 (setq head (nreverse head))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
546 (if (or (zerop isuf) (> isuf len))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
547 ;; no suffix at all
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
548 (cons nil lis)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
549 (let* ((n (- (length head) isuf))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
550 ;; get suffix
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
551 (suffix (nthcdr n head))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
552 (tail (and (> n 0)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
553 (progn
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
554 (setcdr (nthcdr (1- n) head) nil)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
555 head)))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
556 before empty-p)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
557 ;; adjust first element
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
558 (if (or (not (eq (ebnf-node-kind (car lis)) 'ebnf-generate-sequence))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
559 (null tail))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
560 (setq lis (cdr lis)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
561 tail lis
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
562 empty-p t)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
563 (if (= (length tail) 1)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
564 (setcar lis (car tail))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
565 (ebnf-node-list (car lis) tail))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
566 (setq tail (cdr lis)))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
567 ;; eliminate suffix from lis based on isuf
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
568 (while tail
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
569 (let ((elt (car tail))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
570 rest)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
571 (if (and (eq (ebnf-node-kind elt) 'ebnf-generate-sequence)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
572 (setq rest (ebnf-node-list elt)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
573 n (- (length rest) isuf))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
574 (> n 0))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
575 (progn
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
576 (if (= n 1)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
577 (setcar tail (car rest))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
578 (setcdr (nthcdr (1- n) rest) nil)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
579 (ebnf-node-list elt rest))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
580 (setq before tail))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
581 (setq empty-p t)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
582 (if before
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
583 (setcdr before (cdr tail))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
584 (setq lis (cdr lis))))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
585 (setq tail (cdr tail))))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
586 (cons suffix (ebnf-unique-list
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
587 (if empty-p
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
588 (nconc lis (list (ebnf-make-empty)))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
589 lis)))))))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
590
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
591
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
592 (defun ebnf-unique-list (nlist)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
593 (let ((current nlist)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
594 before)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
595 (while current
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
596 (let ((tail (cdr current))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
597 (head (car current))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
598 remove-p)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
599 (while tail
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
600 (if (not (ebnf-node-equal head (car tail)))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
601 (setq tail (cdr tail))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
602 (setq remove-p t
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
603 tail nil)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
604 (if before
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
605 (setcdr before (cdr current))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
606 (setq nlist (cdr nlist)))))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
607 (or remove-p
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
608 (setq before current))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
609 (setq current (cdr current))))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
610 nlist))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
611
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
612
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
613 (defun ebnf-node-equal (A B)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
614 (let ((kindA (ebnf-node-kind A))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
615 (kindB (ebnf-node-kind B)))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
616 (and (eq kindA kindB)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
617 (cond
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
618 ;; empty
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
619 ((eq kindA 'ebnf-generate-empty)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
620 t)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
621 ;; non-terminal, terminal, special
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
622 ((memq kindA '(ebnf-generate-non-terminal
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
623 ebnf-generate-terminal
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
624 ebnf-generate-special))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
625 (string= (ebnf-node-name A) (ebnf-node-name B)))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
626 ;; alternative, sequence
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
627 ((memq kindA '(ebnf-generate-alternative ; any order
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
628 ebnf-generate-sequence)) ; order is important
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
629 (let ((listA (ebnf-node-list A))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
630 (listB (ebnf-node-list B)))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
631 (and (= (length listA) (length listB))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
632 (let ((ok t))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
633 (while (and ok listA)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
634 (setq ok (ebnf-node-equal (car listA) (car listB))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
635 listA (cdr listA)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
636 listB (cdr listB)))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
637 ok))))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
638 ;; production
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
639 ((eq kindA 'ebnf-generate-production)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
640 (and (string= (ebnf-node-name A) (ebnf-node-name B))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
641 (ebnf-node-equal (ebnf-node-production A)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
642 (ebnf-node-production B))))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
643 ;; otherwise
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
644 (t
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
645 nil)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
646 ))))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
647
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
648
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
649 (defun ebnf-create-alternative (alt)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
650 (if (> (length alt) 1)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
651 (ebnf-make-alternative alt)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
652 (car alt)))
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
653
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
654
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
655 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
656
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
657
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
658 (provide 'ebnf-otz)
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
659
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
660
f062cc830f07 *** empty log message ***
Gerd Moellmann <gerd@gnu.org>
parents:
diff changeset
661 ;;; ebnf-otz.el ends here