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 librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* A lexical scanner generated by flex */
25 /* scanner skeleton version:
26 * $TOG: tokenStyle.C /main/6 1998/04/17 11:52:06 mgreess $
34 /* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
46 #if !defined(__osf__) && !defined(USL) && !defined(linux) && \
47 !defined(CSRG_BASED) && !defined(sun)
51 /* use prototypes in function declarations */
52 #define style_USE_PROTOS
54 /* the "const" storage-class-modifier is valid */
55 #define style_USE_CONST
57 #else /* ! __cplusplus */
63 void *malloc( size_t );
69 #define style_USE_PROTOS
70 #define style_USE_CONST
73 #endif /* ! __cplusplus */
77 #define style_USE_CONST
81 #ifndef style_USE_CONST
86 #ifdef style_USE_PROTOS
87 #define style_PROTO(proto) proto
89 #define style_PROTO(proto) ()
90 /* we can't get here if it's an ANSI C compiler, or a C++ compiler,
91 * so it's got to be a K&R compiler, and therefore there's no standard
92 * place from which to include these definitions
100 /* amount of stuff to slurp up with each read */
101 #ifndef style_READ_BUF_SIZE
102 #define style_READ_BUF_SIZE 8192
105 /* returned upon end-of-file */
106 #define style_END_TOK 0
108 /* copy whatever the last rule matched to the standard output */
110 /* cast to (char *) is because for 8-bit chars, styletext is (unsigned char *) */
111 /* this used to be an fputs(), but since the string might contain NUL's,
112 * we now use fwrite()
114 #define ECHO (void) fwrite( (char *) styletext, styleleng, 1, styleout )
116 /* gets input and stuffs it into "buf". number of characters read, or style_NULL,
117 * is returned in "result".
119 #define style_INPUT(buf,result,max_size) \
120 if ( (result = read( fileno(stylein), (char *) buf, max_size )) < 0 ) \
121 style_FATAL_ERROR( "read() in flex scanner failed" );
124 /* no semi-colon after return; correct usage is to write "styleterminate();" -
125 * we don't want an extra ';' after the "return" because that will cause
126 * some compilers to complain about unreachable statements.
128 #define styleterminate() return ( style_NULL )
130 /* report a fatal error */
132 /* The funky do-while is used to turn this macro definition into
133 * a single C statement (which needs a semi-colon terminator).
134 * This avoids problems with code like:
136 * if ( something_happens )
137 * style_FATAL_ERROR( "oops, the something happened" );
141 * Prior to using the do-while the compiler would get upset at the
142 * "else" because it interpreted the "if" statement as being all
143 * done when it reached the ';' after the style_FATAL_ERROR() call.
146 #define style_FATAL_ERROR(msg) \
149 (void) fputs( msg, stderr ); \
150 (void) putc( '\n', stderr ); \
155 /* default stylewrap function - always treat EOF as an EOF */
156 #define stylewrap() 1
158 /* enter a start condition. This macro really ought to take a parameter,
159 * but we do it the disgusting crufty way forced on us by the ()-less
160 * definition of BEGIN
162 #define BEGIN style_start = 1 + 2 *
164 /* action number for EOF rule of a given start state */
165 #define style_STATE_EOF(state) (style_END_OF_BUFFER + state + 1)
167 /* special action meaning "start processing a new file" */
168 #define style_NEW_FILE \
171 style_init_buffer( style_current_buffer, stylein ); \
172 style_load_buffer_state(); \
176 /* default declaration of generated scanner - a define so the user can
177 * easily add parameters
179 #define style_DECL int stylelex style_PROTO(( void ))
181 /* code executed at the end of each rule */
182 #define style_BREAK break;
184 #define style_END_OF_BUFFER_CHAR 0
186 #ifndef style_BUF_SIZE
187 #define style_BUF_SIZE (style_READ_BUF_SIZE * 2) /* size of default input buffer */
190 typedef struct style_buffer_state *style_BUFFER_STATE;
192 #define style_CHAR unsigned char
193 # line 1 "tokenStyle.l"
196 * $TOG: tokenStyle.C /main/6 1998/04/17 11:52:06 mgreess $
198 * Copyright (c) 1993 HAL Computer Systems International, Ltd.
199 * All rights reserved. Unpublished -- rights reserved under
200 * the Copyright Laws of the United States. USE OF A COPYRIGHT
201 * NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
204 * THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
205 * SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
206 * DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
207 * PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
208 * INTERNATIONAL, LTD.
210 * RESTRICTED RIGHTS LEGEND
211 * Use, duplication, or disclosure by the Government is subject
212 * to the restrictions as set forth in subparagraph (c)(l)(ii)
213 * of the Rights in Technical Data and Computer Software clause
214 * at DFARS 252.227-7013.
216 * HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
221 # line 37 "tokenStyle.l"
223 #include "ParserConst.h"
224 #include "Expression.h"
225 #include "FeatureValue.h"
226 #include "PathTable.h"
228 #include "PathQualifier.h"
229 #include "StyleSheetExceptions.h"
230 #include "style.tab.h"
235 istream *g_stylein = 0;
238 #define style_INPUT(buf,result,max_size)\
240 if (g_stylein -> eof()) {\
243 g_stylein -> read((char*)buf, max_size-1); \
244 result = g_stylein -> gcount(); \
249 unsigned char* qstring_buf = new unsigned char[1024];
250 int qstring_buf_size = 1024;
251 int qstring_buf_content_size = 0;
253 char* commentBuffer = new char [1024];
254 int commentBufferSize = 1024;
255 int commentBufferContentSize = 0;
259 void addToQstringBuf(const unsigned char* str, int size)
261 if ( size <= 0 ) return;
263 if ( qstring_buf_size - qstring_buf_content_size < size ) {
264 qstring_buf_size = 2*(size+qstring_buf_content_size);
265 unsigned char* x = new unsigned char[qstring_buf_size];
266 memcpy(x, qstring_buf, qstring_buf_content_size);
271 memcpy(qstring_buf + qstring_buf_content_size, str, size);
272 qstring_buf_content_size += size;
273 qstring_buf[qstring_buf_content_size] = 0;
279 #define quoted_string 3
280 # line 95 "tokenStyle.l"
282 /* done after the current pattern has been matched and before the
283 * corresponding action - sets up styletext
285 #define style_DO_BEFORE_ACTION \
286 styletext = style_bp; \
287 styleleng = style_cp - style_bp; \
288 style_hold_char = *style_cp; \
290 style_c_buf_p = style_cp;
292 #define EOB_ACT_CONTINUE_SCAN 0
293 #define EOB_ACT_END_OF_FILE 1
294 #define EOB_ACT_LAST_MATCH 2
296 /* return all but the first 'n' matched characters back to the input stream */
297 #define styleless(n) \
300 /* undo effects of setting up styletext */ \
301 *style_cp = style_hold_char; \
302 style_c_buf_p = style_cp = style_bp + n; \
303 style_DO_BEFORE_ACTION; /* set up styletext again */ \
307 #define unput(c) styleunput( c, styletext )
310 struct style_buffer_state
312 FILE *style_input_file;
314 style_CHAR *style_ch_buf; /* input buffer */
315 style_CHAR *style_buf_pos; /* current position in input buffer */
317 /* size of input buffer in bytes, not including room for EOB characters*/
320 /* number of characters read into style_ch_buf, not including EOB characters */
323 int style_eof_status; /* whether we've seen an EOF on this buffer */
324 #define EOF_NOT_SEEN 0
325 /* "pending" happens when the EOF has been seen but there's still
328 #define EOF_PENDING 1
332 static style_BUFFER_STATE style_current_buffer;
334 /* we provide macros for accessing buffer states in case in the
335 * future we want to put the buffer states in a more general
338 #define style_CURRENT_BUFFER style_current_buffer
341 /* style_hold_char holds the character lost when styletext is formed */
342 static style_CHAR style_hold_char;
344 static int style_n_chars; /* number of characters read into style_ch_buf */
348 #ifndef style_USER_ACTION
349 #define style_USER_ACTION
352 #ifndef style_USER_INIT
353 #define style_USER_INIT
356 extern style_CHAR *styletext;
357 extern int styleleng;
358 extern FILE *stylein, *styleout;
360 style_CHAR *styletext;
363 FILE *stylein = (FILE *) 0, *styleout = (FILE *) 0;
365 #define style_END_OF_BUFFER 48
366 typedef int style_state_type;
367 static const short int style_accept[134] =
369 0, 0, 0, 0, 0, 0, 36, 36, 48, 39,
370 41, 42, 43, 23, 33, 39, 39, 18, 19, 9,
371 5, 13, 6, 8, 7, 31, 10, 24, 3, 24,
372 11, 4, 39, 39, 39, 39, 39, 39, 39, 16,
373 17, 12, 39, 39, 14, 39, 15, 2, 45, 46,
374 45, 47, 40, 36, 36, 34, 35, 39, 22, 1,
375 21, 0, 31, 39, 39, 39, 24, 38, 39, 39,
376 38, 39, 28, 39, 39, 39, 20, 2, 2, 1,
377 44, 40, 36, 32, 30, 30, 39, 39, 39, 39,
378 39, 29, 39, 39, 39, 39, 0, 0, 0, 39,
380 39, 39, 39, 39, 39, 39, 39, 26, 30, 30,
381 0, 0, 39, 39, 27, 39, 0, 0, 0, 0,
382 39, 0, 0, 39, 39, 39, 39, 39, 39, 39,
386 static const style_CHAR style_ec[256] =
388 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
389 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
390 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
391 1, 4, 5, 6, 7, 1, 1, 8, 1, 9,
392 10, 11, 12, 13, 14, 15, 16, 17, 17, 17,
393 17, 17, 17, 17, 17, 17, 17, 18, 1, 19,
394 20, 21, 22, 23, 24, 25, 26, 25, 27, 28,
395 29, 30, 31, 25, 25, 32, 33, 34, 35, 36,
396 25, 37, 38, 39, 40, 25, 25, 41, 25, 25,
397 42, 43, 44, 45, 1, 1, 46, 25, 47, 25,
399 48, 28, 25, 30, 49, 25, 25, 32, 33, 50,
400 51, 36, 25, 37, 52, 53, 40, 54, 25, 41,
401 25, 25, 55, 56, 57, 1, 1, 1, 1, 1,
402 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
403 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
404 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
405 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
406 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
407 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
408 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
410 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
411 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
412 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
413 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
414 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
418 static const style_CHAR style_meta[58] =
420 1, 2, 3, 2, 2, 4, 1, 1, 2, 2,
421 2, 2, 2, 5, 6, 2, 5, 2, 1, 2,
422 1, 2, 2, 5, 5, 5, 5, 5, 5, 5,
423 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
424 5, 2, 7, 2, 2, 5, 5, 5, 5, 5,
428 static const short int style_base[141] =
430 0, 341, 55, 56, 112, 0, 57, 58, 347, 0,
431 349, 349, 349, 326, 349, 289, 336, 349, 349, 349,
432 349, 349, 0, 349, 349, 50, 349, 323, 322, 321,
433 349, 349, 303, 38, 300, 32, 40, 57, 284, 349,
434 349, 349, 35, 289, 349, 259, 349, 168, 349, 349,
435 307, 349, 0, 0, 0, 349, 349, 0, 349, 0,
436 0, 296, 170, 262, 37, 169, 349, 0, 262, 267,
437 44, 264, 0, 156, 44, 251, 0, 224, 0, 0,
438 349, 0, 0, 224, 0, 47, 168, 46, 51, 244,
439 259, 0, 56, 144, 155, 166, 255, 177, 223, 257,
441 152, 204, 198, 211, 234, 253, 168, 0, 349, 217,
442 237, 226, 250, 212, 0, 213, 223, 221, 229, 246,
443 164, 167, 244, 127, 59, 55, 56, 45, 30, 24,
444 24, 0, 349, 297, 304, 311, 318, 321, 327, 333
447 static const short int style_def[141] =
449 133, 1, 134, 134, 133, 5, 135, 135, 133, 136,
450 133, 133, 133, 133, 133, 136, 136, 133, 133, 133,
451 133, 133, 136, 133, 133, 136, 133, 136, 133, 136,
452 133, 133, 136, 136, 136, 136, 136, 136, 136, 133,
453 133, 133, 136, 136, 133, 136, 133, 137, 133, 133,
454 133, 133, 138, 139, 139, 133, 133, 136, 133, 136,
455 136, 133, 136, 136, 136, 136, 133, 136, 136, 136,
456 136, 136, 136, 136, 136, 136, 136, 137, 140, 78,
457 133, 138, 139, 133, 136, 136, 136, 136, 136, 136,
458 136, 136, 136, 136, 136, 136, 133, 133, 133, 136,
460 136, 136, 136, 136, 136, 136, 136, 136, 133, 133,
461 133, 133, 136, 136, 136, 136, 133, 133, 133, 133,
462 136, 133, 133, 136, 136, 136, 136, 136, 136, 136,
463 136, 136, 0, 133, 133, 133, 133, 133, 133, 133
466 static const short int style_nxt[407] =
468 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
469 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
470 30, 31, 32, 10, 10, 33, 10, 34, 35, 10,
471 36, 10, 10, 10, 37, 38, 10, 10, 39, 10,
472 10, 40, 10, 41, 42, 10, 33, 10, 36, 43,
473 44, 10, 39, 10, 45, 46, 47, 50, 50, 55,
474 55, 69, 56, 56, 62, 71, 63, 72, 73, 91,
475 86, 132, 100, 73, 95, 64, 103, 131, 130, 68,
476 65, 71, 68, 69, 73, 66, 86, 74, 104, 73,
477 91, 75, 95, 100, 103, 68, 64, 129, 65, 57,
479 57, 68, 104, 68, 128, 74, 127, 75, 126, 68,
480 51, 51, 52, 52, 52, 52, 52, 52, 52, 52,
481 52, 52, 52, 52, 52, 53, 53, 52, 53, 52,
482 52, 52, 52, 52, 52, 53, 53, 53, 53, 53,
483 53, 53, 53, 53, 53, 53, 53, 53, 53, 53,
484 53, 53, 53, 52, 52, 52, 52, 53, 53, 53,
485 53, 53, 53, 53, 53, 53, 52, 52, 52, 79,
486 106, 79, 79, 79, 125, 85, 79, 79, 79, 79,
487 79, 93, 79, 79, 62, 79, 63, 79, 107, 79,
488 79, 106, 108, 101, 85, 64, 94, 85, 109, 87,
490 65, 124, 93, 88, 107, 66, 68, 85, 102, 79,
491 110, 79, 79, 108, 101, 85, 64, 87, 65, 88,
492 68, 85, 79, 80, 79, 79, 110, 79, 79, 79,
493 113, 114, 79, 79, 79, 79, 79, 115, 79, 79,
494 84, 79, 117, 79, 109, 79, 79, 114, 109, 97,
495 85, 113, 109, 111, 98, 122, 120, 112, 115, 99,
496 121, 109, 118, 117, 85, 79, 109, 79, 79, 109,
497 97, 111, 98, 112, 120, 109, 122, 119, 79, 123,
498 79, 85, 109, 118, 68, 116, 85, 109, 68, 105,
499 96, 92, 90, 89, 85, 123, 109, 49, 49, 49,
501 49, 49, 49, 49, 54, 54, 54, 54, 54, 54,
502 54, 58, 84, 81, 77, 58, 72, 58, 78, 78,
503 76, 78, 78, 78, 78, 82, 82, 83, 83, 83,
504 70, 83, 83, 79, 79, 68, 79, 79, 79, 79,
505 67, 59, 67, 61, 60, 59, 133, 48, 9, 133,
506 133, 133, 133, 133, 133, 133, 133, 133, 133, 133,
507 133, 133, 133, 133, 133, 133, 133, 133, 133, 133,
508 133, 133, 133, 133, 133, 133, 133, 133, 133, 133,
509 133, 133, 133, 133, 133, 133, 133, 133, 133, 133,
510 133, 133, 133, 133, 133, 133, 133, 133, 133, 133,
512 133, 133, 133, 133, 133, 133
515 static const short int style_chk[407] =
517 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
518 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
519 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
520 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
521 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
522 1, 1, 1, 1, 1, 1, 1, 3, 4, 7,
523 8, 34, 7, 8, 26, 36, 26, 37, 43, 71,
524 65, 131, 86, 37, 75, 26, 88, 130, 129, 93,
525 26, 36, 38, 34, 43, 26, 65, 38, 89, 37,
526 71, 38, 75, 86, 88, 38, 26, 128, 26, 7,
528 8, 93, 89, 38, 127, 38, 126, 38, 125, 38,
529 3, 4, 5, 5, 5, 5, 5, 5, 5, 5,
530 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
531 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
532 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
533 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
534 5, 5, 5, 5, 5, 5, 5, 5, 5, 48,
535 94, 48, 48, 48, 124, 101, 48, 48, 48, 48,
536 48, 74, 48, 48, 63, 48, 63, 48, 95, 48,
537 48, 94, 96, 87, 66, 63, 74, 101, 122, 66,
539 63, 121, 74, 66, 95, 63, 107, 66, 87, 48,
540 98, 48, 48, 96, 87, 66, 63, 66, 63, 66,
541 107, 66, 48, 48, 48, 78, 98, 78, 78, 78,
542 102, 103, 78, 78, 78, 78, 78, 104, 78, 78,
543 84, 78, 110, 78, 118, 78, 78, 103, 99, 84,
544 114, 102, 117, 99, 84, 119, 112, 99, 104, 84,
545 116, 99, 111, 110, 114, 78, 118, 78, 78, 99,
546 84, 99, 84, 99, 112, 99, 119, 111, 78, 120,
547 78, 113, 123, 111, 106, 105, 100, 97, 91, 90,
548 76, 72, 70, 69, 64, 120, 123, 134, 134, 134,
550 134, 134, 134, 134, 135, 135, 135, 135, 135, 135,
551 135, 136, 62, 51, 46, 136, 44, 136, 137, 137,
552 39, 137, 137, 137, 137, 138, 138, 139, 139, 139,
553 35, 139, 139, 140, 140, 33, 140, 140, 140, 140,
554 30, 29, 28, 17, 16, 14, 9, 2, 133, 133,
555 133, 133, 133, 133, 133, 133, 133, 133, 133, 133,
556 133, 133, 133, 133, 133, 133, 133, 133, 133, 133,
557 133, 133, 133, 133, 133, 133, 133, 133, 133, 133,
558 133, 133, 133, 133, 133, 133, 133, 133, 133, 133,
559 133, 133, 133, 133, 133, 133, 133, 133, 133, 133,
561 133, 133, 133, 133, 133, 133
564 static style_state_type style_last_accepting_state;
565 static style_CHAR *style_last_accepting_cpos;
567 /* the intent behind this definition is that it'll catch
568 * any uses of REJECT which flex missed
570 #define REJECT reject_used_but_not_detected
571 #define stylemore() stylemore_used_but_not_detected
572 #define style_MORE_ADJ 0
574 /* these variables are all declared out here so that section 3 code can
577 /* points to current character in buffer */
578 static style_CHAR *style_c_buf_p = (style_CHAR *) 0;
579 static int style_init = 1; /* whether we need to initialize */
580 static int style_start = 0; /* start state number */
582 /* flag which is used to allow stylewrap()'s to do buffer switches
583 * instead of setting up a fresh stylein. A bit of a hack ...
585 static int style_did_buffer_switch_on_eof;
587 static style_state_type style_get_previous_state style_PROTO(( void ));
588 static style_state_type style_try_NUL_trans style_PROTO(( style_state_type current_state ));
589 static int style_get_next_buffer style_PROTO(( void ));
591 static void styleunput style_PROTO(( style_CHAR c, style_CHAR *buf_ptr ));
593 void stylerestart style_PROTO(( FILE *input_file ));
594 void style_switch_to_buffer style_PROTO(( style_BUFFER_STATE new_buffer ));
595 void style_load_buffer_state style_PROTO(( void ));
596 style_BUFFER_STATE style_create_buffer style_PROTO(( FILE *file, int size ));
597 void style_delete_buffer style_PROTO(( style_BUFFER_STATE b ));
598 void style_init_buffer style_PROTO(( style_BUFFER_STATE b, FILE *file ));
600 #define style_new_buffer style_create_buffer
603 static int styleinput style_PROTO(( void ));
605 static int input style_PROTO(( void ));
610 register style_state_type style_current_state;
611 register style_CHAR *style_cp, *style_bp;
612 register int style_act;
622 style_start = 1; /* first start state */
630 if ( style_current_buffer )
631 style_init_buffer( style_current_buffer, stylein );
633 style_current_buffer = style_create_buffer( stylein, style_BUF_SIZE );
635 style_load_buffer_state();
640 while ( 1 ) /* loops until end-of-file is reached */
642 style_cp = style_c_buf_p;
644 /* support of styletext */
645 *style_cp = style_hold_char;
647 /* style_bp points to the position in style_ch_buf of the start of the
652 style_current_state = style_start;
653 if ( style_bp[-1] == '\n' )
654 ++style_current_state;
658 register style_CHAR style_c = style_ec[*style_cp];
659 if ( style_accept[style_current_state] )
661 style_last_accepting_state = style_current_state;
662 style_last_accepting_cpos = style_cp;
664 while ( style_chk[style_base[style_current_state] + style_c] != style_current_state )
666 style_current_state = style_def[style_current_state];
667 if ( style_current_state >= 134 )
668 style_c = style_meta[style_c];
670 style_current_state = style_nxt[style_base[style_current_state] + style_c];
673 while ( style_current_state != 133 );
674 style_cp = style_last_accepting_cpos;
675 style_current_state = style_last_accepting_state;
678 style_act = style_accept[style_current_state];
680 style_DO_BEFORE_ACTION;
683 do_action: /* this label is used only to access EOF actions */
688 case 0: /* must backtrack */
689 /* undo the effects of style_DO_BEFORE_ACTION */
690 *style_cp = style_hold_char;
691 style_cp = style_last_accepting_cpos;
692 style_current_state = style_last_accepting_state;
693 goto style_find_action;
696 # line 97 "tokenStyle.l"
700 # line 99 "tokenStyle.l"
702 if ( commentBufferSize < styleleng ) {
703 delete commentBuffer;
704 commentBufferSize = 2 * styleleng ;
705 commentBuffer = new char [commentBufferSize];
708 commentBufferContentSize = styleleng-1;
709 memcpy(commentBuffer, styletext+1, commentBufferContentSize); // copy everything except the #
710 commentBuffer[commentBufferContentSize] = 0;
714 # line 111 "tokenStyle.l"
720 # line 115 "tokenStyle.l"
726 # line 119 "tokenStyle.l"
728 stylelval.charData = styletext[0];
733 # line 124 "tokenStyle.l"
735 stylelval.charData = styletext[0];
740 # line 129 "tokenStyle.l"
742 stylelval.charData = styletext[0];
747 # line 134 "tokenStyle.l"
753 # line 138 "tokenStyle.l"
755 stylelval.charData = styletext[0];
760 # line 143 "tokenStyle.l"
766 # line 147 "tokenStyle.l"
772 # line 151 "tokenStyle.l"
778 # line 155 "tokenStyle.l"
784 # line 159 "tokenStyle.l"
790 # line 163 "tokenStyle.l"
796 # line 167 "tokenStyle.l"
802 # line 171 "tokenStyle.l"
808 # line 175 "tokenStyle.l"
810 return(OPER_parenopen);
814 # line 179 "tokenStyle.l"
816 return(OPER_parenclose);
820 # line 183 "tokenStyle.l"
826 # line 187 "tokenStyle.l"
832 # line 191 "tokenStyle.l"
834 if ( strcmp((const char*)styletext, "==") == 0 )
835 stylelval.intData = EQUAL;
837 stylelval.intData = NOT_EQUAL;
839 return(OPER_equality);
843 # line 200 "tokenStyle.l"
845 return(OPER_logicalnegate);
849 # line 204 "tokenStyle.l"
851 if ( strcmp((const char*)styletext, "<=") == 0 )
852 stylelval.intData = LESS_OR_EQUAL;
854 if ( strcmp((const char*)styletext, "<") == 0 )
855 stylelval.intData = LESS;
857 if ( strcmp((const char*)styletext, ">=") == 0 )
858 stylelval.intData = GREATER_OR_EQUAL;
860 stylelval.intData = GREATER;
862 return(OPER_relational);
866 # line 219 "tokenStyle.l"
868 return(GI_CASE_SENSITIVE);
872 # line 223 "tokenStyle.l"
874 stylelval.boolData = true;
879 # line 228 "tokenStyle.l"
881 stylelval.boolData = false;
886 # line 233 "tokenStyle.l"
888 stylelval.boolData = true;
893 # line 238 "tokenStyle.l"
895 stylelval.boolData = false;
900 # line 243 "tokenStyle.l"
902 stylelval.charPtrData =
903 (unsigned char*)strdup((const char*)styletext);
908 # line 249 "tokenStyle.l"
910 stylelval.intData = atoi((char*)styletext);
915 # line 254 "tokenStyle.l"
917 stylelval.realData = atof((char*)styletext);
922 # line 259 "tokenStyle.l"
928 # line 263 "tokenStyle.l"
931 stylelval.charPtrData =
932 new unsigned char[qstring_buf_content_size+1];
933 memcpy( stylelval.charPtrData,
935 qstring_buf_content_size+1
938 qstring_buf_content_size = 0;
941 return(QUOTED_STRING);
945 # line 278 "tokenStyle.l"
947 int c = styleinput();
950 addToQstringBuf((unsigned char*)"\"", 1);
953 addToQstringBuf((unsigned char*)"\\", 1);
956 throw(CASTSSEXCEPT StyleSheetException());
961 # line 292 "tokenStyle.l"
963 addToQstringBuf((const unsigned char *)styletext, styleleng);
967 # line 296 "tokenStyle.l"
969 addToQstringBuf((const unsigned char *)styletext, styleleng);
973 # line 300 "tokenStyle.l"
975 stylelval.charPtrData =
976 (unsigned char*)strdup((const char*)styletext);
981 # line 306 "tokenStyle.l"
983 stylelval.charPtrData =
984 (unsigned char*)strdup((const char*)styletext);
985 return(NORMAL_STRING);
989 # line 312 "tokenStyle.l"
991 stylelval.charPtrData =
992 (unsigned char*)strdup((const char*)styletext);
994 return(SGMLGI_STRING);
998 # line 319 "tokenStyle.l"
1003 # line 322 "tokenStyle.l"
1009 # line 326 "tokenStyle.l"
1014 # line 331 "tokenStyle.l"
1018 # line 332 "tokenStyle.l"
1022 # line 333 "tokenStyle.l"
1026 # line 334 "tokenStyle.l"
1027 style_FATAL_ERROR( "flex scanner jammed" );
1029 case style_STATE_EOF(INITIAL):
1030 case style_STATE_EOF(block):
1031 case style_STATE_EOF(sgmlgimode):
1032 case style_STATE_EOF(quoted_string):
1035 case style_END_OF_BUFFER:
1037 /* amount of text matched not including the EOB char */
1038 int style_amount_of_matched_text = style_cp - styletext - 1;
1040 /* undo the effects of style_DO_BEFORE_ACTION */
1041 *style_cp = style_hold_char;
1043 /* note that here we test for style_c_buf_p "<=" to the position
1044 * of the first EOB in the buffer, since style_c_buf_p will
1045 * already have been incremented past the NUL character
1046 * (since all states make transitions on EOB to the end-
1047 * of-buffer state). Contrast this with the test in styleinput().
1049 if ( style_c_buf_p <= &style_current_buffer->style_ch_buf[style_n_chars] )
1050 /* this was really a NUL */
1052 style_state_type style_next_state;
1054 style_c_buf_p = styletext + style_amount_of_matched_text;
1056 style_current_state = style_get_previous_state();
1058 /* okay, we're now positioned to make the
1059 * NUL transition. We couldn't have
1060 * style_get_previous_state() go ahead and do it
1061 * for us because it doesn't know how to deal
1062 * with the possibility of jamming (and we
1063 * don't want to build jamming into it because
1064 * then it will run more slowly)
1067 style_next_state = style_try_NUL_trans( style_current_state );
1069 style_bp = styletext + style_MORE_ADJ;
1071 if ( style_next_state )
1073 /* consume the NUL */
1074 style_cp = ++style_c_buf_p;
1075 style_current_state = style_next_state;
1081 style_cp = style_last_accepting_cpos;
1082 style_current_state = style_last_accepting_state;
1083 goto style_find_action;
1087 else switch ( style_get_next_buffer() )
1089 case EOB_ACT_END_OF_FILE:
1091 style_did_buffer_switch_on_eof = 0;
1095 /* note: because we've taken care in
1096 * style_get_next_buffer() to have set up styletext,
1097 * we can now set up style_c_buf_p so that if some
1098 * total hoser (like flex itself) wants
1099 * to call the scanner after we return the
1100 * style_NULL, it'll still work - another style_NULL
1101 * will get returned.
1103 style_c_buf_p = styletext + style_MORE_ADJ;
1105 style_act = style_STATE_EOF((style_start - 1) / 2);
1111 if ( ! style_did_buffer_switch_on_eof )
1117 case EOB_ACT_CONTINUE_SCAN:
1118 style_c_buf_p = styletext + style_amount_of_matched_text;
1120 style_current_state = style_get_previous_state();
1122 style_cp = style_c_buf_p;
1123 style_bp = styletext + style_MORE_ADJ;
1126 case EOB_ACT_LAST_MATCH:
1128 &style_current_buffer->style_ch_buf[style_n_chars];
1130 style_current_state = style_get_previous_state();
1132 style_cp = style_c_buf_p;
1133 style_bp = styletext + style_MORE_ADJ;
1134 goto style_find_action;
1141 printf( "action # %d\n", style_act );
1144 "fatal flex scanner internal error--no action found" );
1150 /* style_get_next_buffer - try to read in a new buffer
1153 * int style_get_next_buffer();
1155 * returns a code representing an action
1156 * EOB_ACT_LAST_MATCH -
1157 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1158 * EOB_ACT_END_OF_FILE - end of file
1161 static int style_get_next_buffer()
1164 register style_CHAR *dest = style_current_buffer->style_ch_buf;
1165 register style_CHAR *source = styletext - 1; /* copy prev. char, too */
1166 register int number_to_move, i;
1169 if ( style_c_buf_p > &style_current_buffer->style_ch_buf[style_n_chars + 1] )
1171 "fatal flex scanner internal error--end of buffer missed" );
1173 /* try to read more data */
1175 /* first move last chars to start of buffer */
1176 number_to_move = style_c_buf_p - styletext;
1178 for ( i = 0; i < number_to_move; ++i )
1179 *(dest++) = *(source++);
1181 if ( style_current_buffer->style_eof_status != EOF_NOT_SEEN )
1182 /* don't do the read, it's not guaranteed to return an EOF,
1189 int num_to_read = style_current_buffer->style_buf_size - number_to_move - 1;
1191 if ( num_to_read > style_READ_BUF_SIZE )
1192 num_to_read = style_READ_BUF_SIZE;
1194 else if ( num_to_read <= 0 )
1195 style_FATAL_ERROR( "fatal error - scanner input buffer overflow" );
1197 /* read in more data */
1198 style_INPUT( (&style_current_buffer->style_ch_buf[number_to_move]),
1199 style_n_chars, num_to_read );
1202 if ( style_n_chars == 0 )
1204 if ( number_to_move == 1 )
1206 ret_val = EOB_ACT_END_OF_FILE;
1207 style_current_buffer->style_eof_status = EOF_DONE;
1212 ret_val = EOB_ACT_LAST_MATCH;
1213 style_current_buffer->style_eof_status = EOF_PENDING;
1218 ret_val = EOB_ACT_CONTINUE_SCAN;
1220 style_n_chars += number_to_move;
1221 style_current_buffer->style_ch_buf[style_n_chars] = style_END_OF_BUFFER_CHAR;
1222 style_current_buffer->style_ch_buf[style_n_chars + 1] = style_END_OF_BUFFER_CHAR;
1224 /* styletext begins at the second character in style_ch_buf; the first
1225 * character is the one which preceded it before reading in the latest
1226 * buffer; it needs to be kept around in case it's a newline, so
1227 * style_get_previous_state() will have with '^' rules active
1230 styletext = &style_current_buffer->style_ch_buf[1];
1236 /* style_get_previous_state - get the state just before the EOB char was reached
1239 * style_state_type style_get_previous_state();
1242 static style_state_type style_get_previous_state()
1245 register style_state_type style_current_state;
1246 register style_CHAR *style_cp;
1248 register style_CHAR *style_bp = styletext;
1250 style_current_state = style_start;
1251 if ( style_bp[-1] == '\n' )
1252 ++style_current_state;
1254 for ( style_cp = styletext + style_MORE_ADJ; style_cp < style_c_buf_p; ++style_cp )
1256 register style_CHAR style_c = (*style_cp ? style_ec[*style_cp] : 1);
1257 if ( style_accept[style_current_state] )
1259 style_last_accepting_state = style_current_state;
1260 style_last_accepting_cpos = style_cp;
1262 while ( style_chk[style_base[style_current_state] + style_c] != style_current_state )
1264 style_current_state = style_def[style_current_state];
1265 if ( style_current_state >= 134 )
1266 style_c = style_meta[style_c];
1268 style_current_state = style_nxt[style_base[style_current_state] + style_c];
1271 return ( style_current_state );
1275 /* style_try_NUL_trans - try to make a transition on the NUL character
1278 * next_state = style_try_NUL_trans( current_state );
1281 #ifdef style_USE_PROTOS
1282 static style_state_type style_try_NUL_trans( register style_state_type style_current_state )
1284 static style_state_type style_try_NUL_trans( style_current_state )
1285 register style_state_type style_current_state;
1289 register int style_is_jam;
1290 register style_CHAR *style_cp = style_c_buf_p;
1292 register style_CHAR style_c = 1;
1293 if ( style_accept[style_current_state] )
1295 style_last_accepting_state = style_current_state;
1296 style_last_accepting_cpos = style_cp;
1298 while ( style_chk[style_base[style_current_state] + style_c] != style_current_state )
1300 style_current_state = style_def[style_current_state];
1301 if ( style_current_state >= 134 )
1302 style_c = style_meta[style_c];
1304 style_current_state = style_nxt[style_base[style_current_state] + style_c];
1305 style_is_jam = (style_current_state == 133);
1307 return ( style_is_jam ? 0 : style_current_state );
1312 #ifdef style_USE_PROTOS
1313 static void styleunput( style_CHAR c, register style_CHAR *style_bp )
1315 static void styleunput( c, style_bp )
1317 register style_CHAR *style_bp;
1321 register style_CHAR *style_cp = style_c_buf_p;
1323 /* undo effects of setting up styletext */
1324 *style_cp = style_hold_char;
1326 if ( style_cp < style_current_buffer->style_ch_buf + 2 )
1327 { /* need to shift things up to make room */
1328 register int number_to_move = style_n_chars + 2; /* +2 for EOB chars */
1329 register style_CHAR *dest =
1330 &style_current_buffer->style_ch_buf[style_current_buffer->style_buf_size + 2];
1331 register style_CHAR *source =
1332 &style_current_buffer->style_ch_buf[number_to_move];
1334 while ( source > style_current_buffer->style_ch_buf )
1335 *--dest = *--source;
1337 style_cp += dest - source;
1338 style_bp += dest - source;
1339 style_n_chars = style_current_buffer->style_buf_size;
1341 if ( style_cp < style_current_buffer->style_ch_buf + 2 )
1342 style_FATAL_ERROR( "flex scanner push-back overflow" );
1345 if ( style_cp > style_bp && style_cp[-1] == '\n' )
1346 style_cp[-2] = '\n';
1350 /* note: the formal parameter *must* be called "style_bp" for this
1351 * macro to now work correctly
1353 style_DO_BEFORE_ACTION; /* set up styletext again */
1359 static int styleinput()
1366 style_CHAR *style_cp = style_c_buf_p;
1368 *style_cp = style_hold_char;
1370 if ( *style_c_buf_p == style_END_OF_BUFFER_CHAR )
1372 /* style_c_buf_p now points to the character we want to return.
1373 * If this occurs *before* the EOB characters, then it's a
1374 * valid NUL; if not, then we've hit the end of the buffer.
1376 if ( style_c_buf_p < &style_current_buffer->style_ch_buf[style_n_chars] )
1377 /* this was really a NUL */
1378 *style_c_buf_p = '\0';
1381 { /* need more input */
1382 styletext = style_c_buf_p;
1385 switch ( style_get_next_buffer() )
1387 case EOB_ACT_END_OF_FILE:
1391 style_c_buf_p = styletext + style_MORE_ADJ;
1398 return ( styleinput() );
1405 case EOB_ACT_CONTINUE_SCAN:
1406 style_c_buf_p = styletext + style_MORE_ADJ;
1409 case EOB_ACT_LAST_MATCH:
1411 style_FATAL_ERROR( "unexpected last match in styleinput()" );
1413 style_FATAL_ERROR( "unexpected last match in input()" );
1420 style_hold_char = *++style_c_buf_p;
1426 #ifdef style_USE_PROTOS
1427 void stylerestart( FILE *input_file )
1429 void stylerestart( input_file )
1434 style_init_buffer( style_current_buffer, input_file );
1435 style_load_buffer_state();
1439 #ifdef style_USE_PROTOS
1440 void style_switch_to_buffer( style_BUFFER_STATE new_buffer )
1442 void style_switch_to_buffer( new_buffer )
1443 style_BUFFER_STATE new_buffer;
1447 if ( style_current_buffer == new_buffer )
1450 if ( style_current_buffer )
1452 /* flush out information for old buffer */
1453 *style_c_buf_p = style_hold_char;
1454 style_current_buffer->style_buf_pos = style_c_buf_p;
1455 style_current_buffer->style_n_chars = style_n_chars;
1458 style_current_buffer = new_buffer;
1459 style_load_buffer_state();
1461 /* we don't actually know whether we did this switch during
1462 * EOF (stylewrap()) processing, but the only time this flag
1463 * is looked at is after stylewrap() is called, so it's safe
1464 * to go ahead and always set it.
1466 style_did_buffer_switch_on_eof = 1;
1470 #ifdef style_USE_PROTOS
1471 void style_load_buffer_state( void )
1473 void style_load_buffer_state()
1477 style_n_chars = style_current_buffer->style_n_chars;
1478 styletext = style_c_buf_p = style_current_buffer->style_buf_pos;
1479 stylein = style_current_buffer->style_input_file;
1480 style_hold_char = *style_c_buf_p;
1484 #ifdef style_USE_PROTOS
1485 style_BUFFER_STATE style_create_buffer( FILE *file, int size )
1487 style_BUFFER_STATE style_create_buffer( file, size )
1493 style_BUFFER_STATE b;
1495 b = (style_BUFFER_STATE) malloc( sizeof( struct style_buffer_state ) );
1498 style_FATAL_ERROR( "out of dynamic memory in style_create_buffer()" );
1500 b->style_buf_size = size;
1502 /* style_ch_buf has to be 2 characters longer than the size given because
1503 * we need to put in 2 end-of-buffer characters.
1505 b->style_ch_buf = (style_CHAR *) malloc( (unsigned) (b->style_buf_size + 2) );
1507 if ( ! b->style_ch_buf )
1508 style_FATAL_ERROR( "out of dynamic memory in style_create_buffer()" );
1510 style_init_buffer( b, file );
1516 #ifdef style_USE_PROTOS
1517 void style_delete_buffer( style_BUFFER_STATE b )
1519 void style_delete_buffer( b )
1520 style_BUFFER_STATE b;
1524 if ( b == style_current_buffer )
1525 style_current_buffer = (style_BUFFER_STATE) 0;
1527 free( (char *) b->style_ch_buf );
1532 #ifdef style_USE_PROTOS
1533 void style_init_buffer( style_BUFFER_STATE b, FILE *file )
1535 void style_init_buffer( b, file )
1536 style_BUFFER_STATE b;
1541 b->style_input_file = file;
1543 /* we put in the '\n' and start reading from [1] so that an
1544 * initial match-at-newline will be true.
1547 b->style_ch_buf[0] = '\n';
1548 b->style_n_chars = 1;
1550 /* we always need two end-of-buffer characters. The first causes
1551 * a transition to the end-of-buffer state. The second causes
1552 * a jam in that state.
1554 b->style_ch_buf[1] = style_END_OF_BUFFER_CHAR;
1555 b->style_ch_buf[2] = style_END_OF_BUFFER_CHAR;
1557 b->style_buf_pos = &b->style_ch_buf[1];
1559 b->style_eof_status = EOF_NOT_SEEN;
1561 # line 334 "tokenStyle.l"
1564 void enter_sgmlgi_context()
1570 void report_error_location()
1572 if ( commentBufferContentSize > 0 ) {
1573 cerr << commentBuffer << "\n";
1577 void styleerror(char* msg)
1580 cerr << "line " << stylelineno << ": " << msg << "\n";
1582 throw(CASTSSEXCEPT StyleSheetSyntaxError());