]> code.delx.au - gnu-emacs/blob - test/etags/y-src/parse.c
7b1eedc85db52f311e4c75272b303a0a114ae03a
[gnu-emacs] / test / etags / y-src / parse.c
1 /* A Bison parser, made from parse.y
2 by GNU bison 1.32. */
3
4 #define YYBISON 1 /* Identify Bison output. */
5
6 # define NE 257
7 # define LE 258
8 # define GE 259
9 # define NEG 260
10 # define L_CELL 261
11 # define L_RANGE 262
12 # define L_VAR 263
13 # define L_CONST 264
14 # define L_FN0 265
15 # define L_FN1 266
16 # define L_FN2 267
17 # define L_FN3 268
18 # define L_FN4 269
19 # define L_FNN 270
20 # define L_FN1R 271
21 # define L_FN2R 272
22 # define L_FN3R 273
23 # define L_FN4R 274
24 # define L_FNNR 275
25 # define L_LE 276
26 # define L_NE 277
27 # define L_GE 278
28
29 #line 1 "parse.y"
30
31 /* Copyright (C) 1990, 1992, 1993 Free Software Foundation, Inc.
32
33 This file is part of Oleo, the GNU Spreadsheet.
34
35 Oleo is free software; you can redistribute it and/or modify
36 it under the terms of the GNU General Public License as published by
37 the Free Software Foundation; either version 2, or (at your option)
38 any later version.
39
40 Oleo is distributed in the hope that it will be useful,
41 but WITHOUT ANY WARRANTY; without even the implied warranty of
42 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
43 GNU General Public License for more details.
44
45 You should have received a copy of the GNU General Public License
46 along with Oleo; see the file COPYING. If not, write to
47 the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
48 #line 41 "parse.y"
49
50 #include "funcdef.h"
51
52 #include <ctype.h>
53
54 #define obstack_chunk_alloc ck_malloc
55 #define obstack_chunk_free free
56 #include "obstack.h"
57 #include "sysdef.h"
58
59 #include "global.h"
60 #include "errors.h"
61 #include "node.h"
62 #include "eval.h"
63 #include "ref.h"
64
65 int yylex ();
66 #ifdef __STDC__
67 void yyerror (char *);
68 #else
69 void yyerror ();
70 #endif
71 VOIDSTAR parse_hash;
72 extern VOIDSTAR hash_find();
73
74 /* This table contains a list of the infix single-char functions */
75 unsigned char fnin[] = {
76 SUM, DIFF, DIV, PROD, MOD, /* AND, OR, */ POW, EQUAL, IF, CONCAT, 0
77 };
78
79 #define YYSTYPE _y_y_s_t_y_p_e
80 typedef struct node *YYSTYPE;
81 YYSTYPE parse_return;
82 #ifdef __STDC__
83 YYSTYPE make_list (YYSTYPE, YYSTYPE);
84 #else
85 YYSTYPE make_list ();
86 #endif
87
88 char *instr;
89 int parse_error = 0;
90 extern struct obstack tmp_mem;
91
92 #ifndef YYSTYPE
93 #define YYSTYPE int
94 #endif
95 #ifndef YYDEBUG
96 # define YYDEBUG 0
97 #endif
98
99
100
101 #define YYFINAL 131
102 #define YYFLAG -32768
103 #define YYNTBASE 41
104
105 /* YYTRANSLATE(YYLEX) -- Bison token number corresponding to YYLEX. */
106 #define YYTRANSLATE(x) ((unsigned)(x) <= 278 ? yytranslate[x] : 47)
107
108 /* YYTRANSLATE[YYLEX] -- Bison token number corresponding to YYLEX. */
109 static const char yytranslate[] =
110 {
111 0, 2, 2, 2, 2, 2, 2, 2, 2, 2,
112 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
113 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
114 2, 2, 2, 19, 2, 2, 2, 16, 5, 2,
115 38, 39, 14, 12, 40, 13, 2, 15, 2, 2,
116 2, 2, 2, 2, 2, 2, 2, 2, 4, 2,
117 8, 6, 10, 3, 2, 2, 2, 2, 2, 2,
118 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
119 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
120 2, 2, 2, 2, 17, 2, 2, 2, 2, 2,
121 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
122 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
123 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
124 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
125 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
126 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
127 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
128 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
129 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
130 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
131 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
132 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
133 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
134 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
135 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
136 2, 2, 2, 2, 2, 2, 1, 7, 9, 11,
137 18, 20, 21, 22, 23, 24, 25, 26, 27, 28,
138 29, 30, 31, 32, 33, 34, 35, 36, 37
139 };
140
141 #if YYDEBUG
142 static const short yyprhs[] =
143 {
144 0, 0, 2, 4, 6, 8, 12, 17, 24, 33,
145 44, 49, 54, 59, 66, 73, 82, 91, 100, 109,
146 114, 120, 124, 128, 132, 136, 140, 144, 148, 152,
147 156, 160, 164, 168, 172, 175, 178, 182, 186, 189,
148 191, 195, 197, 199, 201, 205, 207
149 };
150 static const short yyrhs[] =
151 {
152 42, 0, 1, 0, 23, 0, 46, 0, 24, 38,
153 39, 0, 25, 38, 42, 39, 0, 26, 38, 42,
154 40, 42, 39, 0, 27, 38, 42, 40, 42, 40,
155 42, 39, 0, 28, 38, 42, 40, 42, 40, 42,
156 40, 42, 39, 0, 29, 38, 43, 39, 0, 30,
157 38, 21, 39, 0, 30, 38, 22, 39, 0, 31,
158 38, 21, 40, 42, 39, 0, 31, 38, 22, 40,
159 42, 39, 0, 31, 38, 21, 40, 42, 40, 42,
160 39, 0, 31, 38, 22, 40, 42, 40, 42, 39,
161 0, 32, 38, 21, 40, 42, 40, 42, 39, 0,
162 32, 38, 22, 40, 42, 40, 42, 39, 0, 34,
163 38, 45, 39, 0, 42, 3, 42, 4, 42, 0,
164 42, 5, 42, 0, 42, 8, 42, 0, 42, 9,
165 42, 0, 42, 6, 42, 0, 42, 7, 42, 0,
166 42, 10, 42, 0, 42, 11, 42, 0, 42, 12,
167 42, 0, 42, 13, 42, 0, 42, 14, 42, 0,
168 42, 15, 42, 0, 42, 16, 42, 0, 42, 17,
169 42, 0, 13, 42, 0, 19, 42, 0, 38, 42,
170 39, 0, 38, 42, 1, 0, 38, 1, 0, 42,
171 0, 43, 40, 42, 0, 21, 0, 42, 0, 44,
172 0, 45, 40, 44, 0, 20, 0, 22, 0
173 };
174
175 #endif
176
177 #if YYDEBUG
178 /* YYRLINE[YYN] -- source line where rule number YYN was defined. */
179 static const short yyrline[] =
180 {
181 0, 86, 88, 94, 95, 96, 98, 102, 106, 110,
182 114, 118, 121, 125, 129, 135, 142, 150, 154, 159,
183 163, 174, 178, 182, 186, 190, 194, 198, 202, 206,
184 210, 214, 218, 222, 226, 241, 245, 247, 255, 262,
185 264, 268, 269, 272, 274, 278, 280
186 };
187 #endif
188
189
190 #if (YYDEBUG) || defined YYERROR_VERBOSE
191
192 /* YYTNAME[TOKEN_NUM] -- String name of the token TOKEN_NUM. */
193 static const char *const yytname[] =
194 {
195 "$", "error", "$undefined.", "'?'", "':'", "'&'", "'='", "NE", "'<'",
196 "LE", "'>'", "GE", "'+'", "'-'", "'*'", "'/'", "'%'", "'^'", "NEG",
197 "'!'", "L_CELL", "L_RANGE", "L_VAR", "L_CONST", "L_FN0", "L_FN1",
198 "L_FN2", "L_FN3", "L_FN4", "L_FNN", "L_FN1R", "L_FN2R", "L_FN3R",
199 "L_FN4R", "L_FNNR", "L_LE", "L_NE", "L_GE", "'('", "')'", "','", "line",
200 "exp", "exp_list", "range_exp", "range_exp_list", "cell", NULL
201 };
202 #endif
203
204 /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
205 static const short yyr1[] =
206 {
207 0, 41, 41, 42, 42, 42, 42, 42, 42, 42,
208 42, 42, 42, 42, 42, 42, 42, 42, 42, 42,
209 42, 42, 42, 42, 42, 42, 42, 42, 42, 42,
210 42, 42, 42, 42, 42, 42, 42, 42, 42, 43,
211 43, 44, 44, 45, 45, 46, 46
212 };
213
214 /* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
215 static const short yyr2[] =
216 {
217 0, 1, 1, 1, 1, 3, 4, 6, 8, 10,
218 4, 4, 4, 6, 6, 8, 8, 8, 8, 4,
219 5, 3, 3, 3, 3, 3, 3, 3, 3, 3,
220 3, 3, 3, 3, 2, 2, 3, 3, 2, 1,
221 3, 1, 1, 1, 3, 1, 1
222 };
223
224 /* YYDEFACT[S] -- default rule to reduce with in state S when YYTABLE
225 doesn't specify something else to do. Zero means the default is an
226 error. */
227 static const short yydefact[] =
228 {
229 0, 2, 0, 0, 45, 46, 3, 0, 0, 0,
230 0, 0, 0, 0, 0, 0, 0, 0, 1, 4,
231 34, 35, 0, 0, 0, 0, 0, 0, 0, 0,
232 0, 0, 38, 0, 0, 0, 0, 0, 0, 0,
233 0, 0, 0, 0, 0, 0, 0, 0, 5, 0,
234 0, 0, 0, 39, 0, 0, 0, 0, 0, 0,
235 0, 41, 42, 43, 0, 37, 36, 0, 21, 24,
236 25, 22, 23, 26, 27, 28, 29, 30, 31, 32,
237 33, 6, 0, 0, 0, 10, 0, 11, 12, 0,
238 0, 0, 0, 19, 0, 0, 0, 0, 0, 40,
239 0, 0, 0, 0, 44, 20, 7, 0, 0, 13,
240 0, 14, 0, 0, 0, 0, 0, 0, 0, 0,
241 0, 8, 0, 15, 16, 17, 18, 0, 9, 0,
242 0, 0
243 };
244
245 static const short yydefgoto[] =
246 {
247 129, 62, 54, 63, 64, 19
248 };
249
250 static const short yypact[] =
251 {
252 104,-32768, 486, 486,-32768,-32768,-32768, -37, -22, -16,
253 10, 12, 14, 29, 43, 47, 50, 124, 537,-32768,
254 -32768,-32768, 59, 486, 486, 486, 486, 486, 7, 9,
255 11, 464,-32768, 48, 486, 486, 486, 486, 486, 486,
256 486, 486, 486, 486, 486, 486, 486, 486,-32768, 332,
257 173, 209, 224, 537, 54, 60, 61, 64, 66, 69,
258 71,-32768, 537,-32768, 57,-32768,-32768, 522, -2, 193,
259 193, 547, 547, 547, 547, 4, 4, 84, 84, 84,
260 84,-32768, 486, 486, 486,-32768, 486,-32768,-32768, 486,
261 486, 486, 486,-32768, 464, 486, 353, 245, 260, 537,
262 63, 158, 281, 296,-32768, 537,-32768, 486, 486,-32768,
263 486,-32768, 486, 486, 486, 369, 317, 388, 404, 423,
264 439,-32768, 486,-32768,-32768,-32768,-32768, 458,-32768, 115,
265 116,-32768
266 };
267
268 static const short yypgoto[] =
269 {
270 -32768, 0,-32768, 24,-32768,-32768
271 };
272
273
274 #define YYLAST 564
275
276
277 static const short yytable[] =
278 {
279 18, 22, 20, 21, 36, 37, 38, 39, 40, 41,
280 42, 43, 44, 45, 46, 47, 23, 33, 44, 45,
281 46, 47, 24, 49, 50, 51, 52, 53, 55, 56,
282 57, 58, 59, 60, 67, 68, 69, 70, 71, 72,
283 73, 74, 75, 76, 77, 78, 79, 80, 25, 65,
284 26, 34, 27, 35, 36, 37, 38, 39, 40, 41,
285 42, 43, 44, 45, 46, 47, 34, 28, 35, 36,
286 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
287 47, 29, 96, 97, 98, 30, 99, 66, 31, 100,
288 101, 102, 103, 85, 86, 105, 93, 94, 48, 87,
289 88, 47, 109, 110, 89, 1, 90, 115, 116, 91,
290 117, 92, 118, 119, 120, 130, 131, 2, 104, 0,
291 0, 0, 127, 3, 4, 32, 5, 6, 7, 8,
292 9, 10, 11, 12, 13, 14, 15, 2, 16, 0,
293 0, 0, 17, 3, 4, 0, 5, 6, 7, 8,
294 9, 10, 11, 12, 13, 14, 15, 0, 16, 0,
295 0, 34, 17, 35, 36, 37, 38, 39, 40, 41,
296 42, 43, 44, 45, 46, 47, 34, 0, 35, 36,
297 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
298 47, 0, 0, 0, 0, 0, 0, 111, 112,-32768,
299 -32768, 38, 39, 40, 41, 42, 43, 44, 45, 46,
300 47, 0, 34, 82, 35, 36, 37, 38, 39, 40,
301 41, 42, 43, 44, 45, 46, 47, 34, 0, 35,
302 36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
303 46, 47, 0, 0, 0, 0, 0, 0, 34, 83,
304 35, 36, 37, 38, 39, 40, 41, 42, 43, 44,
305 45, 46, 47, 34, 84, 35, 36, 37, 38, 39,
306 40, 41, 42, 43, 44, 45, 46, 47, 0, 0,
307 0, 0, 0, 0, 34, 107, 35, 36, 37, 38,
308 39, 40, 41, 42, 43, 44, 45, 46, 47, 34,
309 108, 35, 36, 37, 38, 39, 40, 41, 42, 43,
310 44, 45, 46, 47, 0, 0, 0, 0, 0, 0,
311 34, 113, 35, 36, 37, 38, 39, 40, 41, 42,
312 43, 44, 45, 46, 47, 34, 114, 35, 36, 37,
313 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
314 0, 0, 0, 0, 0, 0, 34, 122, 35, 36,
315 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
316 47, 81, 34, 0, 35, 36, 37, 38, 39, 40,
317 41, 42, 43, 44, 45, 46, 47, 0, 0, 0,
318 0, 34, 106, 35, 36, 37, 38, 39, 40, 41,
319 42, 43, 44, 45, 46, 47, 0, 34, 121, 35,
320 36, 37, 38, 39, 40, 41, 42, 43, 44, 45,
321 46, 47, 0, 0, 0, 0, 34, 123, 35, 36,
322 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
323 47, 0, 34, 124, 35, 36, 37, 38, 39, 40,
324 41, 42, 43, 44, 45, 46, 47, 0, 0, 0,
325 0, 34, 125, 35, 36, 37, 38, 39, 40, 41,
326 42, 43, 44, 45, 46, 47, 0, 2, 126, 0,
327 0, 0, 0, 3, 4, 61, 5, 6, 7, 8,
328 9, 10, 11, 12, 13, 14, 15, 128, 16, 2,
329 0, 0, 17, 0, 0, 3, 4, 0, 5, 6,
330 7, 8, 9, 10, 11, 12, 13, 14, 15, 0,
331 16, 0, 0, 0, 17, 34, 95, 35, 36, 37,
332 38, 39, 40, 41, 42, 43, 44, 45, 46, 47,
333 34, 0, 35, 36, 37, 38, 39, 40, 41, 42,
334 43, 44, 45, 46, 47,-32768,-32768,-32768,-32768, 42,
335 43, 44, 45, 46, 47
336 };
337
338 static const short yycheck[] =
339 {
340 0, 38, 2, 3, 6, 7, 8, 9, 10, 11,
341 12, 13, 14, 15, 16, 17, 38, 17, 14, 15,
342 16, 17, 38, 23, 24, 25, 26, 27, 21, 22,
343 21, 22, 21, 22, 34, 35, 36, 37, 38, 39,
344 40, 41, 42, 43, 44, 45, 46, 47, 38, 1,
345 38, 3, 38, 5, 6, 7, 8, 9, 10, 11,
346 12, 13, 14, 15, 16, 17, 3, 38, 5, 6,
347 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
348 17, 38, 82, 83, 84, 38, 86, 39, 38, 89,
349 90, 91, 92, 39, 40, 95, 39, 40, 39, 39,
350 39, 17, 39, 40, 40, 1, 40, 107, 108, 40,
351 110, 40, 112, 113, 114, 0, 0, 13, 94, -1,
352 -1, -1, 122, 19, 20, 1, 22, 23, 24, 25,
353 26, 27, 28, 29, 30, 31, 32, 13, 34, -1,
354 -1, -1, 38, 19, 20, -1, 22, 23, 24, 25,
355 26, 27, 28, 29, 30, 31, 32, -1, 34, -1,
356 -1, 3, 38, 5, 6, 7, 8, 9, 10, 11,
357 12, 13, 14, 15, 16, 17, 3, -1, 5, 6,
358 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
359 17, -1, -1, -1, -1, -1, -1, 39, 40, 6,
360 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
361 17, -1, 3, 40, 5, 6, 7, 8, 9, 10,
362 11, 12, 13, 14, 15, 16, 17, 3, -1, 5,
363 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
364 16, 17, -1, -1, -1, -1, -1, -1, 3, 40,
365 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
366 15, 16, 17, 3, 40, 5, 6, 7, 8, 9,
367 10, 11, 12, 13, 14, 15, 16, 17, -1, -1,
368 -1, -1, -1, -1, 3, 40, 5, 6, 7, 8,
369 9, 10, 11, 12, 13, 14, 15, 16, 17, 3,
370 40, 5, 6, 7, 8, 9, 10, 11, 12, 13,
371 14, 15, 16, 17, -1, -1, -1, -1, -1, -1,
372 3, 40, 5, 6, 7, 8, 9, 10, 11, 12,
373 13, 14, 15, 16, 17, 3, 40, 5, 6, 7,
374 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
375 -1, -1, -1, -1, -1, -1, 3, 40, 5, 6,
376 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
377 17, 39, 3, -1, 5, 6, 7, 8, 9, 10,
378 11, 12, 13, 14, 15, 16, 17, -1, -1, -1,
379 -1, 3, 39, 5, 6, 7, 8, 9, 10, 11,
380 12, 13, 14, 15, 16, 17, -1, 3, 39, 5,
381 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
382 16, 17, -1, -1, -1, -1, 3, 39, 5, 6,
383 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
384 17, -1, 3, 39, 5, 6, 7, 8, 9, 10,
385 11, 12, 13, 14, 15, 16, 17, -1, -1, -1,
386 -1, 3, 39, 5, 6, 7, 8, 9, 10, 11,
387 12, 13, 14, 15, 16, 17, -1, 13, 39, -1,
388 -1, -1, -1, 19, 20, 21, 22, 23, 24, 25,
389 26, 27, 28, 29, 30, 31, 32, 39, 34, 13,
390 -1, -1, 38, -1, -1, 19, 20, -1, 22, 23,
391 24, 25, 26, 27, 28, 29, 30, 31, 32, -1,
392 34, -1, -1, -1, 38, 3, 4, 5, 6, 7,
393 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
394 3, -1, 5, 6, 7, 8, 9, 10, 11, 12,
395 13, 14, 15, 16, 17, 8, 9, 10, 11, 12,
396 13, 14, 15, 16, 17
397 };
398 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
399 #line 3 "/usr/share/bison/bison.simple"
400
401 /* Skeleton output parser for bison,
402 Copyright (C) 1984, 1989, 1990, 2000, 2001 Free Software Foundation, Inc.
403
404 This program is free software; you can redistribute it and/or modify
405 it under the terms of the GNU General Public License as published by
406 the Free Software Foundation; either version 2, or (at your option)
407 any later version.
408
409 This program is distributed in the hope that it will be useful,
410 but WITHOUT ANY WARRANTY; without even the implied warranty of
411 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
412 GNU General Public License for more details.
413
414 You should have received a copy of the GNU General Public License
415 along with this program; if not, write to the Free Software
416 Foundation, Inc., 59 Temple Place - Suite 330,
417 Boston, MA 02111-1307, USA. */
418
419 /* As a special exception, when this file is copied by Bison into a
420 Bison output file, you may use that output file without restriction.
421 This special exception was added by the Free Software Foundation
422 in version 1.24 of Bison. */
423
424 /* This is the parser code that is written into each bison parser when
425 the %semantic_parser declaration is not specified in the grammar.
426 It was written by Richard Stallman by simplifying the hairy parser
427 used when %semantic_parser is specified. */
428
429 /* All symbols defined below should begin with yy or YY, to avoid
430 infringing on user name space. This should be done even for local
431 variables, as they might otherwise be expanded by user macros.
432 There are some unavoidable exceptions within include files to
433 define necessary library symbols; they are noted "INFRINGES ON
434 USER NAME SPACE" below. */
435
436 #ifdef __cplusplus
437 # define YYSTD(x) std::x
438 #else
439 # define YYSTD(x) x
440 #endif
441
442 #if ! defined (yyoverflow) || defined (YYERROR_VERBOSE)
443
444 /* The parser invokes alloca or malloc; define the necessary symbols. */
445
446 # if YYSTACK_USE_ALLOCA
447 # define YYSTACK_ALLOC alloca
448 # define YYSIZE_T YYSTD (size_t)
449 # else
450 # ifndef YYSTACK_USE_ALLOCA
451 # if defined (alloca) || defined (_ALLOCA_H)
452 # define YYSTACK_ALLOC alloca
453 # define YYSIZE_T YYSTD (size_t)
454 # else
455 # ifdef __GNUC__
456 # define YYSTACK_ALLOC __builtin_alloca
457 # endif
458 # endif
459 # endif
460 # endif
461
462 # ifdef YYSTACK_ALLOC
463 /* Pacify GCC's `empty if-body' warning. */
464 # define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
465 # else
466 # ifdef __cplusplus
467 # include <cstdlib> /* INFRINGES ON USER NAME SPACE */
468 # define YYSIZE_T std::size_t
469 # else
470 # ifdef __STDC__
471 # include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
472 # define YYSIZE_T size_t
473 # endif
474 # endif
475 # define YYSTACK_ALLOC YYSTD (malloc)
476 # define YYSTACK_FREE YYSTD (free)
477 # endif
478
479 /* A type that is properly aligned for any stack member. */
480 union yyalloc
481 {
482 short yyss;
483 YYSTYPE yyvs;
484 # if YYLSP_NEEDED
485 YYLTYPE yyls;
486 # endif
487 };
488
489 /* The size of the maximum gap between one aligned stack and the next. */
490 # define YYSTACK_GAP_MAX (sizeof (union yyalloc) - 1)
491
492 /* The size of an array large to enough to hold all stacks, each with
493 N elements. */
494 # if YYLSP_NEEDED
495 # define YYSTACK_BYTES(N) \
496 ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
497 + 2 * YYSTACK_GAP_MAX)
498 # else
499 # define YYSTACK_BYTES(N) \
500 ((N) * (sizeof (short) + sizeof (YYSTYPE)) \
501 + YYSTACK_GAP_MAX)
502 # endif
503
504 /* Relocate the TYPE STACK from its old location to the new one. The
505 local variables YYSIZE and YYSTACKSIZE give the old and new number of
506 elements in the stack, and YYPTR gives the new location of the
507 stack. Advance YYPTR to a properly aligned location for the next
508 stack. */
509 # define YYSTACK_RELOCATE(Type, Stack) \
510 do \
511 { \
512 YYSIZE_T yynewbytes; \
513 yymemcpy ((char *) yyptr, (char *) (Stack), \
514 yysize * (YYSIZE_T) sizeof (Type)); \
515 Stack = &yyptr->Stack; \
516 yynewbytes = yystacksize * sizeof (Type) + YYSTACK_GAP_MAX; \
517 yyptr += yynewbytes / sizeof (*yyptr); \
518 } \
519 while (0)
520
521 #endif /* ! defined (yyoverflow) || defined (YYERROR_VERBOSE) */
522
523
524 #if ! defined (YYSIZE_T) && defined (__SIZE_TYPE__)
525 # define YYSIZE_T __SIZE_TYPE__
526 #endif
527 #if ! defined (YYSIZE_T) && defined (size_t)
528 # define YYSIZE_T size_t
529 #endif
530 #if ! defined (YYSIZE_T)
531 # ifdef __cplusplus
532 # include <cstddef> /* INFRINGES ON USER NAME SPACE */
533 # define YYSIZE_T std::size_t
534 # else
535 # ifdef __STDC__
536 # include <stddef.h> /* INFRINGES ON USER NAME SPACE */
537 # define YYSIZE_T size_t
538 # endif
539 # endif
540 #endif
541 #if ! defined (YYSIZE_T)
542 # define YYSIZE_T unsigned int
543 #endif
544
545 #define yyerrok (yyerrstatus = 0)
546 #define yyclearin (yychar = YYEMPTY)
547 #define YYEMPTY -2
548 #define YYEOF 0
549 #define YYACCEPT goto yyacceptlab
550 #define YYABORT goto yyabortlab
551 #define YYERROR goto yyerrlab1
552 /* Like YYERROR except do call yyerror. This remains here temporarily
553 to ease the transition to the new meaning of YYERROR, for GCC.
554 Once GCC version 2 has supplanted version 1, this can go. */
555 #define YYFAIL goto yyerrlab
556 #define YYRECOVERING() (!!yyerrstatus)
557 #define YYBACKUP(Token, Value) \
558 do \
559 if (yychar == YYEMPTY && yylen == 1) \
560 { \
561 yychar = (Token); \
562 yylval = (Value); \
563 yychar1 = YYTRANSLATE (yychar); \
564 YYPOPSTACK; \
565 goto yybackup; \
566 } \
567 else \
568 { \
569 yyerror ("syntax error: cannot back up"); \
570 YYERROR; \
571 } \
572 while (0)
573
574 #define YYTERROR 1
575 #define YYERRCODE 256
576
577
578 /* YYLLOC_DEFAULT -- Compute the default location (before the actions
579 are run).
580
581 When YYLLOC_DEFAULT is run, CURRENT is set the location of the
582 first token. By default, to implement support for ranges, extend
583 its range to the last symbol. */
584
585 #ifndef YYLLOC_DEFAULT
586 # define YYLLOC_DEFAULT(Current, Rhs, N) \
587 Current.last_line = Rhs[N].last_line; \
588 Current.last_column = Rhs[N].last_column;
589 #endif
590
591
592 /* YYLEX -- calling `yylex' with the right arguments. */
593
594 #if YYPURE
595 # if YYLSP_NEEDED
596 # ifdef YYLEX_PARAM
597 # define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
598 # else
599 # define YYLEX yylex (&yylval, &yylloc)
600 # endif
601 # else /* !YYLSP_NEEDED */
602 # ifdef YYLEX_PARAM
603 # define YYLEX yylex (&yylval, YYLEX_PARAM)
604 # else
605 # define YYLEX yylex (&yylval)
606 # endif
607 # endif /* !YYLSP_NEEDED */
608 #else /* !YYPURE */
609 # define YYLEX yylex ()
610 #endif /* !YYPURE */
611
612
613 /* Enable debugging if requested. */
614 #if YYDEBUG
615
616 # ifndef YYFPRINTF
617 # ifdef __cplusplus
618 # include <cstdio> /* INFRINGES ON USER NAME SPACE */
619 # else
620 # include <stdio.h> /* INFRINGES ON USER NAME SPACE */
621 # endif
622 # define YYFPRINTF YYSTD (fprintf)
623 # endif
624
625 # define YYDPRINTF(Args) \
626 do { \
627 if (yydebug) \
628 YYFPRINTF Args; \
629 } while (0)
630 /* Nonzero means print parse trace. [The following comment makes no
631 sense to me. Could someone clarify it? --akim] Since this is
632 uninitialized, it does not stop multiple parsers from coexisting.
633 */
634 int yydebug;
635 #else /* !YYDEBUG */
636 # define YYDPRINTF(Args)
637 #endif /* !YYDEBUG */
638
639 /* YYINITDEPTH -- initial size of the parser's stacks. */
640 #ifndef YYINITDEPTH
641 # define YYINITDEPTH 200
642 #endif
643
644 /* YYMAXDEPTH -- maximum size the stacks can grow to (effective only
645 if the built-in stack extension method is used).
646
647 Do not make this value too large; the results are undefined if
648 SIZE_MAX < YYSTACK_BYTES (YYMAXDEPTH)
649 evaluated with infinite-precision integer arithmetic. */
650
651 #if YYMAXDEPTH == 0
652 # undef YYMAXDEPTH
653 #endif
654
655 #ifndef YYMAXDEPTH
656 # define YYMAXDEPTH 10000
657 #endif
658 \f
659 #if ! defined (yyoverflow) && ! defined (yymemcpy)
660 # if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
661 # define yymemcpy __builtin_memcpy
662 # else /* not GNU C or C++ */
663
664 /* This is the most reliable way to avoid incompatibilities
665 in available built-in functions on various systems. */
666 static void
667 # if defined (__STDC__) || defined (__cplusplus)
668 yymemcpy (char *yyto, const char *yyfrom, YYSIZE_T yycount)
669 # else
670 yymemcpy (yyto, yyfrom, yycount)
671 char *yyto;
672 const char *yyfrom;
673 YYSIZE_T yycount;
674 # endif
675 {
676 register const char *yyf = yyfrom;
677 register char *yyt = yyto;
678 register YYSIZE_T yyi = yycount;
679
680 while (yyi-- != 0)
681 *yyt++ = *yyf++;
682 }
683 # endif
684 #endif
685
686 #ifdef YYERROR_VERBOSE
687
688 # ifndef yystrlen
689 # if defined (__GLIBC__) && defined (_STRING_H)
690 # define yystrlen strlen
691 # else
692 /* Return the length of YYSTR. */
693 static YYSIZE_T
694 # if defined (__STDC__) || defined (__cplusplus)
695 yystrlen (const char *yystr)
696 # else
697 yystrlen (yystr)
698 const char *yystr;
699 # endif
700 {
701 register const char *yys = yystr;
702
703 while (*yys++ != '\0')
704 continue;
705
706 return yys - yystr - 1;
707 }
708 # endif
709 # endif
710
711 # ifndef yystpcpy
712 # if defined (__GLIBC__) && defined (_STRING_H) && defined (_GNU_SOURCE)
713 # define yystpcpy stpcpy
714 # else
715 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
716 YYDEST. */
717 static char *
718 # if defined (__STDC__) || defined (__cplusplus)
719 yystpcpy (char *yydest, const char *yysrc)
720 # else
721 yystpcpy (yydest, yysrc)
722 char *yydest;
723 const char *yysrc;
724 # endif
725 {
726 register char *yyd = yydest;
727 register const char *yys = yysrc;
728
729 while ((*yyd++ = *yys++) != '\0')
730 continue;
731
732 return yyd - 1;
733 }
734 # endif
735 # endif
736 #endif
737 \f
738 #line 341 "/usr/share/bison/bison.simple"
739
740
741 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
742 into yyparse. The argument should have type void *.
743 It should actually point to an object.
744 Grammar actions can access the variable by casting it
745 to the proper pointer type. */
746
747 #ifdef YYPARSE_PARAM
748 # ifdef __cplusplus
749 # define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
750 # define YYPARSE_PARAM_DECL
751 # else /* !__cplusplus */
752 # define YYPARSE_PARAM_ARG YYPARSE_PARAM
753 # define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
754 # endif /* !__cplusplus */
755 #else /* !YYPARSE_PARAM */
756 # define YYPARSE_PARAM_ARG
757 # define YYPARSE_PARAM_DECL
758 #endif /* !YYPARSE_PARAM */
759
760 /* Prevent warning if -Wstrict-prototypes. */
761 #ifdef __GNUC__
762 # ifdef YYPARSE_PARAM
763 int yyparse (void *);
764 # else
765 int yyparse (void);
766 # endif
767 #endif
768
769 /* YY_DECL_VARIABLES -- depending whether we use a pure parser,
770 variables are global, or local to YYPARSE. */
771
772 #define YY_DECL_NON_LSP_VARIABLES \
773 /* The lookahead symbol. */ \
774 int yychar; \
775 \
776 /* The semantic value of the lookahead symbol. */ \
777 YYSTYPE yylval; \
778 \
779 /* Number of parse errors so far. */ \
780 int yynerrs;
781
782 #if YYLSP_NEEDED
783 # define YY_DECL_VARIABLES \
784 YY_DECL_NON_LSP_VARIABLES \
785 \
786 /* Location data for the lookahead symbol. */ \
787 YYLTYPE yylloc;
788 #else
789 # define YY_DECL_VARIABLES \
790 YY_DECL_NON_LSP_VARIABLES
791 #endif
792
793
794 /* If nonreentrant, generate the variables here. */
795
796 #if !YYPURE
797 YY_DECL_VARIABLES
798 #endif /* !YYPURE */
799
800 int
801 yyparse (YYPARSE_PARAM_ARG)
802 YYPARSE_PARAM_DECL
803 {
804 /* If reentrant, generate the variables here. */
805 #if YYPURE
806 YY_DECL_VARIABLES
807 #endif /* !YYPURE */
808
809 register int yystate;
810 register int yyn;
811 int yyresult;
812 /* Number of tokens to shift before error messages enabled. */
813 int yyerrstatus;
814 /* Lookahead token as an internal (translated) token number. */
815 int yychar1 = 0;
816
817 /* Three stacks and their tools:
818 `yyss': related to states,
819 `yyvs': related to semantic values,
820 `yyls': related to locations.
821
822 Refer to the stacks thru separate pointers, to allow yyoverflow
823 to reallocate them elsewhere. */
824
825 /* The state stack. */
826 short yyssa[YYINITDEPTH];
827 short *yyss = yyssa;
828 register short *yyssp;
829
830 /* The semantic value stack. */
831 YYSTYPE yyvsa[YYINITDEPTH];
832 YYSTYPE *yyvs = yyvsa;
833 register YYSTYPE *yyvsp;
834
835 #if YYLSP_NEEDED
836 /* The location stack. */
837 YYLTYPE yylsa[YYINITDEPTH];
838 YYLTYPE *yyls = yylsa;
839 YYLTYPE *yylsp;
840 #endif
841
842 #if YYLSP_NEEDED
843 # define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
844 #else
845 # define YYPOPSTACK (yyvsp--, yyssp--)
846 #endif
847
848 YYSIZE_T yystacksize = YYINITDEPTH;
849
850
851 /* The variables used to return semantic value and location from the
852 action routines. */
853 YYSTYPE yyval;
854 #if YYLSP_NEEDED
855 YYLTYPE yyloc;
856 #endif
857
858 /* When reducing, the number of symbols on the RHS of the reduced
859 rule. */
860 int yylen;
861
862 YYDPRINTF ((stderr, "Starting parse\n"));
863
864 yystate = 0;
865 yyerrstatus = 0;
866 yynerrs = 0;
867 yychar = YYEMPTY; /* Cause a token to be read. */
868
869 /* Initialize stack pointers.
870 Waste one element of value and location stack
871 so that they stay on the same level as the state stack.
872 The wasted elements are never initialized. */
873
874 yyssp = yyss;
875 yyvsp = yyvs;
876 #if YYLSP_NEEDED
877 yylsp = yyls;
878 #endif
879 goto yysetstate;
880
881 /*------------------------------------------------------------.
882 | yynewstate -- Push a new state, which is found in yystate. |
883 `------------------------------------------------------------*/
884 yynewstate:
885 /* In all cases, when you get here, the value and location stacks
886 have just been pushed. so pushing a state here evens the stacks.
887 */
888 yyssp++;
889
890 yysetstate:
891 *yyssp = yystate;
892
893 if (yyssp >= yyss + yystacksize - 1)
894 {
895 /* Get the current used size of the three stacks, in elements. */
896 YYSIZE_T yysize = yyssp - yyss + 1;
897
898 #ifdef yyoverflow
899 {
900 /* Give user a chance to reallocate the stack. Use copies of
901 these so that the &'s don't force the real ones into
902 memory. */
903 YYSTYPE *yyvs1 = yyvs;
904 short *yyss1 = yyss;
905
906 /* Each stack pointer address is followed by the size of the
907 data in use in that stack, in bytes. */
908 # if YYLSP_NEEDED
909 YYLTYPE *yyls1 = yyls;
910 /* This used to be a conditional around just the two extra args,
911 but that might be undefined if yyoverflow is a macro. */
912 yyoverflow ("parser stack overflow",
913 &yyss1, yysize * sizeof (*yyssp),
914 &yyvs1, yysize * sizeof (*yyvsp),
915 &yyls1, yysize * sizeof (*yylsp),
916 &yystacksize);
917 yyls = yyls1;
918 # else
919 yyoverflow ("parser stack overflow",
920 &yyss1, yysize * sizeof (*yyssp),
921 &yyvs1, yysize * sizeof (*yyvsp),
922 &yystacksize);
923 # endif
924 yyss = yyss1;
925 yyvs = yyvs1;
926 }
927 #else /* no yyoverflow */
928 /* Extend the stack our own way. */
929 if (yystacksize >= YYMAXDEPTH)
930 goto yyoverflowlab;
931 yystacksize *= 2;
932 if (yystacksize > YYMAXDEPTH)
933 yystacksize = YYMAXDEPTH;
934
935 {
936 short *yyss1 = yyss;
937 union yyalloc *yyptr =
938 (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
939 if (! yyptr)
940 goto yyoverflowlab;
941 YYSTACK_RELOCATE (short, yyss);
942 YYSTACK_RELOCATE (YYSTYPE, yyvs);
943 # if YYLSP_NEEDED
944 YYSTACK_RELOCATE (YYLTYPE, yyls);
945 # endif
946 # undef YYSTACK_RELOCATE
947 if (yyss1 != yyssa)
948 YYSTACK_FREE (yyss1);
949 }
950 #endif /* no yyoverflow */
951
952 yyssp = yyss + yysize - 1;
953 yyvsp = yyvs + yysize - 1;
954 #if YYLSP_NEEDED
955 yylsp = yyls + yysize - 1;
956 #endif
957
958 YYDPRINTF ((stderr, "Stack size increased to %lu\n",
959 (unsigned long int) yystacksize));
960
961 if (yyssp >= yyss + yystacksize - 1)
962 YYABORT;
963 }
964
965 YYDPRINTF ((stderr, "Entering state %d\n", yystate));
966
967 goto yybackup;
968
969
970 /*-----------.
971 | yybackup. |
972 `-----------*/
973 yybackup:
974
975 /* Do appropriate processing given the current state. */
976 /* Read a lookahead token if we need one and don't already have one. */
977 /* yyresume: */
978
979 /* First try to decide what to do without reference to lookahead token. */
980
981 yyn = yypact[yystate];
982 if (yyn == YYFLAG)
983 goto yydefault;
984
985 /* Not known => get a lookahead token if don't already have one. */
986
987 /* yychar is either YYEMPTY or YYEOF
988 or a valid token in external form. */
989
990 if (yychar == YYEMPTY)
991 {
992 YYDPRINTF ((stderr, "Reading a token: "));
993 yychar = YYLEX;
994 }
995
996 /* Convert token to internal form (in yychar1) for indexing tables with */
997
998 if (yychar <= 0) /* This means end of input. */
999 {
1000 yychar1 = 0;
1001 yychar = YYEOF; /* Don't call YYLEX any more */
1002
1003 YYDPRINTF ((stderr, "Now at end of input.\n"));
1004 }
1005 else
1006 {
1007 yychar1 = YYTRANSLATE (yychar);
1008
1009 #if YYDEBUG
1010 /* We have to keep this `#if YYDEBUG', since we use variables
1011 which are defined only if `YYDEBUG' is set. */
1012 if (yydebug)
1013 {
1014 YYFPRINTF (stderr, "Next token is %d (%s",
1015 yychar, yytname[yychar1]);
1016 /* Give the individual parser a way to print the precise
1017 meaning of a token, for further debugging info. */
1018 # ifdef YYPRINT
1019 YYPRINT (stderr, yychar, yylval);
1020 # endif
1021 YYFPRINTF (stderr, ")\n");
1022 }
1023 #endif
1024 }
1025
1026 yyn += yychar1;
1027 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
1028 goto yydefault;
1029
1030 yyn = yytable[yyn];
1031
1032 /* yyn is what to do for this token type in this state.
1033 Negative => reduce, -yyn is rule number.
1034 Positive => shift, yyn is new state.
1035 New state is final state => don't bother to shift,
1036 just return success.
1037 0, or most negative number => error. */
1038
1039 if (yyn < 0)
1040 {
1041 if (yyn == YYFLAG)
1042 goto yyerrlab;
1043 yyn = -yyn;
1044 goto yyreduce;
1045 }
1046 else if (yyn == 0)
1047 goto yyerrlab;
1048
1049 if (yyn == YYFINAL)
1050 YYACCEPT;
1051
1052 /* Shift the lookahead token. */
1053 YYDPRINTF ((stderr, "Shifting token %d (%s), ",
1054 yychar, yytname[yychar1]));
1055
1056 /* Discard the token being shifted unless it is eof. */
1057 if (yychar != YYEOF)
1058 yychar = YYEMPTY;
1059
1060 *++yyvsp = yylval;
1061 #if YYLSP_NEEDED
1062 *++yylsp = yylloc;
1063 #endif
1064
1065 /* Count tokens shifted since error; after three, turn off error
1066 status. */
1067 if (yyerrstatus)
1068 yyerrstatus--;
1069
1070 yystate = yyn;
1071 goto yynewstate;
1072
1073
1074 /*-----------------------------------------------------------.
1075 | yydefault -- do the default action for the current state. |
1076 `-----------------------------------------------------------*/
1077 yydefault:
1078 yyn = yydefact[yystate];
1079 if (yyn == 0)
1080 goto yyerrlab;
1081 goto yyreduce;
1082
1083
1084 /*-----------------------------.
1085 | yyreduce -- Do a reduction. |
1086 `-----------------------------*/
1087 yyreduce:
1088 /* yyn is the number of a rule to reduce with. */
1089 yylen = yyr2[yyn];
1090
1091 /* If YYLEN is nonzero, implement the default value of the action:
1092 `$$ = $1'.
1093
1094 Otherwise, the following line sets YYVAL to the semantic value of
1095 the lookahead token. This behavior is undocumented and Bison
1096 users should not rely upon it. Assigning to YYVAL
1097 unconditionally makes the parser a bit smaller, and it avoids a
1098 GCC warning that YYVAL may be used uninitialized. */
1099 yyval = yyvsp[1-yylen];
1100
1101 #if YYLSP_NEEDED
1102 /* Similarly for the default location. Let the user run additional
1103 commands if for instance locations are ranges. */
1104 yyloc = yylsp[1-yylen];
1105 YYLLOC_DEFAULT (yyloc, (yylsp - yylen), yylen);
1106 #endif
1107
1108 #if YYDEBUG
1109 /* We have to keep this `#if YYDEBUG', since we use variables which
1110 are defined only if `YYDEBUG' is set. */
1111 if (yydebug)
1112 {
1113 int yyi;
1114
1115 YYFPRINTF (stderr, "Reducing via rule %d (line %d), ",
1116 yyn, yyrline[yyn]);
1117
1118 /* Print the symbols being reduced, and their result. */
1119 for (yyi = yyprhs[yyn]; yyrhs[yyi] > 0; yyi++)
1120 YYFPRINTF (stderr, "%s ", yytname[yyrhs[yyi]]);
1121 YYFPRINTF (stderr, " -> %s\n", yytname[yyr1[yyn]]);
1122 }
1123 #endif
1124
1125 switch (yyn) {
1126
1127 case 1:
1128 #line 87 "parse.y"
1129 { parse_return=yyvsp[0]; }
1130 break;
1131 case 2:
1132 #line 88 "parse.y"
1133 {
1134 if(!parse_error)
1135 parse_error=PARSE_ERR;
1136 parse_return=0; }
1137 break;
1138 case 5:
1139 #line 96 "parse.y"
1140 {
1141 yyval=yyvsp[-2]; }
1142 break;
1143 case 6:
1144 #line 98 "parse.y"
1145 {
1146 (yyvsp[-3])->n_x.v_subs[0]=yyvsp[-1];
1147 (yyvsp[-3])->n_x.v_subs[1]=(struct node *)0;
1148 yyval=yyvsp[-3]; }
1149 break;
1150 case 7:
1151 #line 102 "parse.y"
1152 {
1153 (yyvsp[-5])->n_x.v_subs[0]=yyvsp[-3];
1154 (yyvsp[-5])->n_x.v_subs[1]=yyvsp[-1];
1155 yyval=yyvsp[-5]; }
1156 break;
1157 case 8:
1158 #line 106 "parse.y"
1159 {
1160 (yyvsp[-7])->n_x.v_subs[0]=make_list(yyvsp[-5],yyvsp[-3]);
1161 (yyvsp[-7])->n_x.v_subs[1]=yyvsp[-1];
1162 yyval=yyvsp[-7];}
1163 break;
1164 case 9:
1165 #line 110 "parse.y"
1166 {
1167 (yyvsp[-9])->n_x.v_subs[0]=make_list(yyvsp[-7],yyvsp[-5]);
1168 (yyvsp[-9])->n_x.v_subs[1]=make_list(yyvsp[-3],yyvsp[-1]);
1169 yyval=yyvsp[-9];}
1170 break;
1171 case 10:
1172 #line 114 "parse.y"
1173 {
1174 (yyvsp[-3])->n_x.v_subs[0]=(struct node *)0;
1175 (yyvsp[-3])->n_x.v_subs[1]=yyvsp[-1];
1176 yyval=yyvsp[-3]; }
1177 break;
1178 case 11:
1179 #line 118 "parse.y"
1180 {
1181 yyvsp[-3]->n_x.v_subs[0]=yyvsp[-1];
1182 yyval=yyvsp[-3]; }
1183 break;
1184 case 12:
1185 #line 121 "parse.y"
1186 {
1187 yyvsp[-3]->n_x.v_subs[0]=yyvsp[-1];
1188 yyval=yyvsp[-3]; }
1189 break;
1190 case 13:
1191 #line 125 "parse.y"
1192 {
1193 yyvsp[-5]->n_x.v_subs[0]=yyvsp[-3];
1194 yyvsp[-5]->n_x.v_subs[1]=yyvsp[-1];
1195 yyval=yyvsp[-5]; }
1196 break;
1197 case 14:
1198 #line 129 "parse.y"
1199 {
1200 yyvsp[-5]->n_x.v_subs[0]=yyvsp[-3];
1201 yyvsp[-5]->n_x.v_subs[1]=yyvsp[-1];
1202 yyval=yyvsp[-5]; }
1203 break;
1204 case 15:
1205 #line 135 "parse.y"
1206 {
1207 if(yyvsp[-7]->comp_value!=F_INDEX)
1208 parse_error=PARSE_ERR;
1209 yyvsp[-7]->comp_value=F_INDEX2;
1210 yyvsp[-7]->n_x.v_subs[0]=make_list(yyvsp[-5],yyvsp[-3]);
1211 yyvsp[-7]->n_x.v_subs[1]=yyvsp[-1];
1212 yyval=yyvsp[-7]; }
1213 break;
1214 case 16:
1215 #line 142 "parse.y"
1216 {
1217 if(yyvsp[-7]->comp_value!=F_INDEX)
1218 parse_error=PARSE_ERR;
1219 yyvsp[-7]->comp_value=F_INDEX2;
1220 yyvsp[-7]->n_x.v_subs[0]=make_list(yyvsp[-5],yyvsp[-3]);
1221 yyvsp[-7]->n_x.v_subs[1]=yyvsp[-1];
1222 yyval=yyvsp[-7]; }
1223 break;
1224 case 17:
1225 #line 150 "parse.y"
1226 {
1227 (yyvsp[-7])->n_x.v_subs[0]=make_list(yyvsp[-5],yyvsp[-3]);
1228 (yyvsp[-7])->n_x.v_subs[1]=yyvsp[-1];
1229 yyval=yyvsp[-7];}
1230 break;
1231 case 18:
1232 #line 154 "parse.y"
1233 {
1234 (yyvsp[-7])->n_x.v_subs[0]=make_list(yyvsp[-5],yyvsp[-3]);
1235 (yyvsp[-7])->n_x.v_subs[1]=yyvsp[-1];
1236 yyval=yyvsp[-7];}
1237 break;
1238 case 19:
1239 #line 159 "parse.y"
1240 {
1241 (yyvsp[-3])->n_x.v_subs[0]=(struct node *)0;
1242 (yyvsp[-3])->n_x.v_subs[1]=yyvsp[-1];
1243 yyval=yyvsp[-3]; }
1244 break;
1245 case 20:
1246 #line 163 "parse.y"
1247 {
1248 yyvsp[-3]->comp_value=IF;
1249 yyvsp[-3]->n_x.v_subs[0]=yyvsp[-1];
1250 yyvsp[-3]->n_x.v_subs[1]=yyvsp[0];
1251 yyvsp[-1]->n_x.v_subs[0]=yyvsp[-4];
1252 yyvsp[-1]->n_x.v_subs[1]=yyvsp[-2];
1253 yyval=yyvsp[-3]; }
1254 break;
1255 case 21:
1256 #line 174 "parse.y"
1257 {
1258 yyvsp[-1]->n_x.v_subs[0]=yyvsp[-2];
1259 yyvsp[-1]->n_x.v_subs[1]=yyvsp[0];
1260 yyval = yyvsp[-1]; }
1261 break;
1262 case 22:
1263 #line 178 "parse.y"
1264 {
1265 yyvsp[-1]->n_x.v_subs[0]=yyvsp[-2];
1266 yyvsp[-1]->n_x.v_subs[1]=yyvsp[0];
1267 yyval = yyvsp[-1]; }
1268 break;
1269 case 23:
1270 #line 182 "parse.y"
1271 {
1272 yyvsp[-1]->n_x.v_subs[0]=yyvsp[-2];
1273 yyvsp[-1]->n_x.v_subs[1]=yyvsp[0];
1274 yyval = yyvsp[-1]; }
1275 break;
1276 case 24:
1277 #line 186 "parse.y"
1278 {
1279 yyvsp[-1]->n_x.v_subs[0]=yyvsp[-2];
1280 yyvsp[-1]->n_x.v_subs[1]=yyvsp[0];
1281 yyval = yyvsp[-1]; }
1282 break;
1283 case 25:
1284 #line 190 "parse.y"
1285 {
1286 yyvsp[-1]->n_x.v_subs[0]=yyvsp[-2];
1287 yyvsp[-1]->n_x.v_subs[1]=yyvsp[0];
1288 yyval = yyvsp[-1]; }
1289 break;
1290 case 26:
1291 #line 194 "parse.y"
1292 {
1293 yyvsp[-1]->n_x.v_subs[0]=yyvsp[-2];
1294 yyvsp[-1]->n_x.v_subs[1]=yyvsp[0];
1295 yyval = yyvsp[-1]; }
1296 break;
1297 case 27:
1298 #line 198 "parse.y"
1299 {
1300 yyvsp[-1]->n_x.v_subs[0]=yyvsp[-2];
1301 yyvsp[-1]->n_x.v_subs[1]=yyvsp[0];
1302 yyval = yyvsp[-1]; }
1303 break;
1304 case 28:
1305 #line 202 "parse.y"
1306 {
1307 yyvsp[-1]->n_x.v_subs[0]=yyvsp[-2];
1308 yyvsp[-1]->n_x.v_subs[1]=yyvsp[0];
1309 yyval = yyvsp[-1]; }
1310 break;
1311 case 29:
1312 #line 206 "parse.y"
1313 {
1314 yyvsp[-1]->n_x.v_subs[0]=yyvsp[-2];
1315 yyvsp[-1]->n_x.v_subs[1]=yyvsp[0];
1316 yyval = yyvsp[-1]; }
1317 break;
1318 case 30:
1319 #line 210 "parse.y"
1320 {
1321 yyvsp[-1]->n_x.v_subs[0]=yyvsp[-2];
1322 yyvsp[-1]->n_x.v_subs[1]=yyvsp[0];
1323 yyval = yyvsp[-1]; }
1324 break;
1325 case 31:
1326 #line 214 "parse.y"
1327 {
1328 yyvsp[-1]->n_x.v_subs[0]=yyvsp[-2];
1329 yyvsp[-1]->n_x.v_subs[1]=yyvsp[0];
1330 yyval = yyvsp[-1]; }
1331 break;
1332 case 32:
1333 #line 218 "parse.y"
1334 {
1335 yyvsp[-1]->n_x.v_subs[0]=yyvsp[-2];
1336 yyvsp[-1]->n_x.v_subs[1]=yyvsp[0];
1337 yyval = yyvsp[-1]; }
1338 break;
1339 case 33:
1340 #line 222 "parse.y"
1341 {
1342 yyvsp[-1]->n_x.v_subs[0]=yyvsp[-2];
1343 yyvsp[-1]->n_x.v_subs[1]=yyvsp[0];
1344 yyval = yyvsp[-1]; }
1345 break;
1346 case 34:
1347 #line 226 "parse.y"
1348 {
1349 if(yyvsp[0]->comp_value==CONST_FLT) {
1350 yyvsp[0]->n_x.v_float= -(yyvsp[0]->n_x.v_float);
1351 /* free($1); */
1352 yyval=yyvsp[0];
1353 } else if(yyvsp[0]->comp_value==CONST_INT) {
1354 yyvsp[0]->n_x.v_int= -(yyvsp[0]->n_x.v_int);
1355 /* free($1); */
1356 yyval=yyvsp[0];
1357 } else {
1358 yyvsp[-1]->comp_value = NEGATE;
1359 yyvsp[-1]->n_x.v_subs[0]=yyvsp[0];
1360 yyvsp[-1]->n_x.v_subs[1]=(struct node *)0;
1361 yyval = yyvsp[-1];
1362 } }
1363 break;
1364 case 35:
1365 #line 241 "parse.y"
1366 {
1367 yyvsp[-1]->n_x.v_subs[0]=yyvsp[0];
1368 yyvsp[-1]->n_x.v_subs[1]=(struct node *)0;
1369 yyval = yyvsp[-1]; }
1370 break;
1371 case 36:
1372 #line 246 "parse.y"
1373 { yyval = yyvsp[-1]; }
1374 break;
1375 case 37:
1376 #line 247 "parse.y"
1377 {
1378 if(!parse_error)
1379 parse_error=NO_CLOSE;
1380 }
1381 break;
1382 case 38:
1383 #line 255 "parse.y"
1384 {
1385 if(!parse_error)
1386 parse_error=NO_CLOSE;
1387 }
1388 break;
1389 case 39:
1390 #line 263 "parse.y"
1391 { yyval = make_list(yyvsp[0], 0); }
1392 break;
1393 case 40:
1394 #line 265 "parse.y"
1395 { yyval = make_list(yyvsp[0], yyvsp[-2]); }
1396 break;
1397 case 43:
1398 #line 273 "parse.y"
1399 { yyval=make_list(yyvsp[0], 0); }
1400 break;
1401 case 44:
1402 #line 275 "parse.y"
1403 { yyval=make_list(yyvsp[0],yyvsp[-2]); }
1404 break;
1405 case 45:
1406 #line 279 "parse.y"
1407 { yyval=yyvsp[0]; }
1408 break;
1409 }
1410
1411 #line 727 "/usr/share/bison/bison.simple"
1412
1413 \f
1414 yyvsp -= yylen;
1415 yyssp -= yylen;
1416 #if YYLSP_NEEDED
1417 yylsp -= yylen;
1418 #endif
1419
1420 #if YYDEBUG
1421 if (yydebug)
1422 {
1423 short *yyssp1 = yyss - 1;
1424 YYFPRINTF (stderr, "state stack now");
1425 while (yyssp1 != yyssp)
1426 YYFPRINTF (stderr, " %d", *++yyssp1);
1427 YYFPRINTF (stderr, "\n");
1428 }
1429 #endif
1430
1431 *++yyvsp = yyval;
1432 #if YYLSP_NEEDED
1433 *++yylsp = yyloc;
1434 #endif
1435
1436 /* Now `shift' the result of the reduction. Determine what state
1437 that goes to, based on the state we popped back to and the rule
1438 number reduced by. */
1439
1440 yyn = yyr1[yyn];
1441
1442 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
1443 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1444 yystate = yytable[yystate];
1445 else
1446 yystate = yydefgoto[yyn - YYNTBASE];
1447
1448 goto yynewstate;
1449
1450
1451 /*------------------------------------.
1452 | yyerrlab -- here on detecting error |
1453 `------------------------------------*/
1454 yyerrlab:
1455 /* If not already recovering from an error, report this error. */
1456 if (!yyerrstatus)
1457 {
1458 ++yynerrs;
1459
1460 #ifdef YYERROR_VERBOSE
1461 yyn = yypact[yystate];
1462
1463 if (yyn > YYFLAG && yyn < YYLAST)
1464 {
1465 YYSIZE_T yysize = 0;
1466 char *yymsg;
1467 int yyx, yycount;
1468
1469 yycount = 0;
1470 /* Start YYX at -YYN if negative to avoid negative indexes in
1471 YYCHECK. */
1472 for (yyx = yyn < 0 ? -yyn : 0;
1473 yyx < (int) (sizeof (yytname) / sizeof (char *)); yyx++)
1474 if (yycheck[yyx + yyn] == yyx)
1475 yysize += yystrlen (yytname[yyx]) + 15, yycount++;
1476 yysize += yystrlen ("parse error, unexpected ") + 1;
1477 yysize += yystrlen (yytname[YYTRANSLATE (yychar)]);
1478 yymsg = (char *) YYSTACK_ALLOC (yysize);
1479 if (yymsg != 0)
1480 {
1481 char *yyp = yystpcpy (yymsg, "parse error, unexpected ");
1482 yyp = yystpcpy (yyp, yytname[YYTRANSLATE (yychar)]);
1483
1484 if (yycount < 5)
1485 {
1486 yycount = 0;
1487 for (yyx = yyn < 0 ? -yyn : 0;
1488 yyx < (int) (sizeof (yytname) / sizeof (char *));
1489 yyx++)
1490 if (yycheck[yyx + yyn] == yyx)
1491 {
1492 const char *yyq = ! yycount ? ", expecting " : " or ";
1493 yyp = yystpcpy (yyp, yyq);
1494 yyp = yystpcpy (yyp, yytname[yyx]);
1495 yycount++;
1496 }
1497 }
1498 yyerror (yymsg);
1499 YYSTACK_FREE (yymsg);
1500 }
1501 else
1502 yyerror ("parse error; also virtual memory exhausted");
1503 }
1504 else
1505 #endif /* defined (YYERROR_VERBOSE) */
1506 yyerror ("parse error");
1507 }
1508 goto yyerrlab1;
1509
1510
1511 /*--------------------------------------------------.
1512 | yyerrlab1 -- error raised explicitly by an action |
1513 `--------------------------------------------------*/
1514 yyerrlab1:
1515 if (yyerrstatus == 3)
1516 {
1517 /* If just tried and failed to reuse lookahead token after an
1518 error, discard it. */
1519
1520 /* return failure if at end of input */
1521 if (yychar == YYEOF)
1522 YYABORT;
1523 YYDPRINTF ((stderr, "Discarding token %d (%s).\n",
1524 yychar, yytname[yychar1]));
1525 yychar = YYEMPTY;
1526 }
1527
1528 /* Else will try to reuse lookahead token after shifting the error
1529 token. */
1530
1531 yyerrstatus = 3; /* Each real token shifted decrements this */
1532
1533 goto yyerrhandle;
1534
1535
1536 /*-------------------------------------------------------------------.
1537 | yyerrdefault -- current state does not do anything special for the |
1538 | error token. |
1539 `-------------------------------------------------------------------*/
1540 yyerrdefault:
1541 #if 0
1542 /* This is wrong; only states that explicitly want error tokens
1543 should shift them. */
1544
1545 /* If its default is to accept any token, ok. Otherwise pop it. */
1546 yyn = yydefact[yystate];
1547 if (yyn)
1548 goto yydefault;
1549 #endif
1550
1551
1552 /*---------------------------------------------------------------.
1553 | yyerrpop -- pop the current state because it cannot handle the |
1554 | error token |
1555 `---------------------------------------------------------------*/
1556 yyerrpop:
1557 if (yyssp == yyss)
1558 YYABORT;
1559 yyvsp--;
1560 yystate = *--yyssp;
1561 #if YYLSP_NEEDED
1562 yylsp--;
1563 #endif
1564
1565 #if YYDEBUG
1566 if (yydebug)
1567 {
1568 short *yyssp1 = yyss - 1;
1569 YYFPRINTF (stderr, "Error: state stack now");
1570 while (yyssp1 != yyssp)
1571 YYFPRINTF (stderr, " %d", *++yyssp1);
1572 YYFPRINTF (stderr, "\n");
1573 }
1574 #endif
1575
1576 /*--------------.
1577 | yyerrhandle. |
1578 `--------------*/
1579 yyerrhandle:
1580 yyn = yypact[yystate];
1581 if (yyn == YYFLAG)
1582 goto yyerrdefault;
1583
1584 yyn += YYTERROR;
1585 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
1586 goto yyerrdefault;
1587
1588 yyn = yytable[yyn];
1589 if (yyn < 0)
1590 {
1591 if (yyn == YYFLAG)
1592 goto yyerrpop;
1593 yyn = -yyn;
1594 goto yyreduce;
1595 }
1596 else if (yyn == 0)
1597 goto yyerrpop;
1598
1599 if (yyn == YYFINAL)
1600 YYACCEPT;
1601
1602 YYDPRINTF ((stderr, "Shifting error token, "));
1603
1604 *++yyvsp = yylval;
1605 #if YYLSP_NEEDED
1606 *++yylsp = yylloc;
1607 #endif
1608
1609 yystate = yyn;
1610 goto yynewstate;
1611
1612
1613 /*-------------------------------------.
1614 | yyacceptlab -- YYACCEPT comes here. |
1615 `-------------------------------------*/
1616 yyacceptlab:
1617 yyresult = 0;
1618 goto yyreturn;
1619
1620 /*-----------------------------------.
1621 | yyabortlab -- YYABORT comes here. |
1622 `-----------------------------------*/
1623 yyabortlab:
1624 yyresult = 1;
1625 goto yyreturn;
1626
1627 /*---------------------------------------------.
1628 | yyoverflowab -- parser overflow comes here. |
1629 `---------------------------------------------*/
1630 yyoverflowlab:
1631 yyerror ("parser stack overflow");
1632 yyresult = 2;
1633 /* Fall through. */
1634
1635 yyreturn:
1636 #ifndef yyoverflow
1637 if (yyss != yyssa)
1638 YYSTACK_FREE (yyss);
1639 #endif
1640 return yyresult;
1641 }
1642 #line 282 "parse.y"
1643
1644
1645 void
1646 yyerror FUN1(char *, s)
1647 {
1648 if(!parse_error)
1649 parse_error=PARSE_ERR;
1650 }
1651
1652 YYSTYPE
1653 make_list FUN2(YYSTYPE, car, YYSTYPE, cdr)
1654 {
1655 YYSTYPE ret;
1656
1657 ret=(YYSTYPE)obstack_alloc(&tmp_mem,sizeof(*ret));
1658 ret->comp_value = 0;
1659 ret->n_x.v_subs[0]=car;
1660 ret->n_x.v_subs[1]=cdr;
1661 return ret;
1662 }
1663
1664 #define ERROR -1
1665
1666 extern struct node *yylval;
1667
1668 #ifdef __STDC__
1669 unsigned char parse_cell_or_range (char **,struct rng *);
1670 #else
1671 unsigned char parse_cell_or_range ();
1672 #endif
1673
1674 int
1675 yylex FUN0()
1676 {
1677 int ch;
1678 struct node *new;
1679 int isflt;
1680 char *begin;
1681 char *tmp_str;
1682 unsigned char byte_value;
1683 int n;
1684
1685 /* unsigned char *ptr; */
1686 int nn;
1687 struct function *fp;
1688 int tmp_ch;
1689
1690 #ifdef TEST
1691 if(!instr)
1692 return ERROR;
1693 #endif
1694 while(isspace(*instr))
1695 instr++;
1696 ch = *instr++;
1697 if(ch=='(' || ch==',' || ch==')')
1698 return ch;
1699
1700 new=(struct node *)obstack_alloc(&tmp_mem,sizeof(struct node));
1701 new->add_byte=0;
1702 new->sub_value=0;
1703 switch(ch) {
1704 case 0:
1705 return 0;
1706
1707 case '0': case '1': case '2': case '3': case '4': case '5': case '6':
1708 case '7': case '8': case '9': case '.':
1709 isflt = (ch=='.');
1710
1711 begin=instr-1;
1712 tmp_str=instr;
1713
1714 while(isdigit(*tmp_str) || (!isflt && *tmp_str=='.' && ++isflt))
1715 tmp_str++;
1716 if(*tmp_str=='e' || *tmp_str=='E') {
1717 isflt=1;
1718 tmp_str++;
1719 if(*tmp_str=='-' || *tmp_str=='+')
1720 tmp_str++;
1721 while(isdigit(*tmp_str))
1722 tmp_str++;
1723 }
1724 if(isflt) {
1725 new->n_x.v_float=astof((char **)(&begin));
1726 byte_value=CONST_FLT;
1727 } else {
1728 new->n_x.v_int=astol((char **)(&begin));
1729 if(begin!=tmp_str) {
1730 begin=instr-1;
1731 new->n_x.v_float=astof((char **)(&begin));
1732 byte_value=CONST_FLT;
1733 } else
1734 byte_value=CONST_INT;
1735 }
1736 ch=L_CONST;
1737 instr=begin;
1738 break;
1739
1740 case '"':
1741 begin=instr;
1742 while(*instr && *instr!='"') {
1743 if(*instr=='\\' && instr[1])
1744 instr++;
1745 instr++;
1746 }
1747 if(!*instr) {
1748 parse_error=NO_QUOTE;
1749 return ERROR;
1750 }
1751 tmp_str=new->n_x.v_string=(char *)ck_malloc(1+instr-begin);
1752 while(begin!=instr) {
1753 unsigned char n;
1754
1755 if(*begin=='\\') {
1756 begin++;
1757 if(begin[0]>='0' && begin[0]<='7') {
1758 if(begin[1]>='0' && begin[1]<='7') {
1759 if(begin[2]>='0' && begin[2]<='7') {
1760 n=(begin[2]-'0') + (010 * (begin[1]-'0')) + ( 0100 * (begin[0]-'0'));
1761 begin+=3;
1762 } else {
1763 n=(begin[1]-'0') + (010 * (begin[0]-'0'));
1764 begin+=2;
1765 }
1766 } else {
1767 n=begin[0]-'0';
1768 begin++;
1769 }
1770 } else
1771 n= *begin++;
1772 *tmp_str++= n;
1773 } else
1774 *tmp_str++= *begin++;
1775 }
1776 *tmp_str='\0';
1777 instr++;
1778 byte_value=CONST_STR;
1779 ch=L_CONST;
1780 break;
1781
1782 case '+': case '-':
1783
1784 case '*': case '/': case '%': case '&':
1785 /* case '|': */ case '^': case '=':
1786
1787 case '?':
1788 {
1789 unsigned char *ptr;
1790
1791 for(ptr= fnin;*ptr;ptr++)
1792 if(the_funs[*ptr].fn_str[0]==ch)
1793 break;
1794 #ifdef TEST
1795 if(!*ptr)
1796 panic("Can't find fnin[] entry for '%c'",ch);
1797 #endif
1798 byte_value= *ptr;
1799 }
1800 break;
1801
1802 case ':':
1803 byte_value=IF;
1804 break;
1805
1806 case '!':
1807 case '<':
1808 case '>':
1809 if(*instr!='=') {
1810 byte_value = (ch=='<') ? LESS : (ch=='>') ? GREATER : NOT;
1811 break;
1812 }
1813 instr++;
1814 byte_value = (ch=='<') ? LESSEQ : (ch=='>') ? GREATEQ : NOTEQUAL;
1815 ch = (ch=='<') ? LE : (ch=='>') ? GE : NE;
1816 break;
1817
1818 case '\'':
1819 case ';':
1820 case '[':
1821 case '\\':
1822 case ']':
1823 case '`':
1824 case '{':
1825 case '}':
1826 case '~':
1827 bad_chr:
1828 parse_error=BAD_CHAR;
1829 return ERROR;
1830
1831 case '#':
1832 begin=instr-1;
1833 while(*instr && (isalnum(*instr) || *instr=='_'))
1834 instr++;
1835 ch= *instr;
1836 *instr=0;
1837 if(!stricmp(begin,tname))
1838 byte_value=F_TRUE;
1839 else if(!stricmp(begin,fname))
1840 byte_value=F_FALSE;
1841 else if(!stricmp(begin,iname) && (begin[4]==0 || !stricmp(begin+4,"inity")))
1842 byte_value=CONST_INF;
1843 else if(!stricmp(begin,mname) ||
1844 !stricmp(begin,"#ninf"))
1845 byte_value=CONST_NINF;
1846 else if(!stricmp(begin,nname) ||
1847 !stricmp(begin,"#nan"))
1848 byte_value=CONST_NAN;
1849 else {
1850 for(n=1;n<=ERR_MAX;n++)
1851 if(!stricmp(begin,ename[n]))
1852 break;
1853 if(n>ERR_MAX)
1854 n=BAD_CHAR;
1855 new->n_x.v_int=n;
1856 byte_value=CONST_ERR;
1857 }
1858 *instr=ch;
1859 ch=L_CONST;
1860 break;
1861
1862 default:
1863 if(!a0 && (ch=='@' || ch=='$'))
1864 goto bad_chr;
1865
1866 if(a0 && ch=='@') {
1867 begin=instr;
1868 while(*instr && (isalpha(*instr) || isdigit(*instr) || *instr=='_'))
1869 instr++;
1870 n=instr-begin;
1871 } else {
1872 begin=instr-1;
1873 byte_value=parse_cell_or_range(&begin,&(new->n_x.v_rng));
1874 if(byte_value) {
1875 if((byte_value& ~0x3)==R_CELL)
1876 ch=L_CELL;
1877 else
1878 ch=L_RANGE;
1879 instr=begin;
1880 break;
1881 }
1882
1883 while(*instr && (isalpha(*instr) || isdigit(*instr) || *instr=='_'))
1884 instr++;
1885
1886 n=instr-begin;
1887 while(isspace(*instr))
1888 instr++;
1889
1890 if(*instr!='(') {
1891 ch=L_VAR;
1892 byte_value=VAR;
1893 new->n_x.v_var=find_or_make_var(begin,n);
1894 break;
1895 }
1896 }
1897 tmp_ch=begin[n];
1898 begin[n]='\0';
1899 fp=hash_find(parse_hash,begin);
1900 begin[n]=tmp_ch;
1901 byte_value= ERROR;
1902 if(!fp) {
1903 parse_error=BAD_FUNC;
1904 return ERROR;
1905 }
1906
1907 if(fp>=the_funs && fp<=&the_funs[USR1])
1908 byte_value=fp-the_funs;
1909 else {
1910 for(nn=0;nn<n_usr_funs;nn++) {
1911 if(fp>=&usr_funs[nn][0] && fp<=&usr_funs[nn][usr_n_funs[nn]]) {
1912 byte_value=USR1+nn;
1913 new->sub_value=fp-&usr_funs[nn][0];
1914 break;
1915 }
1916 }
1917 #ifdef TEST
1918 if(nn==n_usr_funs) {
1919 io_error_msg("Couln't turn fp into a ##");
1920 parse_error=BAD_FUNC;
1921 return ERROR;
1922 }
1923 #endif
1924 }
1925
1926 if(fp->fn_argn&X_J)
1927 ch= byte_value==F_IF ? L_FN3 : L_FN2;
1928 else if(fp->fn_argt[0]=='R' || fp->fn_argt[0]=='E')
1929 ch=L_FN1R-1+fp->fn_argn-X_A0;
1930 else
1931 ch=L_FN0 + fp->fn_argn-X_A0;
1932
1933 break;
1934 }
1935 /* new->node_type=ch; */
1936 new->comp_value=byte_value;
1937 yylval=new;
1938 return ch;
1939 }
1940
1941 /* Return value is
1942 0 if it doesn't look like a cell or a range,
1943 R_CELL if it is a cell (ptr now points past the characters, lr and lc hold the row and col of the cell)
1944 RANGE if it is a range (ptr points past the chars)
1945 */
1946 unsigned char
1947 parse_cell_or_range FUN2(char **,ptr, struct rng *,retp)
1948 {
1949 if(a0) {
1950 unsigned tmpc,tmpr;
1951 char *p;
1952 int abz = ROWREL|COLREL;
1953
1954 p= *ptr;
1955 tmpc=0;
1956 if(*p=='$') {
1957 abz-=COLREL;
1958 p++;
1959 }
1960 if(!isalpha(*p))
1961 return 0;
1962 tmpc=str_to_col(&p);
1963 if(tmpc<MIN_COL || tmpc>MAX_COL)
1964 return 0;
1965 if(*p=='$') {
1966 abz-=ROWREL;
1967 p++;
1968 }
1969 if(!isdigit(*p))
1970 return 0;
1971 for(tmpr=0;isdigit(*p);p++)
1972 tmpr=tmpr*10 + *p - '0';
1973
1974 if(tmpr<MIN_ROW || tmpr>MAX_ROW)
1975 return 0;
1976
1977 if(*p==':' || *p=='.') {
1978 unsigned tmpc1,tmpr1;
1979
1980 abz = ((abz&COLREL) ? LCREL : 0)|((abz&ROWREL) ? LRREL : 0)|HRREL|HCREL;
1981 p++;
1982 if(*p=='$') {
1983 abz-=HCREL;
1984 p++;
1985 }
1986 if(!isalpha(*p))
1987 return 0;
1988 tmpc1=str_to_col(&p);
1989 if(tmpc1<MIN_COL || tmpc1>MAX_COL)
1990 return 0;
1991 if(*p=='$') {
1992 abz-=HRREL;
1993 p++;
1994 }
1995 if(!isdigit(*p))
1996 return 0;
1997 for(tmpr1=0;isdigit(*p);p++)
1998 tmpr1=tmpr1*10 + *p - '0';
1999 if(tmpr1<MIN_ROW || tmpr1>MAX_ROW)
2000 return 0;
2001
2002 if(tmpr<tmpr1) {
2003 retp->lr=tmpr;
2004 retp->hr=tmpr1;
2005 } else {
2006 retp->lr=tmpr1;
2007 retp->hr=tmpr;
2008 }
2009 if(tmpc<tmpc1) {
2010 retp->lc=tmpc;
2011 retp->hc=tmpc1;
2012 } else {
2013 retp->lc=tmpc1;
2014 retp->hc=tmpc;
2015 }
2016 *ptr= p;
2017 return RANGE | abz;
2018 }
2019 retp->lr = retp->hr = tmpr;
2020 retp->lc = retp->hc = tmpc;
2021 *ptr=p;
2022 return R_CELL | abz;
2023 } else {
2024 char *p;
2025 unsigned char retr;
2026 unsigned char retc;
2027 int ended;
2028 long num;
2029 CELLREF tmp;
2030
2031 #define CK_ABS_R(x) if((x)<MIN_ROW || (x)>MAX_ROW) \
2032 return 0; \
2033 else
2034
2035 #define CK_REL_R(x) if( ((x)>0 && MAX_ROW-(x)<cur_row) \
2036 || ((x)<0 && MIN_ROW-(x)>cur_row)) \
2037 return 0; \
2038 else
2039
2040 #define CK_ABS_C(x) if((x)<MIN_COL || (x)>MAX_COL) \
2041 return 0; \
2042 else
2043
2044 #define CK_REL_C(x) if( ((x)>0 && MAX_COL-(x)<cur_col) \
2045 || ((x)<0 && MIN_COL-(x)>cur_col)) \
2046 return 0; \
2047 else
2048
2049 #define MAYBEREL(p) (*(p)=='[' && (isdigit((p)[1]) || (((p)[1]=='+' || (p)[1]=='-') && isdigit((p)[2]))))
2050
2051 p= *ptr;
2052 retr=0;
2053 retc=0;
2054 ended=0;
2055 while(ended==0) {
2056 switch(*p) {
2057 case 'r':
2058 case 'R':
2059 if(retr) {
2060 ended++;
2061 break;
2062 }
2063 p++;
2064 retr=R_CELL;
2065 if(isdigit(*p)) {
2066 num=astol(&p);
2067 CK_ABS_R(num);
2068 retp->lr= retp->hr=num;
2069 } else if(MAYBEREL(p)) {
2070 p++;
2071 num=astol(&p);
2072 CK_REL_R(num);
2073 retp->lr= retp->hr=num+cur_row;
2074 retr|=ROWREL;
2075 if(*p==':') {
2076 retr=RANGE|LRREL|HRREL;
2077 p++;
2078 num=astol(&p);
2079 CK_REL_R(num);
2080 retp->hr=num+cur_row;
2081 }
2082 if(*p++!=']')
2083 return 0;
2084 } else if(retc || *p=='c' || *p=='C') {
2085 retr|=ROWREL;
2086 retp->lr= retp->hr=cur_row;
2087 } else
2088 return 0;
2089 if(*p==':' && retr!=(RANGE|LRREL|HRREL)) {
2090 retr= (retr&ROWREL) ? RANGE|LRREL : RANGE;
2091 p++;
2092 if(isdigit(*p)) {
2093 num=astol(&p);
2094 CK_ABS_R(num);
2095 retp->hr=num;
2096 } else if(MAYBEREL(p)) {
2097 p++;
2098 num=astol(&p);
2099 CK_REL_R(num);
2100 retp->hr=num+cur_row;
2101 retr|=HRREL;
2102 if(*p++!=']')
2103 return 0;
2104 } else
2105 return 0;
2106 }
2107
2108 if(retc)
2109 ended++;
2110 break;
2111
2112 case 'c':
2113 case 'C':
2114 if(retc) {
2115 ended++;
2116 break;
2117 }
2118 p++;
2119 retc=R_CELL;
2120 if(isdigit(*p)) {
2121 num=astol(&p);
2122 CK_ABS_C(num);
2123 retp->lc= retp->hc=num;
2124 } else if(MAYBEREL(p)) {
2125 p++;
2126 num=astol(&p);
2127 CK_REL_C(num);
2128 retp->lc= retp->hc=num+cur_col;
2129 retc|=COLREL;
2130 if(*p==':') {
2131 retc=RANGE|LCREL|HCREL;
2132 p++;
2133 num=astol(&p);
2134 CK_REL_C(num);
2135 retp->hc=num+cur_col;
2136 }
2137 if(*p++!=']')
2138 return 0;
2139 } else if(retr || *p=='r' || *p=='R') {
2140 retc|=COLREL;
2141 retp->lc= retp->hc=cur_col;
2142 } else
2143 return 0;
2144 if(*p==':' && retc!=(RANGE|LCREL|HCREL)) {
2145 retc= (retc&COLREL) ? RANGE|LCREL : RANGE;
2146 p++;
2147 if(isdigit(*p)) {
2148 num=astol(&p);
2149 CK_ABS_C(num);
2150 retp->hc=num;
2151 } else if(MAYBEREL(p)) {
2152 p++;
2153 num=astol(&p);
2154 CK_REL_C(num);
2155 retp->hc=num+cur_col;
2156 retc|=HCREL;
2157 if(*p++!=']')
2158 return 0;
2159 } else
2160 return 0;
2161 }
2162
2163 if(retr)
2164 ended++;
2165 break;
2166 default:
2167 if(retr) {
2168 *ptr=p;
2169 retp->lc=MIN_COL;
2170 retp->hc=MAX_COL;
2171 if((retr|ROWREL)==(R_CELL|ROWREL))
2172 return (retr&ROWREL) ? (RANGE|LRREL|HRREL) : RANGE;
2173 else
2174 return retr;
2175 } else if(retc) {
2176 *ptr=p;
2177 retp->lr=MIN_ROW;
2178 retp->hr=MAX_COL;
2179 if((retc|COLREL)==(R_CELL|COLREL))
2180 return (retc&COLREL) ? (RANGE|LCREL|HCREL) : RANGE;
2181 else
2182 return retc;
2183 }
2184 return 0;
2185 }
2186 }
2187 if(!retr || !retc)
2188 return 0;
2189 *ptr=p;
2190 if(retp->lr>retp->hr)
2191 tmp=retp->lr,retp->lr=retp->hr,retp->hr=tmp;
2192 if(retp->lc>retp->hc)
2193 tmp=retp->lc,retp->lc=retp->hc,retp->hc=tmp;
2194
2195 if((retr|ROWREL)==(R_CELL|ROWREL)) {
2196 if((retc|COLREL)==(R_CELL|COLREL))
2197 return retr|retc;
2198 return (retr&ROWREL) ? (retc|LRREL|HRREL) : retc;
2199 }
2200 if((retc|COLREL)==(R_CELL|COLREL))
2201 return (retc&COLREL) ? (retr|LCREL|HCREL) : retr;
2202 return retr|retc;
2203 }
2204 }
2205
2206 int
2207 str_to_col FUN1(char **,str)
2208 {
2209 int ret;
2210 char c,cc,ccc;
2211 #if MAX_COL>702
2212 char cccc;
2213 #endif
2214
2215 ret=0;
2216 c=str[0][0];
2217 if(!isalpha((cc=str[0][1]))) {
2218 (*str)++;
2219 return MIN_COL + (isupper(c) ? c-'A' : c-'a');
2220 }
2221 if(!isalpha((ccc=str[0][2]))) {
2222 (*str)+=2;
2223 return MIN_COL+26 + (isupper(c) ? c-'A' : c-'a')*26 + (isupper(cc) ? cc-'A' : cc-'a');
2224 }
2225 #if MAX_COL>702
2226 if(!isalpha((cccc=str[0][3]))) {
2227 (*str)+=3;
2228 return MIN_COL+702 + (isupper(c) ? c-'A' : c-'a')*26*26 + (isupper(cc) ? cc-'A' : cc-'a')*26 + (isupper(ccc) ? ccc-'A' : ccc-'a');
2229 }
2230 if(!isalpha(str[0][4])) {
2231 (*str)+=4;
2232 return MIN_COL+18278 + (isupper(c) ? c-'A' : c-'a')*26*26*26 + (isupper(cc) ? cc-'A' : cc-'a')*26*26 + (isupper(ccc) ? ccc-'A' : ccc-'a')*26 + (isupper(cccc) ? cccc-'A' : cccc-'a');
2233 }
2234 #endif
2235 return 0;
2236 }