1
2 /* A Bison parser, made from grammy.y
3 by GNU Bison version 1.28 */
4
5 #define YYBISON 1 /* Identify Bison output. */
6
7 #define ID 257
8 #define HELP 258
9 #define INTER 259
10 #define UNION 260
11 #define DIFF 261
12 #define VALUE 262
13 #define IMAGE 263
14 #define PREIMAGE 264
15 #define INITVISU 265
16 #define VISU 266
17 #define PRINT 267
18 #define PLPRINT 268
19 #define PLCONS 269
20 #define PLRAYS 270
21 #define DD 271
22 #define LIST 272
23 #define EHRHART 273
24 #define VERTICES 274
25 #define CONVEX 275
26 #define DELETE 276
27 #define QUIT 277
28 #define LT 278
29 #define GT 279
30 #define LE 280
31 #define LG 281
32 #define EQ 282
33 #define AFF 283
34 #define PIPE 284
35 #define GE 285
36
37 #line 1 "grammy.y"
38
39 #include "visutypes.h"
40 #include "gramm_fctn.h"
41 #include "grammy.h"
42 #include "gtk_windows.h"
43 #include "gtk_properties.h"
44 #include "gtk_domain.h"
45 #include "domains.h"
46 #include "gtk_context.h"
47
48 int reinit = FALSE;
49 gint row = -1;
50 Domain * domain_cur = NULL;
51
52
53
54
55 #line 20 "grammy.y"
56 #ifndef YYSTYPE
57 typedef union {
58 char *Chain;
59 Value Val;
60 int Op;
61 struct {
62 IndList Mline;
63 Value Const;
64 } A_Exp;
65 IndList Mat_line;
66 ChainList List;
67 } yystype;
68 #define YYSTYPE yystype
69 #endif
70 #include <stdio.h>
71
72 #ifndef __cplusplus
73 #ifndef __STDC__
74 #define const
75 #endif
76 #endif
77
78
79
80 #define YYFINAL 193
81 #define YYFLAG -32768
82 #define YYNTBASE 42
83
84 #define YYTRANSLATE(x) ((unsigned)(x) <= 285 ? yytranslate[x] : 59)
85
86 static const char yytranslate[] = { 0,
87 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
88 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
89 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
90 2, 2, 2, 2, 2, 2, 2, 2, 2, 30,
91 31, 39, 37, 34, 38, 35, 2, 2, 2, 2,
92 2, 2, 2, 2, 2, 2, 2, 2, 36, 2,
93 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
94 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
95 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
96 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
97 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
98 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
99 2, 2, 32, 2, 33, 2, 2, 2, 2, 2,
100 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
101 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
102 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
103 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
104 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
105 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
106 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
107 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
108 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
109 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
110 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
111 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
112 2, 2, 2, 2, 2, 1, 3, 4, 5, 6,
113 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
114 17, 18, 19, 20, 21, 22, 23, 24, 25, 26,
115 27, 28, 29, 40, 41
116 };
117
118 #if YYDEBUG != 0
119 static const short yyprhs[] = { 0,
120 0, 2, 5, 7, 9, 11, 13, 15, 17, 19,
121 26, 27, 37, 45, 52, 58, 65, 72, 79, 86,
122 93, 100, 107, 117, 123, 133, 139, 145, 151, 157,
123 165, 169, 177, 181, 189, 193, 199, 203, 206, 210,
124 214, 218, 222, 226, 230, 234, 238, 242, 246, 249,
125 251, 256, 260, 263, 269, 273, 277, 279, 281, 284,
126 287, 291, 293, 297, 299, 300, 302, 304, 308, 310,
127 314, 316, 318, 320, 322, 326, 330, 334, 338, 341,
128 344, 346
129 };
130
131 static const short yyrhs[] = { 43,
132 0, 43, 47, 0, 47, 0, 6, 0, 37, 0,
133 5, 0, 35, 0, 7, 0, 38, 0, 3, 29,
134 32, 40, 33, 36, 0, 0, 3, 29, 32, 52,
135 40, 48, 53, 33, 36, 0, 3, 29, 32, 52,
136 40, 1, 36, 0, 3, 29, 32, 52, 1, 36,
137 0, 3, 29, 32, 1, 36, 0, 3, 29, 30,
138 49, 31, 36, 0, 3, 29, 3, 44, 3, 36,
139 0, 3, 29, 3, 44, 1, 36, 0, 3, 29,
140 3, 45, 3, 36, 0, 3, 29, 3, 45, 1,
141 36, 0, 3, 29, 3, 46, 3, 36, 0, 3,
142 29, 3, 46, 1, 36, 0, 3, 29, 9, 30,
143 3, 34, 3, 31, 36, 0, 3, 29, 9, 1,
144 36, 0, 3, 29, 10, 30, 3, 34, 3, 31,
145 36, 0, 3, 29, 10, 1, 36, 0, 3, 29,
146 17, 3, 36, 0, 3, 29, 21, 3, 36, 0,
147 3, 29, 21, 1, 36, 0, 20, 30, 3, 34,
148 3, 31, 36, 0, 20, 1, 36, 0, 19, 30,
149 3, 34, 3, 31, 36, 0, 19, 1, 36, 0,
150 11, 30, 8, 34, 3, 31, 36, 0, 11, 1,
151 36, 0, 12, 30, 3, 31, 36, 0, 12, 1,
152 36, 0, 18, 36, 0, 13, 3, 36, 0, 13,
153 1, 36, 0, 14, 3, 36, 0, 14, 1, 36,
154 0, 15, 3, 36, 0, 15, 1, 36, 0, 16,
155 3, 36, 0, 16, 1, 36, 0, 22, 3, 36,
156 0, 22, 1, 36, 0, 4, 36, 0, 23, 0,
157 3, 29, 1, 36, 0, 3, 1, 36, 0, 1,
158 36, 0, 49, 34, 30, 50, 31, 0, 30, 50,
159 31, 0, 50, 34, 51, 0, 51, 0, 8, 0,
160 38, 8, 0, 37, 8, 0, 52, 34, 3, 0,
161 3, 0, 53, 34, 54, 0, 54, 0, 0, 55,
162 0, 56, 0, 55, 57, 55, 0, 58, 0, 58,
163 28, 58, 0, 24, 0, 25, 0, 26, 0, 41,
164 0, 58, 37, 58, 0, 58, 38, 58, 0, 8,
165 39, 58, 0, 30, 58, 31, 0, 38, 58, 0,
166 8, 3, 0, 3, 0, 8, 0
167 };
168
169 #endif
170
171 #if YYDEBUG != 0
172 static const short yyrline[] = { 0,
173 55, 61, 62, 68, 68, 69, 69, 70, 70, 83,
174 92, 94, 102, 109, 116, 125, 133, 140, 144, 151,
175 155, 162, 165, 172, 176, 183, 187, 195, 202, 206,
176 212, 215, 221, 224, 236, 239, 275, 278, 302, 331,
177 334, 360, 362, 378, 380, 396, 401, 427, 431, 435,
178 444, 450, 456, 468, 492, 509, 518, 525, 526, 527,
179 532, 533, 537, 538, 539, 545, 546, 551, 634, 642,
180 666, 667, 668, 669, 678, 685, 688, 691, 694, 697,
181 701, 707
182 };
183 #endif
184
185
186 #if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
187
188 static const char * const yytname[] = { "$","error","$undefined.","ID","HELP",
189 "INTER","UNION","DIFF","VALUE","IMAGE","PREIMAGE","INITVISU","VISU","PRINT",
190 "PLPRINT","PLCONS","PLRAYS","DD","LIST","EHRHART","VERTICES","CONVEX","DELETE",
191 "QUIT","LT","GT","LE","LG","EQ","AFF","'('","')'","'{'","'}'","','","'.'","';'",
192 "'+'","'-'","'*'","PIPE","GE","COMMANDS","L_INSTR","Union","Inter","Diff","INSTR",
193 "@1","MATRIX","L_VALUE","VAL","L_VAR","L_CONSTRAINTS","CONSTRAINT","INEG","EG",
194 "OPREL","ARTHM_EXP", NULL
195 };
196 #endif
197
198 static const short yyr1[] = { 0,
199 42, 43, 43, 44, 44, 45, 45, 46, 46, 47,
200 48, 47, 47, 47, 47, 47, 47, 47, 47, 47,
201 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
202 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
203 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
204 47, 47, 47, 49, 49, 50, 50, 51, 51, 51,
205 52, 52, 53, 53, 53, 54, 54, 55, 55, 56,
206 57, 57, 57, 57, 58, 58, 58, 58, 58, 58,
207 58, 58
208 };
209
210 static const short yyr2[] = { 0,
211 1, 2, 1, 1, 1, 1, 1, 1, 1, 6,
212 0, 9, 7, 6, 5, 6, 6, 6, 6, 6,
213 6, 6, 9, 5, 9, 5, 5, 5, 5, 7,
214 3, 7, 3, 7, 3, 5, 3, 2, 3, 3,
215 3, 3, 3, 3, 3, 3, 3, 3, 2, 1,
216 4, 3, 2, 5, 3, 3, 1, 1, 2, 2,
217 3, 1, 3, 1, 0, 1, 1, 3, 1, 3,
218 1, 1, 1, 1, 3, 3, 3, 3, 2, 2,
219 1, 1
220 };
221
222 static const short yydefact[] = { 0,
223 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
224 0, 0, 0, 50, 0, 3, 53, 0, 0, 49,
225 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
226 0, 0, 38, 0, 0, 0, 0, 0, 0, 2,
227 52, 0, 0, 0, 0, 0, 0, 0, 0, 35,
228 0, 37, 0, 40, 39, 42, 41, 44, 43, 46,
229 45, 33, 0, 31, 0, 48, 47, 51, 6, 4,
230 8, 7, 5, 9, 0, 0, 0, 0, 0, 0,
231 0, 0, 0, 0, 0, 0, 0, 62, 0, 0,
232 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
233 24, 0, 26, 0, 27, 29, 28, 58, 0, 0,
234 0, 57, 0, 0, 15, 0, 0, 0, 0, 0,
235 36, 0, 0, 18, 17, 20, 19, 22, 21, 0,
236 0, 60, 59, 55, 0, 16, 0, 10, 14, 61,
237 0, 65, 0, 0, 0, 0, 0, 56, 0, 13,
238 81, 82, 0, 0, 0, 64, 66, 67, 69, 34,
239 32, 30, 0, 0, 54, 80, 0, 0, 79, 0,
240 0, 71, 72, 73, 74, 0, 0, 0, 0, 23,
241 25, 77, 78, 12, 63, 68, 69, 70, 75, 76,
242 0, 0, 0
243 };
244
245 static const short yydefgoto[] = { 191,
246 15, 75, 76, 77, 16, 142, 86, 111, 112, 90,
247 155, 156, 157, 158, 176, 159
248 };
249
250 static const short yypact[] = { 102,
251 -24, 30, -11, 2, 8, 18, 59, 106, 107, -6,
252 25, 26, 125,-32768, 79,-32768,-32768, 39, 44,-32768,
253 49, 36, 60, 32, 64, 68, 83, 87, 99, 101,
254 103, 104,-32768, 105, 135, 108, 139, 109, 110,-32768,
255 -32768, 111, 11, 27, 28, 140, 126, 118, -1,-32768,
256 115,-32768, 119,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
257 -32768,-32768, 117,-32768, 120,-32768,-32768,-32768,-32768,-32768,
258 -32768,-32768,-32768,-32768, 129, 130, 133, 116, 150, 121,
259 152, 122, 123, 124, 14, -26, 127,-32768, 128, 0,
260 153, 131, 159, 161, 132, 134, 136, 137, 138, 141,
261 -32768, 142,-32768, 144,-32768,-32768,-32768,-32768, 157, 158,
262 -21,-32768, 143, 145,-32768, 146, 147, 166, 3, 149,
263 -32768, 154, 155,-32768,-32768,-32768,-32768,-32768,-32768, 168,
264 178,-32768,-32768,-32768, 14,-32768, 14,-32768,-32768,-32768,
265 148, 12, 151, 156, 160, 162, 163,-32768, 47,-32768,
266 -32768, 4, 12, 12, 37,-32768, 43,-32768, -14,-32768,
267 -32768,-32768, 164, 165,-32768,-32768, 12, 35,-32768, 167,
268 12,-32768,-32768,-32768,-32768, 12, 12, 12, 12,-32768,
269 -32768,-32768,-32768,-32768,-32768, 43, 74, 74,-32768,-32768,
270 188, 189,-32768
271 };
272
273 static const short yypgoto[] = {-32768,
274 -32768,-32768,-32768,-32768, 175,-32768,-32768, 54, 62,-32768,
275 -32768, 24, 22,-32768,-32768, -90
276 };
277
278
279 #define YYLAST 203
280
281
282 static const short yytable[] = { 87,
283 117, 88, 21, 141, 113, -11, 166, 114, 23, 134,
284 -11, 17, 135, 177, 151, 69, 70, 71, 25, 152,
285 26, 108, 178, 179, 20, 34, 36, 78, 80, 33,
286 18, 22, -11, 118, 53, -11, -11, 24, 89, 119,
287 -11, 153, 167, 51, 42, 72, 43, 73, 74, 154,
288 109, 110, 44, 45, 35, 37, 79, 81, 19, 27,
289 46, 28, 168, 169, 47, 183, 172, 173, 174, 170,
290 171, 178, 179, 48, 41, 49, 182, 165, -1, 1,
291 135, 2, 3, 175, 50, 187, 188, 189, 190, 4,
292 5, 6, 7, 8, 9, 52, 10, 11, 12, 54,
293 13, 14, 1, 55, 2, 3, 29, 31, 30, 32,
294 178, 179, 4, 5, 6, 7, 8, 9, 56, 10,
295 11, 12, 57, 13, 14, 38, 83, 39, 84, 95,
296 97, 96, 98, 99, 58, 100, 59, 63, 60, 61,
297 62, 65, 82, 64, 66, 67, 68, 85, 91, 92,
298 93, 101, 102, 94, 104, 120, 103, 105, 106, 107,
299 116, 122, 115, 123, 132, 133, 121, 124, 140, 125,
300 146, 126, 127, 128, 137, 130, 129, 131, 136, 143,
301 147, 138, 139, 150, 144, 145, 160, 192, 193, 40,
302 149, 161, 163, 164, 185, 162, 148, 186, 0, 180,
303 181, 0, 184
304 };
305
306 static const short yycheck[] = { 1,
307 1, 3, 1, 1, 31, 3, 3, 34, 1, 31,
308 8, 36, 34, 28, 3, 5, 6, 7, 1, 8,
309 3, 8, 37, 38, 36, 1, 1, 1, 1, 36,
310 1, 30, 30, 34, 3, 33, 34, 30, 40, 40,
311 38, 30, 39, 8, 1, 35, 3, 37, 38, 38,
312 37, 38, 9, 10, 30, 30, 30, 30, 29, 1,
313 17, 3, 153, 154, 21, 31, 24, 25, 26, 33,
314 34, 37, 38, 30, 36, 32, 167, 31, 0, 1,
315 34, 3, 4, 41, 36, 176, 177, 178, 179, 11,
316 12, 13, 14, 15, 16, 36, 18, 19, 20, 36,
317 22, 23, 1, 36, 3, 4, 1, 1, 3, 3,
318 37, 38, 11, 12, 13, 14, 15, 16, 36, 18,
319 19, 20, 36, 22, 23, 1, 1, 3, 3, 1,
320 1, 3, 3, 1, 36, 3, 36, 3, 36, 36,
321 36, 3, 3, 36, 36, 36, 36, 30, 34, 31,
322 34, 36, 3, 34, 3, 3, 36, 36, 36, 36,
323 33, 3, 36, 3, 8, 8, 36, 36, 3, 36,
324 3, 36, 36, 36, 30, 34, 36, 34, 36, 31,
325 3, 36, 36, 36, 31, 31, 36, 0, 0, 15,
326 137, 36, 31, 31, 171, 36, 135, 176, -1, 36,
327 36, -1, 36
328 };
329 /* -*-C-*- Note some compilers choke on comments on `#line' lines. */
330 #line 3 "/usr/lib/bison.simple"
331 /* This file comes from bison-1.28. */
332
333 /* Skeleton output parser for bison,
334 Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
335
336 This program is free software; you can redistribute it and/or modify
337 it under the terms of the GNU General Public License as published by
338 the Free Software Foundation; either version 2, or (at your option)
339 any later version.
340
341 This program is distributed in the hope that it will be useful,
342 but WITHOUT ANY WARRANTY; without even the implied warranty of
343 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
344 GNU General Public License for more details.
345
346 You should have received a copy of the GNU General Public License
347 along with this program; if not, write to the Free Software
348 Foundation, Inc., 59 Temple Place - Suite 330,
349 Boston, MA 02111-1307, USA. */
350
351 /* As a special exception, when this file is copied by Bison into a
352 Bison output file, you may use that output file without restriction.
353 This special exception was added by the Free Software Foundation
354 in version 1.24 of Bison. */
355
356 /* This is the parser code that is written into each bison parser
357 when the %semantic_parser declaration is not specified in the grammar.
358 It was written by Richard Stallman by simplifying the hairy parser
359 used when %semantic_parser is specified. */
360
361 #ifndef YYSTACK_USE_ALLOCA
362 #ifdef alloca
363 #define YYSTACK_USE_ALLOCA
364 #else /* alloca not defined */
365 #ifdef __GNUC__
366 #define YYSTACK_USE_ALLOCA
367 #define alloca __builtin_alloca
368 #else /* not GNU C. */
369 #if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
370 #define YYSTACK_USE_ALLOCA
371 #include <alloca.h>
372 #else /* not sparc */
373 /* We think this test detects Watcom and Microsoft C. */
374 /* This used to test MSDOS, but that is a bad idea
375 since that symbol is in the user namespace. */
376 #if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
377 #if 0 /* No need for malloc.h, which pollutes the namespace;
378 instead, just don't use alloca. */
379 #include <malloc.h>
380 #endif
381 #else /* not MSDOS, or __TURBOC__ */
382 #if defined(_AIX)
383 /* I don't know what this was needed for, but it pollutes the namespace.
384 So I turned it off. rms, 2 May 1997. */
385 /* #include <malloc.h> */
386 #pragma alloca
387 #define YYSTACK_USE_ALLOCA
388 #else /* not MSDOS, or __TURBOC__, or _AIX */
389 #if 0
390 #ifdef __hpux /* haible@ilog.fr says this works for HPUX 9.05 and up,
391 and on HPUX 10. Eventually we can turn this on. */
392 #define YYSTACK_USE_ALLOCA
393 #define alloca __builtin_alloca
394 #endif /* __hpux */
395 #endif
396 #endif /* not _AIX */
397 #endif /* not MSDOS, or __TURBOC__ */
398 #endif /* not sparc */
399 #endif /* not GNU C */
400 #endif /* alloca not defined */
401 #endif /* YYSTACK_USE_ALLOCA not defined */
402
403 #ifdef YYSTACK_USE_ALLOCA
404 #define YYSTACK_ALLOC alloca
405 #else
406 #define YYSTACK_ALLOC malloc
407 #endif
408
409 /* Note: there must be only one dollar sign in this file.
410 It is replaced by the list of actions, each action
411 as one case of the switch. */
412
413 #define yyerrok (yyerrstatus = 0)
414 #define yyclearin (yychar = YYEMPTY)
415 #define YYEMPTY -2
416 #define YYEOF 0
417 #define YYACCEPT goto yyacceptlab
418 #define YYABORT goto yyabortlab
419 #define YYERROR goto yyerrlab1
420 /* Like YYERROR except do call yyerror.
421 This remains here temporarily to ease the
422 transition to the new meaning of YYERROR, for GCC.
423 Once GCC version 2 has supplanted version 1, this can go. */
424 #define YYFAIL goto yyerrlab
425 #define YYRECOVERING() (!!yyerrstatus)
426 #define YYBACKUP(token, value) \
427 do \
428 if (yychar == YYEMPTY && yylen == 1) \
429 { yychar = (token), yylval = (value); \
430 yychar1 = YYTRANSLATE (yychar); \
431 YYPOPSTACK; \
432 goto yybackup; \
433 } \
434 else \
435 { yyerror ("syntax error: cannot back up"); YYERROR; } \
436 while (0)
437
438 #define YYTERROR 1
439 #define YYERRCODE 256
440
441 #ifndef YYPURE
442 #define YYLEX yylex()
443 #endif
444
445 #ifdef YYPURE
446 #ifdef YYLSP_NEEDED
447 #ifdef YYLEX_PARAM
448 #define YYLEX yylex(&yylval, &yylloc, YYLEX_PARAM)
449 #else
450 #define YYLEX yylex(&yylval, &yylloc)
451 #endif
452 #else /* not YYLSP_NEEDED */
453 #ifdef YYLEX_PARAM
454 #define YYLEX yylex(&yylval, YYLEX_PARAM)
455 #else
456 #define YYLEX yylex(&yylval)
457 #endif
458 #endif /* not YYLSP_NEEDED */
459 #endif
460
461 /* If nonreentrant, generate the variables here */
462
463 #ifndef YYPURE
464
465 int yychar; /* the lookahead symbol */
466 YYSTYPE yylval; /* the semantic value of the */
467 /* lookahead symbol */
468
469 #ifdef YYLSP_NEEDED
470 YYLTYPE yylloc; /* location data for the lookahead */
471 /* symbol */
472 #endif
473
474 int yynerrs; /* number of parse errors so far */
475 #endif /* not YYPURE */
476
477 #if YYDEBUG != 0
478 int yydebug; /* nonzero means print parse trace */
479 /* Since this is uninitialized, it does not stop multiple parsers
480 from coexisting. */
481 #endif
482
483 /* YYINITDEPTH indicates the initial size of the parser's stacks */
484
485 #ifndef YYINITDEPTH
486 #define YYINITDEPTH 200
487 #endif
488
489 /* YYMAXDEPTH is the maximum size the stacks can grow to
490 (effective only if the built-in stack extension method is used). */
491
492 #if YYMAXDEPTH == 0
493 #undef YYMAXDEPTH
494 #endif
495
496 #ifndef YYMAXDEPTH
497 #define YYMAXDEPTH 10000
498 #endif
499
500 /* Define __yy_memcpy. Note that the size argument
501 should be passed with type unsigned int, because that is what the non-GCC
502 definitions require. With GCC, __builtin_memcpy takes an arg
503 of type size_t, but it can handle unsigned int. */
504
505 #if __GNUC__ > 1 /* GNU C and GNU C++ define this. */
506 #define __yy_memcpy(TO,FROM,COUNT) __builtin_memcpy(TO,FROM,COUNT)
507 #else /* not GNU C or C++ */
508 #ifndef __cplusplus
509
510 /* This is the most reliable way to avoid incompatibilities
511 in available built-in functions on various systems. */
512 static void
__yy_memcpy(to,from,count)513 __yy_memcpy (to, from, count)
514 char *to;
515 char *from;
516 unsigned int count;
517 {
518 register char *f = from;
519 register char *t = to;
520 register int i = count;
521
522 while (i-- > 0)
523 *t++ = *f++;
524 }
525
526 #else /* __cplusplus */
527
528 /* This is the most reliable way to avoid incompatibilities
529 in available built-in functions on various systems. */
530 static void
__yy_memcpy(char * to,char * from,unsigned int count)531 __yy_memcpy (char *to, char *from, unsigned int count)
532 {
533 register char *t = to;
534 register char *f = from;
535 register int i = count;
536
537 while (i-- > 0)
538 *t++ = *f++;
539 }
540
541 #endif
542 #endif
543
544 #line 217 "/usr/lib/bison.simple"
545
546 /* The user can define YYPARSE_PARAM as the name of an argument to be passed
547 into yyparse. The argument should have type void *.
548 It should actually point to an object.
549 Grammar actions can access the variable by casting it
550 to the proper pointer type. */
551
552 #ifdef YYPARSE_PARAM
553 #ifdef __cplusplus
554 #define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
555 #define YYPARSE_PARAM_DECL
556 #else /* not __cplusplus */
557 #define YYPARSE_PARAM_ARG YYPARSE_PARAM
558 #define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
559 #endif /* not __cplusplus */
560 #else /* not YYPARSE_PARAM */
561 #define YYPARSE_PARAM_ARG
562 #define YYPARSE_PARAM_DECL
563 #endif /* not YYPARSE_PARAM */
564
565 /* Prevent warning if -Wstrict-prototypes. */
566 #ifdef __GNUC__
567 #ifdef YYPARSE_PARAM
568 int yyparse (void *);
569 #else
570 int yyparse (void);
571 #endif
572 #endif
573
574 int
yyparse(YYPARSE_PARAM_ARG)575 yyparse(YYPARSE_PARAM_ARG)
576 YYPARSE_PARAM_DECL
577 {
578 register int yystate;
579 register int yyn;
580 register short *yyssp;
581 register YYSTYPE *yyvsp;
582 int yyerrstatus; /* number of tokens to shift before error messages enabled */
583 int yychar1 = 0; /* lookahead token as an internal (translated) token number */
584
585 short yyssa[YYINITDEPTH]; /* the state stack */
586 YYSTYPE yyvsa[YYINITDEPTH]; /* the semantic value stack */
587
588 short *yyss = yyssa; /* refer to the stacks thru separate pointers */
589 YYSTYPE *yyvs = yyvsa; /* to allow yyoverflow to reallocate them elsewhere */
590
591 #ifdef YYLSP_NEEDED
592 YYLTYPE yylsa[YYINITDEPTH]; /* the location stack */
593 YYLTYPE *yyls = yylsa;
594 YYLTYPE *yylsp;
595
596 #define YYPOPSTACK (yyvsp--, yyssp--, yylsp--)
597 #else
598 #define YYPOPSTACK (yyvsp--, yyssp--)
599 #endif
600
601 int yystacksize = YYINITDEPTH;
602 int yyfree_stacks = 0;
603
604 #ifdef YYPURE
605 int yychar;
606 YYSTYPE yylval;
607 int yynerrs;
608 #ifdef YYLSP_NEEDED
609 YYLTYPE yylloc;
610 #endif
611 #endif
612
613 YYSTYPE yyval; /* the variable used to return */
614 /* semantic values from the action */
615 /* routines */
616
617 int yylen;
618
619 #if YYDEBUG != 0
620 if (yydebug)
621 fprintf(stderr, "Starting parse\n");
622 #endif
623
624 yystate = 0;
625 yyerrstatus = 0;
626 yynerrs = 0;
627 yychar = YYEMPTY; /* Cause a token to be read. */
628
629 /* Initialize stack pointers.
630 Waste one element of value and location stack
631 so that they stay on the same level as the state stack.
632 The wasted elements are never initialized. */
633
634 yyssp = yyss - 1;
635 yyvsp = yyvs;
636 #ifdef YYLSP_NEEDED
637 yylsp = yyls;
638 #endif
639
640 /* Push a new state, which is found in yystate . */
641 /* In all cases, when you get here, the value and location stacks
642 have just been pushed. so pushing a state here evens the stacks. */
643 yynewstate:
644
645 *++yyssp = yystate;
646
647 if (yyssp >= yyss + yystacksize - 1)
648 {
649 /* Give user a chance to reallocate the stack */
650 /* Use copies of these so that the &'s don't force the real ones into memory. */
651 YYSTYPE *yyvs1 = yyvs;
652 short *yyss1 = yyss;
653 #ifdef YYLSP_NEEDED
654 YYLTYPE *yyls1 = yyls;
655 #endif
656
657 /* Get the current used size of the three stacks, in elements. */
658 int size = yyssp - yyss + 1;
659
660 #ifdef yyoverflow
661 /* Each stack pointer address is followed by the size of
662 the data in use in that stack, in bytes. */
663 #ifdef YYLSP_NEEDED
664 /* This used to be a conditional around just the two extra args,
665 but that might be undefined if yyoverflow is a macro. */
666 yyoverflow("parser stack overflow",
667 &yyss1, size * sizeof (*yyssp),
668 &yyvs1, size * sizeof (*yyvsp),
669 &yyls1, size * sizeof (*yylsp),
670 &yystacksize);
671 #else
672 yyoverflow("parser stack overflow",
673 &yyss1, size * sizeof (*yyssp),
674 &yyvs1, size * sizeof (*yyvsp),
675 &yystacksize);
676 #endif
677
678 yyss = yyss1; yyvs = yyvs1;
679 #ifdef YYLSP_NEEDED
680 yyls = yyls1;
681 #endif
682 #else /* no yyoverflow */
683 /* Extend the stack our own way. */
684 if (yystacksize >= YYMAXDEPTH)
685 {
686 yyerror("parser stack overflow");
687 if (yyfree_stacks)
688 {
689 free (yyss);
690 free (yyvs);
691 #ifdef YYLSP_NEEDED
692 free (yyls);
693 #endif
694 }
695 return 2;
696 }
697 yystacksize *= 2;
698 if (yystacksize > YYMAXDEPTH)
699 yystacksize = YYMAXDEPTH;
700 #ifndef YYSTACK_USE_ALLOCA
701 yyfree_stacks = 1;
702 #endif
703 yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
704 __yy_memcpy ((char *)yyss, (char *)yyss1,
705 size * (unsigned int) sizeof (*yyssp));
706 yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
707 __yy_memcpy ((char *)yyvs, (char *)yyvs1,
708 size * (unsigned int) sizeof (*yyvsp));
709 #ifdef YYLSP_NEEDED
710 yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
711 __yy_memcpy ((char *)yyls, (char *)yyls1,
712 size * (unsigned int) sizeof (*yylsp));
713 #endif
714 #endif /* no yyoverflow */
715
716 yyssp = yyss + size - 1;
717 yyvsp = yyvs + size - 1;
718 #ifdef YYLSP_NEEDED
719 yylsp = yyls + size - 1;
720 #endif
721
722 #if YYDEBUG != 0
723 if (yydebug)
724 fprintf(stderr, "Stack size increased to %d\n", yystacksize);
725 #endif
726
727 if (yyssp >= yyss + yystacksize - 1)
728 YYABORT;
729 }
730
731 #if YYDEBUG != 0
732 if (yydebug)
733 fprintf(stderr, "Entering state %d\n", yystate);
734 #endif
735
736 goto yybackup;
737 yybackup:
738
739 /* Do appropriate processing given the current state. */
740 /* Read a lookahead token if we need one and don't already have one. */
741 /* yyresume: */
742
743 /* First try to decide what to do without reference to lookahead token. */
744
745 yyn = yypact[yystate];
746 if (yyn == YYFLAG)
747 goto yydefault;
748
749 /* Not known => get a lookahead token if don't already have one. */
750
751 /* yychar is either YYEMPTY or YYEOF
752 or a valid token in external form. */
753
754 if (yychar == YYEMPTY)
755 {
756 #if YYDEBUG != 0
757 if (yydebug)
758 fprintf(stderr, "Reading a token: ");
759 #endif
760 yychar = YYLEX;
761 }
762
763 /* Convert token to internal form (in yychar1) for indexing tables with */
764
765 if (yychar <= 0) /* This means end of input. */
766 {
767 yychar1 = 0;
768 yychar = YYEOF; /* Don't call YYLEX any more */
769
770 #if YYDEBUG != 0
771 if (yydebug)
772 fprintf(stderr, "Now at end of input.\n");
773 #endif
774 }
775 else
776 {
777 yychar1 = YYTRANSLATE(yychar);
778
779 #if YYDEBUG != 0
780 if (yydebug)
781 {
782 fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
783 /* Give the individual parser a way to print the precise meaning
784 of a token, for further debugging info. */
785 #ifdef YYPRINT
786 YYPRINT (stderr, yychar, yylval);
787 #endif
788 fprintf (stderr, ")\n");
789 }
790 #endif
791 }
792
793 yyn += yychar1;
794 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
795 goto yydefault;
796
797 yyn = yytable[yyn];
798
799 /* yyn is what to do for this token type in this state.
800 Negative => reduce, -yyn is rule number.
801 Positive => shift, yyn is new state.
802 New state is final state => don't bother to shift,
803 just return success.
804 0, or most negative number => error. */
805
806 if (yyn < 0)
807 {
808 if (yyn == YYFLAG)
809 goto yyerrlab;
810 yyn = -yyn;
811 goto yyreduce;
812 }
813 else if (yyn == 0)
814 goto yyerrlab;
815
816 if (yyn == YYFINAL)
817 YYACCEPT;
818
819 /* Shift the lookahead token. */
820
821 #if YYDEBUG != 0
822 if (yydebug)
823 fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
824 #endif
825
826 /* Discard the token being shifted unless it is eof. */
827 if (yychar != YYEOF)
828 yychar = YYEMPTY;
829
830 *++yyvsp = yylval;
831 #ifdef YYLSP_NEEDED
832 *++yylsp = yylloc;
833 #endif
834
835 /* count tokens shifted since error; after three, turn off error status. */
836 if (yyerrstatus) yyerrstatus--;
837
838 yystate = yyn;
839 goto yynewstate;
840
841 /* Do the default action for the current state. */
842 yydefault:
843
844 yyn = yydefact[yystate];
845 if (yyn == 0)
846 goto yyerrlab;
847
848 /* Do a reduction. yyn is the number of a rule to reduce with. */
849 yyreduce:
850 yylen = yyr2[yyn];
851 if (yylen > 0)
852 yyval = yyvsp[1-yylen]; /* implement default value of the action */
853
854 #if YYDEBUG != 0
855 if (yydebug)
856 {
857 int i;
858
859 fprintf (stderr, "Reducing via rule %d (line %d), ",
860 yyn, yyrline[yyn]);
861
862 /* Print the symbols being reduced, and their result. */
863 for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
864 fprintf (stderr, "%s ", yytname[yyrhs[i]]);
865 fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
866 }
867 #endif
868
869
870 switch (yyn) {
871
872 case 1:
873 #line 55 "grammy.y"
874 {;
875 break;}
876 case 2:
877 #line 61 "grammy.y"
878 {;
879 break;}
880 case 3:
881 #line 62 "grammy.y"
882 {;
883 break;}
884 case 10:
885 #line 85 "grammy.y"
886 {
887 G_LOCK (verrou_domains);
888 DomainList = polyhedron_declaration (yyvsp[-5].Chain, NULL, DomainList);
889 //graphic_actualize();
890 G_UNLOCK (verrou_domains);
891 ;
892 break;}
893 case 11:
894 #line 93 "grammy.y"
895 { curr_matrix = Matrix_Alloc (WS, dim+1); ;
896 break;}
897 case 12:
898 #line 95 "grammy.y"
899 {
900 G_LOCK (verrou_domains);
901 DomainList = polyhedron_declaration (yyvsp[-8].Chain, VarList, DomainList);
902 graphic_actualize();
903 G_UNLOCK (verrou_domains);
904 ;
905 break;}
906 case 13:
907 #line 103 "grammy.y"
908 {
909 yyclearin; //discards lookahead
910 yyerrok;
911 init_curr_vars();
912 printf (">> error in constraints \n");
913 ;
914 break;}
915 case 14:
916 #line 110 "grammy.y"
917 {
918 yyclearin; //discards lookahead
919 yyerrok;
920 init_curr_vars();
921 printf (">> '|' missing\n");
922 ;
923 break;}
924 case 15:
925 #line 117 "grammy.y"
926 {
927 yyclearin; //discards lookahead
928 yyerrok;
929 init_curr_vars();
930 printf (">> error in variable list\n");
931 ;
932 break;}
933 case 16:
934 #line 126 "grammy.y"
935 { MatrixList = add_matrix_to_list (yyvsp[-5].Chain, MatrixList); ;
936 break;}
937 case 17:
938 #line 134 "grammy.y"
939 {
940 G_LOCK (verrou_domains);
941 DomainList = gen_binop_pol (yyvsp[-5].Chain, yyvsp[-3].Chain, yyvsp[-1].Chain, "union", DomainList);
942 graphic_actualize();
943 G_UNLOCK (verrou_domains);
944 ;
945 break;}
946 case 18:
947 #line 141 "grammy.y"
948 { fprintf (stdout, "> Syntax : 'res' := 'P1' union 'P2' ;\n");;
949 break;}
950 case 19:
951 #line 145 "grammy.y"
952 {
953 G_LOCK (verrou_domains);
954 DomainList = gen_binop_pol (yyvsp[-5].Chain, yyvsp[-3].Chain, yyvsp[-1].Chain, "inter", DomainList);
955 graphic_actualize();
956 G_UNLOCK (verrou_domains);
957 ;
958 break;}
959 case 20:
960 #line 152 "grammy.y"
961 { fprintf (stdout, "> Syntax : 'res' := 'P1' inter 'P2' ;\n");;
962 break;}
963 case 21:
964 #line 156 "grammy.y"
965 {
966 G_LOCK (verrou_domains);
967 DomainList = gen_binop_pol (yyvsp[-5].Chain, yyvsp[-3].Chain, yyvsp[-1].Chain, "diff", DomainList);
968 graphic_actualize();
969 G_UNLOCK (verrou_domains);
970 ;
971 break;}
972 case 22:
973 #line 163 "grammy.y"
974 { fprintf (stdout, "> Syntax : 'res' := 'P1' diff 'P2' ;\n");;
975 break;}
976 case 23:
977 #line 166 "grammy.y"
978 {
979 G_LOCK (verrou_domains);
980 DomainList = gen_image (yyvsp[-8].Chain, yyvsp[-4].Chain, yyvsp[-2].Chain, "image", DomainList);
981 graphic_actualize();
982 G_UNLOCK (verrou_domains);
983 ;
984 break;}
985 case 24:
986 #line 173 "grammy.y"
987 { fprintf (stdout, "> Syntax : 'name' := image ('domain', 'matrix') ;\n");;
988 break;}
989 case 25:
990 #line 177 "grammy.y"
991 {
992 G_LOCK (verrou_domains);
993 DomainList = gen_image (yyvsp[-8].Chain, yyvsp[-4].Chain, yyvsp[-2].Chain, "preimage", DomainList);
994 graphic_actualize();
995 G_UNLOCK (verrou_domains);
996 ;
997 break;}
998 case 26:
999 #line 184 "grammy.y"
1000 { fprintf (stdout, "> Syntax : 'name' := preimage ('domain', 'matrix') ;\n");;
1001 break;}
1002 case 27:
1003 #line 188 "grammy.y"
1004 {
1005 G_LOCK (verrou_domains);
1006 DomainList = gen_disjoint (yyvsp[-4].Chain, yyvsp[-1].Chain, DomainList);
1007 graphic_actualize();
1008 G_UNLOCK (verrou_domains);
1009 ;
1010 break;}
1011 case 28:
1012 #line 196 "grammy.y"
1013 {
1014 G_LOCK (verrou_domains);
1015 DomainList = gen_convex (yyvsp[-4].Chain, yyvsp[-1].Chain, DomainList);
1016 graphic_actualize();
1017 G_UNLOCK (verrou_domains);
1018 ;
1019 break;}
1020 case 29:
1021 #line 203 "grammy.y"
1022 { fprintf (stdout, "> Syntax : 'name' := convex 'domain' ;\n");;
1023 break;}
1024 case 30:
1025 #line 207 "grammy.y"
1026 {
1027 G_LOCK (verrou_domains);
1028 gen_vert (yyvsp[-4].Chain, yyvsp[-2].Chain, DomainList);
1029 G_UNLOCK (verrou_domains);
1030 ;
1031 break;}
1032 case 31:
1033 #line 213 "grammy.y"
1034 { fprintf (stdout, "> Syntax : vertices ('domain', 'context') ;\n");;
1035 break;}
1036 case 32:
1037 #line 216 "grammy.y"
1038 {
1039 G_LOCK (verrou_domains);
1040 gen_ehrhart (yyvsp[-4].Chain, yyvsp[-2].Chain, DomainList);
1041 G_UNLOCK (verrou_domains);
1042 ;
1043 break;}
1044 case 33:
1045 #line 222 "grammy.y"
1046 { fprintf (stdout, "> Syntax : ehrhart ('domain', 'context') ;\n");;
1047 break;}
1048 case 34:
1049 #line 225 "grammy.y"
1050 {
1051
1052 DimNP = (int)yyvsp[-4].Val;
1053 if (TmpDomainName)
1054 free (TmpDomainName);
1055 TmpDomainName = (char *)malloc ((strlen(yyvsp[-2].Chain)+1)*sizeof(char));
1056 strcpy(TmpDomainName, yyvsp[-2].Chain);
1057 gdk_threads_enter ();
1058 init_visu ();
1059 gdk_threads_leave ();
1060 ;
1061 break;}
1062 case 35:
1063 #line 237 "grammy.y"
1064 { fprintf (stdout, "> Syntax : initvisu ('dimension', 'context') ;\n");;
1065 break;}
1066 case 36:
1067 #line 240 "grammy.y"
1068 {
1069 if (TmpDomainName)
1070 free (TmpDomainName);
1071 TmpDomainName = (char*)malloc((strlen(yyvsp[-2].Chain)+1)*sizeof(char));
1072 strcpy (TmpDomainName, yyvsp[-2].Chain);
1073 gdk_threads_enter ();
1074 /* Recherche du domaine dans la liste des domaines visualisables */
1075 G_LOCK (verrou_domains);
1076 for( domain_cur = DomainList; domain_cur; domain_cur = domain_cur->next )
1077 {
1078 if (strcmp (domain_cur->name, TmpDomainName) == 0)
1079 {
1080 row = gtk_clist_find_row_from_data (
1081 GTK_CLIST (clist),
1082 (gpointer) domain_cur);
1083 break;
1084 }
1085 }
1086 G_UNLOCK (verrou_domains);
1087 if (domain_cur == NULL)
1088 {
1089 char errmsg[100];
1090 sprintf (errmsg, " '%s' undeclared - visu: command ignored", yyvsp[-2].Chain);
1091 yyerror (errmsg);
1092 }
1093 else
1094 { /* Afficher/Masquer */
1095 if (row != -1)
1096 reinit = PropertiesActions (GTK_CLIST (clist), row, 1, NULL, NULL);
1097 else
1098 Warn ("Can't visualize this domain (probably wrong dimension)!");
1099 }
1100 gdk_threads_leave ();
1101
1102 ;
1103 break;}
1104 case 37:
1105 #line 276 "grammy.y"
1106 { fprintf (stdout, "> Syntax : visu (domain) ;\n"); ;
1107 break;}
1108 case 38:
1109 #line 279 "grammy.y"
1110 {
1111 Domain *tmp;
1112 ChainMatrix *mat;
1113 char **pname;
1114 fprintf(stdout, "> Domain List: \n");
1115 for(tmp=DomainList; tmp ; tmp=tmp->next )
1116 {
1117 pname = chaintochar (tmp->v_list);
1118 fprintf (stdout, "> %s := ", tmp->name);
1119 VP_Print_Domain (stdout, tmp->Pdomain, pname);
1120 }
1121 fprintf(stdout, "\n");
1122 fprintf(stdout, "> Matrix List : \n\t");
1123 for( mat = MatrixList; mat ; mat=mat->next )
1124 {
1125 if (mat->next)
1126 fprintf(stdout, "%s, ", mat->name);
1127 else
1128 fprintf(stdout, "%s\n", mat->name);
1129 }
1130 printf ("\n");
1131 ;
1132 break;}
1133 case 39:
1134 #line 302 "grammy.y"
1135 {
1136 char **pname; // param name
1137 Domain *dom;
1138 Matrix *mat;
1139 char errmsg[100];
1140
1141 dom = search_domain_in_list (yyvsp[-1].Chain, DomainList);
1142 if (dom)
1143 {
1144 // conversion de v_list en char**
1145 pname = chaintochar (dom->v_list);
1146 fprintf (stdout, "> %s := ", yyvsp[-1].Chain);
1147 VP_Print_Domain (stdout, dom->Pdomain, pname);
1148 }
1149 else
1150 {
1151 mat = search_matrix_in_list (yyvsp[-1].Chain, MatrixList);
1152 if (mat == NULL)
1153 {
1154 sprintf (errmsg, " '%s' undeclared - print: command ignored", yyvsp[-1].Chain);
1155 yyerror (errmsg);
1156 }
1157 else
1158 {
1159 fprintf(stdout, "> %s := ", yyvsp[-1].Chain);
1160 VP_Print_Matrix (stdout, mat);
1161 }
1162 }
1163 ;
1164 break;}
1165 case 40:
1166 #line 331 "grammy.y"
1167 { fprintf (stdout, "> Syntax: print 'name' ;\n");;
1168 break;}
1169 case 41:
1170 #line 334 "grammy.y"
1171 { /* print domain, polylib format */
1172 Domain *tmp;
1173 Matrix *mat;
1174 char errmsg[100];
1175 tmp = search_domain_in_list (yyvsp[-1].Chain, DomainList);
1176 if (tmp )
1177 {
1178 fprintf (stdout, "> Domain '%s':\n", yyvsp[-1].Chain);
1179 Polyhedron_Print (stdout, "%3d", tmp->Pdomain);
1180 printf("\n");
1181 }
1182 else
1183 {
1184 mat = search_matrix_in_list (yyvsp[-1].Chain, MatrixList);
1185 if (mat)
1186 {
1187 fprintf(stdout, "> Matrix '%s':\n", yyvsp[-1].Chain);
1188 Matrix_Print (stdout, "%4d ", mat);
1189 }
1190 else
1191 {
1192 sprintf (errmsg, " '%s' undeclared - PLprint: command ignored", yyvsp[-1].Chain);
1193 yyerror (errmsg);
1194 }
1195 }
1196 ;
1197 break;}
1198 case 42:
1199 #line 360 "grammy.y"
1200 { fprintf (stdout, "> Syntax: PLprint 'name' ;\n"); ;
1201 break;}
1202 case 43:
1203 #line 362 "grammy.y"
1204 { /* print constraints matrix(-ces), polylib format */
1205 Domain *tmp;
1206 char errmsg[100];
1207 tmp = search_domain_in_list (yyvsp[-1].Chain, DomainList);
1208 if (tmp == NULL)
1209 {
1210 sprintf (errmsg, " '%s' undeclared - PLcons: command ignored\n", yyvsp[-1].Chain);
1211 yyerror (errmsg);
1212 }
1213 else
1214 {
1215 fprintf (stdout, "> Domain '%s' - Constraints matrix:\n", yyvsp[-1].Chain);
1216 Constraints_Print (stdout, "%3d", tmp->Pdomain);
1217 printf("\n");
1218 }
1219 ;
1220 break;}
1221 case 44:
1222 #line 378 "grammy.y"
1223 { fprintf (stdout, "> Syntax: PLcons 'domain' ;\n"); ;
1224 break;}
1225 case 45:
1226 #line 380 "grammy.y"
1227 { /* print rays matrix(-ces), polylib format */
1228 Domain *tmp;
1229 char errmsg[100];
1230 tmp = search_domain_in_list (yyvsp[-1].Chain, DomainList);
1231 if (tmp == NULL)
1232 {
1233 sprintf (errmsg, " '%s' undeclared - PLrays: command ignored\n", yyvsp[-1].Chain);
1234 yyerror (errmsg);
1235 }
1236 else
1237 {
1238 fprintf (stdout, "> Domain '%s' - Rays matrix:\n", yyvsp[-1].Chain);
1239 Rays_Print (stdout, "%3d", tmp->Pdomain);
1240 printf("\n");
1241 }
1242 ;
1243 break;}
1244 case 46:
1245 #line 396 "grammy.y"
1246 { fprintf (stdout, "> Syntax: PLrays 'domain' ;\n"); ;
1247 break;}
1248 case 47:
1249 #line 401 "grammy.y"
1250 { Domain *tmp;
1251 Matrix *mat;
1252 char errmsg[100];
1253
1254 tmp = search_domain_in_list (yyvsp[-1].Chain, DomainList);
1255 if (tmp)
1256 {
1257 DomainList = delete_domain_in_list (yyvsp[-1].Chain, DomainList);
1258 fprintf(stdout, "> Succeded ! '%s' is deleted from DomainList\n", yyvsp[-1].Chain);
1259 }
1260 else
1261 {
1262 mat = search_matrix_in_list (yyvsp[-1].Chain, MatrixList);
1263 if (mat)
1264 {
1265 MatrixList = delete_matrix_in_list (yyvsp[-1].Chain, MatrixList);
1266 fprintf(stdout, "> Succeded ! '%s' is deleted from MatrixList\n", yyvsp[-1].Chain);
1267 }
1268 else
1269 {
1270 sprintf (errmsg, "> '%s' undeclared - del : command ignored\n", yyvsp[-1].Chain);
1271 yyerror (errmsg);
1272 }
1273 }
1274 ;
1275 break;}
1276 case 48:
1277 #line 427 "grammy.y"
1278 { fprintf (stdout, "> Syntax : del 'domain' ;\n"); ;
1279 break;}
1280 case 49:
1281 #line 431 "grammy.y"
1282 { help_print (); ;
1283 break;}
1284 case 50:
1285 #line 435 "grammy.y"
1286 { if (DEBUG == 1)
1287 {
1288 print_domain_list (DomainList);
1289 print_matrix_list (MatrixList);
1290 }
1291 printf ("\n bye...\n\n");
1292 return (-1);
1293 ;
1294 break;}
1295 case 51:
1296 #line 444 "grammy.y"
1297 { yyclearin; //discards lookahead
1298 yyerrok;
1299 printf (">> bad command - type 'help' for informations about syntax \n");
1300 ;
1301 break;}
1302 case 52:
1303 #line 450 "grammy.y"
1304 { yyclearin; //discards lookahead
1305 yyerrok;
1306 printf (">> there must be a ':=' after identifier ! \n");
1307 ;
1308 break;}
1309 case 53:
1310 #line 456 "grammy.y"
1311 { printf (">> bad command - type 'help' for informations about syntax\n");
1312 yyclearin; yyerrok;
1313 init_curr_vars();
1314 ;
1315 break;}
1316 case 54:
1317 #line 468 "grammy.y"
1318 {
1319 IndList tmp = yyvsp[-1].Mat_line;
1320 if (curr_matrix)
1321 {
1322 if (curr_matrix->NbColumns == dim)
1323 {
1324 while (tmp)
1325 {
1326 curr_matrix->p[curr_constr_num][tmp->pos] = tmp->val;
1327 tmp = tmp->suiv;
1328 }
1329 curr_constr_num ++;
1330 dim = 1;
1331 }
1332 else
1333 {
1334 input_error = true;
1335 Matrix_Free (curr_matrix);
1336 curr_matrix = NULL;
1337 fprintf (stdout, "> Matrix declaration : error in dimension\n");
1338 }
1339 }
1340 ;
1341 break;}
1342 case 55:
1343 #line 492 "grammy.y"
1344 { IndList tmp = yyvsp[-1].Mat_line;
1345 curr_matrix = Matrix_Alloc (100, dim);
1346 while (tmp)
1347 {
1348 curr_matrix->p[curr_constr_num][tmp->pos] = tmp->val;
1349 tmp = tmp->suiv;
1350 }
1351 curr_constr_num ++;
1352 dim = 1;
1353 ;
1354 break;}
1355 case 56:
1356 #line 509 "grammy.y"
1357 { yyval.Mat_line = (IndList)malloc(sizeof(t_IndList));
1358 yyval.Mat_line->pos = dim;
1359 yyval.Mat_line->val = yyvsp[0].Val;
1360 yyval.Mat_line->suiv = yyvsp[-2].Mat_line;
1361 dim ++;
1362 ;
1363 break;}
1364 case 57:
1365 #line 518 "grammy.y"
1366 { yyval.Mat_line = (IndList)malloc(sizeof(t_IndList));
1367 yyval.Mat_line->pos = 0;
1368 yyval.Mat_line->val = yyvsp[0].Val;
1369 yyval.Mat_line->suiv = NULL;
1370 ;
1371 break;}
1372 case 58:
1373 #line 525 "grammy.y"
1374 { yyval.Val = yyvsp[0].Val; ;
1375 break;}
1376 case 59:
1377 #line 526 "grammy.y"
1378 { yyval.Val = - yyvsp[0].Val; ;
1379 break;}
1380 case 60:
1381 #line 527 "grammy.y"
1382 { yyval.Val = yyvsp[0].Val; ;
1383 break;}
1384 case 61:
1385 #line 532 "grammy.y"
1386 { VarList = add_var_to_list (yyvsp[0].Chain, VarList); ;
1387 break;}
1388 case 62:
1389 #line 533 "grammy.y"
1390 { VarList = add_var_to_list (yyvsp[0].Chain, VarList); ;
1391 break;}
1392 case 63:
1393 #line 537 "grammy.y"
1394 {;
1395 break;}
1396 case 64:
1397 #line 538 "grammy.y"
1398 {;
1399 break;}
1400 case 65:
1401 #line 539 "grammy.y"
1402 {;
1403 break;}
1404 case 66:
1405 #line 545 "grammy.y"
1406 {;
1407 break;}
1408 case 67:
1409 #line 546 "grammy.y"
1410 {;
1411 break;}
1412 case 68:
1413 #line 551 "grammy.y"
1414 { if (curr_matrix)
1415 {
1416 if (DEBUG == 1) printf("REDUCE INEG : INEG OP INEG\n");
1417 yyval.A_Exp.Mline = yyvsp[-2].A_Exp.Mline;
1418 yyval.A_Exp.Const = yyvsp[-2].A_Exp.Const;
1419 if (DEBUG == 1)
1420 {
1421 printf("Membre gauche : ");
1422 Affiche_listeInd (yyval.A_Exp.Mline);
1423 printf("Membre droit : ");
1424 Affiche_listeInd (yyvsp[0].A_Exp.Mline);
1425 }
1426 curr_matrix->p[curr_constr_num][0] = 1;
1427 switch (yyvsp[-1].Op) {
1428 case 1 : /* <= */
1429 while (yyvsp[-2].A_Exp.Mline)
1430 {
1431 curr_matrix->p[curr_constr_num][(yyvsp[-2].A_Exp.Mline)->pos] += - (yyvsp[-2].A_Exp.Mline)->val;
1432 yyvsp[-2].A_Exp.Mline = (yyvsp[-2].A_Exp.Mline)->suiv;
1433 }
1434 while (yyvsp[0].A_Exp.Mline)
1435 {
1436 curr_matrix->p[curr_constr_num][(yyvsp[0].A_Exp.Mline)->pos] += (yyvsp[0].A_Exp.Mline)->val;
1437 yyvsp[0].A_Exp.Mline = (yyvsp[0].A_Exp.Mline)->suiv;
1438 }
1439
1440 /* constante */
1441 curr_matrix->p[curr_constr_num][dim] = yyvsp[0].A_Exp.Const - yyvsp[-2].A_Exp.Const;
1442 break;
1443
1444 case 2 : /* >= */
1445 while (yyvsp[-2].A_Exp.Mline)
1446 {
1447 curr_matrix->p[curr_constr_num][(yyvsp[-2].A_Exp.Mline)->pos] += (yyvsp[-2].A_Exp.Mline)->val;
1448 yyvsp[-2].A_Exp.Mline = (yyvsp[-2].A_Exp.Mline)->suiv;
1449 }
1450 while (yyvsp[0].A_Exp.Mline)
1451 {
1452 curr_matrix->p[curr_constr_num][(yyvsp[0].A_Exp.Mline)->pos] += - (yyvsp[0].A_Exp.Mline)->val;
1453 yyvsp[0].A_Exp.Mline = (yyvsp[0].A_Exp.Mline)->suiv;
1454 }
1455 curr_matrix->p[curr_constr_num][dim] = yyvsp[-2].A_Exp.Const - yyvsp[0].A_Exp.Const;
1456 break;
1457
1458 case 3 : /* < */
1459 while (yyvsp[-2].A_Exp.Mline)
1460 {
1461 curr_matrix->p[curr_constr_num][(yyvsp[-2].A_Exp.Mline)->pos] += - (yyvsp[-2].A_Exp.Mline)->val;
1462 yyvsp[-2].A_Exp.Mline = (yyvsp[-2].A_Exp.Mline)->suiv;
1463 }
1464 while (yyvsp[0].A_Exp.Mline)
1465 {
1466 curr_matrix->p[curr_constr_num][(yyvsp[0].A_Exp.Mline)->pos] += (yyvsp[0].A_Exp.Mline)->val;
1467 yyvsp[0].A_Exp.Mline = (yyvsp[0].A_Exp.Mline)->suiv;
1468 }
1469
1470 /* constante */
1471 curr_matrix->p[curr_constr_num][dim] = yyvsp[0].A_Exp.Const - yyvsp[-2].A_Exp.Const - 1;
1472 break;
1473
1474 case 4 : /* > */
1475 while (yyvsp[-2].A_Exp.Mline)
1476 {
1477 curr_matrix->p[curr_constr_num][(yyvsp[-2].A_Exp.Mline)->pos] += (yyvsp[-2].A_Exp.Mline)->val;
1478 yyvsp[-2].A_Exp.Mline = (yyvsp[-2].A_Exp.Mline)->suiv;
1479 }
1480 while (yyvsp[0].A_Exp.Mline)
1481 {
1482 curr_matrix->p[curr_constr_num][(yyvsp[0].A_Exp.Mline)->pos] += - (yyvsp[0].A_Exp.Mline)->val;
1483 yyvsp[0].A_Exp.Mline = (yyvsp[0].A_Exp.Mline)->suiv;
1484 }
1485 curr_matrix->p[curr_constr_num][dim] = yyvsp[-2].A_Exp.Const - yyvsp[0].A_Exp.Const - 1;
1486 break;
1487
1488 default : fprintf (stderr, "ineg : ineg op ineg : C'EST PAS NORMAL DETRE LA\n");
1489 break;
1490 } //switch
1491
1492 curr_constr_num ++;
1493 }
1494 ;
1495 break;}
1496 case 69:
1497 #line 634 "grammy.y"
1498 { if (DEBUG == 1) printf("REDUCE INEG : ARTHM_EXP\n");
1499 yyval.A_Exp.Mline = yyvsp[0].A_Exp.Mline;
1500 yyval.A_Exp.Const = yyvsp[0].A_Exp.Const;
1501 ;
1502 break;}
1503 case 70:
1504 #line 642 "grammy.y"
1505 { if (curr_matrix)
1506 {
1507 if (DEBUG == 1) printf ("REDUCE EG : E = E\n");
1508 curr_matrix->p[curr_constr_num][0] = 0;
1509 while (yyvsp[-2].A_Exp.Mline)
1510 {
1511 curr_matrix->p[curr_constr_num][(yyvsp[-2].A_Exp.Mline)->pos] += (yyvsp[-2].A_Exp.Mline)->val;
1512 yyvsp[-2].A_Exp.Mline = (yyvsp[-2].A_Exp.Mline)->suiv;
1513 }
1514 while (yyvsp[0].A_Exp.Mline)
1515 {
1516 curr_matrix->p[curr_constr_num][(yyvsp[0].A_Exp.Mline)->pos] += - (yyvsp[0].A_Exp.Mline)->val;
1517 yyvsp[0].A_Exp.Mline = (yyvsp[0].A_Exp.Mline)->suiv;
1518 }
1519
1520 /* constante */
1521 curr_matrix->p[curr_constr_num][dim] = yyvsp[-2].A_Exp.Const - yyvsp[0].A_Exp.Const;
1522 curr_constr_num ++;
1523 }
1524 ;
1525 break;}
1526 case 71:
1527 #line 666 "grammy.y"
1528 { yyval.Op = 3; ;
1529 break;}
1530 case 72:
1531 #line 667 "grammy.y"
1532 { yyval.Op = 4; ;
1533 break;}
1534 case 73:
1535 #line 668 "grammy.y"
1536 { yyval.Op = 1; ;
1537 break;}
1538 case 74:
1539 #line 669 "grammy.y"
1540 { yyval.Op = 2; ;
1541 break;}
1542 case 75:
1543 #line 678 "grammy.y"
1544 { if (DEBUG == 1)
1545 printf ("E1 + E2\n");
1546 yyval.A_Exp.Mline = concat (yyvsp[-2].A_Exp.Mline, yyvsp[0].A_Exp.Mline);
1547 yyval.A_Exp.Const = yyvsp[-2].A_Exp.Const + yyvsp[0].A_Exp.Const;
1548 if (DEBUG == 1)
1549 Affiche_listeInd (yyval.A_Exp.Mline); ;
1550 break;}
1551 case 76:
1552 #line 685 "grammy.y"
1553 { yyval.A_Exp.Mline = concat (yyvsp[-2].A_Exp.Mline, neg(yyvsp[0].A_Exp.Mline));
1554 yyval.A_Exp.Const = yyvsp[-2].A_Exp.Const - yyvsp[0].A_Exp.Const; ;
1555 break;}
1556 case 77:
1557 #line 688 "grammy.y"
1558 { yyval.A_Exp.Mline = mult (yyvsp[0].A_Exp.Mline, yyvsp[-2].Val);
1559 yyval.A_Exp.Const = yyvsp[-2].Val * yyvsp[0].A_Exp.Const; ;
1560 break;}
1561 case 78:
1562 #line 691 "grammy.y"
1563 { yyval.A_Exp.Mline = yyvsp[-1].A_Exp.Mline;
1564 yyval.A_Exp.Const = yyvsp[-1].A_Exp.Const; ;
1565 break;}
1566 case 79:
1567 #line 694 "grammy.y"
1568 { yyval.A_Exp.Mline = neg(yyvsp[0].A_Exp.Mline);
1569 yyval.A_Exp.Const = - yyvsp[0].A_Exp.Const; ;
1570 break;}
1571 case 80:
1572 #line 697 "grammy.y"
1573 { yyval.A_Exp.Mline = (IndList)malloc (sizeof(t_IndList));
1574 yyval.A_Exp.Mline = mult (search_var_in_list (yyvsp[0].Chain, VarList), yyvsp[-1].Val);
1575 yyval.A_Exp.Const = 0; ;
1576 break;}
1577 case 81:
1578 #line 701 "grammy.y"
1579 { yyval.A_Exp.Mline = (IndList)malloc (sizeof(t_IndList));
1580 yyval.A_Exp.Mline = search_var_in_list (yyvsp[0].Chain, VarList);
1581 yyval.A_Exp.Const = 0;
1582 if (DEBUG == 1)
1583 Affiche_listeInd (yyval.A_Exp.Mline); ;
1584 break;}
1585 case 82:
1586 #line 707 "grammy.y"
1587 { if (DEBUG == 1) printf ("ValueConst = " P_VALUE_FMT "\n", yyvsp[0].Val);
1588 yyval.A_Exp.Mline = NULL;
1589 yyval.A_Exp.Const = yyvsp[0].Val; ;
1590 break;}
1591 }
1592 /* the action file gets copied in in place of this dollarsign */
1593 #line 543 "/usr/lib/bison.simple"
1594
1595 yyvsp -= yylen;
1596 yyssp -= yylen;
1597 #ifdef YYLSP_NEEDED
1598 yylsp -= yylen;
1599 #endif
1600
1601 #if YYDEBUG != 0
1602 if (yydebug)
1603 {
1604 short *ssp1 = yyss - 1;
1605 fprintf (stderr, "state stack now");
1606 while (ssp1 != yyssp)
1607 fprintf (stderr, " %d", *++ssp1);
1608 fprintf (stderr, "\n");
1609 }
1610 #endif
1611
1612 *++yyvsp = yyval;
1613
1614 #ifdef YYLSP_NEEDED
1615 yylsp++;
1616 if (yylen == 0)
1617 {
1618 yylsp->first_line = yylloc.first_line;
1619 yylsp->first_column = yylloc.first_column;
1620 yylsp->last_line = (yylsp-1)->last_line;
1621 yylsp->last_column = (yylsp-1)->last_column;
1622 yylsp->text = 0;
1623 }
1624 else
1625 {
1626 yylsp->last_line = (yylsp+yylen-1)->last_line;
1627 yylsp->last_column = (yylsp+yylen-1)->last_column;
1628 }
1629 #endif
1630
1631 /* Now "shift" the result of the reduction.
1632 Determine what state that goes to,
1633 based on the state we popped back to
1634 and the rule number reduced by. */
1635
1636 yyn = yyr1[yyn];
1637
1638 yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
1639 if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
1640 yystate = yytable[yystate];
1641 else
1642 yystate = yydefgoto[yyn - YYNTBASE];
1643
1644 goto yynewstate;
1645
1646 yyerrlab: /* here on detecting error */
1647
1648 if (! yyerrstatus)
1649 /* If not already recovering from an error, report this error. */
1650 {
1651 ++yynerrs;
1652
1653 #ifdef YYERROR_VERBOSE
1654 yyn = yypact[yystate];
1655
1656 if (yyn > YYFLAG && yyn < YYLAST)
1657 {
1658 int size = 0;
1659 char *msg;
1660 int x, count;
1661
1662 count = 0;
1663 /* Start X at -yyn if nec to avoid negative indexes in yycheck. */
1664 for (x = (yyn < 0 ? -yyn : 0);
1665 x < (sizeof(yytname) / sizeof(char *)); x++)
1666 if (yycheck[x + yyn] == x)
1667 size += strlen(yytname[x]) + 15, count++;
1668 msg = (char *) malloc(size + 15);
1669 if (msg != 0)
1670 {
1671 strcpy(msg, "parse error");
1672
1673 if (count < 5)
1674 {
1675 count = 0;
1676 for (x = (yyn < 0 ? -yyn : 0);
1677 x < (sizeof(yytname) / sizeof(char *)); x++)
1678 if (yycheck[x + yyn] == x)
1679 {
1680 strcat(msg, count == 0 ? ", expecting `" : " or `");
1681 strcat(msg, yytname[x]);
1682 strcat(msg, "'");
1683 count++;
1684 }
1685 }
1686 yyerror(msg);
1687 free(msg);
1688 }
1689 else
1690 yyerror ("parse error; also virtual memory exceeded");
1691 }
1692 else
1693 #endif /* YYERROR_VERBOSE */
1694 yyerror("parse error");
1695 }
1696
1697 goto yyerrlab1;
1698 yyerrlab1: /* here on error raised explicitly by an action */
1699
1700 if (yyerrstatus == 3)
1701 {
1702 /* if just tried and failed to reuse lookahead token after an error, discard it. */
1703
1704 /* return failure if at end of input */
1705 if (yychar == YYEOF)
1706 YYABORT;
1707
1708 #if YYDEBUG != 0
1709 if (yydebug)
1710 fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
1711 #endif
1712
1713 yychar = YYEMPTY;
1714 }
1715
1716 /* Else will try to reuse lookahead token
1717 after shifting the error token. */
1718
1719 yyerrstatus = 3; /* Each real token shifted decrements this */
1720
1721 goto yyerrhandle;
1722
1723 yyerrdefault: /* current state does not do anything special for the error token. */
1724
1725 #if 0
1726 /* This is wrong; only states that explicitly want error tokens
1727 should shift them. */
1728 yyn = yydefact[yystate]; /* If its default is to accept any token, ok. Otherwise pop it.*/
1729 if (yyn) goto yydefault;
1730 #endif
1731
1732 yyerrpop: /* pop the current state because it cannot handle the error token */
1733
1734 if (yyssp == yyss) YYABORT;
1735 yyvsp--;
1736 yystate = *--yyssp;
1737 #ifdef YYLSP_NEEDED
1738 yylsp--;
1739 #endif
1740
1741 #if YYDEBUG != 0
1742 if (yydebug)
1743 {
1744 short *ssp1 = yyss - 1;
1745 fprintf (stderr, "Error: state stack now");
1746 while (ssp1 != yyssp)
1747 fprintf (stderr, " %d", *++ssp1);
1748 fprintf (stderr, "\n");
1749 }
1750 #endif
1751
1752 yyerrhandle:
1753
1754 yyn = yypact[yystate];
1755 if (yyn == YYFLAG)
1756 goto yyerrdefault;
1757
1758 yyn += YYTERROR;
1759 if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
1760 goto yyerrdefault;
1761
1762 yyn = yytable[yyn];
1763 if (yyn < 0)
1764 {
1765 if (yyn == YYFLAG)
1766 goto yyerrpop;
1767 yyn = -yyn;
1768 goto yyreduce;
1769 }
1770 else if (yyn == 0)
1771 goto yyerrpop;
1772
1773 if (yyn == YYFINAL)
1774 YYACCEPT;
1775
1776 #if YYDEBUG != 0
1777 if (yydebug)
1778 fprintf(stderr, "Shifting error token, ");
1779 #endif
1780
1781 *++yyvsp = yylval;
1782 #ifdef YYLSP_NEEDED
1783 *++yylsp = yylloc;
1784 #endif
1785
1786 yystate = yyn;
1787 goto yynewstate;
1788
1789 yyacceptlab:
1790 /* YYACCEPT comes here. */
1791 if (yyfree_stacks)
1792 {
1793 free (yyss);
1794 free (yyvs);
1795 #ifdef YYLSP_NEEDED
1796 free (yyls);
1797 #endif
1798 }
1799 return 0;
1800
1801 yyabortlab:
1802 /* YYABORT comes here. */
1803 if (yyfree_stacks)
1804 {
1805 free (yyss);
1806 free (yyvs);
1807 #ifdef YYLSP_NEEDED
1808 free (yyls);
1809 #endif
1810 }
1811 return 1;
1812 }
1813 #line 714 "grammy.y"
1814
1815
1816
1817
1818 ChainMatrix *MatrixList = NULL; /* Matrix List */
1819 Domain *DomainList = NULL; /* Domain List */
1820 Matrix *curr_matrix; /* current matrix of constraints */
1821 int compteur = 1; /* line counter */
1822 ChainList VarList = NULL; /* current variables list */
1823 unsigned dim = 1; /* dimension of current polyhedron */
1824 int curr_constr_num = 0; /* current constraint number */
1825 int input_error = false; /* memorize if an error occurs during declaration */
1826
1827
1828 //old
yyerror2(char * s)1829 void yyerror2(char *s)
1830 {
1831 printf("> Error - line %d : %s \n", compteur, s);
1832 }
1833
1834
1835