Fix warnings on FreeBSD
[oweals/cde.git] / cde / programs / dtinfo / DtMmdb / StyleSheet / style.C
1 /*
2  * CDE - Common Desktop Environment
3  *
4  * Copyright (c) 1993-2012, The Open Group. All rights reserved.
5  *
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)
10  * any later version.
11  *
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
16  * details.
17  *
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
22  */
23 // $TOG: style.C /main/6 1998/04/17 11:51:49 mgreess $
24 #ifndef lint
25 __attribute__((unused))
26 static const char stylesccsid[] = "@(#)yaccpar  1.8 (Berkeley) 01/20/90";
27 #endif
28 #define styleBYACC 1
29 #include <stdio.h>
30 #include <ctype.h>
31 #include <sstream>
32 #include <iostream>
33 using namespace std;
34 #include <assert.h>
35 #include "StyleSheetExceptions.h"
36 #include "VariableTable.h"
37 #include "FeatureValue.h"
38 #include "Expression.h"
39 #include "SSPath.h"
40 #include "PathTable.h"
41 #include "Renderer.h"
42 #include "PathQualifier.h"
43 #include "Debug.h"
44 #include "ParserConst.h"
45 #include "FeatureDefDictionary.h"
46 #include <utility/funcs.h>
47
48 #include "HardCopy/autoNumberFP.h"
49 extern autoNumberFP gAutoNumberFP;
50
51
52 #ifdef alloca
53 # undef alloca
54 #endif
55 #define alloca(x)       (malloc(x))
56
57 extern void styleerror(char*);
58 extern int stylelex();
59
60 extern void enter_sgmlgi_context();
61
62 extern featureDefDictionary* g_FeatureDefDictionary;
63 extern unsigned g_validation_mode;
64 extern unsigned g_hasSemanticError;
65
66 static char localCharToCharPtrBuf[2];
67
68 #undef stylewrap
69
70 const char* toUpperCase(unsigned char* string)
71 {
72    static char buffer[512];
73    int j=0;
74    for ( unsigned int i=0; i<strlen((const char*)string); i++ )
75    {
76                  if (islower(string[i]))
77                    buffer[j] = toupper(string[i]) ;
78                  else
79                    buffer[j] = (char)string[i] ;
80                  j++;
81    }
82    buffer[j] = 0;
83    return buffer;
84 }
85
86 typedef union
87 {
88  unsigned char  charData;
89  unsigned char* charPtrData;
90  unsigned int   boolData;
91  int            intData;
92  float          realData;
93  Expression*    expPtrData;
94  TermNode*      termNodePtrData;
95  FeatureValue*  FeatureValuePtrData;
96  FeatureSet*    FeatureSetPtrData;
97  Feature*       FeaturePtrData;
98  SSPath*        PathPtrData;
99  PathTerm*      PathTermPtrData;
100  charPtrDlist*  charPtrDlistData;
101  PathFeatureList* PathFeatureListPtrData;
102  CompositeVariableNode*      CompositeVariableNodePtrData;
103
104  CC_TPtrSlist<FeatureValue>* FeatureValueSlistPtrData;
105
106  PQExpr*        PQExprPtrData;
107 } styleSTYPE;
108 #define INTEGER 257
109 #define OPER_equality 258
110 #define OPER_relational 259
111 #define BOOLVAL 260
112 #define REAL 261
113 #define OPER_assign 262
114 #define ARRAYOPEN 263
115 #define ARRAYCLOSE 264
116 #define SEPARATOR 265
117 #define FSOPEN 266
118 #define FSCLOSE 267
119 #define OPER_modify 268
120 #define OPER_parent 269
121 #define OPER_attr 270
122 #define OPER_oneof 271
123 #define OPER_star 272
124 #define OPER_or 273
125 #define OPER_and 274
126 #define OPER_div 275
127 #define OPER_parenopen 276
128 #define OPER_parenclose 277
129 #define OPER_logicalnegate 278
130 #define PMEMOPEN 279
131 #define PMEMCLOSE 280
132 #define OPER_period 281
133 #define OPER_plus 282
134 #define OPER_minus 283
135 #define DIMENSION 284
136 #define NORMAL_STRING 285
137 #define UNIT_STRING 286
138 #define QUOTED_STRING 287
139 #define GI_CASE_SENSITIVE 288
140 #define SGMLGI_STRING 289
141 #define styleERRCODE 256
142 short stylelhs[] = {                                        -1,
143     0,   37,   38,   38,   39,   13,   13,   13,   22,   22,
144    14,   15,   19,   19,   19,   11,   11,   10,   10,    7,
145     7,    6,    6,   12,   12,   12,   12,   12,   12,   12,
146    12,   12,   12,   20,   20,    4,    4,   23,   23,   21,
147    21,   17,   17,   18,   18,   40,   40,   24,   29,   29,
148    28,   28,   27,   27,   25,   25,   26,   26,   26,    9,
149     8,    8,    2,   41,    5,    5,    5,   16,    3,    3,
150    34,   30,   30,   31,   31,   32,   32,    1,    1,   35,
151    35,   36,   36,   42,   42,   33,   33,
152 };
153 short stylelen[] = {                                         2,
154     2,    3,    1,    1,    3,    1,    2,    1,    3,    1,
155     2,    2,    1,    1,    1,    3,    1,    3,    1,    1,
156     1,    1,    1,    1,    2,    1,    1,    1,    2,    2,
157     1,    1,    3,    4,    3,    1,    0,    3,    1,    1,
158     1,    4,    2,    3,    1,    1,    0,    3,    3,    1,
159     2,    4,    3,    1,    2,    1,    2,    1,    1,    1,
160     1,    1,    1,    0,    4,    2,    1,    1,    1,    1,
161     3,    1,    3,    1,    3,    4,    3,    1,    1,    1,
162     0,    1,    0,    2,    1,    1,    0,
163 };
164 short styledefred[] = {                                      0,
165     0,    0,    0,   80,    0,   58,   59,   69,   70,    0,
166     0,   63,    0,   56,    4,    1,   85,    3,    0,    2,
167     0,   57,   86,    0,    0,    0,    0,    0,   51,   55,
168    84,    0,    0,    0,    0,   74,    0,   24,    0,    0,
169     0,    0,   68,   28,    0,    0,    0,    0,   19,    0,
170     0,    6,   27,   15,    5,   14,    0,    0,   43,   50,
171     0,   45,    0,    0,   54,    0,    0,   71,    0,    0,
172    29,   30,   11,   12,   10,    0,    0,   22,   23,    0,
173    61,   62,    0,   25,    0,   60,    0,   65,    0,    0,
174     0,    0,    0,   52,    0,   78,   79,   77,    0,   75,
175    33,   35,    0,   41,    0,    0,   18,    0,    9,   44,
176    42,   48,   49,   53,   76,    0,   34,   38,
177 };
178 short styledgoto[] = {                                       2,
179    98,   10,   28,   46,   12,   80,    0,   83,   87,   47,
180    48,   49,   50,   51,   52,   53,   54,   61,   55,   56,
181   105,   57,  106,   62,   13,   14,   64,   15,   63,   34,
182    35,   36,   22,   23,    3,   16,    4,   17,   18,   90,
183    58,   19,
184 };
185 short stylesindex[] = {                                   -277,
186  -246,    0, -225,    0, -218,    0,    0,    0,    0, -231,
187  -228,    0, -259,    0,    0,    0,    0,    0, -225,    0,
188  -265,    0,    0, -221,    0, -234, -225, -222,    0,    0,
189     0, -229, -196, -206, -204,    0, -213,    0, -187, -229,
190  -229, -168,    0,    0,    0, -156, -251, -177,    0, -172,
191  -229,    0,    0,    0,    0,    0, -161, -167,    0,    0,
192  -141,    0, -237, -255,    0, -133, -249,    0, -265, -265,
193     0,    0,    0,    0,    0, -199, -189,    0,    0, -168,
194     0,    0, -168,    0, -161,    0, -229,    0, -229, -139,
195  -221, -229, -225,    0, -158,    0,    0,    0, -204,    0,
196     0,    0, -177,    0, -132, -130,    0, -251,    0,    0,
197     0,    0,    0,    0,    0, -168,    0,    0,
198 };
199 short stylerindex[] = {                                     37,
200     0,    0,  132,    0,    0,    0,    0,    0,    0, -145,
201  -257,    0,    0,    0,    0,    0,    0,    0,  135,    0,
202     0,    0,    0, -127,    1,    0,    0,   30,    0,    0,
203     0,    0,    0,    0, -179,    0,  169,    0,  178,    0,
204     0,    0,    0,    0,   54,    0,  123,  130,    0,  200,
205     0,    0,    0,    0,    0,    0,   77,    0,    0,    0,
206  -129,    0,    0,    0,    0,    0,    0,    0,    0,    0,
207     0,    0,    0,    0,    0,    0, -127,    0,    0,    0,
208     0,    0,    0,    0,  100,    0,    0,    0, -128,    0,
209  -127,    0,    0,    0,    0,    0,    0,    0, -160,    0,
210     0,    0, -155,    0, -122,    0,    0,  146,    0,    0,
211     0,    0,    0,    0,    0, -127,    0,    0,
212 };
213 short stylegindex[] = {                                      0,
214     0,   71,   -1,    0,    0,    0,    0,    0,   74,   60,
215   -42,   64,    0,    0,    0,    0,  134,    0,   57,  -73,
216     0,   94,   33,   61,    0,  138,    0,  -24,    0,    0,
217    83,   84,    0,    0,    0,    0,    0,  136,    0,    0,
218     0,    0,
219 };
220 #define styleTABLESIZE 485
221 short styletable[] = {                                      76,
222    66,   11,   65,  104,   32,   67,   26,   96,   67,   93,
223     1,    6,    7,   67,   67,    5,   27,   11,   67,   33,
224    78,   94,   45,   79,   60,    8,    9,   67,   67,   67,
225    91,   21,   59,   24,  103,   37,   81,   97,   38,   39,
226    75,   20,  104,   86,   26,    6,    7,   40,   41,   75,
227     8,    9,   25,   10,   42,    8,    9,   68,   25,    8,
228     9,   67,   43,    8,    9,   44,   69,   37,  114,   70,
229    38,   39,   71,  103,  102,   45,    8,  101,   75,   40,
230    41,   75,   81,   82,   72,  109,   42,   60,   37,   45,
231   113,   38,   39,   72,   43,    8,    9,   44,   72,    7,
232    40,   41,   66,   73,   81,   82,   77,   42,   40,   40,
233    73,   74,   73,   84,   45,   43,    8,    9,   44,   86,
234    87,   88,   17,   89,   95,   87,   87,  111,  115,   13,
235    87,   83,  116,  117,   82,   37,   92,   47,   46,   87,
236    87,   39,  108,  107,   85,   16,   29,  112,  118,  110,
237    30,   99,    0,  100,   31,    0,    0,    0,    0,    0,
238     0,    0,    0,    0,    0,    0,    0,    0,   31,    0,
239     0,    0,    0,    0,    0,    0,    0,   32,    0,    0,
240     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
241     0,    0,    0,    0,    0,    0,    0,    0,    0,   26,
242     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
243     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
244     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
245     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
246     0,    0,    0,    0,    0,    0,    0,    0,    0,    0,
247     0,    0,    0,    0,    0,    0,    0,    0,   66,    0,
248     0,    0,    0,   66,   66,   66,   66,   66,    0,    0,
249     0,   66,   66,    0,    0,   66,   66,   66,    0,    0,
250     0,    0,   66,   66,    0,   66,   66,   67,    0,   64,
251     0,    0,   67,   67,   67,   67,   67,    0,    0,    0,
252    67,   67,    0,    0,   67,   67,   67,   81,   81,    0,
253     0,   67,   67,    0,   67,   67,   36,   10,   10,    0,
254    10,   81,   81,    0,   10,   10,    0,    0,   10,    0,
255     0,    0,    0,    0,   10,   10,   10,    0,   10,   10,
256     8,    8,    0,    8,    0,    0,    0,    8,    8,    0,
257     0,    8,    0,    8,    0,    0,    0,    0,    8,    8,
258     0,    8,    8,    7,    7,    0,    7,    0,    0,    0,
259     7,    7,    0,    0,    7,    0,    7,    0,    0,    0,
260     0,    7,    7,    0,    7,    7,   17,   17,    0,   17,
261     0,    0,    0,   17,   13,    0,   13,    0,    0,   17,
262    13,   13,    0,    0,   17,   17,    0,   17,   17,   16,
263    16,    0,   16,    0,   13,   13,   16,    0,    0,    0,
264     0,    0,   16,    0,    0,    0,    0,   16,   16,    0,
265    16,   16,   31,   31,    0,   31,    0,    0,    0,   31,
266    31,   32,   32,   31,   32,   31,    0,    0,   32,   32,
267    31,   31,   32,   31,   32,    0,    0,    0,    0,   32,
268    32,    0,   32,   26,   26,    0,   26,    0,    0,    0,
269    26,   26,    0,    0,   26,    0,   26,    0,    0,    0,
270     0,   26,   26,    0,   26,
271 };
272 short stylecheck[] = {                                      42,
273     0,    3,   27,   77,  270,  263,  266,  257,  266,  265,
274   288,  271,  272,  271,  272,  262,  276,   19,  276,  285,
275   272,  277,   24,  275,   26,  285,  286,  285,  286,    0,
276   268,  263,  267,  262,   77,  257,    0,  287,  260,  261,
277    42,  260,  116,  281,  266,  271,  272,  269,  270,   51,
278   285,  286,  281,    0,  276,  285,  286,  264,  281,  285,
279   286,  258,  284,  285,  286,  287,  273,  257,   93,  274,
280   260,  261,  286,  116,  264,   77,    0,  277,   80,  269,
281   270,   83,  282,  283,  264,   87,  276,   89,  257,   91,
282    92,  260,  261,  273,  284,  285,  286,  287,  286,    0,
283   269,  270,   32,  264,  282,  283,  263,  276,  264,  265,
284    40,   41,  273,  286,  116,  284,  285,  286,  287,  281,
285   266,  289,    0,  265,  258,  271,  272,  267,  287,    0,
286   276,    0,  265,  264,    0,  263,   63,  267,  267,  285,
287   286,  264,   83,   80,   51,    0,   13,   91,  116,   89,
288    13,   69,   -1,   70,   19,   -1,   -1,   -1,   -1,   -1,
289    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,    0,   -1,
290    -1,   -1,   -1,   -1,   -1,   -1,   -1,    0,   -1,   -1,
291    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
292    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,    0,
293    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
294    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
295    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
296    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
297    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
298    -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,  258,   -1,
299    -1,   -1,   -1,  263,  264,  265,  266,  267,   -1,   -1,
300    -1,  271,  272,   -1,   -1,  275,  276,  277,   -1,   -1,
301    -1,   -1,  282,  283,   -1,  285,  286,  258,   -1,  289,
302    -1,   -1,  263,  264,  265,  266,  267,   -1,   -1,   -1,
303   271,  272,   -1,   -1,  275,  276,  277,  271,  272,   -1,
304    -1,  282,  283,   -1,  285,  286,  263,  264,  265,   -1,
305   267,  285,  286,   -1,  271,  272,   -1,   -1,  275,   -1,
306    -1,   -1,   -1,   -1,  281,  282,  283,   -1,  285,  286,
307   264,  265,   -1,  267,   -1,   -1,   -1,  271,  272,   -1,
308    -1,  275,   -1,  277,   -1,   -1,   -1,   -1,  282,  283,
309    -1,  285,  286,  264,  265,   -1,  267,   -1,   -1,   -1,
310   271,  272,   -1,   -1,  275,   -1,  277,   -1,   -1,   -1,
311    -1,  282,  283,   -1,  285,  286,  264,  265,   -1,  267,
312    -1,   -1,   -1,  271,  265,   -1,  267,   -1,   -1,  277,
313   271,  272,   -1,   -1,  282,  283,   -1,  285,  286,  264,
314   265,   -1,  267,   -1,  285,  286,  271,   -1,   -1,   -1,
315    -1,   -1,  277,   -1,   -1,   -1,   -1,  282,  283,   -1,
316   285,  286,  264,  265,   -1,  267,   -1,   -1,   -1,  271,
317   272,  264,  265,  275,  267,  277,   -1,   -1,  271,  272,
318   282,  283,  275,  285,  277,   -1,   -1,   -1,   -1,  282,
319   283,   -1,  285,  264,  265,   -1,  267,   -1,   -1,   -1,
320   271,  272,   -1,   -1,  275,   -1,  277,   -1,   -1,   -1,
321    -1,  282,  283,   -1,  285,
322 };
323 #define styleFINAL 2
324 #ifndef styleDEBUG
325 #define styleDEBUG 0
326 #endif
327 #define styleMAXTOKEN 289
328 #if styleDEBUG
329 char *stylename[] = {
330 "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,
331 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,
332 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,
333 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,
334 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,
335 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,
336 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,"INTEGER","OPER_equality",
337 "OPER_relational","BOOLVAL","REAL","OPER_assign","ARRAYOPEN","ARRAYCLOSE",
338 "SEPARATOR","FSOPEN","FSCLOSE","OPER_modify","OPER_parent","OPER_attr",
339 "OPER_oneof","OPER_star","OPER_or","OPER_and","OPER_div","OPER_parenopen",
340 "OPER_parenclose","OPER_logicalnegate","PMEMOPEN","PMEMCLOSE","OPER_period",
341 "OPER_plus","OPER_minus","DIMENSION","NORMAL_STRING","UNIT_STRING",
342 "QUOTED_STRING","GI_CASE_SENSITIVE","SGMLGI_STRING",
343 };
344 char *stylerule[] = {
345 "$accept : stylesheet",
346 "stylesheet : sensitivityOPTL statement.gpOPTL",
347 "sensitivity : GI_CASE_SENSITIVE OPER_assign BOOLVAL",
348 "statement.gp : var_assignment",
349 "statement.gp : path_expr",
350 "var_assignment : STRING OPER_assign rhs.gp",
351 "symbol : attr",
352 "symbol : parent string_list",
353 "symbol : string_list",
354 "string_list : string_list OPER_feature STRING",
355 "string_list : STRING",
356 "parent : OPER_parent SGMLGI",
357 "attr : OPER_attr SGMLGI",
358 "rhs.gp : simple_expr",
359 "rhs.gp : array",
360 "rhs.gp : featureset",
361 "simple_expr : simple_expr OPER_add multi_expr",
362 "simple_expr : multi_expr",
363 "multi_expr : multi_expr OPER_mult term",
364 "multi_expr : term",
365 "OPER_binop : OPER_mult",
366 "OPER_binop : OPER_add",
367 "OPER_mult : OPER_star",
368 "OPER_mult : OPER_div",
369 "term : BOOLVAL",
370 "term : symbol UNIT_STRING",
371 "term : symbol",
372 "term : dimension",
373 "term : QUOTED_STRING",
374 "term : INTEGER UNIT_STRING",
375 "term : REAL UNIT_STRING",
376 "term : INTEGER",
377 "term : REAL",
378 "term : OPER_parenopen simple_expr OPER_parenclose",
379 "array : array_name ARRAYOPEN array_member_list ARRAYCLOSE",
380 "array : array_name ARRAYOPEN ARRAYCLOSE",
381 "array_name : STRING",
382 "array_name :",
383 "array_member_list : array_member SEPARATOR array_member_list",
384 "array_member_list : array_member",
385 "array_member : simple_expr",
386 "array_member : array",
387 "featureset : FSOPEN feature_list SEPARATOR_OPTL FSCLOSE",
388 "featureset : FSOPEN FSCLOSE",
389 "feature_list : feature_list SEPARATOR feature",
390 "feature_list : feature",
391 "SEPARATOR_OPTL : SEPARATOR",
392 "SEPARATOR_OPTL :",
393 "feature : feature_name_list OPER_modify rhs.gp",
394 "feature_name_list : feature_name_list OPER_feature STRING",
395 "feature_name_list : STRING",
396 "path_expr : path_term_list featureset",
397 "path_expr : path_term_list OPER_parenopen path_expr_list OPER_parenclose",
398 "path_expr_list : path_expr_list SEPARATOR path_expr",
399 "path_expr_list : path_expr",
400 "path_term_list : path_term_list path_term",
401 "path_term_list : path_term",
402 "path_term : SGMLGI path_selectorOPTL",
403 "path_term : OPER_oneof",
404 "path_term : OPER_star",
405 "OPER_feature : OPER_period",
406 "OPER_add : OPER_plus",
407 "OPER_add : OPER_minus",
408 "SGMLGI : SGMLGI_CONTENT",
409 "$$1 :",
410 "SGMLGI_CONTENT : STRING OPER_period $$1 SGMLGI_STRING",
411 "SGMLGI_CONTENT : STRING OPER_period",
412 "SGMLGI_CONTENT : STRING",
413 "dimension : DIMENSION",
414 "STRING : NORMAL_STRING",
415 "STRING : UNIT_STRING",
416 "path_selector : ARRAYOPEN boolean_expr ARRAYCLOSE",
417 "boolean_expr : logical_and_expr",
418 "boolean_expr : boolean_expr OPER_or logical_and_expr",
419 "logical_and_expr : equality_expr",
420 "logical_and_expr : logical_and_expr OPER_and equality_expr",
421 "equality_expr : OPER_attr SGMLGI OPER_equality QUOTED_STRING",
422 "equality_expr : NORMAL_STRING OPER_equality POSITION_VALUE",
423 "POSITION_VALUE : INTEGER",
424 "POSITION_VALUE : QUOTED_STRING",
425 "sensitivityOPTL : sensitivity",
426 "sensitivityOPTL :",
427 "statement.gpOPTL : statement.gpPLUS",
428 "statement.gpOPTL :",
429 "statement.gpPLUS : statement.gpPLUS statement.gp",
430 "statement.gpPLUS : statement.gp",
431 "path_selectorOPTL : path_selector",
432 "path_selectorOPTL :",
433 };
434 #endif
435 #define styleclearin (stylechar=(-1))
436 #define styleerrok (styleerrflag=0)
437 #ifdef styleSTACKSIZE
438 #ifndef styleMAXDEPTH
439 #define styleMAXDEPTH styleSTACKSIZE
440 #endif
441 #else
442 #ifdef styleMAXDEPTH
443 #define styleSTACKSIZE styleMAXDEPTH
444 #else
445 #define styleSTACKSIZE 500
446 #define styleMAXDEPTH 500
447 #endif
448 #endif
449 int styledebug;
450 int stylenerrs;
451 int styleerrflag;
452 int stylechar;
453 short *stylessp;
454 styleSTYPE *stylevsp;
455 styleSTYPE styleval;
456 styleSTYPE stylelval;
457 short styless[styleSTACKSIZE];
458 styleSTYPE stylevs[styleSTACKSIZE];
459 #define stylestacksize styleSTACKSIZE
460 #define styleABORT goto styleabort
461 #define styleACCEPT goto styleaccept
462 #define styleERROR goto styleerrlab
463 #if styleDEBUG
464 #ifndef __cplusplus
465 extern char *getenv(const char *);
466 #endif
467 #endif
468 int
469 styleparse()
470 {
471     register int stylem, stylen, stylestate;
472 #if styleDEBUG
473     register char *styles;
474
475     if (styles = getenv("styleDEBUG"))
476     {
477         stylen = *styles;
478         if (stylen >= '0' && stylen <= '9')
479             styledebug = stylen - '0';
480     }
481 #endif
482
483     stylenerrs = 0;
484     styleerrflag = 0;
485     stylechar = (-1);
486
487     stylessp = styless;
488     stylevsp = stylevs;
489     *stylessp = stylestate = 0;
490
491 styleloop:
492     if ((stylen = styledefred[stylestate])) goto stylereduce;
493     if (stylechar < 0)
494     {
495         if ((stylechar = stylelex()) < 0) stylechar = 0;
496 #if styleDEBUG
497         if (styledebug)
498         {
499             styles = 0;
500             if (stylechar <= styleMAXTOKEN) styles = stylename[stylechar];
501             if (!styles) styles = "illegal-symbol";
502             printf("styledebug: state %d, reading %d (%s)\n", stylestate,
503                     stylechar, styles);
504         }
505 #endif
506     }
507     if ((stylen = stylesindex[stylestate]) && (stylen += stylechar) >= 0 &&
508             stylen <= styleTABLESIZE && stylecheck[stylen] == stylechar)
509     {
510 #if styleDEBUG
511         if (styledebug)
512             printf("styledebug: state %d, shifting to state %d\n",
513                     stylestate, styletable[stylen]);
514 #endif
515         if (stylessp >= styless + stylestacksize - 1)
516         {
517             goto styleoverflow;
518         }
519         *++stylessp = stylestate = styletable[stylen];
520         *++stylevsp = stylelval;
521         stylechar = (-1);
522         if (styleerrflag > 0)  --styleerrflag;
523         goto styleloop;
524     }
525     if ((stylen = stylerindex[stylestate]) && (stylen += stylechar) >= 0 &&
526             stylen <= styleTABLESIZE && stylecheck[stylen] == stylechar)
527     {
528         stylen = styletable[stylen];
529         goto stylereduce;
530     }
531     if (styleerrflag) goto styleinrecovery;
532 #if 0                                   /* remove if needed */
533 #ifdef lint
534     goto stylenewerror;
535 #endif
536 stylenewerror:
537 #endif  /* if 0 */
538     styleerror((char*)"syntax error");
539 #if 0                                   /* remove if needed */
540 #ifdef lint
541     goto styleerrlab;
542 #endif
543 styleerrlab:
544 #endif /* if 0 */
545     ++stylenerrs;
546 styleinrecovery:
547     if (styleerrflag < 3)
548     {
549         styleerrflag = 3;
550         for (;;)
551         {
552             if ((stylen = stylesindex[*stylessp]) && (stylen += styleERRCODE) >= 0 &&
553                     stylen <= styleTABLESIZE && stylecheck[stylen] == styleERRCODE)
554             {
555 #if styleDEBUG
556                 if (styledebug)
557                     printf("styledebug: state %d, error recovery shifting\
558  to state %d\n", *stylessp, styletable[stylen]);
559 #endif
560                 if (stylessp >= styless + stylestacksize - 1)
561                 {
562                     goto styleoverflow;
563                 }
564                 *++stylessp = stylestate = styletable[stylen];
565                 *++stylevsp = stylelval;
566                 goto styleloop;
567             }
568             else
569             {
570 #if styleDEBUG
571                 if (styledebug)
572                     printf("styledebug: error recovery discarding state %d\n",
573                             *stylessp);
574 #endif
575                 if (stylessp <= styless) goto styleabort;
576                 --stylessp;
577                 --stylevsp;
578             }
579         }
580     }
581     else
582     {
583         if (stylechar == 0) goto styleabort;
584 #if styleDEBUG
585         if (styledebug)
586         {
587             styles = 0;
588             if (stylechar <= styleMAXTOKEN) styles = stylename[stylechar];
589             if (!styles) styles = "illegal-symbol";
590             printf("styledebug: state %d, error recovery discards token %d (%s)\n",
591                     stylestate, stylechar, styles);
592         }
593 #endif
594         stylechar = (-1);
595         goto styleloop;
596     }
597 stylereduce:
598 #if styleDEBUG
599     if (styledebug)
600         printf("styledebug: state %d, reducing by rule %d (%s)\n",
601                 stylestate, stylen, stylerule[stylen]);
602 #endif
603     stylem = stylelen[stylen];
604     styleval = stylevsp[1-stylem];
605     switch (stylen)
606     {
607 case 1:
608 {
609         }
610 break;
611 case 2:
612 {
613           gGI_CASE_SENSITIVE = stylevsp[0].boolData;
614         }
615 break;
616 case 3:
617 {
618         }
619 break;
620 case 4:
621 {
622           /* copy items form the feature list into the path table */
623           PathFeatureListIterator l_Iter(*(stylevsp[0].PathFeatureListPtrData));
624
625           PathFeature *x = 0;
626
627           while ( ++l_Iter ) {
628
629             x = l_Iter.key();
630
631             if ( g_validation_mode == true )
632               if ( g_FeatureDefDictionary -> checkSemantics(x -> featureSet()) == false )
633                  g_hasSemanticError = true;
634                
635             gPathTab -> addPathFeatureSet( x );
636
637
638           }
639
640 /* clear out the first list so the elements are not deleted
641              with the list because they are still referenced by the
642              path table */
643
644           stylevsp[0].PathFeatureListPtrData -> clear();
645           delete stylevsp[0].PathFeatureListPtrData;
646
647         }
648 break;
649 case 5:
650 {
651            Expression *x = new Expression(new ConstantNode(stylevsp[0].FeatureValuePtrData));
652
653            if ( gAutoNumberFP.accept((const char*)stylevsp[-2].charPtrData, x) ) {
654                  delete stylevsp[-2].charPtrData;
655                  delete x;
656                  break;
657            }
658
659            gVariableTable -> enter( gSymTab -> intern((const char*)stylevsp[-2].charPtrData), x);
660            delete stylevsp[-2].charPtrData;
661         }
662 break;
663 case 6:
664 {
665           styleval.termNodePtrData=stylevsp[0].termNodePtrData;
666         }
667 break;
668 case 7:
669 {
670           styleval.termNodePtrData=stylevsp[-1].termNodePtrData;
671         }
672 break;
673 case 8:
674 {
675           const Symbol* x = stylevsp[0].CompositeVariableNodePtrData -> convertableToVariable();
676           if ( x ) {
677             styleval.termNodePtrData=new VariableNode(*x);
678             delete stylevsp[0].CompositeVariableNodePtrData;
679           } else
680             styleval.termNodePtrData=stylevsp[0].CompositeVariableNodePtrData;
681         }
682 break;
683 case 9:
684 {
685
686           stylevsp[-2].CompositeVariableNodePtrData->appendItem(gSymTab->intern(toUpperCase(stylevsp[0].charPtrData)));
687           styleval.CompositeVariableNodePtrData=stylevsp[-2].CompositeVariableNodePtrData;
688           delete stylevsp[0].charPtrData ;
689         }
690 break;
691 case 10:
692 {
693           styleval.CompositeVariableNodePtrData=new CompositeVariableNode;
694           styleval.CompositeVariableNodePtrData -> appendItem(gSymTab->intern(toUpperCase(stylevsp[0].charPtrData)));
695           delete stylevsp[0].charPtrData;
696         }
697 break;
698 case 11:
699 {
700 /*
701           $$=new
702             ParentNode(gSymTab->intern((const char*)$1));
703 */
704           MESSAGE(cerr, "^ operator not supported.");
705           throw(CASTSSEXCEPT StyleSheetException());
706         }
707 break;
708 case 12:
709 {
710           styleval.termNodePtrData=new
711             SgmlAttributeNode(gSymTab->intern((const char*)stylevsp[0].charPtrData));
712           delete stylevsp[0].charPtrData;
713         }
714 break;
715 case 13:
716 {
717           styleval.FeatureValuePtrData=new FeatureValueExpression(stylevsp[0].expPtrData);
718         }
719 break;
720 case 14:
721 {
722           styleval.FeatureValuePtrData=stylevsp[0].FeatureValuePtrData;
723         }
724 break;
725 case 15:
726 {
727           styleval.FeatureValuePtrData=new FeatureValueFeatureSet(stylevsp[0].FeatureSetPtrData);
728         }
729 break;
730 case 16:
731 {
732            BinaryOperatorNode::operatorType opType;
733            switch (stylevsp[-1].charData) {
734              case '+': opType=BinaryOperatorNode::PLUS; break;
735              case '-': opType=BinaryOperatorNode::MINUS; break;
736              default:
737               throw(CASTBEEXCEPT badEvaluationException());
738            }
739
740            FeatureValueExpression* FVexprL = new FeatureValueExpression(stylevsp[-2].expPtrData);
741            FeatureValueExpression* FVexprR = new FeatureValueExpression(stylevsp[0].expPtrData);
742            
743            styleval.expPtrData = new Expression(
744                  new BinaryOperatorNode(opType, 
745                                         new ConstantNode(FVexprL),
746                                         new ConstantNode(FVexprR)
747                                        )
748                               );
749         }
750 break;
751 case 17:
752 {
753            styleval.expPtrData=stylevsp[0].expPtrData;
754         }
755 break;
756 case 18:
757 {
758            BinaryOperatorNode::operatorType opType;
759            switch (stylevsp[-1].charData) {
760              case '*': opType=BinaryOperatorNode::TIMES; break;
761              case '/': opType=BinaryOperatorNode::DIVIDE; break;
762              default:
763               throw(CASTBEEXCEPT badEvaluationException());
764            }
765
766            FeatureValueExpression* FVexpr = new FeatureValueExpression(stylevsp[-2].expPtrData);
767            
768            styleval.expPtrData = new Expression(
769                  new BinaryOperatorNode(opType, new ConstantNode(FVexpr), stylevsp[0].termNodePtrData)
770                               );
771         }
772 break;
773 case 19:
774 {
775            styleval.expPtrData = new Expression(stylevsp[0].termNodePtrData);
776         }
777 break;
778 case 20:
779 {
780            styleval.charData=stylevsp[0].charData;
781         }
782 break;
783 case 21:
784 {
785            styleval.charData=stylevsp[0].charData;
786         }
787 break;
788 case 22:
789 {
790            styleval.charData=stylevsp[0].charData;
791         }
792 break;
793 case 23:
794 {
795            styleval.charData=stylevsp[0].charData;
796         }
797 break;
798 case 24:
799 {
800           styleval.termNodePtrData=new ConstantNode(new FeatureValueInt(int(stylevsp[0].boolData)));
801         }
802 break;
803 case 25:
804 {
805           FeatureValueExpression* fve = 
806                 new FeatureValueExpression(new Expression(stylevsp[-1].termNodePtrData));
807           FeatureValueDimension* x = 
808              new FeatureValueDimension(fve, (const char*)stylevsp[0].charPtrData);
809           delete stylevsp[0].charPtrData ;
810           styleval.termNodePtrData=new ConstantNode(x);
811         }
812 break;
813 case 26:
814 {
815           styleval.termNodePtrData=stylevsp[0].termNodePtrData;
816         }
817 break;
818 case 27:
819 {
820           styleval.termNodePtrData=stylevsp[0].termNodePtrData;
821         }
822 break;
823 case 28:
824 {
825           styleval.termNodePtrData=new ConstantNode(new FeatureValueString((const char*)stylevsp[0].charPtrData));
826           delete stylevsp[0].charPtrData ;
827         }
828 break;
829 case 29:
830 {
831           styleval.termNodePtrData=new ConstantNode(new FeatureValueDimension(new FeatureValueInt(stylevsp[-1].intData), (const char*)stylevsp[0].charPtrData));
832           delete stylevsp[0].charPtrData ;
833         }
834 break;
835 case 30:
836 {
837           styleval.termNodePtrData=new ConstantNode(new FeatureValueDimension(new FeatureValueReal(stylevsp[-1].realData), (const char*)stylevsp[0].charPtrData));
838           delete stylevsp[0].charPtrData ;
839         }
840 break;
841 case 31:
842 {
843           styleval.termNodePtrData=new ConstantNode(new FeatureValueInt(stylevsp[0].intData));
844         }
845 break;
846 case 32:
847 {
848           styleval.termNodePtrData=new ConstantNode(new FeatureValueReal(stylevsp[0].realData));
849         }
850 break;
851 case 33:
852 {
853           styleval.termNodePtrData=new ConstantNode(new FeatureValueExpression(stylevsp[-1].expPtrData));
854         }
855 break;
856 case 34:
857 {
858           FeatureValueArray* x = 
859              new FeatureValueArray((const char*)stylevsp[-3].charPtrData, stylevsp[-1].FeatureValueSlistPtrData -> entries());
860           CC_TPtrSlistIterator<FeatureValue> iter(*stylevsp[-1].FeatureValueSlistPtrData);
861
862           int i = 0;
863           while ( ++iter ) {
864             (*x)[i++] = iter.key();
865           }
866
867           delete stylevsp[-3].charPtrData;
868           delete stylevsp[-1].FeatureValueSlistPtrData;
869
870           styleval.FeatureValuePtrData = x;
871         }
872 break;
873 case 35:
874 {
875           styleval.FeatureValuePtrData = new FeatureValueArray((const char*)stylevsp[-2].charPtrData, 0);
876           delete stylevsp[-2].charPtrData;
877         }
878 break;
879 case 36:
880 {
881           styleval.charPtrData = stylevsp[0].charPtrData;
882         }
883 break;
884 case 37:
885 {
886           styleval.charPtrData = new unsigned char[1];
887           styleval.charPtrData[0] = 0;
888         }
889 break;
890 case 38:
891 {
892            stylevsp[0].FeatureValueSlistPtrData -> prepend(stylevsp[-2].FeatureValuePtrData);
893            styleval.FeatureValueSlistPtrData = stylevsp[0].FeatureValueSlistPtrData;
894         }
895 break;
896 case 39:
897 {
898            styleval.FeatureValueSlistPtrData=new CC_TPtrSlist<FeatureValue>;
899            styleval.FeatureValueSlistPtrData -> append(stylevsp[0].FeatureValuePtrData);
900         }
901 break;
902 case 40:
903 {
904            styleval.FeatureValuePtrData = new FeatureValueExpression(stylevsp[0].expPtrData);
905         }
906 break;
907 case 41:
908 {
909            styleval.FeatureValuePtrData=stylevsp[0].FeatureValuePtrData;
910         }
911 break;
912 case 42:
913 {
914            styleval.FeatureSetPtrData=stylevsp[-2].FeatureSetPtrData;
915         }
916 break;
917 case 43:
918 {
919           styleval.FeatureSetPtrData = new FeatureSet ();
920         }
921 break;
922 case 44:
923 {
924            if (stylevsp[0].FeaturePtrData -> name() == Symbol(gSymTab->intern("FAMILY"))) {
925              /* the evaluate() call clones $3 */
926              FeatureValueFeatureSet *fvfs = 
927                (FeatureValueFeatureSet*) stylevsp[0].FeaturePtrData->evaluate();
928              const FeatureSet* fs = fvfs->value();
929               const Feature* charsetF =
930                 fs->lookup(gSymTab->intern("CHARSET"));
931               /* charsetF is a mandatory entry in fontfamily*/
932               assert( charsetF );
933               const FeatureValueString* fv_string =
934                         (FeatureValueString*)charsetF->value();
935               const char* charset = *fv_string;
936               assert( charset );
937               
938               int entries = stylevsp[-2].FeatureSetPtrData -> entries();
939               for (int i=0; i<entries; i++) {
940                 const Feature* entry = stylevsp[-2].FeatureSetPtrData->at(i);
941                 if (! (entry->name() == Symbol(gSymTab->intern("FAMILY"))))
942                   continue;
943                 const FeatureSet* entry_fs =
944                         ((FeatureValueFeatureSet*)(entry->evaluate()))->value();
945                 const Feature* entry_charsetF =
946                         entry_fs->lookup(gSymTab->intern("CHARSET"));
947                 assert( entry_charsetF );
948                 const char* entry_charset =
949                         *((FeatureValueString*)(entry_charsetF->value()));
950                 assert( entry_charset );
951                 if (! strcmp(charset, entry_charset)) {
952                   delete stylevsp[-2].FeatureSetPtrData -> removeAt(i);
953                   break; /* escape from for-loop*/
954                 }
955               }
956               delete fvfs ;
957
958               styleval.FeatureSetPtrData = stylevsp[-2].FeatureSetPtrData;
959               styleval.FeatureSetPtrData -> add(stylevsp[0].FeaturePtrData);
960            }
961            else {
962               if ( stylevsp[-2].FeatureSetPtrData -> find((Feature*)stylevsp[0].FeaturePtrData) ) {
963                 FeatureSet* fs = new FeatureSet();
964                 fs -> add(stylevsp[0].FeaturePtrData);
965
966                 styleval.FeatureSetPtrData =new FeatureSet(*stylevsp[-2].FeatureSetPtrData, *fs);
967                 delete stylevsp[-2].FeatureSetPtrData;
968                 delete fs;
969               }
970               else {
971                 styleval.FeatureSetPtrData=stylevsp[-2].FeatureSetPtrData;
972                 styleval.FeatureSetPtrData -> add(stylevsp[0].FeaturePtrData);
973               }
974            }
975         }
976 break;
977 case 45:
978 {
979            styleval.FeatureSetPtrData=new FeatureSet();
980            styleval.FeatureSetPtrData -> add(stylevsp[0].FeaturePtrData);
981         }
982 break;
983 case 46:
984 {
985         }
986 break;
987 case 47:
988 {
989         }
990 break;
991 case 48:
992 {
993           CC_TPtrDlistIterator<char> l_Iter(*(stylevsp[-2].charPtrDlistData));
994
995           FeatureSet *fs = 0;
996           Feature *f = 0;
997           FeatureValue *fv = stylevsp[0].FeatureValuePtrData;
998           const char* cptr = 0;
999           char buffer[256];
1000           while (++l_Iter) {
1001              cptr = l_Iter.key();
1002              int index = 0 ;
1003              const char *c = cptr ;
1004              while (*c)
1005                {
1006                  if (islower(*c))
1007                    buffer[index] = toupper(*c) ;
1008                  else
1009                    buffer[index] = *c ;
1010                  c++ ;
1011                  index++;
1012                }
1013              buffer[index] = 0;
1014              /* fprintf(stderr, "converted: %s to %s\n", cptr, buffer); */
1015              f = new Feature(gSymTab -> intern(buffer), fv);
1016
1017              if ( stylevsp[-2].charPtrDlistData -> last() != cptr ) {
1018                 fs = new FeatureSet();
1019                 fs -> add(f);
1020                 fv = new FeatureValueFeatureSet(fs);
1021              }
1022           }
1023
1024           stylevsp[-2].charPtrDlistData->clearAndDestroy();
1025           delete stylevsp[-2].charPtrDlistData ;
1026           styleval.FeaturePtrData=f;
1027         }
1028 break;
1029 case 49:
1030 {
1031           stylevsp[-2].charPtrDlistData -> prepend((char *)stylevsp[0].charPtrData);
1032           styleval.charPtrDlistData=stylevsp[-2].charPtrDlistData;
1033         }
1034 break;
1035 case 50:
1036 {
1037           styleval.charPtrDlistData=new CC_TPtrDlist<char>;
1038           styleval.charPtrDlistData -> append((char *)stylevsp[0].charPtrData);
1039         }
1040 break;
1041 case 51:
1042 {
1043            styleval.PathFeatureListPtrData=new PathFeatureList;
1044            styleval.PathFeatureListPtrData -> append(new PathFeature(stylevsp[-1].PathPtrData, stylevsp[0].FeatureSetPtrData));
1045         }
1046 break;
1047 case 52:
1048 {
1049           
1050           PathFeatureListIterator l_Iter(*(stylevsp[-1].PathFeatureListPtrData));
1051
1052           while ( ++l_Iter ) {
1053              (l_Iter.key()) -> path() -> prependPath(*stylevsp[-3].PathPtrData);
1054           }
1055           delete stylevsp[-3].PathPtrData;
1056           styleval.PathFeatureListPtrData=stylevsp[-1].PathFeatureListPtrData;
1057         }
1058 break;
1059 case 53:
1060 {
1061            styleval.PathFeatureListPtrData=stylevsp[-2].PathFeatureListPtrData;
1062            styleval.PathFeatureListPtrData -> appendList(*stylevsp[0].PathFeatureListPtrData);
1063            delete stylevsp[0].PathFeatureListPtrData ;
1064         }
1065 break;
1066 case 54:
1067 {
1068            styleval.PathFeatureListPtrData=stylevsp[0].PathFeatureListPtrData;
1069         }
1070 break;
1071 case 55:
1072 {
1073           stylevsp[-1].PathPtrData -> appendPathTerm(stylevsp[0].PathTermPtrData);
1074           styleval.PathPtrData=stylevsp[-1].PathPtrData;
1075         }
1076 break;
1077 case 56:
1078 {
1079           styleval.PathPtrData = new SSPath;
1080           styleval.PathPtrData -> appendPathTerm(stylevsp[0].PathTermPtrData);
1081         }
1082 break;
1083 case 57:
1084 {
1085           styleval.PathTermPtrData=new PathTerm((const char*)stylevsp[-1].charPtrData, stylevsp[0].PQExprPtrData);
1086           delete stylevsp[-1].charPtrData;
1087         }
1088 break;
1089 case 58:
1090 {
1091           localCharToCharPtrBuf[0]=stylevsp[0].charData; localCharToCharPtrBuf[1]=0;
1092           styleval.PathTermPtrData=new PathTerm(localCharToCharPtrBuf, 0);
1093         }
1094 break;
1095 case 59:
1096 {
1097           localCharToCharPtrBuf[0]=stylevsp[0].charData; localCharToCharPtrBuf[1]=0;
1098           styleval.PathTermPtrData=new PathTerm(localCharToCharPtrBuf, 0);
1099         }
1100 break;
1101 case 60:
1102 {
1103         }
1104 break;
1105 case 61:
1106 {
1107         }
1108 break;
1109 case 62:
1110 {
1111         }
1112 break;
1113 case 63:
1114 {
1115         /* char % can start an OLIAS internal element which*/
1116         /* is used only by the browser.*/
1117         /* Example %BOGUS within HEAD1 in OLIAS book*/
1118
1119            if ( stylevsp[0].charPtrData[0] != '%' && isalnum(stylevsp[0].charPtrData[0]) == 0 ) {
1120               MESSAGE(cerr, form("%s is not a SGMLGI", stylevsp[0].charPtrData));
1121               throw(CASTBEEXCEPT badEvaluationException());
1122            }
1123           /* note, should probably be using RCStrings, would make wide */
1124           /* char handling better too? */
1125            if ( gGI_CASE_SENSITIVE == false )
1126              {
1127                for (unsigned int i=0; i<strlen((const char*)stylevsp[0].charPtrData); i++)
1128                  if ( islower(stylevsp[0].charPtrData[i]) )
1129                    stylevsp[0].charPtrData[i] = toupper(stylevsp[0].charPtrData[i]);
1130              }
1131            styleval.charPtrData=stylevsp[0].charPtrData;
1132         }
1133 break;
1134 case 64:
1135 {enter_sgmlgi_context();}
1136 break;
1137 case 65:
1138 {
1139            int l3 = strlen((char*)stylevsp[-3].charPtrData);
1140            int l0 = strlen((char*)stylevsp[0].charPtrData);
1141            int l = l3 + l0 + 2;
1142            styleval.charPtrData=new unsigned char[l];
1143
1144            *((char *) memcpy((char*)styleval.charPtrData,
1145                              (char*)stylevsp[-3].charPtrData, l3) + l3) = '\0';
1146            *((char *) memcpy((char*)(styleval.charPtrData + l3),
1147                              ".", 1) + 1) = '\0';
1148            *((char *) memcpy((char*)(styleval.charPtrData + l3 + 1),
1149                              (char*)stylevsp[0].charPtrData, l0) + l0) = '\0';
1150
1151            delete stylevsp[-3].charPtrData;
1152            delete stylevsp[0].charPtrData;
1153         }
1154 break;
1155 case 66:
1156 {
1157            int l1 = strlen((char*)stylevsp[-1].charPtrData);
1158            int l = l1 + 2;
1159            styleval.charPtrData=new unsigned char[l];
1160
1161            *((char *) memcpy((char*)styleval.charPtrData,
1162                              (char*)stylevsp[-1].charPtrData, l1) + l1) = '\0';
1163            *((char *) memcpy((char*)styleval.charPtrData + l1,
1164                              ".", 1) + 1) = '\0';
1165
1166            delete stylevsp[-1].charPtrData;
1167         }
1168 break;
1169 case 67:
1170 {
1171            styleval.charPtrData=stylevsp[0].charPtrData;
1172         }
1173 break;
1174 case 68:
1175 {
1176           unsigned int i;
1177
1178           for (i=0; i<strlen((const char*)stylevsp[0].charPtrData); i++) {
1179
1180             if ( isalpha(stylevsp[0].charPtrData[i]) ) 
1181                break;
1182           }
1183
1184           char c;
1185           float x;
1186           if ( i > 0 ) {
1187              c = stylevsp[0].charPtrData[i]; stylevsp[0].charPtrData[i]=0;
1188              x = atof((const char*)stylevsp[0].charPtrData);
1189              stylevsp[0].charPtrData[i]=c;
1190           } else
1191              x = 1;
1192
1193           styleval.termNodePtrData=new ConstantNode(new FeatureValueDimension(new FeatureValueReal(x), (const char*)&stylevsp[0].charPtrData[i]));
1194
1195           delete stylevsp[0].charPtrData;
1196         }
1197 break;
1198 case 69:
1199 {
1200            styleval.charPtrData=stylevsp[0].charPtrData;
1201         }
1202 break;
1203 case 70:
1204 {
1205            styleval.charPtrData=stylevsp[0].charPtrData;
1206         }
1207 break;
1208 case 71:
1209 {
1210            styleval.PQExprPtrData=stylevsp[-1].PQExprPtrData;
1211         }
1212 break;
1213 case 72:
1214 {
1215 /*////////////////////////////////////////////////////*/
1216 /* This portion of the code (up to equality_expr) is */
1217 /* hacked for V1.1 only. Due to the way */
1218 /* PathQualifier.h is written, this code is not */
1219 /* general at all. qfc 8/16/94*/
1220 /*////////////////////////////////////////////////////*/
1221            styleval.PQExprPtrData=stylevsp[0].PQExprPtrData;
1222         }
1223 break;
1224 case 73:
1225 {
1226            styleval.PQExprPtrData = new PQLogExpr(stylevsp[-2].PQExprPtrData, PQor, stylevsp[0].PQExprPtrData);
1227         }
1228 break;
1229 case 74:
1230 {
1231            styleval.PQExprPtrData=stylevsp[0].PQExprPtrData;
1232         }
1233 break;
1234 case 75:
1235 {
1236            styleval.PQExprPtrData = new PQLogExpr(stylevsp[-2].PQExprPtrData, PQand, stylevsp[0].PQExprPtrData);
1237         }
1238 break;
1239 case 76:
1240 {
1241           styleval.PQExprPtrData = new PQAttributeSelector(
1242                         gSymTab->intern((const char*)stylevsp[-2].charPtrData),
1243                         ( stylevsp[-1].intData == EQUAL ) ? PQEqual : PQNotEqual,
1244                         (const char*)stylevsp[0].charPtrData
1245                                       );
1246           delete stylevsp[-2].charPtrData;
1247           delete stylevsp[0].charPtrData;
1248         }
1249 break;
1250 case 77:
1251 {
1252            if ( strcasecmp((char*)stylevsp[-2].charPtrData, "position") == 0 ) {
1253              styleval.PQExprPtrData=new PQPosition(
1254                   ( stylevsp[-1].intData == EQUAL ) ? PQEqual : PQNotEqual, 
1255                   stylevsp[0].intData
1256                                 );
1257            } else
1258            if ( strcasecmp((char*)stylevsp[-2].charPtrData, "sibling") == 0 ) {
1259              styleval.PQExprPtrData=new PQSibling(
1260                   ( stylevsp[-1].intData == EQUAL ) ? PQEqual : PQNotEqual, 
1261                   stylevsp[0].intData
1262                                 );
1263            } else
1264               throw(CASTSSEXCEPT StyleSheetException());
1265
1266            delete stylevsp[-2].charPtrData;
1267         }
1268 break;
1269 case 78:
1270 {
1271            styleval.intData = (int)stylevsp[0].intData;
1272         }
1273 break;
1274 case 79:
1275 {
1276            if ( strcasecmp((char*)stylevsp[0].charPtrData, "#LAST") != 0 ) 
1277               throw(CASTSSEXCEPT StyleSheetException());
1278
1279            styleval.intData = -1;
1280         }
1281 break;
1282 case 80:
1283 {
1284
1285         }
1286 break;
1287 case 81:
1288 {
1289
1290         }
1291 break;
1292 case 82:
1293 {
1294         }
1295 break;
1296 case 83:
1297 {
1298         }
1299 break;
1300 case 84:
1301 {
1302
1303         }
1304 break;
1305 case 85:
1306 {
1307
1308         }
1309 break;
1310 case 86:
1311 {
1312           styleval.PQExprPtrData=stylevsp[0].PQExprPtrData;
1313         }
1314 break;
1315 case 87:
1316 {
1317           styleval.PQExprPtrData=0;
1318         }
1319 break;
1320     }
1321     stylessp -= stylem;
1322     stylestate = *stylessp;
1323     stylevsp -= stylem;
1324     stylem = stylelhs[stylen];
1325     if (stylestate == 0 && stylem == 0)
1326     {
1327 #if styleDEBUG
1328         if (styledebug)
1329             printf("styledebug: after reduction, shifting from state 0 to\
1330  state %d\n", styleFINAL);
1331 #endif
1332         stylestate = styleFINAL;
1333         *++stylessp = styleFINAL;
1334         *++stylevsp = styleval;
1335         if (stylechar < 0)
1336         {
1337             if ((stylechar = stylelex()) < 0) stylechar = 0;
1338 #if styleDEBUG
1339             if (styledebug)
1340             {
1341                 styles = 0;
1342                 if (stylechar <= styleMAXTOKEN) styles = stylename[stylechar];
1343                 if (!styles) styles = "illegal-symbol";
1344                 printf("styledebug: state %d, reading %d (%s)\n",
1345                         styleFINAL, stylechar, styles);
1346             }
1347 #endif
1348         }
1349         if (stylechar == 0) goto styleaccept;
1350         goto styleloop;
1351     }
1352     if ((stylen = stylegindex[stylem]) && (stylen += stylestate) >= 0 &&
1353             stylen <= styleTABLESIZE && stylecheck[stylen] == stylestate)
1354         stylestate = styletable[stylen];
1355     else
1356         stylestate = styledgoto[stylem];
1357 #if styleDEBUG
1358     if (styledebug)
1359         printf("styledebug: after reduction, shifting from state %d \
1360 to state %d\n", *stylessp, stylestate);
1361 #endif
1362     if (stylessp >= styless + stylestacksize - 1)
1363     {
1364         goto styleoverflow;
1365     }
1366     *++stylessp = stylestate;
1367     *++stylevsp = styleval;
1368     goto styleloop;
1369 styleoverflow:
1370     styleerror((char*)"yacc stack overflow");
1371 styleabort:
1372     return (1);
1373 styleaccept:
1374     return (0);
1375 }