2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these libraries and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 // $TOG: sheet.C /main/4 1997/12/23 11:20:35 bill $
25 __attribute__((unused))
26 static const char schemasccsid[] = "@(#)yaccpar 1.8 (Berkeley) 01/20/90";
32 #include "utility/funcs.h"
33 #include "schema/store_desc.h"
34 #include "schema/index_desc.h"
35 #include "schema/inv_desc.h"
36 #include "schema/agent_desc.h"
37 #include "schema/container_desc.h"
39 extern desc* desc_ptr;
40 extern desc* last_desc_ptr;
42 #define CAST_TO_STORED_OBJECT(x) ((stored_object_desc*)x)
43 #define CAST_TO_PAGE_STORE(x) ((page_store_desc*)x)
45 #define CAST_TO_INDEX(x) ((index_desc*)x)
46 #define CAST_TO_MPHF_INDEX(x) ((index_desc*)x)
47 #define CAST_TO_SMPHF_INDEX(x) ((smphf_index_desc*)x)
49 #define CAST_TO_INV(x) ((inv_desc*)x)
51 #define CAST_TO_MPHF(x) ((mphf_desc*)x)
52 #define CAST_TO_SMPHF(x) ((smphf_desc*)x)
53 #define CAST_TO_BTREE(x) ((btree_desc*)x)
55 #define CAST_TO_CONTAINER(x) ((container_desc*)x)
58 #define alloca(x) (malloc(x))
60 extern void schemaerror(char*);
61 extern int schemalex();
70 page_store_desc* ps_trans;
76 #define INDEX_NAME 261
80 #define AGENT_NAME 265
81 #define STORE_NAME 266
84 #define MPHF_INDEX 269
85 #define SMPHF_INDEX 270
86 #define BTREE_INDEX 271
87 #define INDEX_AGENT 272
96 #define PAGE_STORE 281
101 #define CACHED_PAGES 286
103 #define BYTE_ORDER 287
104 #define SEPARATOR 288
105 #define schemaERRCODE 256
106 short schemalhs[] = { -1,
107 0, 1, 1, 2, 2, 2, 2, 2, 2, 3,
108 4, 6, 7, 5, 8, 15, 16, 16, 16, 17,
109 18, 18, 19, 19, 19, 20, 20, 9, 9, 10,
110 10, 12, 12, 13, 13, 11, 11, 14, 14, 21,
111 21, 21, 21, 25, 25, 26, 26, 22, 22, 27,
112 27, 27, 23, 23, 24, 24,
114 short schemalen[] = { 2,
115 1, 2, 1, 2, 2, 2, 2, 2, 2, 3,
116 3, 3, 3, 3, 3, 1, 1, 1, 1, 1,
117 1, 1, 1, 1, 1, 1, 1, 3, 1, 3,
118 1, 3, 1, 3, 1, 3, 1, 3, 1, 1,
119 3, 3, 3, 1, 3, 3, 3, 3, 1, 3,
122 short schemadefred[] = { 0,
123 0, 0, 0, 0, 0, 0, 0, 1, 0, 26,
124 27, 9, 0, 20, 6, 0, 21, 22, 7, 0,
125 17, 18, 19, 5, 0, 23, 25, 24, 8, 0,
126 16, 4, 0, 2, 0, 0, 0, 0, 0, 0,
127 0, 0, 0, 0, 15, 56, 0, 54, 12, 0,
128 13, 0, 0, 0, 0, 11, 0, 52, 49, 14,
129 0, 0, 0, 0, 0, 10, 0, 40, 44, 0,
130 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
131 0, 0, 0, 0, 0, 0, 55, 53, 46, 47,
132 38, 32, 34, 50, 51, 48, 30, 36, 45, 43,
135 short schemadgoto[] = { 7,
136 8, 9, 32, 24, 29, 15, 19, 12, 66, 56,
137 60, 49, 51, 45, 33, 25, 16, 20, 30, 13,
138 67, 57, 46, 47, 68, 48, 59,
140 short schemasindex[] = { -250,
141 -206, -260, -221, -219, -254, -272, 0, 0, -250, 0,
142 0, 0, -277, 0, 0, -243, 0, 0, 0, -231,
143 0, 0, 0, 0, -230, 0, 0, 0, 0, -229,
144 0, 0, -228, 0, -251, -249, -249, -241, -249, -247,
145 -217, -216, -215, -214, 0, 0, -223, 0, 0, -222,
146 0, -220, -211, -209, -208, 0, -213, 0, 0, 0,
147 -212, -207, -205, -204, -201, 0, -210, 0, 0, -185,
148 -178, -177, -176, -251, -249, -249, -175, -174, -232, -241,
149 -249, -173, -194, -193, -170, -247, 0, 0, 0, 0,
150 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
153 short schemarindex[] = { 0,
154 0, 0, 0, 0, 0, 0, 0, 0, 28, 0,
155 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
156 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
157 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
158 0, 0, 0, 0, 0, 0, 1, 0, 0, 3,
159 0, 14, 0, 0, 0, 0, 16, 0, 0, 0,
160 27, 0, 0, 0, 0, 0, 29, 0, 0, 0,
161 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
162 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
163 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
166 short schemagindex[] = { 0,
167 79, 0, 0, 0, 0, 0, 0, 0, 4, 9,
168 10, 17, 18, 19, 0, 0, 0, 0, 0, 0,
169 0, 0, -32, 0, 0, -40, 0,
171 #define schemaTABLESIZE 309
172 short schematable[] = { 69,
173 39, 14, 33, 50, 52, 58, 61, 1, 31, 41,
174 35, 2, 3, 35, 42, 31, 42, 4, 26, 27,
175 28, 5, 53, 54, 42, 55, 37, 3, 29, 6,
176 43, 44, 43, 44, 43, 44, 62, 63, 64, 65,
177 43, 44, 50, 52, 36, 69, 96, 58, 61, 21,
178 22, 23, 10, 11, 17, 18, 37, 38, 39, 40,
179 70, 71, 72, 73, 74, 75, 77, 76, 78, 79,
180 82, 87, 83, 84, 80, 81, 85, 86, 88, 89,
181 90, 94, 95, 99, 100, 101, 102, 34, 97, 103,
182 98, 92, 91, 93, 0, 0, 0, 0, 0, 0,
183 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
184 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
185 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
186 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
187 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
188 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
189 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
190 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
191 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
192 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
193 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
194 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
195 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
196 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
197 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
198 0, 0, 0, 0, 0, 0, 0, 0, 39, 0,
199 33, 0, 39, 39, 33, 33, 0, 0, 39, 0,
200 33, 35, 39, 31, 33, 35, 35, 31, 31, 0,
201 39, 35, 33, 31, 37, 35, 29, 31, 37, 37,
202 29, 29, 0, 35, 37, 31, 29, 0, 37, 0,
203 29, 0, 0, 0, 0, 0, 37, 0, 29,
205 short schemacheck[] = { 40,
206 0, 262, 0, 36, 37, 38, 39, 258, 281, 261,
207 288, 262, 263, 0, 266, 0, 266, 268, 273, 274,
208 275, 272, 264, 265, 266, 267, 0, 0, 0, 280,
209 282, 283, 282, 283, 282, 283, 284, 285, 286, 287,
210 282, 283, 75, 76, 288, 86, 279, 80, 81, 269,
211 270, 271, 259, 260, 276, 277, 288, 288, 288, 288,
212 278, 278, 278, 278, 288, 288, 278, 288, 278, 278,
213 278, 257, 278, 278, 288, 288, 278, 288, 257, 257,
214 257, 257, 257, 257, 279, 279, 257, 9, 80, 86,
215 81, 75, 74, 76, -1, -1, -1, -1, -1, -1,
216 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
217 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
218 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
219 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
220 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
221 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
222 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
223 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
224 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
225 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
226 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
227 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
228 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
229 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
230 -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
231 -1, -1, -1, -1, -1, -1, -1, -1, 258, -1,
232 258, -1, 262, 263, 262, 263, -1, -1, 268, -1,
233 268, 258, 272, 258, 272, 262, 263, 262, 263, -1,
234 280, 268, 280, 268, 258, 272, 258, 272, 262, 263,
235 262, 263, -1, 280, 268, 280, 268, -1, 272, -1,
236 272, -1, -1, -1, -1, -1, 280, -1, 280,
238 #define schemaFINAL 7
240 #define schemaDEBUG 0
242 #define schemaMAXTOKEN 288
244 char * schemaname[] = {
245 "end-of-file",0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
246 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
247 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
248 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
249 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
250 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
251 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"TOKEN","CONTAINER","SET","LIST",
252 "INDEX_NAME","INV","COMPRESS","INV_NAME","AGENT_NAME","STORE_NAME","POSITION",
253 "INDEX","MPHF_INDEX","SMPHF_INDEX","BTREE_INDEX","INDEX_AGENT","MPHF","SMPHF",
254 "BTREE","HUFFMAN","DICT","EQUAL","NUMBER","STORE","PAGE_STORE","NM","V_OID",
255 "MODE","PAGE_SZ","CACHED_PAGES","BYTE_ORDER","SEPARATOR",
257 char * schemarule[] = {
259 "Sheet : DescriptionList",
260 "DescriptionList : Description DescriptionList",
261 "DescriptionList : Description",
262 "Description : STORE Store_description",
263 "Description : INDEX Index_description",
264 "Description : INV Inv_description",
265 "Description : COMPRESS Compress_description",
266 "Description : INDEX_AGENT Index_Agent_description",
267 "Description : CONTAINER Container_description",
268 "Store_description : Page_Store_Head SEPARATOR Page_store_descriptions",
269 "Index_description : Index_Head SEPARATOR MPHF_index_descriptions",
270 "Inv_description : Inv_Head SEPARATOR Inv_descriptions",
271 "Compress_description : Compress_Head SEPARATOR Compress_descriptions",
272 "Index_Agent_description : Index_Agent_Head SEPARATOR Hash_descriptions",
273 "Container_description : Container_Head SEPARATOR Container_descriptions",
274 "Page_Store_Head : PAGE_STORE",
275 "Index_Head : MPHF_INDEX",
276 "Index_Head : SMPHF_INDEX",
277 "Index_Head : BTREE_INDEX",
279 "Compress_Head : HUFFMAN",
280 "Compress_Head : DICT",
281 "Index_Agent_Head : MPHF",
282 "Index_Agent_Head : BTREE",
283 "Index_Agent_Head : SMPHF",
284 "Container_Head : SET",
285 "Container_Head : LIST",
286 "Page_store_descriptions : Page_Store_Term SEPARATOR Page_store_descriptions",
287 "Page_store_descriptions : Page_Store_Term",
288 "MPHF_index_descriptions : MPHF_Index_Term SEPARATOR MPHF_index_descriptions",
289 "MPHF_index_descriptions : MPHF_Index_Term",
290 "Inv_descriptions : Stored_Object_Term SEPARATOR Inv_descriptions",
291 "Inv_descriptions : Stored_Object_Term",
292 "Compress_descriptions : Stored_Object_Term SEPARATOR Compress_descriptions",
293 "Compress_descriptions : Stored_Object_Term",
294 "Hash_descriptions : Stored_Object_Term SEPARATOR Hash_descriptions",
295 "Hash_descriptions : Stored_Object_Term",
296 "Container_descriptions : Container_Term SEPARATOR Container_descriptions",
297 "Container_descriptions : Container_Term",
298 "Page_Store_Term : Store_Term",
299 "Page_Store_Term : CACHED_PAGES EQUAL NUMBER",
300 "Page_Store_Term : BYTE_ORDER EQUAL TOKEN",
301 "Page_Store_Term : PAGE_SZ EQUAL NUMBER",
303 "Store_Term : MODE EQUAL TOKEN",
304 "Term : NM EQUAL TOKEN",
305 "Term : V_OID EQUAL TOKEN",
306 "MPHF_Index_Term : POSITION EQUAL NUMBER",
307 "MPHF_Index_Term : Index_Term",
308 "Index_Term : INV_NAME EQUAL TOKEN",
309 "Index_Term : AGENT_NAME EQUAL TOKEN",
310 "Index_Term : Stored_Object_Term",
311 "Stored_Object_Term : STORE_NAME EQUAL TOKEN",
312 "Stored_Object_Term : Term",
313 "Container_Term : INDEX_NAME EQUAL TOKEN",
314 "Container_Term : Stored_Object_Term",
317 #define schemaclearin ( schemachar=(-1))
318 #define schemaerrok ( schemaerrflag=0)
319 #ifdef schemaSTACKSIZE
320 #ifndef schemaMAXDEPTH
321 #define schemaMAXDEPTH schemaSTACKSIZE
324 #ifdef schemaMAXDEPTH
325 #define schemaSTACKSIZE schemaMAXDEPTH
327 #define schemaSTACKSIZE 500
328 #define schemaMAXDEPTH 500
336 schemaSTYPE * schemavsp;
337 schemaSTYPE schemaval;
338 schemaSTYPE schemalval;
339 short schemass[ schemaSTACKSIZE];
340 schemaSTYPE schemavs[ schemaSTACKSIZE];
341 #define schemastacksize schemaSTACKSIZE
342 #define schemaABORT goto schemaabort
343 #define schemaACCEPT goto schemaaccept
344 #define schemaERROR goto schemaerrlab
347 extern char *getenv(const char *);
353 register int schemam, scheman, schemastate;
355 register char * schemas;
357 if ( schemas = getenv(" schemaDEBUG"))
360 if ( scheman >= '0' && scheman <= '9')
361 schemadebug = scheman - '0';
369 schemassp = schemass;
370 schemavsp = schemavs;
371 * schemassp = schemastate = 0;
374 if ( (scheman = schemadefred[ schemastate])) goto schemareduce;
377 if (( schemachar = schemalex()) < 0) schemachar = 0;
382 if ( schemachar <= schemaMAXTOKEN) schemas = schemaname[ schemachar];
383 if (! schemas) schemas = "illegal-symbol";
384 printf(" schemadebug: state %d, reading %d (%s)\n", schemastate,
385 schemachar, schemas);
389 if (( scheman = schemasindex[ schemastate]) && ( scheman += schemachar) >= 0 &&
390 scheman <= schemaTABLESIZE && schemacheck[ scheman] == schemachar)
394 printf(" schemadebug: state %d, shifting to state %d\n",
395 schemastate, schematable[ scheman]);
397 if ( schemassp >= schemass + schemastacksize - 1)
401 *++ schemassp = schemastate = schematable[ scheman];
402 *++ schemavsp = schemalval;
404 if ( schemaerrflag > 0) -- schemaerrflag;
407 if (( scheman = schemarindex[ schemastate]) && ( scheman += schemachar) >= 0 &&
408 scheman <= schemaTABLESIZE && schemacheck[ scheman] == schemachar)
410 scheman = schematable[ scheman];
413 if ( schemaerrflag) goto schemainrecovery;
414 #if 0 /* remove if needed */
420 schemaerror((char*)"syntax error");
421 #if 0 /* remove if needed */
429 if ( schemaerrflag < 3)
434 if (( scheman = schemasindex[* schemassp]) && ( scheman += schemaERRCODE) >= 0 &&
435 scheman <= schemaTABLESIZE && schemacheck[ scheman] == schemaERRCODE)
439 printf(" schemadebug: state %d, error recovery shifting\
440 to state %d\n", * schemassp, schematable[ scheman]);
442 if ( schemassp >= schemass + schemastacksize - 1)
446 *++ schemassp = schemastate = schematable[ scheman];
447 *++ schemavsp = schemalval;
454 printf(" schemadebug: error recovery discarding state %d\n",
457 if ( schemassp <= schemass) goto schemaabort;
465 if ( schemachar == 0) goto schemaabort;
470 if ( schemachar <= schemaMAXTOKEN) schemas = schemaname[ schemachar];
471 if (! schemas) schemas = "illegal-symbol";
472 printf(" schemadebug: state %d, error recovery discards token %d (%s)\n",
473 schemastate, schemachar, schemas);
482 printf(" schemadebug: state %d, reducing by rule %d (%s)\n",
483 schemastate, scheman, schemarule[ scheman]);
485 schemam = schemalen[ scheman];
486 schemaval = schemavsp[1- schemam];
491 /*$1 -> asciiOutList(cerr);*/
492 desc_ptr = schemavsp[0].trans;
497 schemavsp[-1].trans -> set_next_desc( schemavsp[0].trans);
498 schemaval.trans = schemavsp[-1].trans;
503 schemavsp[0].trans -> set_next_desc(0);
504 last_desc_ptr = schemavsp[0].trans;
505 schemaval.trans = schemavsp[0].trans;
510 schemaval.trans = schemavsp[0].trans;
515 schemaval.trans = schemavsp[0].trans;
520 schemaval.trans = schemavsp[0].trans;
525 schemaval.trans = schemavsp[0].trans;
530 schemaval.trans = schemavsp[0].trans;
535 schemaval.trans = schemavsp[0].trans;
540 schemaval.trans = desc_ptr;
545 schemaval.trans = desc_ptr;
550 schemaval.trans = desc_ptr;
555 schemaval.trans = desc_ptr;
560 schemaval.trans = desc_ptr;
565 schemaval.trans = desc_ptr;
570 desc_ptr = new page_store_desc;
575 desc_ptr= new mphf_index_desc;
580 desc_ptr= new smphf_index_desc;
585 desc_ptr= new btree_index_desc;
590 desc_ptr= new inv_desc;
595 desc_ptr= new huffman_desc;
600 desc_ptr= new dict_desc;
605 desc_ptr= new mphf_desc;
610 desc_ptr= new btree_desc;
615 desc_ptr= new smphf_desc;
620 desc_ptr= new set_desc;
625 desc_ptr= new list_desc;
682 CAST_TO_PAGE_STORE(desc_ptr) -> set_cached_pages( schemavsp[0].integer);
687 CAST_TO_PAGE_STORE(desc_ptr) -> set_order( schemavsp[0].string);
692 CAST_TO_PAGE_STORE(desc_ptr) -> set_page_sz( schemavsp[0].integer);
701 CAST_TO_PAGE_STORE(desc_ptr) -> set_mode( schemavsp[0].string);
706 desc_ptr -> set_nm( schemavsp[0].string);
711 desc_ptr -> set_oid( schemavsp[0].string);
716 CAST_TO_MPHF_INDEX(desc_ptr) -> set_position( schemavsp[0].integer);
725 CAST_TO_INDEX(desc_ptr) -> set_inv_nm( schemavsp[0].string);
730 CAST_TO_INDEX(desc_ptr) -> set_agent_nm( schemavsp[0].string);
739 CAST_TO_STORED_OBJECT(desc_ptr) -> set_store_nm( schemavsp[0].string);
748 CAST_TO_CONTAINER(desc_ptr) -> set_index_nm( schemavsp[0].string);
756 schemassp -= schemam;
757 schemastate = * schemassp;
758 schemavsp -= schemam;
759 schemam = schemalhs[ scheman];
760 if ( schemastate == 0 && schemam == 0)
764 printf(" schemadebug: after reduction, shifting from state 0 to\
765 state %d\n", schemaFINAL);
767 schemastate = schemaFINAL;
768 *++ schemassp = schemaFINAL;
769 *++ schemavsp = schemaval;
772 if (( schemachar = schemalex()) < 0) schemachar = 0;
777 if ( schemachar <= schemaMAXTOKEN) schemas = schemaname[ schemachar];
778 if (! schemas) schemas = "illegal-symbol";
779 printf(" schemadebug: state %d, reading %d (%s)\n",
780 schemaFINAL, schemachar, schemas);
784 if ( schemachar == 0) goto schemaaccept;
787 if (( scheman = schemagindex[ schemam]) && ( scheman += schemastate) >= 0 &&
788 scheman <= schemaTABLESIZE && schemacheck[ scheman] == schemastate)
789 schemastate = schematable[ scheman];
791 schemastate = schemadgoto[ schemam];
794 printf(" schemadebug: after reduction, shifting from state %d \
795 to state %d\n", * schemassp, schemastate);
797 if ( schemassp >= schemass + schemastacksize - 1)
801 *++ schemassp = schemastate;
802 *++ schemavsp = schemaval;
805 schemaerror((char*)"yacc stack overflow");