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 /* 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(__linux__) && !defined(CSRG_BASED) && !defined(sun)
50 /* use prototypes in function declarations */
51 #define style_USE_PROTOS
53 /* the "const" storage-class-modifier is valid */
54 #define style_USE_CONST
56 #else /* ! __cplusplus */
62 void *malloc( size_t );
68 #define style_USE_PROTOS
69 #define style_USE_CONST
72 #endif /* ! __cplusplus */
76 #define style_USE_CONST
80 #ifndef style_USE_CONST
85 #ifdef style_USE_PROTOS
86 #define style_PROTO(proto) proto
88 #define style_PROTO(proto) ()
89 /* we can't get here if it's an ANSI C compiler, or a C++ compiler,
90 * so it's got to be a K&R compiler, and therefore there's no standard
91 * place from which to include these definitions
99 /* amount of stuff to slurp up with each read */
100 #ifndef style_READ_BUF_SIZE
101 #define style_READ_BUF_SIZE 8192
104 /* returned upon end-of-file */
105 #define style_END_TOK 0
107 /* copy whatever the last rule matched to the standard output */
109 /* cast to (char *) is because for 8-bit chars, styletext is (unsigned char *) */
110 /* this used to be an fputs(), but since the string might contain NUL's,
111 * we now use fwrite()
113 #define ECHO (void) fwrite( (char *) styletext, styleleng, 1, styleout )
115 /* gets input and stuffs it into "buf". number of characters read, or style_NULL,
116 * is returned in "result".
118 #define style_INPUT(buf,result,max_size) \
119 if ( (result = read( fileno(stylein), (char *) buf, max_size )) < 0 ) \
120 style_FATAL_ERROR( "read() in flex scanner failed" );
123 /* no semi-colon after return; correct usage is to write "styleterminate();" -
124 * we don't want an extra ';' after the "return" because that will cause
125 * some compilers to complain about unreachable statements.
127 #define styleterminate() return ( style_NULL )
129 /* report a fatal error */
131 /* The funky do-while is used to turn this macro definition into
132 * a single C statement (which needs a semi-colon terminator).
133 * This avoids problems with code like:
135 * if ( something_happens )
136 * style_FATAL_ERROR( "oops, the something happened" );
140 * Prior to using the do-while the compiler would get upset at the
141 * "else" because it interpreted the "if" statement as being all
142 * done when it reached the ';' after the style_FATAL_ERROR() call.
145 #define style_FATAL_ERROR(msg) \
148 (void) fputs( msg, stderr ); \
149 (void) putc( '\n', stderr ); \
154 /* default stylewrap function - always treat EOF as an EOF */
155 #define stylewrap() 1
157 /* enter a start condition. This macro really ought to take a parameter,
158 * but we do it the disgusting crufty way forced on us by the ()-less
159 * definition of BEGIN
161 #define BEGIN style_start = 1 + 2 *
163 /* action number for EOF rule of a given start state */
164 #define style_STATE_EOF(state) (style_END_OF_BUFFER + state + 1)
166 /* special action meaning "start processing a new file" */
167 #define style_NEW_FILE \
170 style_init_buffer( style_current_buffer, stylein ); \
171 style_load_buffer_state(); \
175 /* default declaration of generated scanner - a define so the user can
176 * easily add parameters
178 #define style_DECL int stylelex style_PROTO(( void ))
180 /* code executed at the end of each rule */
181 #define style_BREAK break;
183 #define style_END_OF_BUFFER_CHAR 0
185 #ifndef style_BUF_SIZE
186 #define style_BUF_SIZE (style_READ_BUF_SIZE * 2) /* size of default input buffer */
189 typedef struct style_buffer_state *style_BUFFER_STATE;
191 #define style_CHAR unsigned char
192 # line 1 "tokenStyle.l"
195 * $TOG: tokenStyle.C /main/6 1998/04/17 11:52:06 mgreess $
197 * Copyright (c) 1993 HAL Computer Systems International, Ltd.
198 * All rights reserved. Unpublished -- rights reserved under
199 * the Copyright Laws of the United States. USE OF A COPYRIGHT
200 * NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
203 * THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
204 * SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
205 * DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
206 * PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
207 * INTERNATIONAL, LTD.
209 * RESTRICTED RIGHTS LEGEND
210 * Use, duplication, or disclosure by the Government is subject
211 * to the restrictions as set forth in subparagraph (c)(l)(ii)
212 * of the Rights in Technical Data and Computer Software clause
213 * at DFARS 252.227-7013.
215 * HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
220 # line 37 "tokenStyle.l"
222 #include "ParserConst.h"
223 #include "Expression.h"
224 #include "FeatureValue.h"
225 #include "PathTable.h"
227 #include "PathQualifier.h"
228 #include "StyleSheetExceptions.h"
229 #include "style.tab.h"
234 istream *g_stylein = 0;
237 #define style_INPUT(buf,result,max_size)\
239 if (g_stylein -> eof()) {\
242 g_stylein -> read((char*)buf, max_size-1); \
243 result = g_stylein -> gcount(); \
248 unsigned char* qstring_buf = new unsigned char[1024];
249 int qstring_buf_size = 1024;
250 int qstring_buf_content_size = 0;
252 char* commentBuffer = new char [1024];
253 int commentBufferSize = 1024;
254 int commentBufferContentSize = 0;
258 void addToQstringBuf(const unsigned char* str, int size)
260 if ( size <= 0 ) return;
262 if ( qstring_buf_size - qstring_buf_content_size < size ) {
263 qstring_buf_size = 2*(size+qstring_buf_content_size);
264 unsigned char* x = new unsigned char[qstring_buf_size];
265 memcpy(x, qstring_buf, qstring_buf_content_size);
266 delete [] qstring_buf;
270 memcpy(qstring_buf + qstring_buf_content_size, str, size);
271 qstring_buf_content_size += size;
272 qstring_buf[qstring_buf_content_size] = 0;
278 #define quoted_string 3
279 # line 95 "tokenStyle.l"
281 /* done after the current pattern has been matched and before the
282 * corresponding action - sets up styletext
284 #define style_DO_BEFORE_ACTION \
285 styletext = style_bp; \
286 styleleng = style_cp - style_bp; \
287 style_hold_char = *style_cp; \
289 style_c_buf_p = style_cp;
291 #define EOB_ACT_CONTINUE_SCAN 0
292 #define EOB_ACT_END_OF_FILE 1
293 #define EOB_ACT_LAST_MATCH 2
295 /* return all but the first 'n' matched characters back to the input stream */
296 #define styleless(n) \
299 /* undo effects of setting up styletext */ \
300 *style_cp = style_hold_char; \
301 style_c_buf_p = style_cp = style_bp + n; \
302 style_DO_BEFORE_ACTION; /* set up styletext again */ \
306 #define unput(c) styleunput( c, styletext )
309 struct style_buffer_state
311 FILE *style_input_file;
313 style_CHAR *style_ch_buf; /* input buffer */
314 style_CHAR *style_buf_pos; /* current position in input buffer */
316 /* size of input buffer in bytes, not including room for EOB characters*/
319 /* number of characters read into style_ch_buf, not including EOB characters */
322 int style_eof_status; /* whether we've seen an EOF on this buffer */
323 #define EOF_NOT_SEEN 0
324 /* "pending" happens when the EOF has been seen but there's still
327 #define EOF_PENDING 1
331 static style_BUFFER_STATE style_current_buffer;
333 /* we provide macros for accessing buffer states in case in the
334 * future we want to put the buffer states in a more general
337 #define style_CURRENT_BUFFER style_current_buffer
340 /* style_hold_char holds the character lost when styletext is formed */
341 static style_CHAR style_hold_char;
343 static int style_n_chars; /* number of characters read into style_ch_buf */
347 #ifndef style_USER_ACTION
348 #define style_USER_ACTION
351 #ifndef style_USER_INIT
352 #define style_USER_INIT
355 extern style_CHAR *styletext;
356 extern int styleleng;
357 extern FILE *stylein, *styleout;
359 style_CHAR *styletext;
362 FILE *stylein = (FILE *) 0, *styleout = (FILE *) 0;
364 #define style_END_OF_BUFFER 48
365 typedef int style_state_type;
366 static const short int style_accept[134] =
368 0, 0, 0, 0, 0, 0, 36, 36, 48, 39,
369 41, 42, 43, 23, 33, 39, 39, 18, 19, 9,
370 5, 13, 6, 8, 7, 31, 10, 24, 3, 24,
371 11, 4, 39, 39, 39, 39, 39, 39, 39, 16,
372 17, 12, 39, 39, 14, 39, 15, 2, 45, 46,
373 45, 47, 40, 36, 36, 34, 35, 39, 22, 1,
374 21, 0, 31, 39, 39, 39, 24, 38, 39, 39,
375 38, 39, 28, 39, 39, 39, 20, 2, 2, 1,
376 44, 40, 36, 32, 30, 30, 39, 39, 39, 39,
377 39, 29, 39, 39, 39, 39, 0, 0, 0, 39,
379 39, 39, 39, 39, 39, 39, 39, 26, 30, 30,
380 0, 0, 39, 39, 27, 39, 0, 0, 0, 0,
381 39, 0, 0, 39, 39, 39, 39, 39, 39, 39,
385 static const style_CHAR style_ec[256] =
387 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
388 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
389 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
390 1, 4, 5, 6, 7, 1, 1, 8, 1, 9,
391 10, 11, 12, 13, 14, 15, 16, 17, 17, 17,
392 17, 17, 17, 17, 17, 17, 17, 18, 1, 19,
393 20, 21, 22, 23, 24, 25, 26, 25, 27, 28,
394 29, 30, 31, 25, 25, 32, 33, 34, 35, 36,
395 25, 37, 38, 39, 40, 25, 25, 41, 25, 25,
396 42, 43, 44, 45, 1, 1, 46, 25, 47, 25,
398 48, 28, 25, 30, 49, 25, 25, 32, 33, 50,
399 51, 36, 25, 37, 52, 53, 40, 54, 25, 41,
400 25, 25, 55, 56, 57, 1, 1, 1, 1, 1,
401 1, 1, 1, 1, 1, 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,
409 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,
417 static const style_CHAR style_meta[58] =
419 1, 2, 3, 2, 2, 4, 1, 1, 2, 2,
420 2, 2, 2, 5, 6, 2, 5, 2, 1, 2,
421 1, 2, 2, 5, 5, 5, 5, 5, 5, 5,
422 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
423 5, 2, 7, 2, 2, 5, 5, 5, 5, 5,
427 static const short int style_base[141] =
429 0, 341, 55, 56, 112, 0, 57, 58, 347, 0,
430 349, 349, 349, 326, 349, 289, 336, 349, 349, 349,
431 349, 349, 0, 349, 349, 50, 349, 323, 322, 321,
432 349, 349, 303, 38, 300, 32, 40, 57, 284, 349,
433 349, 349, 35, 289, 349, 259, 349, 168, 349, 349,
434 307, 349, 0, 0, 0, 349, 349, 0, 349, 0,
435 0, 296, 170, 262, 37, 169, 349, 0, 262, 267,
436 44, 264, 0, 156, 44, 251, 0, 224, 0, 0,
437 349, 0, 0, 224, 0, 47, 168, 46, 51, 244,
438 259, 0, 56, 144, 155, 166, 255, 177, 223, 257,
440 152, 204, 198, 211, 234, 253, 168, 0, 349, 217,
441 237, 226, 250, 212, 0, 213, 223, 221, 229, 246,
442 164, 167, 244, 127, 59, 55, 56, 45, 30, 24,
443 24, 0, 349, 297, 304, 311, 318, 321, 327, 333
446 static const short int style_def[141] =
448 133, 1, 134, 134, 133, 5, 135, 135, 133, 136,
449 133, 133, 133, 133, 133, 136, 136, 133, 133, 133,
450 133, 133, 136, 133, 133, 136, 133, 136, 133, 136,
451 133, 133, 136, 136, 136, 136, 136, 136, 136, 133,
452 133, 133, 136, 136, 133, 136, 133, 137, 133, 133,
453 133, 133, 138, 139, 139, 133, 133, 136, 133, 136,
454 136, 133, 136, 136, 136, 136, 133, 136, 136, 136,
455 136, 136, 136, 136, 136, 136, 136, 137, 140, 78,
456 133, 138, 139, 133, 136, 136, 136, 136, 136, 136,
457 136, 136, 136, 136, 136, 136, 133, 133, 133, 136,
459 136, 136, 136, 136, 136, 136, 136, 136, 133, 133,
460 133, 133, 136, 136, 136, 136, 133, 133, 133, 133,
461 136, 133, 133, 136, 136, 136, 136, 136, 136, 136,
462 136, 136, 0, 133, 133, 133, 133, 133, 133, 133
465 static const short int style_nxt[407] =
467 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
468 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
469 30, 31, 32, 10, 10, 33, 10, 34, 35, 10,
470 36, 10, 10, 10, 37, 38, 10, 10, 39, 10,
471 10, 40, 10, 41, 42, 10, 33, 10, 36, 43,
472 44, 10, 39, 10, 45, 46, 47, 50, 50, 55,
473 55, 69, 56, 56, 62, 71, 63, 72, 73, 91,
474 86, 132, 100, 73, 95, 64, 103, 131, 130, 68,
475 65, 71, 68, 69, 73, 66, 86, 74, 104, 73,
476 91, 75, 95, 100, 103, 68, 64, 129, 65, 57,
478 57, 68, 104, 68, 128, 74, 127, 75, 126, 68,
479 51, 51, 52, 52, 52, 52, 52, 52, 52, 52,
480 52, 52, 52, 52, 52, 53, 53, 52, 53, 52,
481 52, 52, 52, 52, 52, 53, 53, 53, 53, 53,
482 53, 53, 53, 53, 53, 53, 53, 53, 53, 53,
483 53, 53, 53, 52, 52, 52, 52, 53, 53, 53,
484 53, 53, 53, 53, 53, 53, 52, 52, 52, 79,
485 106, 79, 79, 79, 125, 85, 79, 79, 79, 79,
486 79, 93, 79, 79, 62, 79, 63, 79, 107, 79,
487 79, 106, 108, 101, 85, 64, 94, 85, 109, 87,
489 65, 124, 93, 88, 107, 66, 68, 85, 102, 79,
490 110, 79, 79, 108, 101, 85, 64, 87, 65, 88,
491 68, 85, 79, 80, 79, 79, 110, 79, 79, 79,
492 113, 114, 79, 79, 79, 79, 79, 115, 79, 79,
493 84, 79, 117, 79, 109, 79, 79, 114, 109, 97,
494 85, 113, 109, 111, 98, 122, 120, 112, 115, 99,
495 121, 109, 118, 117, 85, 79, 109, 79, 79, 109,
496 97, 111, 98, 112, 120, 109, 122, 119, 79, 123,
497 79, 85, 109, 118, 68, 116, 85, 109, 68, 105,
498 96, 92, 90, 89, 85, 123, 109, 49, 49, 49,
500 49, 49, 49, 49, 54, 54, 54, 54, 54, 54,
501 54, 58, 84, 81, 77, 58, 72, 58, 78, 78,
502 76, 78, 78, 78, 78, 82, 82, 83, 83, 83,
503 70, 83, 83, 79, 79, 68, 79, 79, 79, 79,
504 67, 59, 67, 61, 60, 59, 133, 48, 9, 133,
505 133, 133, 133, 133, 133, 133, 133, 133, 133, 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,
511 133, 133, 133, 133, 133, 133
514 static const short int style_chk[407] =
516 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
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, 3, 4, 7,
522 8, 34, 7, 8, 26, 36, 26, 37, 43, 71,
523 65, 131, 86, 37, 75, 26, 88, 130, 129, 93,
524 26, 36, 38, 34, 43, 26, 65, 38, 89, 37,
525 71, 38, 75, 86, 88, 38, 26, 128, 26, 7,
527 8, 93, 89, 38, 127, 38, 126, 38, 125, 38,
528 3, 4, 5, 5, 5, 5, 5, 5, 5, 5,
529 5, 5, 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, 48,
534 94, 48, 48, 48, 124, 101, 48, 48, 48, 48,
535 48, 74, 48, 48, 63, 48, 63, 48, 95, 48,
536 48, 94, 96, 87, 66, 63, 74, 101, 122, 66,
538 63, 121, 74, 66, 95, 63, 107, 66, 87, 48,
539 98, 48, 48, 96, 87, 66, 63, 66, 63, 66,
540 107, 66, 48, 48, 48, 78, 98, 78, 78, 78,
541 102, 103, 78, 78, 78, 78, 78, 104, 78, 78,
542 84, 78, 110, 78, 118, 78, 78, 103, 99, 84,
543 114, 102, 117, 99, 84, 119, 112, 99, 104, 84,
544 116, 99, 111, 110, 114, 78, 118, 78, 78, 99,
545 84, 99, 84, 99, 112, 99, 119, 111, 78, 120,
546 78, 113, 123, 111, 106, 105, 100, 97, 91, 90,
547 76, 72, 70, 69, 64, 120, 123, 134, 134, 134,
549 134, 134, 134, 134, 135, 135, 135, 135, 135, 135,
550 135, 136, 62, 51, 46, 136, 44, 136, 137, 137,
551 39, 137, 137, 137, 137, 138, 138, 139, 139, 139,
552 35, 139, 139, 140, 140, 33, 140, 140, 140, 140,
553 30, 29, 28, 17, 16, 14, 9, 2, 133, 133,
554 133, 133, 133, 133, 133, 133, 133, 133, 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,
560 133, 133, 133, 133, 133, 133
563 static style_state_type style_last_accepting_state;
564 static style_CHAR *style_last_accepting_cpos;
566 /* the intent behind this definition is that it'll catch
567 * any uses of REJECT which flex missed
569 #define REJECT reject_used_but_not_detected
570 #define stylemore() stylemore_used_but_not_detected
571 #define style_MORE_ADJ 0
573 /* these variables are all declared out here so that section 3 code can
576 /* points to current character in buffer */
577 static style_CHAR *style_c_buf_p = (style_CHAR *) 0;
578 static int style_init = 1; /* whether we need to initialize */
579 static int style_start = 0; /* start state number */
581 /* flag which is used to allow stylewrap()'s to do buffer switches
582 * instead of setting up a fresh stylein. A bit of a hack ...
584 static int style_did_buffer_switch_on_eof;
586 static style_state_type style_get_previous_state style_PROTO(( void ));
587 static style_state_type style_try_NUL_trans style_PROTO(( style_state_type current_state ));
588 static int style_get_next_buffer style_PROTO(( void ));
590 static void styleunput style_PROTO(( style_CHAR c, style_CHAR *buf_ptr ));
592 void stylerestart style_PROTO(( FILE *input_file ));
593 void style_switch_to_buffer style_PROTO(( style_BUFFER_STATE new_buffer ));
594 void style_load_buffer_state style_PROTO(( void ));
595 style_BUFFER_STATE style_create_buffer style_PROTO(( FILE *file, int size ));
596 void style_delete_buffer style_PROTO(( style_BUFFER_STATE b ));
597 void style_init_buffer style_PROTO(( style_BUFFER_STATE b, FILE *file ));
599 #define style_new_buffer style_create_buffer
602 static int styleinput style_PROTO(( void ));
604 static int input style_PROTO(( void ));
609 register style_state_type style_current_state;
610 register style_CHAR *style_cp, *style_bp;
611 register int style_act;
621 style_start = 1; /* first start state */
629 if ( style_current_buffer )
630 style_init_buffer( style_current_buffer, stylein );
632 style_current_buffer = style_create_buffer( stylein, style_BUF_SIZE );
634 style_load_buffer_state();
639 while ( 1 ) /* loops until end-of-file is reached */
641 style_cp = style_c_buf_p;
643 /* support of styletext */
644 *style_cp = style_hold_char;
646 /* style_bp points to the position in style_ch_buf of the start of the
651 style_current_state = style_start;
652 if ( style_bp[-1] == '\n' )
653 ++style_current_state;
657 register style_CHAR style_c = style_ec[*style_cp];
658 if ( style_accept[style_current_state] )
660 style_last_accepting_state = style_current_state;
661 style_last_accepting_cpos = style_cp;
663 while ( style_chk[style_base[style_current_state] + style_c] != style_current_state )
665 style_current_state = style_def[style_current_state];
666 if ( style_current_state >= 134 )
667 style_c = style_meta[style_c];
669 style_current_state = style_nxt[style_base[style_current_state] + style_c];
672 while ( style_current_state != 133 );
673 style_cp = style_last_accepting_cpos;
674 style_current_state = style_last_accepting_state;
677 style_act = style_accept[style_current_state];
679 style_DO_BEFORE_ACTION;
682 do_action: /* this label is used only to access EOF actions */
687 case 0: /* must backtrack */
688 /* undo the effects of style_DO_BEFORE_ACTION */
689 *style_cp = style_hold_char;
690 style_cp = style_last_accepting_cpos;
691 style_current_state = style_last_accepting_state;
692 goto style_find_action;
695 # line 97 "tokenStyle.l"
699 # line 99 "tokenStyle.l"
701 if ( commentBufferSize < styleleng ) {
702 delete [] commentBuffer;
703 commentBufferSize = 2 * styleleng ;
704 commentBuffer = new char [commentBufferSize];
707 commentBufferContentSize = styleleng-1;
708 memcpy(commentBuffer, styletext+1, commentBufferContentSize); // copy everything except the #
709 commentBuffer[commentBufferContentSize] = 0;
713 # line 111 "tokenStyle.l"
719 # line 115 "tokenStyle.l"
725 # line 119 "tokenStyle.l"
727 stylelval.charData = styletext[0];
732 # line 124 "tokenStyle.l"
734 stylelval.charData = styletext[0];
739 # line 129 "tokenStyle.l"
741 stylelval.charData = styletext[0];
746 # line 134 "tokenStyle.l"
752 # line 138 "tokenStyle.l"
754 stylelval.charData = styletext[0];
759 # line 143 "tokenStyle.l"
765 # line 147 "tokenStyle.l"
771 # line 151 "tokenStyle.l"
777 # line 155 "tokenStyle.l"
783 # line 159 "tokenStyle.l"
789 # line 163 "tokenStyle.l"
795 # line 167 "tokenStyle.l"
801 # line 171 "tokenStyle.l"
807 # line 175 "tokenStyle.l"
809 return(OPER_parenopen);
813 # line 179 "tokenStyle.l"
815 return(OPER_parenclose);
819 # line 183 "tokenStyle.l"
825 # line 187 "tokenStyle.l"
831 # line 191 "tokenStyle.l"
833 if ( strcmp((const char*)styletext, "==") == 0 )
834 stylelval.intData = EQUAL;
836 stylelval.intData = NOT_EQUAL;
838 return(OPER_equality);
842 # line 200 "tokenStyle.l"
844 return(OPER_logicalnegate);
848 # line 204 "tokenStyle.l"
850 if ( strcmp((const char*)styletext, "<=") == 0 )
851 stylelval.intData = LESS_OR_EQUAL;
853 if ( strcmp((const char*)styletext, "<") == 0 )
854 stylelval.intData = LESS;
856 if ( strcmp((const char*)styletext, ">=") == 0 )
857 stylelval.intData = GREATER_OR_EQUAL;
859 stylelval.intData = GREATER;
861 return(OPER_relational);
865 # line 219 "tokenStyle.l"
867 return(GI_CASE_SENSITIVE);
871 # line 223 "tokenStyle.l"
873 stylelval.boolData = true;
878 # line 228 "tokenStyle.l"
880 stylelval.boolData = false;
885 # line 233 "tokenStyle.l"
887 stylelval.boolData = true;
892 # line 238 "tokenStyle.l"
894 stylelval.boolData = false;
899 # line 243 "tokenStyle.l"
901 stylelval.charPtrData =
902 (unsigned char*)strdup((const char*)styletext);
907 # line 249 "tokenStyle.l"
909 stylelval.intData = atoi((char*)styletext);
914 # line 254 "tokenStyle.l"
916 stylelval.realData = atof((char*)styletext);
921 # line 259 "tokenStyle.l"
927 # line 263 "tokenStyle.l"
930 stylelval.charPtrData =
931 new unsigned char[qstring_buf_content_size+1];
932 memcpy( stylelval.charPtrData,
934 qstring_buf_content_size+1
937 qstring_buf_content_size = 0;
940 return(QUOTED_STRING);
944 # line 278 "tokenStyle.l"
946 int c = styleinput();
949 addToQstringBuf((unsigned char*)"\"", 1);
952 addToQstringBuf((unsigned char*)"\\", 1);
955 throw(CASTSSEXCEPT StyleSheetException());
960 # line 292 "tokenStyle.l"
962 addToQstringBuf((const unsigned char *)styletext, styleleng);
966 # line 296 "tokenStyle.l"
968 addToQstringBuf((const unsigned char *)styletext, styleleng);
972 # line 300 "tokenStyle.l"
974 stylelval.charPtrData =
975 (unsigned char*)strdup((const char*)styletext);
980 # line 306 "tokenStyle.l"
982 stylelval.charPtrData =
983 (unsigned char*)strdup((const char*)styletext);
984 return(NORMAL_STRING);
988 # line 312 "tokenStyle.l"
990 stylelval.charPtrData =
991 (unsigned char*)strdup((const char*)styletext);
993 return(SGMLGI_STRING);
997 # line 319 "tokenStyle.l"
1002 # line 322 "tokenStyle.l"
1008 # line 326 "tokenStyle.l"
1013 # line 331 "tokenStyle.l"
1017 # line 332 "tokenStyle.l"
1021 # line 333 "tokenStyle.l"
1025 # line 334 "tokenStyle.l"
1026 style_FATAL_ERROR( "flex scanner jammed" );
1028 case style_STATE_EOF(INITIAL):
1029 case style_STATE_EOF(block):
1030 case style_STATE_EOF(sgmlgimode):
1031 case style_STATE_EOF(quoted_string):
1034 case style_END_OF_BUFFER:
1036 /* amount of text matched not including the EOB char */
1037 int style_amount_of_matched_text = style_cp - styletext - 1;
1039 /* undo the effects of style_DO_BEFORE_ACTION */
1040 *style_cp = style_hold_char;
1042 /* note that here we test for style_c_buf_p "<=" to the position
1043 * of the first EOB in the buffer, since style_c_buf_p will
1044 * already have been incremented past the NUL character
1045 * (since all states make transitions on EOB to the end-
1046 * of-buffer state). Contrast this with the test in styleinput().
1048 if ( style_c_buf_p <= &style_current_buffer->style_ch_buf[style_n_chars] )
1049 /* this was really a NUL */
1051 style_state_type style_next_state;
1053 style_c_buf_p = styletext + style_amount_of_matched_text;
1055 style_current_state = style_get_previous_state();
1057 /* okay, we're now positioned to make the
1058 * NUL transition. We couldn't have
1059 * style_get_previous_state() go ahead and do it
1060 * for us because it doesn't know how to deal
1061 * with the possibility of jamming (and we
1062 * don't want to build jamming into it because
1063 * then it will run more slowly)
1066 style_next_state = style_try_NUL_trans( style_current_state );
1068 style_bp = styletext + style_MORE_ADJ;
1070 if ( style_next_state )
1072 /* consume the NUL */
1073 style_cp = ++style_c_buf_p;
1074 style_current_state = style_next_state;
1080 style_cp = style_last_accepting_cpos;
1081 style_current_state = style_last_accepting_state;
1082 goto style_find_action;
1086 else switch ( style_get_next_buffer() )
1088 case EOB_ACT_END_OF_FILE:
1090 style_did_buffer_switch_on_eof = 0;
1094 /* note: because we've taken care in
1095 * style_get_next_buffer() to have set up styletext,
1096 * we can now set up style_c_buf_p so that if some
1097 * total hoser (like flex itself) wants
1098 * to call the scanner after we return the
1099 * style_NULL, it'll still work - another style_NULL
1100 * will get returned.
1102 style_c_buf_p = styletext + style_MORE_ADJ;
1104 style_act = style_STATE_EOF((style_start - 1) / 2);
1110 if ( ! style_did_buffer_switch_on_eof )
1116 case EOB_ACT_CONTINUE_SCAN:
1117 style_c_buf_p = styletext + style_amount_of_matched_text;
1119 style_current_state = style_get_previous_state();
1121 style_cp = style_c_buf_p;
1122 style_bp = styletext + style_MORE_ADJ;
1125 case EOB_ACT_LAST_MATCH:
1127 &style_current_buffer->style_ch_buf[style_n_chars];
1129 style_current_state = style_get_previous_state();
1131 style_cp = style_c_buf_p;
1132 style_bp = styletext + style_MORE_ADJ;
1133 goto style_find_action;
1140 printf( "action # %d\n", style_act );
1143 "fatal flex scanner internal error--no action found" );
1149 /* style_get_next_buffer - try to read in a new buffer
1152 * int style_get_next_buffer();
1154 * returns a code representing an action
1155 * EOB_ACT_LAST_MATCH -
1156 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1157 * EOB_ACT_END_OF_FILE - end of file
1160 static int style_get_next_buffer()
1163 register style_CHAR *dest = style_current_buffer->style_ch_buf;
1164 register style_CHAR *source = styletext - 1; /* copy prev. char, too */
1165 register int number_to_move, i;
1168 if ( style_c_buf_p > &style_current_buffer->style_ch_buf[style_n_chars + 1] )
1170 "fatal flex scanner internal error--end of buffer missed" );
1172 /* try to read more data */
1174 /* first move last chars to start of buffer */
1175 number_to_move = style_c_buf_p - styletext;
1177 for ( i = 0; i < number_to_move; ++i )
1178 *(dest++) = *(source++);
1180 if ( style_current_buffer->style_eof_status != EOF_NOT_SEEN )
1181 /* don't do the read, it's not guaranteed to return an EOF,
1188 int num_to_read = style_current_buffer->style_buf_size - number_to_move - 1;
1190 if ( num_to_read > style_READ_BUF_SIZE )
1191 num_to_read = style_READ_BUF_SIZE;
1193 else if ( num_to_read <= 0 )
1194 style_FATAL_ERROR( "fatal error - scanner input buffer overflow" );
1196 /* read in more data */
1197 style_INPUT( (&style_current_buffer->style_ch_buf[number_to_move]),
1198 style_n_chars, num_to_read );
1201 if ( style_n_chars == 0 )
1203 if ( number_to_move == 1 )
1205 ret_val = EOB_ACT_END_OF_FILE;
1206 style_current_buffer->style_eof_status = EOF_DONE;
1211 ret_val = EOB_ACT_LAST_MATCH;
1212 style_current_buffer->style_eof_status = EOF_PENDING;
1217 ret_val = EOB_ACT_CONTINUE_SCAN;
1219 style_n_chars += number_to_move;
1220 style_current_buffer->style_ch_buf[style_n_chars] = style_END_OF_BUFFER_CHAR;
1221 style_current_buffer->style_ch_buf[style_n_chars + 1] = style_END_OF_BUFFER_CHAR;
1223 /* styletext begins at the second character in style_ch_buf; the first
1224 * character is the one which preceded it before reading in the latest
1225 * buffer; it needs to be kept around in case it's a newline, so
1226 * style_get_previous_state() will have with '^' rules active
1229 styletext = &style_current_buffer->style_ch_buf[1];
1235 /* style_get_previous_state - get the state just before the EOB char was reached
1238 * style_state_type style_get_previous_state();
1241 static style_state_type style_get_previous_state()
1244 register style_state_type style_current_state;
1245 register style_CHAR *style_cp;
1247 register style_CHAR *style_bp = styletext;
1249 style_current_state = style_start;
1250 if ( style_bp[-1] == '\n' )
1251 ++style_current_state;
1253 for ( style_cp = styletext + style_MORE_ADJ; style_cp < style_c_buf_p; ++style_cp )
1255 register style_CHAR style_c = (*style_cp ? style_ec[*style_cp] : 1);
1256 if ( style_accept[style_current_state] )
1258 style_last_accepting_state = style_current_state;
1259 style_last_accepting_cpos = style_cp;
1261 while ( style_chk[style_base[style_current_state] + style_c] != style_current_state )
1263 style_current_state = style_def[style_current_state];
1264 if ( style_current_state >= 134 )
1265 style_c = style_meta[style_c];
1267 style_current_state = style_nxt[style_base[style_current_state] + style_c];
1270 return ( style_current_state );
1274 /* style_try_NUL_trans - try to make a transition on the NUL character
1277 * next_state = style_try_NUL_trans( current_state );
1280 #ifdef style_USE_PROTOS
1281 static style_state_type style_try_NUL_trans( register style_state_type style_current_state )
1283 static style_state_type style_try_NUL_trans( style_current_state )
1284 register style_state_type style_current_state;
1288 register int style_is_jam;
1289 register style_CHAR *style_cp = style_c_buf_p;
1291 register style_CHAR style_c = 1;
1292 if ( style_accept[style_current_state] )
1294 style_last_accepting_state = style_current_state;
1295 style_last_accepting_cpos = style_cp;
1297 while ( style_chk[style_base[style_current_state] + style_c] != style_current_state )
1299 style_current_state = style_def[style_current_state];
1300 if ( style_current_state >= 134 )
1301 style_c = style_meta[style_c];
1303 style_current_state = style_nxt[style_base[style_current_state] + style_c];
1304 style_is_jam = (style_current_state == 133);
1306 return ( style_is_jam ? 0 : style_current_state );
1311 #ifdef style_USE_PROTOS
1312 static void styleunput( style_CHAR c, register style_CHAR *style_bp )
1314 static void styleunput( c, style_bp )
1316 register style_CHAR *style_bp;
1320 register style_CHAR *style_cp = style_c_buf_p;
1322 /* undo effects of setting up styletext */
1323 *style_cp = style_hold_char;
1325 if ( style_cp < style_current_buffer->style_ch_buf + 2 )
1326 { /* need to shift things up to make room */
1327 register int number_to_move = style_n_chars + 2; /* +2 for EOB chars */
1328 register style_CHAR *dest =
1329 &style_current_buffer->style_ch_buf[style_current_buffer->style_buf_size + 2];
1330 register style_CHAR *source =
1331 &style_current_buffer->style_ch_buf[number_to_move];
1333 while ( source > style_current_buffer->style_ch_buf )
1334 *--dest = *--source;
1336 style_cp += dest - source;
1337 style_bp += dest - source;
1338 style_n_chars = style_current_buffer->style_buf_size;
1340 if ( style_cp < style_current_buffer->style_ch_buf + 2 )
1341 style_FATAL_ERROR( "flex scanner push-back overflow" );
1344 if ( style_cp > style_bp && style_cp[-1] == '\n' )
1345 style_cp[-2] = '\n';
1349 /* note: the formal parameter *must* be called "style_bp" for this
1350 * macro to now work correctly
1352 style_DO_BEFORE_ACTION; /* set up styletext again */
1358 static int styleinput()
1365 style_CHAR *style_cp = style_c_buf_p;
1367 *style_cp = style_hold_char;
1369 if ( *style_c_buf_p == style_END_OF_BUFFER_CHAR )
1371 /* style_c_buf_p now points to the character we want to return.
1372 * If this occurs *before* the EOB characters, then it's a
1373 * valid NUL; if not, then we've hit the end of the buffer.
1375 if ( style_c_buf_p < &style_current_buffer->style_ch_buf[style_n_chars] )
1376 /* this was really a NUL */
1377 *style_c_buf_p = '\0';
1380 { /* need more input */
1381 styletext = style_c_buf_p;
1384 switch ( style_get_next_buffer() )
1386 case EOB_ACT_END_OF_FILE:
1390 style_c_buf_p = styletext + style_MORE_ADJ;
1397 return ( styleinput() );
1404 case EOB_ACT_CONTINUE_SCAN:
1405 style_c_buf_p = styletext + style_MORE_ADJ;
1408 case EOB_ACT_LAST_MATCH:
1410 style_FATAL_ERROR( "unexpected last match in styleinput()" );
1412 style_FATAL_ERROR( "unexpected last match in input()" );
1419 style_hold_char = *++style_c_buf_p;
1425 #ifdef style_USE_PROTOS
1426 void stylerestart( FILE *input_file )
1428 void stylerestart( input_file )
1433 style_init_buffer( style_current_buffer, input_file );
1434 style_load_buffer_state();
1438 #ifdef style_USE_PROTOS
1439 void style_switch_to_buffer( style_BUFFER_STATE new_buffer )
1441 void style_switch_to_buffer( new_buffer )
1442 style_BUFFER_STATE new_buffer;
1446 if ( style_current_buffer == new_buffer )
1449 if ( style_current_buffer )
1451 /* flush out information for old buffer */
1452 *style_c_buf_p = style_hold_char;
1453 style_current_buffer->style_buf_pos = style_c_buf_p;
1454 style_current_buffer->style_n_chars = style_n_chars;
1457 style_current_buffer = new_buffer;
1458 style_load_buffer_state();
1460 /* we don't actually know whether we did this switch during
1461 * EOF (stylewrap()) processing, but the only time this flag
1462 * is looked at is after stylewrap() is called, so it's safe
1463 * to go ahead and always set it.
1465 style_did_buffer_switch_on_eof = 1;
1469 #ifdef style_USE_PROTOS
1470 void style_load_buffer_state( void )
1472 void style_load_buffer_state()
1476 style_n_chars = style_current_buffer->style_n_chars;
1477 styletext = style_c_buf_p = style_current_buffer->style_buf_pos;
1478 stylein = style_current_buffer->style_input_file;
1479 style_hold_char = *style_c_buf_p;
1483 #ifdef style_USE_PROTOS
1484 style_BUFFER_STATE style_create_buffer( FILE *file, int size )
1486 style_BUFFER_STATE style_create_buffer( file, size )
1492 style_BUFFER_STATE b;
1494 b = (style_BUFFER_STATE) malloc( sizeof( struct style_buffer_state ) );
1497 style_FATAL_ERROR( "out of dynamic memory in style_create_buffer()" );
1499 b->style_buf_size = size;
1501 /* style_ch_buf has to be 2 characters longer than the size given because
1502 * we need to put in 2 end-of-buffer characters.
1504 b->style_ch_buf = (style_CHAR *) malloc( (unsigned) (b->style_buf_size + 2) );
1506 if ( ! b->style_ch_buf )
1507 style_FATAL_ERROR( "out of dynamic memory in style_create_buffer()" );
1509 style_init_buffer( b, file );
1515 #ifdef style_USE_PROTOS
1516 void style_delete_buffer( style_BUFFER_STATE b )
1518 void style_delete_buffer( b )
1519 style_BUFFER_STATE b;
1523 if ( b == style_current_buffer )
1524 style_current_buffer = (style_BUFFER_STATE) 0;
1526 free( (char *) b->style_ch_buf );
1531 #ifdef style_USE_PROTOS
1532 void style_init_buffer( style_BUFFER_STATE b, FILE *file )
1534 void style_init_buffer( b, file )
1535 style_BUFFER_STATE b;
1540 b->style_input_file = file;
1542 /* we put in the '\n' and start reading from [1] so that an
1543 * initial match-at-newline will be true.
1546 b->style_ch_buf[0] = '\n';
1547 b->style_n_chars = 1;
1549 /* we always need two end-of-buffer characters. The first causes
1550 * a transition to the end-of-buffer state. The second causes
1551 * a jam in that state.
1553 b->style_ch_buf[1] = style_END_OF_BUFFER_CHAR;
1554 b->style_ch_buf[2] = style_END_OF_BUFFER_CHAR;
1556 b->style_buf_pos = &b->style_ch_buf[1];
1558 b->style_eof_status = EOF_NOT_SEEN;
1560 # line 334 "tokenStyle.l"
1563 void enter_sgmlgi_context()
1569 void report_error_location()
1571 if ( commentBufferContentSize > 0 ) {
1572 cerr << commentBuffer << "\n";
1576 void styleerror(char* msg)
1579 cerr << "line " << stylelineno << ": " << msg << "\n";
1581 throw(CASTSSEXCEPT StyleSheetSyntaxError());