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 * $XConsortium: token.cc /main/4 1996/07/05 15:20:12 rws $
34 /* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
46 #if defined(__osf__) || defined(linux) || defined(CSRG_BASED) || defined(sun)
54 /* use prototypes in function declarations */
55 #define schema_USE_PROTOS
57 /* the "const" storage-class-modifier is valid */
58 #define schema_USE_CONST
60 #else /* ! __cplusplus */
66 void *malloc( size_t );
72 #define schema_USE_PROTOS
73 #define schema_USE_CONST
76 #endif /* ! __cplusplus */
80 #define schema_USE_CONST
84 #ifndef schema_USE_CONST
89 #ifdef schema_USE_PROTOS
90 #define schema_PROTO(proto) proto
92 #define schema_PROTO(proto) ()
93 /* we can't get here if it's an ANSI C compiler, or a C++ compiler,
94 * so it's got to be a K&R compiler, and therefore there's no standard
95 * place from which to include these definitions
103 /* amount of stuff to slurp up with each read */
104 #ifndef schema_READ_BUF_SIZE
105 #define schema_READ_BUF_SIZE 8192
108 /* returned upon end-of-file */
109 #define schema_END_TOK 0
111 /* copy whatever the last rule matched to the standard output */
113 /* cast to (char *) is because for 8-bit chars, schematext is (unsigned char *) */
114 /* this used to be an fputs(), but since the string might contain NUL's,
115 * we now use fwrite()
117 #define ECHO (void) fwrite( (char *) schematext, schemaleng, 1, schemaout )
119 /* gets input and stuffs it into "buf". number of characters read, or schema_NULL,
120 * is returned in "result".
122 #define schema_INPUT(buf,result,max_size) \
123 if ( (result = read( fileno( schemain), (char *) buf, max_size )) < 0 ) \
124 schema_FATAL_ERROR( "read() in flex scanner failed" );
125 #define schema_NULL 0
127 /* no semi-colon after return; correct usage is to write " schematerminate();" -
128 * we don't want an extra ';' after the "return" because that will cause
129 * some compilers to complain about unreachable statements.
131 #define schematerminate() return ( schema_NULL )
133 /* report a fatal error */
135 /* The funky do-while is used to turn this macro definition into
136 * a single C statement (which needs a semi-colon terminator).
137 * This avoids problems with code like:
139 * if ( something_happens )
140 * schema_FATAL_ERROR( "oops, the something happened" );
144 * Prior to using the do-while the compiler would get upset at the
145 * "else" because it interpreted the "if" statement as being all
146 * done when it reached the ';' after the schema_FATAL_ERROR() call.
149 #define schema_FATAL_ERROR(msg) \
152 (void) fputs( msg, stderr ); \
153 (void) putc( '\n', stderr ); \
158 /* default schemawrap function - always treat EOF as an EOF */
159 #define schemawrap() 1
161 /* enter a start condition. This macro really ought to take a parameter,
162 * but we do it the disgusting crufty way forced on us by the ()-less
163 * definition of BEGIN
165 #define BEGIN schema_start = 1 + 2 *
167 /* action number for EOF rule of a given start state */
168 #define schema_STATE_EOF(state) ( schema_END_OF_BUFFER + state + 1)
170 /* special action meaning "start processing a new file" */
171 #define schema_NEW_FILE \
174 schema_init_buffer( schema_current_buffer, schemain ); \
175 schema_load_buffer_state(); \
179 /* default declaration of generated scanner - a define so the user can
180 * easily add parameters
182 #define schema_DECL int schemalex schema_PROTO(( void ))
184 /* code executed at the end of each rule */
185 #define schema_BREAK break;
187 #define schema_END_OF_BUFFER_CHAR 0
189 #ifndef schema_BUF_SIZE
190 #define schema_BUF_SIZE ( schema_READ_BUF_SIZE * 2) /* size of default input buffer */
193 typedef struct schema_buffer_state * schema_BUFFER_STATE;
195 #define schema_CHAR unsigned char
198 * $XConsortium: token.cc /main/4 1996/07/05 15:20:12 rws $
200 * Copyright (c) 1993 HAL Computer Systems International, Ltd.
201 * All rights reserved. Unpublished -- rights reserved under
202 * the Copyright Laws of the United States. USE OF A COPYRIGHT
203 * NOTICE IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
206 * THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND TRADE
207 * SECRETS OF HAL COMPUTER SYSTEMS INTERNATIONAL, LTD. USE,
208 * DISCLOSURE, OR REPRODUCTION IS PROHIBITED WITHOUT THE
209 * PRIOR EXPRESS WRITTEN PERMISSION OF HAL COMPUTER SYSTEMS
210 * INTERNATIONAL, LTD.
212 * RESTRICTED RIGHTS LEGEND
213 * Use, duplication, or disclosure by the Government is subject
214 * to the restrictions as set forth in subparagraph (c)(l)(ii)
215 * of the Rights in Technical Data and Computer Software clause
216 * at DFARS 252.227-7013.
218 * HAL COMPUTER SYSTEMS INTERNATIONAL, LTD.
223 #include "store_desc.h"
224 #include "sheet.tab.h"
225 extern char replace_string[PATHSIZ];
226 extern int replace_string_len;
230 /* done after the current pattern has been matched and before the
231 * corresponding action - sets up schematext
233 #define schema_DO_BEFORE_ACTION \
234 schematext = schema_bp; \
235 schemaleng = schema_cp - schema_bp; \
236 schema_hold_char = * schema_cp; \
237 * schema_cp = '\0'; \
238 schema_c_buf_p = schema_cp;
240 #define EOB_ACT_CONTINUE_SCAN 0
241 #define EOB_ACT_END_OF_FILE 1
242 #define EOB_ACT_LAST_MATCH 2
244 /* return all but the first 'n' matched characters back to the input stream */
245 #define schemaless(n) \
248 /* undo effects of setting up schematext */ \
249 * schema_cp = schema_hold_char; \
250 schema_c_buf_p = schema_cp = schema_bp + n; \
251 schema_DO_BEFORE_ACTION; /* set up schematext again */ \
255 #define unput(c) schemaunput( c, schematext )
258 struct schema_buffer_state
260 FILE * schema_input_file;
262 schema_CHAR * schema_ch_buf; /* input buffer */
263 schema_CHAR * schema_buf_pos; /* current position in input buffer */
265 /* size of input buffer in bytes, not including room for EOB characters*/
268 /* number of characters read into schema_ch_buf, not including EOB characters */
271 int schema_eof_status; /* whether we've seen an EOF on this buffer */
272 #define EOF_NOT_SEEN 0
273 /* "pending" happens when the EOF has been seen but there's still
276 #define EOF_PENDING 1
280 static schema_BUFFER_STATE schema_current_buffer;
282 /* we provide macros for accessing buffer states in case in the
283 * future we want to put the buffer states in a more general
286 #define schema_CURRENT_BUFFER schema_current_buffer
289 /* schema_hold_char holds the character lost when schematext is formed */
290 static schema_CHAR schema_hold_char;
292 static int schema_n_chars; /* number of characters read into schema_ch_buf */
296 #ifndef schema_USER_ACTION
297 #define schema_USER_ACTION
300 #ifndef schema_USER_INIT
301 #define schema_USER_INIT
304 extern schema_CHAR * schematext;
305 extern int schemaleng;
306 extern FILE * schemain, * schemaout;
308 schema_CHAR * schematext;
311 FILE * schemain = (FILE *) 0, * schemaout = (FILE *) 0;
313 #define schema_END_OF_BUFFER 37
314 typedef int schema_state_type;
315 static const short int schema_accept[164] =
317 0, 0, 37, 36, 32, 31, 35, 34, 30, 29,
318 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
319 35, 35, 33, 32, 31, 35, 34, 30, 30, 35,
320 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
321 23, 35, 35, 35, 35, 35, 35, 33, 35, 35,
322 35, 35, 35, 35, 35, 35, 35, 5, 35, 35,
323 35, 35, 35, 2, 35, 35, 35, 35, 35, 35,
324 35, 35, 35, 8, 35, 35, 35, 3, 25, 10,
325 35, 35, 35, 35, 35, 35, 11, 35, 35, 35,
326 35, 35, 13, 35, 35, 35, 35, 12, 21, 24,
328 35, 35, 35, 35, 35, 35, 35, 35, 17, 35,
329 35, 35, 35, 35, 35, 35, 35, 35, 35, 35,
330 7, 35, 35, 35, 35, 26, 35, 35, 35, 18,
331 35, 35, 35, 6, 35, 35, 4, 35, 35, 20,
332 35, 19, 35, 35, 35, 1, 35, 35, 35, 35,
333 35, 27, 35, 35, 14, 22, 35, 16, 35, 9,
337 static const schema_CHAR schema_ec[256] =
339 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
340 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
341 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
342 1, 2, 1, 1, 4, 5, 1, 1, 1, 1,
343 1, 1, 1, 1, 5, 5, 1, 6, 6, 6,
344 6, 6, 6, 6, 6, 6, 6, 7, 1, 1,
345 8, 1, 1, 1, 5, 5, 5, 5, 5, 5,
346 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
347 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
348 1, 9, 1, 1, 10, 1, 11, 12, 13, 14,
350 15, 16, 17, 18, 19, 5, 5, 20, 21, 22,
351 23, 24, 5, 25, 26, 27, 28, 29, 5, 30,
352 31, 32, 1, 1, 1, 1, 1, 1, 1, 1,
353 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
354 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
355 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
356 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
357 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
358 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
359 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
361 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
362 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
363 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
364 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
365 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
369 static const schema_CHAR schema_meta[33] =
371 1, 1, 2, 1, 3, 3, 1, 1, 1, 3,
372 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
373 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
377 static const short int schema_base[166] =
379 0, 174, 177, 179, 174, 172, 0, 168, 30, 179,
380 156, 7, 24, 153, 143, 148, 150, 13, 147, 29,
381 27, 157, 0, 164, 162, 0, 158, 179, 160, 147,
382 136, 133, 146, 22, 145, 141, 27, 130, 141, 136,
383 0, 136, 126, 124, 126, 126, 125, 0, 125, 131,
384 130, 126, 119, 115, 114, 124, 124, 128, 110, 121,
385 119, 119, 114, 0, 114, 106, 111, 102, 113, 117,
386 111, 100, 113, 0, 102, 92, 99, 0, 0, 110,
387 109, 91, 101, 101, 101, 104, 103, 89, 97, 95,
388 90, 97, 97, 85, 86, 78, 84, 92, 91, 0,
390 78, 80, 73, 87, 70, 73, 72, 35, 0, 71,
391 18, 69, 72, 68, 68, 66, 73, 62, 59, 69,
392 0, 66, 61, 67, 57, 0, 57, 56, 56, 0,
393 62, 60, 63, 0, 48, 57, 0, 56, 45, 0,
394 55, 0, 53, 42, 49, 0, 43, 34, 48, 47,
395 31, 0, 44, 28, 0, 0, 23, 0, 25, 0,
399 static const short int schema_def[166] =
401 163, 1, 163, 163, 163, 163, 164, 164, 163, 163,
402 164, 164, 164, 164, 164, 164, 164, 164, 164, 164,
403 164, 164, 165, 163, 163, 164, 164, 163, 163, 164,
404 164, 164, 164, 164, 164, 164, 164, 164, 164, 164,
405 164, 164, 164, 164, 164, 164, 164, 165, 164, 164,
406 164, 164, 164, 164, 164, 164, 164, 164, 164, 164,
407 164, 164, 164, 164, 164, 164, 164, 164, 164, 164,
408 164, 164, 164, 164, 164, 164, 164, 164, 164, 164,
409 164, 164, 164, 164, 164, 164, 164, 164, 164, 164,
410 164, 164, 164, 164, 164, 164, 164, 164, 164, 164,
412 164, 164, 164, 164, 164, 164, 164, 164, 164, 164,
413 164, 164, 164, 164, 164, 164, 164, 164, 164, 164,
414 164, 164, 164, 164, 164, 164, 164, 164, 164, 164,
415 164, 164, 164, 164, 164, 164, 164, 164, 164, 164,
416 164, 164, 164, 164, 164, 164, 164, 164, 164, 164,
417 164, 164, 164, 164, 164, 164, 164, 164, 164, 164,
418 164, 164, 0, 163, 163
421 static const short int schema_nxt[212] =
423 4, 5, 6, 4, 7, 8, 9, 10, 4, 7,
424 11, 12, 13, 14, 7, 7, 7, 15, 16, 17,
425 18, 19, 7, 20, 7, 21, 7, 7, 22, 7,
426 7, 7, 28, 31, 33, 39, 40, 32, 29, 42,
427 57, 44, 53, 54, 125, 122, 34, 45, 26, 126,
428 162, 43, 161, 46, 160, 58, 123, 48, 159, 48,
429 158, 157, 156, 155, 154, 153, 152, 151, 150, 149,
430 148, 147, 146, 145, 144, 143, 142, 141, 140, 139,
431 138, 137, 136, 135, 134, 133, 132, 131, 130, 129,
432 128, 127, 124, 121, 120, 119, 118, 117, 116, 115,
434 114, 113, 112, 111, 110, 109, 108, 107, 106, 105,
435 104, 103, 102, 101, 100, 99, 98, 97, 96, 95,
436 94, 93, 92, 91, 90, 89, 88, 87, 86, 85,
437 84, 83, 82, 81, 80, 79, 78, 77, 76, 75,
438 74, 73, 72, 71, 70, 69, 68, 67, 66, 65,
439 64, 63, 62, 61, 60, 59, 56, 55, 52, 51,
440 50, 49, 28, 27, 25, 24, 47, 41, 38, 37,
441 36, 35, 30, 27, 25, 24, 163, 23, 3, 163,
442 163, 163, 163, 163, 163, 163, 163, 163, 163, 163,
443 163, 163, 163, 163, 163, 163, 163, 163, 163, 163,
445 163, 163, 163, 163, 163, 163, 163, 163, 163, 163,
449 static const short int schema_chk[212] =
451 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
452 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
453 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
454 1, 1, 9, 12, 13, 18, 18, 12, 9, 20,
455 37, 21, 34, 34, 111, 108, 13, 21, 164, 111,
456 159, 20, 157, 21, 154, 37, 108, 165, 153, 165,
457 151, 150, 149, 148, 147, 145, 144, 143, 141, 139,
458 138, 136, 135, 133, 132, 131, 129, 128, 127, 125,
459 124, 123, 122, 120, 119, 118, 117, 116, 115, 114,
460 113, 112, 110, 107, 106, 105, 104, 103, 102, 101,
462 99, 98, 97, 96, 95, 94, 93, 92, 91, 90,
463 89, 88, 87, 86, 85, 84, 83, 82, 81, 80,
464 77, 76, 75, 73, 72, 71, 70, 69, 68, 67,
465 66, 65, 63, 62, 61, 60, 59, 58, 57, 56,
466 55, 54, 53, 52, 51, 50, 49, 47, 46, 45,
467 44, 43, 42, 40, 39, 38, 36, 35, 33, 32,
468 31, 30, 29, 27, 25, 24, 22, 19, 17, 16,
469 15, 14, 11, 8, 6, 5, 3, 2, 163, 163,
470 163, 163, 163, 163, 163, 163, 163, 163, 163, 163,
471 163, 163, 163, 163, 163, 163, 163, 163, 163, 163,
473 163, 163, 163, 163, 163, 163, 163, 163, 163, 163,
477 static schema_state_type schema_last_accepting_state;
478 static schema_CHAR * schema_last_accepting_cpos;
480 /* the intent behind this definition is that it'll catch
481 * any uses of REJECT which flex missed
483 #define REJECT reject_used_but_not_detected
484 #define schemamore() schemamore_used_but_not_detected
485 #define schema_MORE_ADJ 0
487 /* these variables are all declared out here so that section 3 code can
490 /* points to current character in buffer */
491 static schema_CHAR * schema_c_buf_p = ( schema_CHAR *) 0;
492 static int schema_init = 1; /* whether we need to initialize */
493 static int schema_start = 0; /* start state number */
495 /* flag which is used to allow schemawrap()'s to do buffer switches
496 * instead of setting up a fresh schemain. A bit of a hack ...
498 static int schema_did_buffer_switch_on_eof;
500 static schema_state_type schema_get_previous_state schema_PROTO(( void ));
501 static schema_state_type schema_try_NUL_trans schema_PROTO(( schema_state_type current_state ));
502 static int schema_get_next_buffer schema_PROTO(( void ));
504 static void schemaunput schema_PROTO(( schema_CHAR c, schema_CHAR *buf_ptr ));
506 void schemarestart schema_PROTO(( FILE *input_file ));
507 void schema_switch_to_buffer schema_PROTO(( schema_BUFFER_STATE new_buffer ));
508 void schema_load_buffer_state schema_PROTO(( void ));
509 schema_BUFFER_STATE schema_create_buffer schema_PROTO(( FILE *file, int size ));
510 void schema_delete_buffer schema_PROTO(( schema_BUFFER_STATE b ));
511 void schema_init_buffer schema_PROTO(( schema_BUFFER_STATE b, FILE *file ));
513 #define schema_new_buffer schema_create_buffer
517 static int schemainput schema_PROTO(( void ));
519 static int input schema_PROTO(( void ));
525 register schema_state_type schema_current_state;
526 register schema_CHAR * schema_cp, * schema_bp;
527 register int schema_act;
536 if ( ! schema_start )
537 schema_start = 1; /* first start state */
545 if ( schema_current_buffer )
546 schema_init_buffer( schema_current_buffer, schemain );
548 schema_current_buffer = schema_create_buffer( schemain, schema_BUF_SIZE );
550 schema_load_buffer_state();
555 while ( 1 ) /* loops until end-of-file is reached */
557 schema_cp = schema_c_buf_p;
559 /* support of schematext */
560 * schema_cp = schema_hold_char;
562 /* schema_bp points to the position in schema_ch_buf of the start of the
565 schema_bp = schema_cp;
567 schema_current_state = schema_start;
568 if ( schema_bp[-1] == '\n' )
569 ++ schema_current_state;
573 register schema_CHAR schema_c = schema_ec[* schema_cp];
574 if ( schema_accept[ schema_current_state] )
576 schema_last_accepting_state = schema_current_state;
577 schema_last_accepting_cpos = schema_cp;
579 while ( schema_chk[ schema_base[ schema_current_state] + schema_c] != schema_current_state )
581 schema_current_state = schema_def[ schema_current_state];
582 if ( schema_current_state >= 164 )
583 schema_c = schema_meta[ schema_c];
585 schema_current_state = schema_nxt[ schema_base[ schema_current_state] + schema_c];
588 while ( schema_current_state != 163 );
589 schema_cp = schema_last_accepting_cpos;
590 schema_current_state = schema_last_accepting_state;
593 schema_act = schema_accept[ schema_current_state];
595 schema_DO_BEFORE_ACTION;
598 do_action: /* this label is used only to access EOF actions */
601 switch ( schema_act )
603 case 0: /* must backtrack */
604 /* undo the effects of schema_DO_BEFORE_ACTION */
605 * schema_cp = schema_hold_char;
606 schema_cp = schema_last_accepting_cpos;
607 schema_current_state = schema_last_accepting_state;
608 goto schema_find_action;
747 return(CACHED_PAGES);
775 schemalval.integer = atoi((char*) schematext);
781 if ( replace_string[0] != 0 && schematext[0] == '$' ) {
782 int len = MIN(strlen((char*) schematext+1),
783 (unsigned int)(PATHSIZ - replace_string_len - 1));
784 *((char *) memcpy(replace_string + replace_string_len,
785 (char*) schematext+1, len) + len) = '\0';
786 schemalval.string = replace_string;
788 schemalval.string = (char*) schematext;
793 schema_FATAL_ERROR( "flex scanner jammed" );
795 case schema_STATE_EOF(INITIAL):
798 case schema_END_OF_BUFFER:
800 /* amount of text matched not including the EOB char */
801 int schema_amount_of_matched_text = schema_cp - schematext - 1;
803 /* undo the effects of schema_DO_BEFORE_ACTION */
804 * schema_cp = schema_hold_char;
806 /* note that here we test for schema_c_buf_p "<=" to the position
807 * of the first EOB in the buffer, since schema_c_buf_p will
808 * already have been incremented past the NUL character
809 * (since all states make transitions on EOB to the end-
810 * of-buffer state). Contrast this with the test in schemainput().
812 if ( schema_c_buf_p <= & schema_current_buffer-> schema_ch_buf[ schema_n_chars] )
813 /* this was really a NUL */
815 schema_state_type schema_next_state;
817 schema_c_buf_p = schematext + schema_amount_of_matched_text;
819 schema_current_state = schema_get_previous_state();
821 /* okay, we're now positioned to make the
822 * NUL transition. We couldn't have
823 * schema_get_previous_state() go ahead and do it
824 * for us because it doesn't know how to deal
825 * with the possibility of jamming (and we
826 * don't want to build jamming into it because
827 * then it will run more slowly)
830 schema_next_state = schema_try_NUL_trans( schema_current_state );
832 schema_bp = schematext + schema_MORE_ADJ;
834 if ( schema_next_state )
836 /* consume the NUL */
837 schema_cp = ++ schema_c_buf_p;
838 schema_current_state = schema_next_state;
844 schema_cp = schema_last_accepting_cpos;
845 schema_current_state = schema_last_accepting_state;
846 goto schema_find_action;
850 else switch ( schema_get_next_buffer() )
852 case EOB_ACT_END_OF_FILE:
854 schema_did_buffer_switch_on_eof = 0;
858 /* note: because we've taken care in
859 * schema_get_next_buffer() to have set up schematext,
860 * we can now set up schema_c_buf_p so that if some
861 * total hoser (like flex itself) wants
862 * to call the scanner after we return the
863 * schema_NULL, it'll still work - another schema_NULL
866 schema_c_buf_p = schematext + schema_MORE_ADJ;
868 schema_act = schema_STATE_EOF(( schema_start - 1) / 2);
874 if ( ! schema_did_buffer_switch_on_eof )
880 case EOB_ACT_CONTINUE_SCAN:
881 schema_c_buf_p = schematext + schema_amount_of_matched_text;
883 schema_current_state = schema_get_previous_state();
885 schema_cp = schema_c_buf_p;
886 schema_bp = schematext + schema_MORE_ADJ;
889 case EOB_ACT_LAST_MATCH:
891 & schema_current_buffer-> schema_ch_buf[ schema_n_chars];
893 schema_current_state = schema_get_previous_state();
895 schema_cp = schema_c_buf_p;
896 schema_bp = schematext + schema_MORE_ADJ;
897 goto schema_find_action;
904 printf( "action # %d\n", schema_act );
907 "fatal flex scanner internal error--no action found" );
913 /* schema_get_next_buffer - try to read in a new buffer
916 * int schema_get_next_buffer();
918 * returns a code representing an action
919 * EOB_ACT_LAST_MATCH -
920 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
921 * EOB_ACT_END_OF_FILE - end of file
924 static int schema_get_next_buffer()
927 register schema_CHAR *dest = schema_current_buffer-> schema_ch_buf;
928 register schema_CHAR *source = schematext - 1; /* copy prev. char, too */
929 register int number_to_move, i;
932 if ( schema_c_buf_p > & schema_current_buffer-> schema_ch_buf[ schema_n_chars + 1] )
934 "fatal flex scanner internal error--end of buffer missed" );
936 /* try to read more data */
938 /* first move last chars to start of buffer */
939 number_to_move = schema_c_buf_p - schematext;
941 for ( i = 0; i < number_to_move; ++i )
942 *(dest++) = *(source++);
944 if ( schema_current_buffer-> schema_eof_status != EOF_NOT_SEEN )
945 /* don't do the read, it's not guaranteed to return an EOF,
952 int num_to_read = schema_current_buffer-> schema_buf_size - number_to_move - 1;
954 if ( num_to_read > schema_READ_BUF_SIZE )
955 num_to_read = schema_READ_BUF_SIZE;
957 else if ( num_to_read <= 0 )
958 schema_FATAL_ERROR( "fatal error - scanner input buffer overflow" );
960 /* read in more data */
961 schema_INPUT( (& schema_current_buffer-> schema_ch_buf[number_to_move]),
962 schema_n_chars, num_to_read );
965 if ( schema_n_chars == 0 )
967 if ( number_to_move == 1 )
969 ret_val = EOB_ACT_END_OF_FILE;
970 schema_current_buffer-> schema_eof_status = EOF_DONE;
975 ret_val = EOB_ACT_LAST_MATCH;
976 schema_current_buffer-> schema_eof_status = EOF_PENDING;
981 ret_val = EOB_ACT_CONTINUE_SCAN;
983 schema_n_chars += number_to_move;
984 schema_current_buffer-> schema_ch_buf[ schema_n_chars] = schema_END_OF_BUFFER_CHAR;
985 schema_current_buffer-> schema_ch_buf[ schema_n_chars + 1] = schema_END_OF_BUFFER_CHAR;
987 /* schematext begins at the second character in schema_ch_buf; the first
988 * character is the one which preceded it before reading in the latest
989 * buffer; it needs to be kept around in case it's a newline, so
990 * schema_get_previous_state() will have with '^' rules active
993 schematext = & schema_current_buffer-> schema_ch_buf[1];
999 /* schema_get_previous_state - get the state just before the EOB char was reached
1002 * schema_state_type schema_get_previous_state();
1005 static schema_state_type schema_get_previous_state()
1008 register schema_state_type schema_current_state;
1009 register schema_CHAR * schema_cp;
1011 register schema_CHAR * schema_bp = schematext;
1013 schema_current_state = schema_start;
1014 if ( schema_bp[-1] == '\n' )
1015 ++ schema_current_state;
1017 for ( schema_cp = schematext + schema_MORE_ADJ; schema_cp < schema_c_buf_p; ++ schema_cp )
1019 register schema_CHAR schema_c = (* schema_cp ? schema_ec[* schema_cp] : 1);
1020 if ( schema_accept[ schema_current_state] )
1022 schema_last_accepting_state = schema_current_state;
1023 schema_last_accepting_cpos = schema_cp;
1025 while ( schema_chk[ schema_base[ schema_current_state] + schema_c] != schema_current_state )
1027 schema_current_state = schema_def[ schema_current_state];
1028 if ( schema_current_state >= 164 )
1029 schema_c = schema_meta[ schema_c];
1031 schema_current_state = schema_nxt[ schema_base[ schema_current_state] + schema_c];
1034 return ( schema_current_state );
1038 /* schema_try_NUL_trans - try to make a transition on the NUL character
1041 * next_state = schema_try_NUL_trans( current_state );
1044 #ifdef schema_USE_PROTOS
1045 static schema_state_type schema_try_NUL_trans( register schema_state_type schema_current_state )
1047 static schema_state_type schema_try_NUL_trans( schema_current_state )
1048 register schema_state_type schema_current_state;
1052 register int schema_is_jam;
1053 register schema_CHAR * schema_cp = schema_c_buf_p;
1055 register schema_CHAR schema_c = 1;
1056 if ( schema_accept[ schema_current_state] )
1058 schema_last_accepting_state = schema_current_state;
1059 schema_last_accepting_cpos = schema_cp;
1061 while ( schema_chk[ schema_base[ schema_current_state] + schema_c] != schema_current_state )
1063 schema_current_state = schema_def[ schema_current_state];
1064 if ( schema_current_state >= 164 )
1065 schema_c = schema_meta[ schema_c];
1067 schema_current_state = schema_nxt[ schema_base[ schema_current_state] + schema_c];
1068 schema_is_jam = ( schema_current_state == 163);
1070 return ( schema_is_jam ? 0 : schema_current_state );
1075 #ifdef schema_USE_PROTOS
1076 static void schemaunput( schema_CHAR c, register schema_CHAR * schema_bp )
1078 static void schemaunput( c, schema_bp )
1080 register schema_CHAR * schema_bp;
1084 register schema_CHAR * schema_cp = schema_c_buf_p;
1086 /* undo effects of setting up schematext */
1087 * schema_cp = schema_hold_char;
1089 if ( schema_cp < schema_current_buffer-> schema_ch_buf + 2 )
1090 { /* need to shift things up to make room */
1091 register int number_to_move = schema_n_chars + 2; /* +2 for EOB chars */
1092 register schema_CHAR *dest =
1093 & schema_current_buffer-> schema_ch_buf[ schema_current_buffer-> schema_buf_size + 2];
1094 register schema_CHAR *source =
1095 & schema_current_buffer-> schema_ch_buf[number_to_move];
1097 while ( source > schema_current_buffer-> schema_ch_buf )
1098 *--dest = *--source;
1100 schema_cp += dest - source;
1101 schema_bp += dest - source;
1102 schema_n_chars = schema_current_buffer-> schema_buf_size;
1104 if ( schema_cp < schema_current_buffer-> schema_ch_buf + 2 )
1105 schema_FATAL_ERROR( "flex scanner push-back overflow" );
1108 if ( schema_cp > schema_bp && schema_cp[-1] == '\n' )
1109 schema_cp[-2] = '\n';
1113 /* note: the formal parameter *must* be called " schema_bp" for this
1114 * macro to now work correctly
1116 schema_DO_BEFORE_ACTION; /* set up schematext again */
1123 static int schemainput()
1130 schema_CHAR * schema_cp = schema_c_buf_p;
1132 * schema_cp = schema_hold_char;
1134 if ( * schema_c_buf_p == schema_END_OF_BUFFER_CHAR )
1136 /* schema_c_buf_p now points to the character we want to return.
1137 * If this occurs *before* the EOB characters, then it's a
1138 * valid NUL; if not, then we've hit the end of the buffer.
1140 if ( schema_c_buf_p < & schema_current_buffer-> schema_ch_buf[ schema_n_chars] )
1141 /* this was really a NUL */
1142 * schema_c_buf_p = '\0';
1145 { /* need more input */
1146 schematext = schema_c_buf_p;
1149 switch ( schema_get_next_buffer() )
1151 case EOB_ACT_END_OF_FILE:
1155 schema_c_buf_p = schematext + schema_MORE_ADJ;
1162 return ( schemainput() );
1169 case EOB_ACT_CONTINUE_SCAN:
1170 schema_c_buf_p = schematext + schema_MORE_ADJ;
1173 case EOB_ACT_LAST_MATCH:
1175 schema_FATAL_ERROR( "unexpected last match in schemainput()" );
1177 schema_FATAL_ERROR( "unexpected last match in input()" );
1183 c = * schema_c_buf_p;
1184 schema_hold_char = *++ schema_c_buf_p;
1191 #ifdef schema_USE_PROTOS
1192 void schemarestart( FILE *input_file )
1194 void schemarestart( input_file )
1199 schema_init_buffer( schema_current_buffer, input_file );
1200 schema_load_buffer_state();
1204 #ifdef schema_USE_PROTOS
1205 void schema_switch_to_buffer( schema_BUFFER_STATE new_buffer )
1207 void schema_switch_to_buffer( new_buffer )
1208 schema_BUFFER_STATE new_buffer;
1212 if ( schema_current_buffer == new_buffer )
1215 if ( schema_current_buffer )
1217 /* flush out information for old buffer */
1218 * schema_c_buf_p = schema_hold_char;
1219 schema_current_buffer-> schema_buf_pos = schema_c_buf_p;
1220 schema_current_buffer-> schema_n_chars = schema_n_chars;
1223 schema_current_buffer = new_buffer;
1224 schema_load_buffer_state();
1226 /* we don't actually know whether we did this switch during
1227 * EOF ( schemawrap()) processing, but the only time this flag
1228 * is looked at is after schemawrap() is called, so it's safe
1229 * to go ahead and always set it.
1231 schema_did_buffer_switch_on_eof = 1;
1235 #ifdef schema_USE_PROTOS
1236 void schema_load_buffer_state( void )
1238 void schema_load_buffer_state()
1242 schema_n_chars = schema_current_buffer-> schema_n_chars;
1243 schematext = schema_c_buf_p = schema_current_buffer-> schema_buf_pos;
1244 schemain = schema_current_buffer-> schema_input_file;
1245 schema_hold_char = * schema_c_buf_p;
1249 #ifdef schema_USE_PROTOS
1250 schema_BUFFER_STATE schema_create_buffer( FILE *file, int size )
1252 schema_BUFFER_STATE schema_create_buffer( file, size )
1258 schema_BUFFER_STATE b;
1260 b = ( schema_BUFFER_STATE) malloc( sizeof( struct schema_buffer_state ) );
1263 schema_FATAL_ERROR( "out of dynamic memory in schema_create_buffer()" );
1265 b-> schema_buf_size = size;
1267 /* schema_ch_buf has to be 2 characters longer than the size given because
1268 * we need to put in 2 end-of-buffer characters.
1270 b-> schema_ch_buf = ( schema_CHAR *) malloc( (unsigned) (b-> schema_buf_size + 2) );
1272 if ( ! b-> schema_ch_buf )
1273 schema_FATAL_ERROR( "out of dynamic memory in schema_create_buffer()" );
1275 schema_init_buffer( b, file );
1281 #ifdef schema_USE_PROTOS
1282 void schema_delete_buffer( schema_BUFFER_STATE b )
1284 void schema_delete_buffer( b )
1285 schema_BUFFER_STATE b;
1289 if ( b == schema_current_buffer )
1290 schema_current_buffer = ( schema_BUFFER_STATE) 0;
1292 free( (char *) b-> schema_ch_buf );
1297 #ifdef schema_USE_PROTOS
1298 void schema_init_buffer( schema_BUFFER_STATE b, FILE *file )
1300 void schema_init_buffer( b, file )
1301 schema_BUFFER_STATE b;
1306 b-> schema_input_file = file;
1308 /* we put in the '\n' and start reading from [1] so that an
1309 * initial match-at-newline will be true.
1312 b-> schema_ch_buf[0] = '\n';
1313 b-> schema_n_chars = 1;
1315 /* we always need two end-of-buffer characters. The first causes
1316 * a transition to the end-of-buffer state. The second causes
1317 * a jam in that state.
1319 b-> schema_ch_buf[1] = schema_END_OF_BUFFER_CHAR;
1320 b-> schema_ch_buf[2] = schema_END_OF_BUFFER_CHAR;
1322 b-> schema_buf_pos = &b-> schema_ch_buf[1];
1324 b-> schema_eof_status = EOF_NOT_SEEN;