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)
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"
231 #include <iostream.h>
233 istream *g_stylein = 0;
236 #define style_INPUT(buf,result,max_size)\
238 if (g_stylein -> eof()) {\
241 g_stylein -> read((char*)buf, max_size-1); \
242 result = g_stylein -> gcount(); \
247 unsigned char* qstring_buf = new unsigned char[1024];
248 int qstring_buf_size = 1024;
249 int qstring_buf_content_size = 0;
251 char* commentBuffer = new char [1024];
252 int commentBufferSize = 1024;
253 int commentBufferContentSize = 0;
257 void addToQstringBuf(const unsigned char* str, int size)
259 if ( size <= 0 ) return;
261 if ( qstring_buf_size - qstring_buf_content_size < size ) {
262 qstring_buf_size = 2*(size+qstring_buf_content_size);
263 unsigned char* x = new unsigned char[qstring_buf_size];
264 memcpy(x, qstring_buf, qstring_buf_content_size);
269 memcpy(qstring_buf + qstring_buf_content_size, str, size);
270 qstring_buf_content_size += size;
271 qstring_buf[qstring_buf_content_size] = 0;
277 #define quoted_string 3
278 # line 95 "tokenStyle.l"
280 /* done after the current pattern has been matched and before the
281 * corresponding action - sets up styletext
283 #define style_DO_BEFORE_ACTION \
284 styletext = style_bp; \
285 styleleng = style_cp - style_bp; \
286 style_hold_char = *style_cp; \
288 style_c_buf_p = style_cp;
290 #define EOB_ACT_CONTINUE_SCAN 0
291 #define EOB_ACT_END_OF_FILE 1
292 #define EOB_ACT_LAST_MATCH 2
294 /* return all but the first 'n' matched characters back to the input stream */
295 #define styleless(n) \
298 /* undo effects of setting up styletext */ \
299 *style_cp = style_hold_char; \
300 style_c_buf_p = style_cp = style_bp + n; \
301 style_DO_BEFORE_ACTION; /* set up styletext again */ \
305 #define unput(c) styleunput( c, styletext )
308 struct style_buffer_state
310 FILE *style_input_file;
312 style_CHAR *style_ch_buf; /* input buffer */
313 style_CHAR *style_buf_pos; /* current position in input buffer */
315 /* size of input buffer in bytes, not including room for EOB characters*/
318 /* number of characters read into style_ch_buf, not including EOB characters */
321 int style_eof_status; /* whether we've seen an EOF on this buffer */
322 #define EOF_NOT_SEEN 0
323 /* "pending" happens when the EOF has been seen but there's still
326 #define EOF_PENDING 1
330 static style_BUFFER_STATE style_current_buffer;
332 /* we provide macros for accessing buffer states in case in the
333 * future we want to put the buffer states in a more general
336 #define style_CURRENT_BUFFER style_current_buffer
339 /* style_hold_char holds the character lost when styletext is formed */
340 static style_CHAR style_hold_char;
342 static int style_n_chars; /* number of characters read into style_ch_buf */
346 #ifndef style_USER_ACTION
347 #define style_USER_ACTION
350 #ifndef style_USER_INIT
351 #define style_USER_INIT
354 extern style_CHAR *styletext;
355 extern int styleleng;
356 extern FILE *stylein, *styleout;
358 style_CHAR *styletext;
361 FILE *stylein = (FILE *) 0, *styleout = (FILE *) 0;
363 #define style_END_OF_BUFFER 48
364 typedef int style_state_type;
365 static const short int style_accept[134] =
367 0, 0, 0, 0, 0, 0, 36, 36, 48, 39,
368 41, 42, 43, 23, 33, 39, 39, 18, 19, 9,
369 5, 13, 6, 8, 7, 31, 10, 24, 3, 24,
370 11, 4, 39, 39, 39, 39, 39, 39, 39, 16,
371 17, 12, 39, 39, 14, 39, 15, 2, 45, 46,
372 45, 47, 40, 36, 36, 34, 35, 39, 22, 1,
373 21, 0, 31, 39, 39, 39, 24, 38, 39, 39,
374 38, 39, 28, 39, 39, 39, 20, 2, 2, 1,
375 44, 40, 36, 32, 30, 30, 39, 39, 39, 39,
376 39, 29, 39, 39, 39, 39, 0, 0, 0, 39,
378 39, 39, 39, 39, 39, 39, 39, 26, 30, 30,
379 0, 0, 39, 39, 27, 39, 0, 0, 0, 0,
380 39, 0, 0, 39, 39, 39, 39, 39, 39, 39,
384 static const style_CHAR style_ec[256] =
386 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
387 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
388 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
389 1, 4, 5, 6, 7, 1, 1, 8, 1, 9,
390 10, 11, 12, 13, 14, 15, 16, 17, 17, 17,
391 17, 17, 17, 17, 17, 17, 17, 18, 1, 19,
392 20, 21, 22, 23, 24, 25, 26, 25, 27, 28,
393 29, 30, 31, 25, 25, 32, 33, 34, 35, 36,
394 25, 37, 38, 39, 40, 25, 25, 41, 25, 25,
395 42, 43, 44, 45, 1, 1, 46, 25, 47, 25,
397 48, 28, 25, 30, 49, 25, 25, 32, 33, 50,
398 51, 36, 25, 37, 52, 53, 40, 54, 25, 41,
399 25, 25, 55, 56, 57, 1, 1, 1, 1, 1,
400 1, 1, 1, 1, 1, 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,
408 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,
416 static const style_CHAR style_meta[58] =
418 1, 2, 3, 2, 2, 4, 1, 1, 2, 2,
419 2, 2, 2, 5, 6, 2, 5, 2, 1, 2,
420 1, 2, 2, 5, 5, 5, 5, 5, 5, 5,
421 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
422 5, 2, 7, 2, 2, 5, 5, 5, 5, 5,
426 static const short int style_base[141] =
428 0, 341, 55, 56, 112, 0, 57, 58, 347, 0,
429 349, 349, 349, 326, 349, 289, 336, 349, 349, 349,
430 349, 349, 0, 349, 349, 50, 349, 323, 322, 321,
431 349, 349, 303, 38, 300, 32, 40, 57, 284, 349,
432 349, 349, 35, 289, 349, 259, 349, 168, 349, 349,
433 307, 349, 0, 0, 0, 349, 349, 0, 349, 0,
434 0, 296, 170, 262, 37, 169, 349, 0, 262, 267,
435 44, 264, 0, 156, 44, 251, 0, 224, 0, 0,
436 349, 0, 0, 224, 0, 47, 168, 46, 51, 244,
437 259, 0, 56, 144, 155, 166, 255, 177, 223, 257,
439 152, 204, 198, 211, 234, 253, 168, 0, 349, 217,
440 237, 226, 250, 212, 0, 213, 223, 221, 229, 246,
441 164, 167, 244, 127, 59, 55, 56, 45, 30, 24,
442 24, 0, 349, 297, 304, 311, 318, 321, 327, 333
445 static const short int style_def[141] =
447 133, 1, 134, 134, 133, 5, 135, 135, 133, 136,
448 133, 133, 133, 133, 133, 136, 136, 133, 133, 133,
449 133, 133, 136, 133, 133, 136, 133, 136, 133, 136,
450 133, 133, 136, 136, 136, 136, 136, 136, 136, 133,
451 133, 133, 136, 136, 133, 136, 133, 137, 133, 133,
452 133, 133, 138, 139, 139, 133, 133, 136, 133, 136,
453 136, 133, 136, 136, 136, 136, 133, 136, 136, 136,
454 136, 136, 136, 136, 136, 136, 136, 137, 140, 78,
455 133, 138, 139, 133, 136, 136, 136, 136, 136, 136,
456 136, 136, 136, 136, 136, 136, 133, 133, 133, 136,
458 136, 136, 136, 136, 136, 136, 136, 136, 133, 133,
459 133, 133, 136, 136, 136, 136, 133, 133, 133, 133,
460 136, 133, 133, 136, 136, 136, 136, 136, 136, 136,
461 136, 136, 0, 133, 133, 133, 133, 133, 133, 133
464 static const short int style_nxt[407] =
466 10, 11, 12, 13, 14, 15, 16, 17, 18, 19,
467 20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
468 30, 31, 32, 10, 10, 33, 10, 34, 35, 10,
469 36, 10, 10, 10, 37, 38, 10, 10, 39, 10,
470 10, 40, 10, 41, 42, 10, 33, 10, 36, 43,
471 44, 10, 39, 10, 45, 46, 47, 50, 50, 55,
472 55, 69, 56, 56, 62, 71, 63, 72, 73, 91,
473 86, 132, 100, 73, 95, 64, 103, 131, 130, 68,
474 65, 71, 68, 69, 73, 66, 86, 74, 104, 73,
475 91, 75, 95, 100, 103, 68, 64, 129, 65, 57,
477 57, 68, 104, 68, 128, 74, 127, 75, 126, 68,
478 51, 51, 52, 52, 52, 52, 52, 52, 52, 52,
479 52, 52, 52, 52, 52, 53, 53, 52, 53, 52,
480 52, 52, 52, 52, 52, 53, 53, 53, 53, 53,
481 53, 53, 53, 53, 53, 53, 53, 53, 53, 53,
482 53, 53, 53, 52, 52, 52, 52, 53, 53, 53,
483 53, 53, 53, 53, 53, 53, 52, 52, 52, 79,
484 106, 79, 79, 79, 125, 85, 79, 79, 79, 79,
485 79, 93, 79, 79, 62, 79, 63, 79, 107, 79,
486 79, 106, 108, 101, 85, 64, 94, 85, 109, 87,
488 65, 124, 93, 88, 107, 66, 68, 85, 102, 79,
489 110, 79, 79, 108, 101, 85, 64, 87, 65, 88,
490 68, 85, 79, 80, 79, 79, 110, 79, 79, 79,
491 113, 114, 79, 79, 79, 79, 79, 115, 79, 79,
492 84, 79, 117, 79, 109, 79, 79, 114, 109, 97,
493 85, 113, 109, 111, 98, 122, 120, 112, 115, 99,
494 121, 109, 118, 117, 85, 79, 109, 79, 79, 109,
495 97, 111, 98, 112, 120, 109, 122, 119, 79, 123,
496 79, 85, 109, 118, 68, 116, 85, 109, 68, 105,
497 96, 92, 90, 89, 85, 123, 109, 49, 49, 49,
499 49, 49, 49, 49, 54, 54, 54, 54, 54, 54,
500 54, 58, 84, 81, 77, 58, 72, 58, 78, 78,
501 76, 78, 78, 78, 78, 82, 82, 83, 83, 83,
502 70, 83, 83, 79, 79, 68, 79, 79, 79, 79,
503 67, 59, 67, 61, 60, 59, 133, 48, 9, 133,
504 133, 133, 133, 133, 133, 133, 133, 133, 133, 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,
510 133, 133, 133, 133, 133, 133
513 static const short int style_chk[407] =
515 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
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, 3, 4, 7,
521 8, 34, 7, 8, 26, 36, 26, 37, 43, 71,
522 65, 131, 86, 37, 75, 26, 88, 130, 129, 93,
523 26, 36, 38, 34, 43, 26, 65, 38, 89, 37,
524 71, 38, 75, 86, 88, 38, 26, 128, 26, 7,
526 8, 93, 89, 38, 127, 38, 126, 38, 125, 38,
527 3, 4, 5, 5, 5, 5, 5, 5, 5, 5,
528 5, 5, 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, 48,
533 94, 48, 48, 48, 124, 101, 48, 48, 48, 48,
534 48, 74, 48, 48, 63, 48, 63, 48, 95, 48,
535 48, 94, 96, 87, 66, 63, 74, 101, 122, 66,
537 63, 121, 74, 66, 95, 63, 107, 66, 87, 48,
538 98, 48, 48, 96, 87, 66, 63, 66, 63, 66,
539 107, 66, 48, 48, 48, 78, 98, 78, 78, 78,
540 102, 103, 78, 78, 78, 78, 78, 104, 78, 78,
541 84, 78, 110, 78, 118, 78, 78, 103, 99, 84,
542 114, 102, 117, 99, 84, 119, 112, 99, 104, 84,
543 116, 99, 111, 110, 114, 78, 118, 78, 78, 99,
544 84, 99, 84, 99, 112, 99, 119, 111, 78, 120,
545 78, 113, 123, 111, 106, 105, 100, 97, 91, 90,
546 76, 72, 70, 69, 64, 120, 123, 134, 134, 134,
548 134, 134, 134, 134, 135, 135, 135, 135, 135, 135,
549 135, 136, 62, 51, 46, 136, 44, 136, 137, 137,
550 39, 137, 137, 137, 137, 138, 138, 139, 139, 139,
551 35, 139, 139, 140, 140, 33, 140, 140, 140, 140,
552 30, 29, 28, 17, 16, 14, 9, 2, 133, 133,
553 133, 133, 133, 133, 133, 133, 133, 133, 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,
559 133, 133, 133, 133, 133, 133
562 static style_state_type style_last_accepting_state;
563 static style_CHAR *style_last_accepting_cpos;
565 /* the intent behind this definition is that it'll catch
566 * any uses of REJECT which flex missed
568 #define REJECT reject_used_but_not_detected
569 #define stylemore() stylemore_used_but_not_detected
570 #define style_MORE_ADJ 0
572 /* these variables are all declared out here so that section 3 code can
575 /* points to current character in buffer */
576 static style_CHAR *style_c_buf_p = (style_CHAR *) 0;
577 static int style_init = 1; /* whether we need to initialize */
578 static int style_start = 0; /* start state number */
580 /* flag which is used to allow stylewrap()'s to do buffer switches
581 * instead of setting up a fresh stylein. A bit of a hack ...
583 static int style_did_buffer_switch_on_eof;
585 static style_state_type style_get_previous_state style_PROTO(( void ));
586 static style_state_type style_try_NUL_trans style_PROTO(( style_state_type current_state ));
587 static int style_get_next_buffer style_PROTO(( void ));
588 static void styleunput style_PROTO(( style_CHAR c, style_CHAR *buf_ptr ));
589 void stylerestart style_PROTO(( FILE *input_file ));
590 void style_switch_to_buffer style_PROTO(( style_BUFFER_STATE new_buffer ));
591 void style_load_buffer_state style_PROTO(( void ));
592 style_BUFFER_STATE style_create_buffer style_PROTO(( FILE *file, int size ));
593 void style_delete_buffer style_PROTO(( style_BUFFER_STATE b ));
594 void style_init_buffer style_PROTO(( style_BUFFER_STATE b, FILE *file ));
596 #define style_new_buffer style_create_buffer
599 static int styleinput style_PROTO(( void ));
601 static int input style_PROTO(( void ));
606 register style_state_type style_current_state;
607 register style_CHAR *style_cp, *style_bp;
608 register int style_act;
618 style_start = 1; /* first start state */
626 if ( style_current_buffer )
627 style_init_buffer( style_current_buffer, stylein );
629 style_current_buffer = style_create_buffer( stylein, style_BUF_SIZE );
631 style_load_buffer_state();
636 while ( 1 ) /* loops until end-of-file is reached */
638 style_cp = style_c_buf_p;
640 /* support of styletext */
641 *style_cp = style_hold_char;
643 /* style_bp points to the position in style_ch_buf of the start of the
648 style_current_state = style_start;
649 if ( style_bp[-1] == '\n' )
650 ++style_current_state;
654 register style_CHAR style_c = style_ec[*style_cp];
655 if ( style_accept[style_current_state] )
657 style_last_accepting_state = style_current_state;
658 style_last_accepting_cpos = style_cp;
660 while ( style_chk[style_base[style_current_state] + style_c] != style_current_state )
662 style_current_state = style_def[style_current_state];
663 if ( style_current_state >= 134 )
664 style_c = style_meta[style_c];
666 style_current_state = style_nxt[style_base[style_current_state] + style_c];
669 while ( style_current_state != 133 );
670 style_cp = style_last_accepting_cpos;
671 style_current_state = style_last_accepting_state;
674 style_act = style_accept[style_current_state];
676 style_DO_BEFORE_ACTION;
679 do_action: /* this label is used only to access EOF actions */
684 case 0: /* must backtrack */
685 /* undo the effects of style_DO_BEFORE_ACTION */
686 *style_cp = style_hold_char;
687 style_cp = style_last_accepting_cpos;
688 style_current_state = style_last_accepting_state;
689 goto style_find_action;
692 # line 97 "tokenStyle.l"
696 # line 99 "tokenStyle.l"
698 if ( commentBufferSize < styleleng ) {
699 delete commentBuffer;
700 commentBufferSize = 2 * styleleng ;
701 commentBuffer = new char [commentBufferSize];
704 commentBufferContentSize = styleleng-1;
705 memcpy(commentBuffer, styletext+1, commentBufferContentSize); // copy everything except the #
706 commentBuffer[commentBufferContentSize] = 0;
710 # line 111 "tokenStyle.l"
716 # line 115 "tokenStyle.l"
722 # line 119 "tokenStyle.l"
724 stylelval.charData = styletext[0];
729 # line 124 "tokenStyle.l"
731 stylelval.charData = styletext[0];
736 # line 129 "tokenStyle.l"
738 stylelval.charData = styletext[0];
743 # line 134 "tokenStyle.l"
749 # line 138 "tokenStyle.l"
751 stylelval.charData = styletext[0];
756 # line 143 "tokenStyle.l"
762 # line 147 "tokenStyle.l"
768 # line 151 "tokenStyle.l"
774 # line 155 "tokenStyle.l"
780 # line 159 "tokenStyle.l"
786 # line 163 "tokenStyle.l"
792 # line 167 "tokenStyle.l"
798 # line 171 "tokenStyle.l"
804 # line 175 "tokenStyle.l"
806 return(OPER_parenopen);
810 # line 179 "tokenStyle.l"
812 return(OPER_parenclose);
816 # line 183 "tokenStyle.l"
822 # line 187 "tokenStyle.l"
828 # line 191 "tokenStyle.l"
830 if ( strcmp((const char*)styletext, "==") == 0 )
831 stylelval.intData = EQUAL;
833 stylelval.intData = NOT_EQUAL;
835 return(OPER_equality);
839 # line 200 "tokenStyle.l"
841 return(OPER_logicalnegate);
845 # line 204 "tokenStyle.l"
847 if ( strcmp((const char*)styletext, "<=") == 0 )
848 stylelval.intData = LESS_OR_EQUAL;
850 if ( strcmp((const char*)styletext, "<") == 0 )
851 stylelval.intData = LESS;
853 if ( strcmp((const char*)styletext, ">=") == 0 )
854 stylelval.intData = GREATER_OR_EQUAL;
856 stylelval.intData = GREATER;
858 return(OPER_relational);
862 # line 219 "tokenStyle.l"
864 return(GI_CASE_SENSITIVE);
868 # line 223 "tokenStyle.l"
870 stylelval.boolData = true;
875 # line 228 "tokenStyle.l"
877 stylelval.boolData = false;
882 # line 233 "tokenStyle.l"
884 stylelval.boolData = true;
889 # line 238 "tokenStyle.l"
891 stylelval.boolData = false;
896 # line 243 "tokenStyle.l"
898 stylelval.charPtrData =
899 (unsigned char*)strdup((const char*)styletext);
904 # line 249 "tokenStyle.l"
906 stylelval.intData = atoi((char*)styletext);
911 # line 254 "tokenStyle.l"
913 stylelval.realData = atof((char*)styletext);
918 # line 259 "tokenStyle.l"
924 # line 263 "tokenStyle.l"
927 stylelval.charPtrData =
928 new unsigned char[qstring_buf_content_size+1];
929 memcpy( stylelval.charPtrData,
931 qstring_buf_content_size+1
934 qstring_buf_content_size = 0;
937 return(QUOTED_STRING);
941 # line 278 "tokenStyle.l"
943 int c = styleinput();
946 addToQstringBuf((unsigned char*)"\"", 1);
949 addToQstringBuf((unsigned char*)"\\", 1);
952 throw(CASTSSEXCEPT StyleSheetException());
957 # line 292 "tokenStyle.l"
959 addToQstringBuf((const unsigned char *)styletext, styleleng);
963 # line 296 "tokenStyle.l"
965 addToQstringBuf((const unsigned char *)styletext, styleleng);
969 # line 300 "tokenStyle.l"
971 stylelval.charPtrData =
972 (unsigned char*)strdup((const char*)styletext);
977 # line 306 "tokenStyle.l"
979 stylelval.charPtrData =
980 (unsigned char*)strdup((const char*)styletext);
981 return(NORMAL_STRING);
985 # line 312 "tokenStyle.l"
987 stylelval.charPtrData =
988 (unsigned char*)strdup((const char*)styletext);
990 return(SGMLGI_STRING);
994 # line 319 "tokenStyle.l"
999 # line 322 "tokenStyle.l"
1005 # line 326 "tokenStyle.l"
1010 # line 331 "tokenStyle.l"
1014 # line 332 "tokenStyle.l"
1018 # line 333 "tokenStyle.l"
1022 # line 334 "tokenStyle.l"
1023 style_FATAL_ERROR( "flex scanner jammed" );
1025 case style_STATE_EOF(INITIAL):
1026 case style_STATE_EOF(block):
1027 case style_STATE_EOF(sgmlgimode):
1028 case style_STATE_EOF(quoted_string):
1031 case style_END_OF_BUFFER:
1033 /* amount of text matched not including the EOB char */
1034 int style_amount_of_matched_text = style_cp - styletext - 1;
1036 /* undo the effects of style_DO_BEFORE_ACTION */
1037 *style_cp = style_hold_char;
1039 /* note that here we test for style_c_buf_p "<=" to the position
1040 * of the first EOB in the buffer, since style_c_buf_p will
1041 * already have been incremented past the NUL character
1042 * (since all states make transitions on EOB to the end-
1043 * of-buffer state). Contrast this with the test in styleinput().
1045 if ( style_c_buf_p <= &style_current_buffer->style_ch_buf[style_n_chars] )
1046 /* this was really a NUL */
1048 style_state_type style_next_state;
1050 style_c_buf_p = styletext + style_amount_of_matched_text;
1052 style_current_state = style_get_previous_state();
1054 /* okay, we're now positioned to make the
1055 * NUL transition. We couldn't have
1056 * style_get_previous_state() go ahead and do it
1057 * for us because it doesn't know how to deal
1058 * with the possibility of jamming (and we
1059 * don't want to build jamming into it because
1060 * then it will run more slowly)
1063 style_next_state = style_try_NUL_trans( style_current_state );
1065 style_bp = styletext + style_MORE_ADJ;
1067 if ( style_next_state )
1069 /* consume the NUL */
1070 style_cp = ++style_c_buf_p;
1071 style_current_state = style_next_state;
1077 style_cp = style_last_accepting_cpos;
1078 style_current_state = style_last_accepting_state;
1079 goto style_find_action;
1083 else switch ( style_get_next_buffer() )
1085 case EOB_ACT_END_OF_FILE:
1087 style_did_buffer_switch_on_eof = 0;
1091 /* note: because we've taken care in
1092 * style_get_next_buffer() to have set up styletext,
1093 * we can now set up style_c_buf_p so that if some
1094 * total hoser (like flex itself) wants
1095 * to call the scanner after we return the
1096 * style_NULL, it'll still work - another style_NULL
1097 * will get returned.
1099 style_c_buf_p = styletext + style_MORE_ADJ;
1101 style_act = style_STATE_EOF((style_start - 1) / 2);
1107 if ( ! style_did_buffer_switch_on_eof )
1113 case EOB_ACT_CONTINUE_SCAN:
1114 style_c_buf_p = styletext + style_amount_of_matched_text;
1116 style_current_state = style_get_previous_state();
1118 style_cp = style_c_buf_p;
1119 style_bp = styletext + style_MORE_ADJ;
1122 case EOB_ACT_LAST_MATCH:
1124 &style_current_buffer->style_ch_buf[style_n_chars];
1126 style_current_state = style_get_previous_state();
1128 style_cp = style_c_buf_p;
1129 style_bp = styletext + style_MORE_ADJ;
1130 goto style_find_action;
1137 printf( "action # %d\n", style_act );
1140 "fatal flex scanner internal error--no action found" );
1146 /* style_get_next_buffer - try to read in a new buffer
1149 * int style_get_next_buffer();
1151 * returns a code representing an action
1152 * EOB_ACT_LAST_MATCH -
1153 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1154 * EOB_ACT_END_OF_FILE - end of file
1157 static int style_get_next_buffer()
1160 register style_CHAR *dest = style_current_buffer->style_ch_buf;
1161 register style_CHAR *source = styletext - 1; /* copy prev. char, too */
1162 register int number_to_move, i;
1165 if ( style_c_buf_p > &style_current_buffer->style_ch_buf[style_n_chars + 1] )
1167 "fatal flex scanner internal error--end of buffer missed" );
1169 /* try to read more data */
1171 /* first move last chars to start of buffer */
1172 number_to_move = style_c_buf_p - styletext;
1174 for ( i = 0; i < number_to_move; ++i )
1175 *(dest++) = *(source++);
1177 if ( style_current_buffer->style_eof_status != EOF_NOT_SEEN )
1178 /* don't do the read, it's not guaranteed to return an EOF,
1185 int num_to_read = style_current_buffer->style_buf_size - number_to_move - 1;
1187 if ( num_to_read > style_READ_BUF_SIZE )
1188 num_to_read = style_READ_BUF_SIZE;
1190 else if ( num_to_read <= 0 )
1191 style_FATAL_ERROR( "fatal error - scanner input buffer overflow" );
1193 /* read in more data */
1194 style_INPUT( (&style_current_buffer->style_ch_buf[number_to_move]),
1195 style_n_chars, num_to_read );
1198 if ( style_n_chars == 0 )
1200 if ( number_to_move == 1 )
1202 ret_val = EOB_ACT_END_OF_FILE;
1203 style_current_buffer->style_eof_status = EOF_DONE;
1208 ret_val = EOB_ACT_LAST_MATCH;
1209 style_current_buffer->style_eof_status = EOF_PENDING;
1214 ret_val = EOB_ACT_CONTINUE_SCAN;
1216 style_n_chars += number_to_move;
1217 style_current_buffer->style_ch_buf[style_n_chars] = style_END_OF_BUFFER_CHAR;
1218 style_current_buffer->style_ch_buf[style_n_chars + 1] = style_END_OF_BUFFER_CHAR;
1220 /* styletext begins at the second character in style_ch_buf; the first
1221 * character is the one which preceded it before reading in the latest
1222 * buffer; it needs to be kept around in case it's a newline, so
1223 * style_get_previous_state() will have with '^' rules active
1226 styletext = &style_current_buffer->style_ch_buf[1];
1232 /* style_get_previous_state - get the state just before the EOB char was reached
1235 * style_state_type style_get_previous_state();
1238 static style_state_type style_get_previous_state()
1241 register style_state_type style_current_state;
1242 register style_CHAR *style_cp;
1244 register style_CHAR *style_bp = styletext;
1246 style_current_state = style_start;
1247 if ( style_bp[-1] == '\n' )
1248 ++style_current_state;
1250 for ( style_cp = styletext + style_MORE_ADJ; style_cp < style_c_buf_p; ++style_cp )
1252 register style_CHAR style_c = (*style_cp ? style_ec[*style_cp] : 1);
1253 if ( style_accept[style_current_state] )
1255 style_last_accepting_state = style_current_state;
1256 style_last_accepting_cpos = style_cp;
1258 while ( style_chk[style_base[style_current_state] + style_c] != style_current_state )
1260 style_current_state = style_def[style_current_state];
1261 if ( style_current_state >= 134 )
1262 style_c = style_meta[style_c];
1264 style_current_state = style_nxt[style_base[style_current_state] + style_c];
1267 return ( style_current_state );
1271 /* style_try_NUL_trans - try to make a transition on the NUL character
1274 * next_state = style_try_NUL_trans( current_state );
1277 #ifdef style_USE_PROTOS
1278 static style_state_type style_try_NUL_trans( register style_state_type style_current_state )
1280 static style_state_type style_try_NUL_trans( style_current_state )
1281 register style_state_type style_current_state;
1285 register int style_is_jam;
1286 register style_CHAR *style_cp = style_c_buf_p;
1288 register style_CHAR style_c = 1;
1289 if ( style_accept[style_current_state] )
1291 style_last_accepting_state = style_current_state;
1292 style_last_accepting_cpos = style_cp;
1294 while ( style_chk[style_base[style_current_state] + style_c] != style_current_state )
1296 style_current_state = style_def[style_current_state];
1297 if ( style_current_state >= 134 )
1298 style_c = style_meta[style_c];
1300 style_current_state = style_nxt[style_base[style_current_state] + style_c];
1301 style_is_jam = (style_current_state == 133);
1303 return ( style_is_jam ? 0 : style_current_state );
1307 #ifdef style_USE_PROTOS
1308 static void styleunput( style_CHAR c, register style_CHAR *style_bp )
1310 static void styleunput( c, style_bp )
1312 register style_CHAR *style_bp;
1316 register style_CHAR *style_cp = style_c_buf_p;
1318 /* undo effects of setting up styletext */
1319 *style_cp = style_hold_char;
1321 if ( style_cp < style_current_buffer->style_ch_buf + 2 )
1322 { /* need to shift things up to make room */
1323 register int number_to_move = style_n_chars + 2; /* +2 for EOB chars */
1324 register style_CHAR *dest =
1325 &style_current_buffer->style_ch_buf[style_current_buffer->style_buf_size + 2];
1326 register style_CHAR *source =
1327 &style_current_buffer->style_ch_buf[number_to_move];
1329 while ( source > style_current_buffer->style_ch_buf )
1330 *--dest = *--source;
1332 style_cp += dest - source;
1333 style_bp += dest - source;
1334 style_n_chars = style_current_buffer->style_buf_size;
1336 if ( style_cp < style_current_buffer->style_ch_buf + 2 )
1337 style_FATAL_ERROR( "flex scanner push-back overflow" );
1340 if ( style_cp > style_bp && style_cp[-1] == '\n' )
1341 style_cp[-2] = '\n';
1345 /* note: the formal parameter *must* be called "style_bp" for this
1346 * macro to now work correctly
1348 style_DO_BEFORE_ACTION; /* set up styletext again */
1353 static int styleinput()
1360 style_CHAR *style_cp = style_c_buf_p;
1362 *style_cp = style_hold_char;
1364 if ( *style_c_buf_p == style_END_OF_BUFFER_CHAR )
1366 /* style_c_buf_p now points to the character we want to return.
1367 * If this occurs *before* the EOB characters, then it's a
1368 * valid NUL; if not, then we've hit the end of the buffer.
1370 if ( style_c_buf_p < &style_current_buffer->style_ch_buf[style_n_chars] )
1371 /* this was really a NUL */
1372 *style_c_buf_p = '\0';
1375 { /* need more input */
1376 styletext = style_c_buf_p;
1379 switch ( style_get_next_buffer() )
1381 case EOB_ACT_END_OF_FILE:
1385 style_c_buf_p = styletext + style_MORE_ADJ;
1392 return ( styleinput() );
1399 case EOB_ACT_CONTINUE_SCAN:
1400 style_c_buf_p = styletext + style_MORE_ADJ;
1403 case EOB_ACT_LAST_MATCH:
1405 style_FATAL_ERROR( "unexpected last match in styleinput()" );
1407 style_FATAL_ERROR( "unexpected last match in input()" );
1414 style_hold_char = *++style_c_buf_p;
1420 #ifdef style_USE_PROTOS
1421 void stylerestart( FILE *input_file )
1423 void stylerestart( input_file )
1428 style_init_buffer( style_current_buffer, input_file );
1429 style_load_buffer_state();
1433 #ifdef style_USE_PROTOS
1434 void style_switch_to_buffer( style_BUFFER_STATE new_buffer )
1436 void style_switch_to_buffer( new_buffer )
1437 style_BUFFER_STATE new_buffer;
1441 if ( style_current_buffer == new_buffer )
1444 if ( style_current_buffer )
1446 /* flush out information for old buffer */
1447 *style_c_buf_p = style_hold_char;
1448 style_current_buffer->style_buf_pos = style_c_buf_p;
1449 style_current_buffer->style_n_chars = style_n_chars;
1452 style_current_buffer = new_buffer;
1453 style_load_buffer_state();
1455 /* we don't actually know whether we did this switch during
1456 * EOF (stylewrap()) processing, but the only time this flag
1457 * is looked at is after stylewrap() is called, so it's safe
1458 * to go ahead and always set it.
1460 style_did_buffer_switch_on_eof = 1;
1464 #ifdef style_USE_PROTOS
1465 void style_load_buffer_state( void )
1467 void style_load_buffer_state()
1471 style_n_chars = style_current_buffer->style_n_chars;
1472 styletext = style_c_buf_p = style_current_buffer->style_buf_pos;
1473 stylein = style_current_buffer->style_input_file;
1474 style_hold_char = *style_c_buf_p;
1478 #ifdef style_USE_PROTOS
1479 style_BUFFER_STATE style_create_buffer( FILE *file, int size )
1481 style_BUFFER_STATE style_create_buffer( file, size )
1487 style_BUFFER_STATE b;
1489 b = (style_BUFFER_STATE) malloc( sizeof( struct style_buffer_state ) );
1492 style_FATAL_ERROR( "out of dynamic memory in style_create_buffer()" );
1494 b->style_buf_size = size;
1496 /* style_ch_buf has to be 2 characters longer than the size given because
1497 * we need to put in 2 end-of-buffer characters.
1499 b->style_ch_buf = (style_CHAR *) malloc( (unsigned) (b->style_buf_size + 2) );
1501 if ( ! b->style_ch_buf )
1502 style_FATAL_ERROR( "out of dynamic memory in style_create_buffer()" );
1504 style_init_buffer( b, file );
1510 #ifdef style_USE_PROTOS
1511 void style_delete_buffer( style_BUFFER_STATE b )
1513 void style_delete_buffer( b )
1514 style_BUFFER_STATE b;
1518 if ( b == style_current_buffer )
1519 style_current_buffer = (style_BUFFER_STATE) 0;
1521 free( (char *) b->style_ch_buf );
1526 #ifdef style_USE_PROTOS
1527 void style_init_buffer( style_BUFFER_STATE b, FILE *file )
1529 void style_init_buffer( b, file )
1530 style_BUFFER_STATE b;
1535 b->style_input_file = file;
1537 /* we put in the '\n' and start reading from [1] so that an
1538 * initial match-at-newline will be true.
1541 b->style_ch_buf[0] = '\n';
1542 b->style_n_chars = 1;
1544 /* we always need two end-of-buffer characters. The first causes
1545 * a transition to the end-of-buffer state. The second causes
1546 * a jam in that state.
1548 b->style_ch_buf[1] = style_END_OF_BUFFER_CHAR;
1549 b->style_ch_buf[2] = style_END_OF_BUFFER_CHAR;
1551 b->style_buf_pos = &b->style_ch_buf[1];
1553 b->style_eof_status = EOF_NOT_SEEN;
1555 # line 334 "tokenStyle.l"
1558 void enter_sgmlgi_context()
1564 void report_error_location()
1566 if ( commentBufferContentSize > 0 ) {
1567 cerr << commentBuffer << "\n";
1571 void styleerror(char* msg)
1574 cerr << "line " << stylelineno << ": " << msg << "\n";
1576 throw(CASTSSEXCEPT StyleSheetSyntaxError());