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 * $XConsortium: defToken.C /main/5 1996/08/21 15:57:31 drk $
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 defParser_USE_PROTOS
54 /* the "const" storage-class-modifier is valid */
55 #define defParser_USE_CONST
57 #else /* ! __cplusplus */
63 void *malloc( size_t );
69 #define defParser_USE_PROTOS
70 #define defParser_USE_CONST
73 #endif /* ! __cplusplus */
77 #define defParser_USE_CONST
81 #ifndef defParser_USE_CONST
86 #ifdef defParser_USE_PROTOS
87 #define defParser_PROTO(proto) proto
89 #define defParser_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 defParser_READ_BUF_SIZE
102 #define defParser_READ_BUF_SIZE 8192
105 /* returned upon end-of-file */
106 #define defParser_END_TOK 0
108 /* copy whatever the last rule matched to the standard output */
110 /* cast to (char *) is because for 8-bit chars, defParsertext 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 *) defParsertext, defParserleng, 1, defParserout )
116 /* gets input and stuffs it into "buf". number of characters read, or defParser_NULL,
117 * is returned in "result".
119 #define defParser_INPUT(buf,result,max_size) \
120 if ( (result = read( fileno(defParserin), (char *) buf, max_size )) < 0 ) \
121 defParser_FATAL_ERROR( "read() in flex scanner failed" );
122 #define defParser_NULL 0
124 /* no semi-colon after return; correct usage is to write "defParserterminate();" -
125 * we don't want an extra ';' after the "return" because that will cause
126 * some compilers to complain about unreachable statements.
128 #define defParserterminate() return ( defParser_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 * defParser_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 defParser_FATAL_ERROR() call.
146 #define defParser_FATAL_ERROR(msg) \
149 (void) fputs( msg, stderr ); \
150 (void) putc( '\n', stderr ); \
155 /* default defParserwrap function - always treat EOF as an EOF */
156 #define defParserwrap() 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 defParser_start = 1 + 2 *
164 /* action number for EOF rule of a given start state */
165 #define defParser_STATE_EOF(state) (defParser_END_OF_BUFFER + state + 1)
167 /* special action meaning "start processing a new file" */
168 #define defParser_NEW_FILE \
171 defParser_init_buffer( defParser_current_buffer, defParserin ); \
172 defParser_load_buffer_state(); \
176 /* default declaration of generated scanner - a define so the user can
177 * easily add parameters
179 #define defParser_DECL int defParserlex defParser_PROTO(( void ))
181 /* code executed at the end of each rule */
182 #define defParser_BREAK break;
184 #define defParser_END_OF_BUFFER_CHAR 0
186 #ifndef defParser_BUF_SIZE
187 #define defParser_BUF_SIZE (defParser_READ_BUF_SIZE * 2) /* size of default input buffer */
190 typedef struct defParser_buffer_state *defParser_BUFFER_STATE;
192 #define defParser_CHAR unsigned char
193 # line 1 "defToken.l"
195 # line 10 "defToken.l"
197 #include "FeatureDefDictionary.h"
198 #include "defParser.tab.h"
203 extern istream *g_defParserin;
205 #undef defParser_INPUT
206 #define defParser_INPUT(buf,result,max_size)\
208 if (g_defParserin -> eof()) {\
211 g_defParserin -> read((char *)buf, max_size-1); \
212 result = g_defParserin -> gcount(); \
217 int defParserlineno=1;
219 unsigned char* defToken_string_buf = new unsigned char[1024];
220 int defToken_string_buf_size = 1024;
221 int defToken_string_buf_content_size = 0;
223 unsigned char* new_copy(const unsigned char* str, int size)
225 unsigned char* x = new unsigned char[ ( size <= 0 ) ? 1 : size + 1];
226 memcpy(x, str, size);
231 void addToDefTokenStringBuf(const unsigned char* str, int size)
233 if ( size <= 0 ) return;
235 if ( defToken_string_buf_size - defToken_string_buf_content_size < size ) {
236 defToken_string_buf_size = 2*(size+defToken_string_buf_content_size);
237 unsigned char* x = new unsigned char[defToken_string_buf_size];
238 memcpy(x, defToken_string_buf, defToken_string_buf_content_size);
239 delete defToken_string_buf;
240 defToken_string_buf = x;
243 memcpy(defToken_string_buf + defToken_string_buf_content_size, str, size);
244 defToken_string_buf_content_size += size;
245 defToken_string_buf[defToken_string_buf_content_size] = 0;
250 #define quoted_string 1
251 # line 74 "defToken.l"
253 /* done after the current pattern has been matched and before the
254 * corresponding action - sets up defParsertext
256 #define defParser_DO_BEFORE_ACTION \
257 defParsertext = defParser_bp; \
258 defParserleng = defParser_cp - defParser_bp; \
259 defParser_hold_char = *defParser_cp; \
260 *defParser_cp = '\0'; \
261 defParser_c_buf_p = defParser_cp;
263 #define EOB_ACT_CONTINUE_SCAN 0
264 #define EOB_ACT_END_OF_FILE 1
265 #define EOB_ACT_LAST_MATCH 2
267 /* return all but the first 'n' matched characters back to the input stream */
268 #define defParserless(n) \
271 /* undo effects of setting up defParsertext */ \
272 *defParser_cp = defParser_hold_char; \
273 defParser_c_buf_p = defParser_cp = defParser_bp + n; \
274 defParser_DO_BEFORE_ACTION; /* set up defParsertext again */ \
278 #define unput(c) defParserunput( c, defParsertext )
281 struct defParser_buffer_state
283 FILE *defParser_input_file;
285 defParser_CHAR *defParser_ch_buf; /* input buffer */
286 defParser_CHAR *defParser_buf_pos; /* current position in input buffer */
288 /* size of input buffer in bytes, not including room for EOB characters*/
289 int defParser_buf_size;
291 /* number of characters read into defParser_ch_buf, not including EOB characters */
292 int defParser_n_chars;
294 int defParser_eof_status; /* whether we've seen an EOF on this buffer */
295 #define EOF_NOT_SEEN 0
296 /* "pending" happens when the EOF has been seen but there's still
299 #define EOF_PENDING 1
303 static defParser_BUFFER_STATE defParser_current_buffer;
305 /* we provide macros for accessing buffer states in case in the
306 * future we want to put the buffer states in a more general
309 #define defParser_CURRENT_BUFFER defParser_current_buffer
312 /* defParser_hold_char holds the character lost when defParsertext is formed */
313 static defParser_CHAR defParser_hold_char;
315 static int defParser_n_chars; /* number of characters read into defParser_ch_buf */
319 #ifndef defParser_USER_ACTION
320 #define defParser_USER_ACTION
323 #ifndef defParser_USER_INIT
324 #define defParser_USER_INIT
327 extern defParser_CHAR *defParsertext;
328 extern int defParserleng;
329 extern FILE *defParserin, *defParserout;
331 defParser_CHAR *defParsertext;
334 FILE *defParserin = (FILE *) 0, *defParserout = (FILE *) 0;
336 #define defParser_END_OF_BUFFER 29
337 typedef int defParser_state_type;
338 static const short int defParser_accept[84] =
340 0, 0, 0, 0, 29, 24, 25, 26, 27, 20,
341 24, 8, 9, 3, 2, 18, 5, 4, 24, 24,
342 24, 24, 24, 24, 6, 7, 1, 22, 28, 21,
343 24, 23, 0, 18, 24, 24, 24, 24, 24, 24,
344 1, 1, 19, 24, 24, 24, 24, 24, 24, 24,
345 24, 24, 24, 13, 24, 16, 24, 24, 24, 24,
346 24, 24, 24, 11, 17, 24, 12, 24, 24, 24,
347 14, 24, 24, 24, 24, 24, 24, 24, 24, 10,
351 static const defParser_CHAR defParser_ec[256] =
353 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
354 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
355 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
356 1, 4, 1, 5, 6, 1, 1, 7, 1, 8,
357 9, 10, 4, 11, 1, 12, 4, 13, 13, 13,
358 13, 13, 13, 13, 13, 13, 13, 14, 15, 1,
359 4, 1, 4, 4, 16, 17, 1, 18, 19, 20,
360 21, 1, 22, 1, 1, 23, 24, 25, 26, 27,
361 1, 28, 29, 30, 1, 1, 1, 31, 32, 1,
362 4, 1, 4, 4, 33, 1, 16, 17, 1, 18,
364 19, 20, 21, 1, 22, 1, 1, 23, 24, 25,
365 26, 27, 1, 28, 29, 30, 1, 1, 1, 31,
366 32, 1, 34, 1, 35, 1, 1, 1, 1, 1,
367 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
368 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
369 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
370 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
371 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
372 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
373 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
375 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
376 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
377 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
378 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
379 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
383 static const defParser_CHAR defParser_meta[36] =
385 1, 2, 3, 2, 2, 1, 1, 2, 2, 2,
386 2, 2, 1, 2, 2, 1, 1, 1, 1, 1,
387 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
391 static const short int defParser_base[89] =
393 0, 119, 33, 34, 124, 0, 126, 126, 126, 126,
394 0, 126, 126, 126, 126, 28, 126, 126, 95, 96,
395 99, 95, 100, 88, 126, 126, 40, 126, 126, 126,
396 0, 0, 104, 34, 79, 80, 81, 74, 87, 74,
397 74, 0, 88, 84, 76, 79, 78, 73, 73, 62,
398 74, 67, 70, 0, 65, 0, 71, 52, 61, 56,
399 48, 50, 43, 37, 0, 43, 0, 41, 42, 38,
400 32, 45, 36, 42, 39, 38, 28, 27, 38, 0,
401 33, 0, 126, 109, 52, 42, 112, 114
404 static const short int defParser_def[89] =
406 83, 1, 84, 84, 83, 85, 83, 83, 83, 83,
407 86, 83, 83, 83, 83, 85, 83, 83, 85, 85,
408 85, 85, 85, 85, 83, 83, 87, 83, 83, 83,
409 85, 86, 83, 85, 85, 85, 85, 85, 85, 85,
410 87, 88, 83, 85, 85, 85, 85, 85, 85, 85,
411 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
412 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
413 85, 85, 85, 85, 85, 85, 85, 85, 85, 85,
414 85, 85, 0, 83, 83, 83, 83, 83
417 static const short int defParser_nxt[162] =
419 6, 7, 8, 9, 10, 6, 11, 12, 13, 14,
420 15, 9, 16, 17, 18, 19, 20, 21, 6, 6,
421 6, 22, 6, 6, 6, 6, 6, 23, 24, 6,
422 6, 6, 6, 25, 26, 29, 29, 30, 30, 33,
423 34, 42, 32, 42, 42, 33, 34, 42, 42, 42,
424 42, 42, 31, 42, 42, 82, 81, 80, 79, 78,
425 77, 76, 75, 74, 73, 72, 71, 70, 69, 68,
426 67, 66, 65, 42, 42, 42, 64, 42, 42, 63,
427 62, 42, 42, 42, 42, 42, 61, 42, 42, 60,
428 59, 58, 57, 56, 55, 54, 53, 52, 51, 50,
430 43, 49, 48, 47, 46, 45, 44, 42, 42, 28,
431 28, 28, 41, 41, 42, 42, 43, 40, 39, 38,
432 37, 36, 35, 83, 27, 5, 83, 83, 83, 83,
433 83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
434 83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
435 83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
439 static const short int defParser_chk[162] =
441 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
442 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
443 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
444 1, 1, 1, 1, 1, 3, 4, 3, 4, 16,
445 16, 27, 86, 27, 27, 34, 34, 27, 27, 27,
446 27, 27, 85, 27, 27, 81, 79, 78, 77, 76,
447 75, 74, 73, 72, 71, 70, 69, 68, 66, 64,
448 63, 62, 61, 27, 27, 41, 60, 41, 41, 59,
449 58, 41, 41, 41, 41, 41, 57, 41, 41, 55,
450 53, 52, 51, 50, 49, 48, 47, 46, 45, 44,
452 43, 40, 39, 38, 37, 36, 35, 41, 41, 84,
453 84, 84, 87, 87, 88, 88, 33, 24, 23, 22,
454 21, 20, 19, 5, 2, 83, 83, 83, 83, 83,
455 83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
456 83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
457 83, 83, 83, 83, 83, 83, 83, 83, 83, 83,
461 static defParser_state_type defParser_last_accepting_state;
462 static defParser_CHAR *defParser_last_accepting_cpos;
464 /* the intent behind this definition is that it'll catch
465 * any uses of REJECT which flex missed
467 #define REJECT reject_used_but_not_detected
468 #define defParsermore() defParsermore_used_but_not_detected
469 #define defParser_MORE_ADJ 0
471 /* these variables are all declared out here so that section 3 code can
474 /* points to current character in buffer */
475 static defParser_CHAR *defParser_c_buf_p = (defParser_CHAR *) 0;
476 static int defParser_init = 1; /* whether we need to initialize */
477 static int defParser_start = 0; /* start state number */
479 /* flag which is used to allow defParserwrap()'s to do buffer switches
480 * instead of setting up a fresh defParserin. A bit of a hack ...
482 static int defParser_did_buffer_switch_on_eof;
484 static defParser_state_type defParser_get_previous_state defParser_PROTO(( void ));
485 static defParser_state_type defParser_try_NUL_trans defParser_PROTO(( defParser_state_type current_state ));
486 static int defParser_get_next_buffer defParser_PROTO(( void ));
488 static void defParserunput defParser_PROTO(( defParser_CHAR c, defParser_CHAR *buf_ptr ));
490 void defParserrestart defParser_PROTO(( FILE *input_file ));
491 void defParser_switch_to_buffer defParser_PROTO(( defParser_BUFFER_STATE new_buffer ));
492 void defParser_load_buffer_state defParser_PROTO(( void ));
493 defParser_BUFFER_STATE defParser_create_buffer defParser_PROTO(( FILE *file, int size ));
494 void defParser_delete_buffer defParser_PROTO(( defParser_BUFFER_STATE b ));
495 void defParser_init_buffer defParser_PROTO(( defParser_BUFFER_STATE b, FILE *file ));
497 #define defParser_new_buffer defParser_create_buffer
501 static int defParserinput defParser_PROTO(( void ));
503 static int input defParser_PROTO(( void ));
509 register defParser_state_type defParser_current_state;
510 register defParser_CHAR *defParser_cp, *defParser_bp;
511 register int defParser_act;
516 if ( defParser_init )
520 if ( ! defParser_start )
521 defParser_start = 1; /* first start state */
526 if ( ! defParserout )
527 defParserout = stdout;
529 if ( defParser_current_buffer )
530 defParser_init_buffer( defParser_current_buffer, defParserin );
532 defParser_current_buffer = defParser_create_buffer( defParserin, defParser_BUF_SIZE );
534 defParser_load_buffer_state();
539 while ( 1 ) /* loops until end-of-file is reached */
541 defParser_cp = defParser_c_buf_p;
543 /* support of defParsertext */
544 *defParser_cp = defParser_hold_char;
546 /* defParser_bp points to the position in defParser_ch_buf of the start of the
549 defParser_bp = defParser_cp;
551 defParser_current_state = defParser_start;
552 if ( defParser_bp[-1] == '\n' )
553 ++defParser_current_state;
557 register defParser_CHAR defParser_c = defParser_ec[*defParser_cp];
558 if ( defParser_accept[defParser_current_state] )
560 defParser_last_accepting_state = defParser_current_state;
561 defParser_last_accepting_cpos = defParser_cp;
563 while ( defParser_chk[defParser_base[defParser_current_state] + defParser_c] != defParser_current_state )
565 defParser_current_state = defParser_def[defParser_current_state];
566 if ( defParser_current_state >= 84 )
567 defParser_c = defParser_meta[defParser_c];
569 defParser_current_state = defParser_nxt[defParser_base[defParser_current_state] + defParser_c];
572 while ( defParser_current_state != 83 );
573 defParser_cp = defParser_last_accepting_cpos;
574 defParser_current_state = defParser_last_accepting_state;
576 defParser_find_action:
577 defParser_act = defParser_accept[defParser_current_state];
579 defParser_DO_BEFORE_ACTION;
580 defParser_USER_ACTION;
582 do_action: /* this label is used only to access EOF actions */
585 switch ( defParser_act )
587 case 0: /* must backtrack */
588 /* undo the effects of defParser_DO_BEFORE_ACTION */
589 *defParser_cp = defParser_hold_char;
590 defParser_cp = defParser_last_accepting_cpos;
591 defParser_current_state = defParser_last_accepting_state;
592 goto defParser_find_action;
595 # line 76 "defToken.l"
600 # line 79 "defToken.l"
606 # line 83 "defToken.l"
612 # line 87 "defToken.l"
618 # line 91 "defToken.l"
624 # line 95 "defToken.l"
630 # line 99 "defToken.l"
636 # line 103 "defToken.l"
638 return(OPER_parenopen);
642 # line 107 "defToken.l"
644 return(OPER_parenclose);
648 # line 112 "defToken.l"
650 defParserlval.charPtrData = new_copy((unsigned char*)defParsertext, defParserleng);
655 # line 117 "defToken.l"
657 defParserlval.charPtrData = new_copy((unsigned char*)defParsertext, defParserleng);
662 # line 122 "defToken.l"
664 defParserlval.charPtrData = new_copy((unsigned char*)defParsertext, defParserleng);
669 # line 127 "defToken.l"
671 defParserlval.charPtrData = new_copy((unsigned char*)defParsertext, defParserleng);
676 # line 132 "defToken.l"
678 defParserlval.charPtrData = new_copy((unsigned char*)defParsertext, defParserleng);
683 # line 137 "defToken.l"
685 defParserlval.charPtrData = new_copy((unsigned char*)defParsertext, defParserleng);
690 # line 142 "defToken.l"
692 defParserlval.charPtrData = new_copy((unsigned char*)defParsertext, defParserleng);
697 # line 147 "defToken.l"
699 defParserlval.charPtrData =
700 new_copy((unsigned char*)"INTEGER", strlen("INTEGER"));
705 # line 153 "defToken.l"
707 defParserlval.intData = atoi((char*)defParsertext);
712 # line 158 "defToken.l"
714 defParserlval.realData = atof((char*)defParsertext);
719 # line 163 "defToken.l"
725 # line 167 "defToken.l"
728 defParserlval.charPtrData =
729 new unsigned char[defToken_string_buf_content_size+1];
730 memcpy( defParserlval.charPtrData,
732 defToken_string_buf_content_size+1
735 defToken_string_buf_content_size = 0;
738 return(QUOTED_STRING);
742 # line 182 "defToken.l"
744 addToDefTokenStringBuf((const unsigned char *)defParsertext, defParserleng);
748 # line 186 "defToken.l"
750 defParserlval.charPtrData =
751 (unsigned char*)strdup((const char*)(defParsertext+1));
756 # line 192 "defToken.l"
758 defParserlval.charPtrData =
759 (unsigned char*)strdup((const char*)defParsertext);
760 return(NORMAL_STRING);
764 # line 198 "defToken.l"
769 # line 201 "defToken.l"
775 # line 205 "defToken.l"
780 # line 210 "defToken.l"
781 defParser_FATAL_ERROR( "flex scanner jammed" );
783 case defParser_STATE_EOF(INITIAL):
784 case defParser_STATE_EOF(quoted_string):
785 defParserterminate();
787 case defParser_END_OF_BUFFER:
789 /* amount of text matched not including the EOB char */
790 int defParser_amount_of_matched_text = defParser_cp - defParsertext - 1;
792 /* undo the effects of defParser_DO_BEFORE_ACTION */
793 *defParser_cp = defParser_hold_char;
795 /* note that here we test for defParser_c_buf_p "<=" to the position
796 * of the first EOB in the buffer, since defParser_c_buf_p will
797 * already have been incremented past the NUL character
798 * (since all states make transitions on EOB to the end-
799 * of-buffer state). Contrast this with the test in defParserinput().
801 if ( defParser_c_buf_p <= &defParser_current_buffer->defParser_ch_buf[defParser_n_chars] )
802 /* this was really a NUL */
804 defParser_state_type defParser_next_state;
806 defParser_c_buf_p = defParsertext + defParser_amount_of_matched_text;
808 defParser_current_state = defParser_get_previous_state();
810 /* okay, we're now positioned to make the
811 * NUL transition. We couldn't have
812 * defParser_get_previous_state() go ahead and do it
813 * for us because it doesn't know how to deal
814 * with the possibility of jamming (and we
815 * don't want to build jamming into it because
816 * then it will run more slowly)
819 defParser_next_state = defParser_try_NUL_trans( defParser_current_state );
821 defParser_bp = defParsertext + defParser_MORE_ADJ;
823 if ( defParser_next_state )
825 /* consume the NUL */
826 defParser_cp = ++defParser_c_buf_p;
827 defParser_current_state = defParser_next_state;
828 goto defParser_match;
833 defParser_cp = defParser_last_accepting_cpos;
834 defParser_current_state = defParser_last_accepting_state;
835 goto defParser_find_action;
839 else switch ( defParser_get_next_buffer() )
841 case EOB_ACT_END_OF_FILE:
843 defParser_did_buffer_switch_on_eof = 0;
845 if ( defParserwrap() )
847 /* note: because we've taken care in
848 * defParser_get_next_buffer() to have set up defParsertext,
849 * we can now set up defParser_c_buf_p so that if some
850 * total hoser (like flex itself) wants
851 * to call the scanner after we return the
852 * defParser_NULL, it'll still work - another defParser_NULL
855 defParser_c_buf_p = defParsertext + defParser_MORE_ADJ;
857 defParser_act = defParser_STATE_EOF((defParser_start - 1) / 2);
863 if ( ! defParser_did_buffer_switch_on_eof )
869 case EOB_ACT_CONTINUE_SCAN:
870 defParser_c_buf_p = defParsertext + defParser_amount_of_matched_text;
872 defParser_current_state = defParser_get_previous_state();
874 defParser_cp = defParser_c_buf_p;
875 defParser_bp = defParsertext + defParser_MORE_ADJ;
876 goto defParser_match;
878 case EOB_ACT_LAST_MATCH:
880 &defParser_current_buffer->defParser_ch_buf[defParser_n_chars];
882 defParser_current_state = defParser_get_previous_state();
884 defParser_cp = defParser_c_buf_p;
885 defParser_bp = defParsertext + defParser_MORE_ADJ;
886 goto defParser_find_action;
893 printf( "action # %d\n", defParser_act );
895 defParser_FATAL_ERROR(
896 "fatal flex scanner internal error--no action found" );
902 /* defParser_get_next_buffer - try to read in a new buffer
905 * int defParser_get_next_buffer();
907 * returns a code representing an action
908 * EOB_ACT_LAST_MATCH -
909 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
910 * EOB_ACT_END_OF_FILE - end of file
913 static int defParser_get_next_buffer()
916 register defParser_CHAR *dest = defParser_current_buffer->defParser_ch_buf;
917 register defParser_CHAR *source = defParsertext - 1; /* copy prev. char, too */
918 register int number_to_move, i;
921 if ( defParser_c_buf_p > &defParser_current_buffer->defParser_ch_buf[defParser_n_chars + 1] )
922 defParser_FATAL_ERROR(
923 "fatal flex scanner internal error--end of buffer missed" );
925 /* try to read more data */
927 /* first move last chars to start of buffer */
928 number_to_move = defParser_c_buf_p - defParsertext;
930 for ( i = 0; i < number_to_move; ++i )
931 *(dest++) = *(source++);
933 if ( defParser_current_buffer->defParser_eof_status != EOF_NOT_SEEN )
934 /* don't do the read, it's not guaranteed to return an EOF,
937 defParser_n_chars = 0;
941 int num_to_read = defParser_current_buffer->defParser_buf_size - number_to_move - 1;
943 if ( num_to_read > defParser_READ_BUF_SIZE )
944 num_to_read = defParser_READ_BUF_SIZE;
946 else if ( num_to_read <= 0 )
947 defParser_FATAL_ERROR( "fatal error - scanner input buffer overflow" );
949 /* read in more data */
950 defParser_INPUT( (&defParser_current_buffer->defParser_ch_buf[number_to_move]),
951 defParser_n_chars, num_to_read );
954 if ( defParser_n_chars == 0 )
956 if ( number_to_move == 1 )
958 ret_val = EOB_ACT_END_OF_FILE;
959 defParser_current_buffer->defParser_eof_status = EOF_DONE;
964 ret_val = EOB_ACT_LAST_MATCH;
965 defParser_current_buffer->defParser_eof_status = EOF_PENDING;
970 ret_val = EOB_ACT_CONTINUE_SCAN;
972 defParser_n_chars += number_to_move;
973 defParser_current_buffer->defParser_ch_buf[defParser_n_chars] = defParser_END_OF_BUFFER_CHAR;
974 defParser_current_buffer->defParser_ch_buf[defParser_n_chars + 1] = defParser_END_OF_BUFFER_CHAR;
976 /* defParsertext begins at the second character in defParser_ch_buf; the first
977 * character is the one which preceded it before reading in the latest
978 * buffer; it needs to be kept around in case it's a newline, so
979 * defParser_get_previous_state() will have with '^' rules active
982 defParsertext = &defParser_current_buffer->defParser_ch_buf[1];
988 /* defParser_get_previous_state - get the state just before the EOB char was reached
991 * defParser_state_type defParser_get_previous_state();
994 static defParser_state_type defParser_get_previous_state()
997 register defParser_state_type defParser_current_state;
998 register defParser_CHAR *defParser_cp;
1000 register defParser_CHAR *defParser_bp = defParsertext;
1002 defParser_current_state = defParser_start;
1003 if ( defParser_bp[-1] == '\n' )
1004 ++defParser_current_state;
1006 for ( defParser_cp = defParsertext + defParser_MORE_ADJ; defParser_cp < defParser_c_buf_p; ++defParser_cp )
1008 register defParser_CHAR defParser_c = (*defParser_cp ? defParser_ec[*defParser_cp] : 1);
1009 if ( defParser_accept[defParser_current_state] )
1011 defParser_last_accepting_state = defParser_current_state;
1012 defParser_last_accepting_cpos = defParser_cp;
1014 while ( defParser_chk[defParser_base[defParser_current_state] + defParser_c] != defParser_current_state )
1016 defParser_current_state = defParser_def[defParser_current_state];
1017 if ( defParser_current_state >= 84 )
1018 defParser_c = defParser_meta[defParser_c];
1020 defParser_current_state = defParser_nxt[defParser_base[defParser_current_state] + defParser_c];
1023 return ( defParser_current_state );
1027 /* defParser_try_NUL_trans - try to make a transition on the NUL character
1030 * next_state = defParser_try_NUL_trans( current_state );
1033 #ifdef defParser_USE_PROTOS
1034 static defParser_state_type defParser_try_NUL_trans( register defParser_state_type defParser_current_state )
1036 static defParser_state_type defParser_try_NUL_trans( defParser_current_state )
1037 register defParser_state_type defParser_current_state;
1041 register int defParser_is_jam;
1042 register defParser_CHAR *defParser_cp = defParser_c_buf_p;
1044 register defParser_CHAR defParser_c = 1;
1045 if ( defParser_accept[defParser_current_state] )
1047 defParser_last_accepting_state = defParser_current_state;
1048 defParser_last_accepting_cpos = defParser_cp;
1050 while ( defParser_chk[defParser_base[defParser_current_state] + defParser_c] != defParser_current_state )
1052 defParser_current_state = defParser_def[defParser_current_state];
1053 if ( defParser_current_state >= 84 )
1054 defParser_c = defParser_meta[defParser_c];
1056 defParser_current_state = defParser_nxt[defParser_base[defParser_current_state] + defParser_c];
1057 defParser_is_jam = (defParser_current_state == 83);
1059 return ( defParser_is_jam ? 0 : defParser_current_state );
1064 #ifdef defParser_USE_PROTOS
1065 static void defParserunput( defParser_CHAR c, register defParser_CHAR *defParser_bp )
1067 static void defParserunput( c, defParser_bp )
1069 register defParser_CHAR *defParser_bp;
1073 register defParser_CHAR *defParser_cp = defParser_c_buf_p;
1075 /* undo effects of setting up defParsertext */
1076 *defParser_cp = defParser_hold_char;
1078 if ( defParser_cp < defParser_current_buffer->defParser_ch_buf + 2 )
1079 { /* need to shift things up to make room */
1080 register int number_to_move = defParser_n_chars + 2; /* +2 for EOB chars */
1081 register defParser_CHAR *dest =
1082 &defParser_current_buffer->defParser_ch_buf[defParser_current_buffer->defParser_buf_size + 2];
1083 register defParser_CHAR *source =
1084 &defParser_current_buffer->defParser_ch_buf[number_to_move];
1086 while ( source > defParser_current_buffer->defParser_ch_buf )
1087 *--dest = *--source;
1089 defParser_cp += dest - source;
1090 defParser_bp += dest - source;
1091 defParser_n_chars = defParser_current_buffer->defParser_buf_size;
1093 if ( defParser_cp < defParser_current_buffer->defParser_ch_buf + 2 )
1094 defParser_FATAL_ERROR( "flex scanner push-back overflow" );
1097 if ( defParser_cp > defParser_bp && defParser_cp[-1] == '\n' )
1098 defParser_cp[-2] = '\n';
1100 *--defParser_cp = c;
1102 /* note: the formal parameter *must* be called "defParser_bp" for this
1103 * macro to now work correctly
1105 defParser_DO_BEFORE_ACTION; /* set up defParsertext again */
1112 static int defParserinput()
1119 defParser_CHAR *defParser_cp = defParser_c_buf_p;
1121 *defParser_cp = defParser_hold_char;
1123 if ( *defParser_c_buf_p == defParser_END_OF_BUFFER_CHAR )
1125 /* defParser_c_buf_p now points to the character we want to return.
1126 * If this occurs *before* the EOB characters, then it's a
1127 * valid NUL; if not, then we've hit the end of the buffer.
1129 if ( defParser_c_buf_p < &defParser_current_buffer->defParser_ch_buf[defParser_n_chars] )
1130 /* this was really a NUL */
1131 *defParser_c_buf_p = '\0';
1134 { /* need more input */
1135 defParsertext = defParser_c_buf_p;
1136 ++defParser_c_buf_p;
1138 switch ( defParser_get_next_buffer() )
1140 case EOB_ACT_END_OF_FILE:
1142 if ( defParserwrap() )
1144 defParser_c_buf_p = defParsertext + defParser_MORE_ADJ;
1151 return ( defParserinput() );
1158 case EOB_ACT_CONTINUE_SCAN:
1159 defParser_c_buf_p = defParsertext + defParser_MORE_ADJ;
1162 case EOB_ACT_LAST_MATCH:
1164 defParser_FATAL_ERROR( "unexpected last match in defParserinput()" );
1166 defParser_FATAL_ERROR( "unexpected last match in input()" );
1172 c = *defParser_c_buf_p;
1173 defParser_hold_char = *++defParser_c_buf_p;
1180 #ifdef defParser_USE_PROTOS
1181 void defParserrestart( FILE *input_file )
1183 void defParserrestart( input_file )
1188 defParser_init_buffer( defParser_current_buffer, input_file );
1189 defParser_load_buffer_state();
1193 #ifdef defParser_USE_PROTOS
1194 void defParser_switch_to_buffer( defParser_BUFFER_STATE new_buffer )
1196 void defParser_switch_to_buffer( new_buffer )
1197 defParser_BUFFER_STATE new_buffer;
1201 if ( defParser_current_buffer == new_buffer )
1204 if ( defParser_current_buffer )
1206 /* flush out information for old buffer */
1207 *defParser_c_buf_p = defParser_hold_char;
1208 defParser_current_buffer->defParser_buf_pos = defParser_c_buf_p;
1209 defParser_current_buffer->defParser_n_chars = defParser_n_chars;
1212 defParser_current_buffer = new_buffer;
1213 defParser_load_buffer_state();
1215 /* we don't actually know whether we did this switch during
1216 * EOF (defParserwrap()) processing, but the only time this flag
1217 * is looked at is after defParserwrap() is called, so it's safe
1218 * to go ahead and always set it.
1220 defParser_did_buffer_switch_on_eof = 1;
1224 #ifdef defParser_USE_PROTOS
1225 void defParser_load_buffer_state( void )
1227 void defParser_load_buffer_state()
1231 defParser_n_chars = defParser_current_buffer->defParser_n_chars;
1232 defParsertext = defParser_c_buf_p = defParser_current_buffer->defParser_buf_pos;
1233 defParserin = defParser_current_buffer->defParser_input_file;
1234 defParser_hold_char = *defParser_c_buf_p;
1238 #ifdef defParser_USE_PROTOS
1239 defParser_BUFFER_STATE defParser_create_buffer( FILE *file, int size )
1241 defParser_BUFFER_STATE defParser_create_buffer( file, size )
1247 defParser_BUFFER_STATE b;
1249 b = (defParser_BUFFER_STATE) malloc( sizeof( struct defParser_buffer_state ) );
1252 defParser_FATAL_ERROR( "out of dynamic memory in defParser_create_buffer()" );
1254 b->defParser_buf_size = size;
1256 /* defParser_ch_buf has to be 2 characters longer than the size given because
1257 * we need to put in 2 end-of-buffer characters.
1259 b->defParser_ch_buf = (defParser_CHAR *) malloc( (unsigned) (b->defParser_buf_size + 2) );
1261 if ( ! b->defParser_ch_buf )
1262 defParser_FATAL_ERROR( "out of dynamic memory in defParser_create_buffer()" );
1264 defParser_init_buffer( b, file );
1270 #ifdef defParser_USE_PROTOS
1271 void defParser_delete_buffer( defParser_BUFFER_STATE b )
1273 void defParser_delete_buffer( b )
1274 defParser_BUFFER_STATE b;
1278 if ( b == defParser_current_buffer )
1279 defParser_current_buffer = (defParser_BUFFER_STATE) 0;
1281 free( (char *) b->defParser_ch_buf );
1286 #ifdef defParser_USE_PROTOS
1287 void defParser_init_buffer( defParser_BUFFER_STATE b, FILE *file )
1289 void defParser_init_buffer( b, file )
1290 defParser_BUFFER_STATE b;
1295 b->defParser_input_file = file;
1297 /* we put in the '\n' and start reading from [1] so that an
1298 * initial match-at-newline will be true.
1301 b->defParser_ch_buf[0] = '\n';
1302 b->defParser_n_chars = 1;
1304 /* we always need two end-of-buffer characters. The first causes
1305 * a transition to the end-of-buffer state. The second causes
1306 * a jam in that state.
1308 b->defParser_ch_buf[1] = defParser_END_OF_BUFFER_CHAR;
1309 b->defParser_ch_buf[2] = defParser_END_OF_BUFFER_CHAR;
1311 b->defParser_buf_pos = &b->defParser_ch_buf[1];
1313 b->defParser_eof_status = EOF_NOT_SEEN;
1315 # line 210 "defToken.l"
1318 void defParsererror(char* msg)
1320 cerr << "line " << defParserlineno << ": " << msg;