/[ascend]/trunk/tcltk/generic/interface/typelex_no_lex.c
ViewVC logotype

Contents of /trunk/tcltk/generic/interface/typelex_no_lex.c

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1522 - (show annotations) (download) (as text)
Sat Jun 30 14:08:56 2007 UTC (17 years, 5 months ago) by jpye
File MIME type: text/x-csrc
File size: 82280 byte(s)
Updated changelog. Minor changes to RPM build, updated no_lex file.
1
2 #line 3 "<stdout>"
3
4 #define YY_INT_ALIGNED short int
5
6 /* A lexical scanner generated by flex */
7
8 #define FLEX_SCANNER
9 #define YY_FLEX_MAJOR_VERSION 2
10 #define YY_FLEX_MINOR_VERSION 5
11 #define YY_FLEX_SUBMINOR_VERSION 33
12 #if YY_FLEX_SUBMINOR_VERSION > 0
13 #define FLEX_BETA
14 #endif
15
16 /* First, we deal with platform-specific or compiler-specific issues. */
17
18 /* begin standard C headers. */
19 #include <stdio.h>
20 #include <string.h>
21 #include <errno.h>
22 #include <stdlib.h>
23
24 /* end standard C headers. */
25
26 /* flex integer type definitions */
27
28 #ifndef FLEXINT_H
29 #define FLEXINT_H
30
31 /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
32
33 #if __STDC_VERSION__ >= 199901L
34
35 /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
36 * if you want the limit (max/min) macros for int types.
37 */
38 #ifndef __STDC_LIMIT_MACROS
39 #define __STDC_LIMIT_MACROS 1
40 #endif
41
42 #include <inttypes.h>
43 typedef int8_t flex_int8_t;
44 typedef uint8_t flex_uint8_t;
45 typedef int16_t flex_int16_t;
46 typedef uint16_t flex_uint16_t;
47 typedef int32_t flex_int32_t;
48 typedef uint32_t flex_uint32_t;
49 #else
50 typedef signed char flex_int8_t;
51 typedef short int flex_int16_t;
52 typedef int flex_int32_t;
53 typedef unsigned char flex_uint8_t;
54 typedef unsigned short int flex_uint16_t;
55 typedef unsigned int flex_uint32_t;
56 #endif /* ! C99 */
57
58 /* Limits of integral types. */
59 #ifndef INT8_MIN
60 #define INT8_MIN (-128)
61 #endif
62 #ifndef INT16_MIN
63 #define INT16_MIN (-32767-1)
64 #endif
65 #ifndef INT32_MIN
66 #define INT32_MIN (-2147483647-1)
67 #endif
68 #ifndef INT8_MAX
69 #define INT8_MAX (127)
70 #endif
71 #ifndef INT16_MAX
72 #define INT16_MAX (32767)
73 #endif
74 #ifndef INT32_MAX
75 #define INT32_MAX (2147483647)
76 #endif
77 #ifndef UINT8_MAX
78 #define UINT8_MAX (255U)
79 #endif
80 #ifndef UINT16_MAX
81 #define UINT16_MAX (65535U)
82 #endif
83 #ifndef UINT32_MAX
84 #define UINT32_MAX (4294967295U)
85 #endif
86
87 #endif /* ! FLEXINT_H */
88
89 #ifdef __cplusplus
90
91 /* The "const" storage-class-modifier is valid. */
92 #define YY_USE_CONST
93
94 #else /* ! __cplusplus */
95
96 #if __STDC__
97
98 #define YY_USE_CONST
99
100 #endif /* __STDC__ */
101 #endif /* ! __cplusplus */
102
103 #ifdef YY_USE_CONST
104 #define yyconst const
105 #else
106 #define yyconst
107 #endif
108
109 /* Returned upon end-of-file. */
110 #define YY_NULL 0
111
112 /* Promotes a possibly negative, possibly signed char to an unsigned
113 * integer for use as an array index. If the signed char is negative,
114 * we want to instead treat it as an 8-bit unsigned char, hence the
115 * double cast.
116 */
117 #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
118
119 /* Enter a start condition. This macro really ought to take a parameter,
120 * but we do it the disgusting crufty way forced on us by the ()-less
121 * definition of BEGIN.
122 */
123 #define BEGIN (yy_start) = 1 + 2 *
124
125 /* Translate the current start state into a value that can be later handed
126 * to BEGIN to return to the state. The YYSTATE alias is for lex
127 * compatibility.
128 */
129 #define YY_START (((yy_start) - 1) / 2)
130 #define YYSTATE YY_START
131
132 /* Action number for EOF rule of a given start state. */
133 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
134
135 /* Special action meaning "start processing a new file". */
136 #define YY_NEW_FILE typ_restart(typ_in )
137
138 #define YY_END_OF_BUFFER_CHAR 0
139
140 /* Size of default input buffer. */
141 #ifndef YY_BUF_SIZE
142 #define YY_BUF_SIZE 16384
143 #endif
144
145 /* The state buf must be large enough to hold one state per character in the main buffer.
146 */
147 #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
148
149 #ifndef YY_TYPEDEF_YY_BUFFER_STATE
150 #define YY_TYPEDEF_YY_BUFFER_STATE
151 typedef struct yy_buffer_state *YY_BUFFER_STATE;
152 #endif
153
154 extern int typ_leng;
155
156 extern FILE *typ_in, *typ_out;
157
158 #define EOB_ACT_CONTINUE_SCAN 0
159 #define EOB_ACT_END_OF_FILE 1
160 #define EOB_ACT_LAST_MATCH 2
161
162 /* Note: We specifically omit the test for yy_rule_can_match_eol because it requires
163 * access to the local variable yy_act. Since yyless() is a macro, it would break
164 * existing scanners that call yyless() from OUTSIDE typ_lex.
165 * One obvious solution it to make yy_act a global. I tried that, and saw
166 * a 5% performance hit in a non-typ_lineno scanner, because yy_act is
167 * normally declared as a register variable-- so it is not worth it.
168 */
169 #define YY_LESS_LINENO(n) \
170 do { \
171 int yyl;\
172 for ( yyl = n; yyl < typ_leng; ++yyl )\
173 if ( typ_text[yyl] == '\n' )\
174 --typ_lineno;\
175 }while(0)
176
177 /* Return all but the first "n" matched characters back to the input stream. */
178 #define yyless(n) \
179 do \
180 { \
181 /* Undo effects of setting up typ_text. */ \
182 int yyless_macro_arg = (n); \
183 YY_LESS_LINENO(yyless_macro_arg);\
184 *yy_cp = (yy_hold_char); \
185 YY_RESTORE_YY_MORE_OFFSET \
186 (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
187 YY_DO_BEFORE_ACTION; /* set up typ_text again */ \
188 } \
189 while ( 0 )
190
191 #define unput(c) yyunput( c, (yytext_ptr) )
192
193 /* The following is because we cannot portably get our hands on size_t
194 * (without autoconf's help, which isn't available because we want
195 * flex-generated scanners to compile on their own).
196 */
197
198 #ifndef YY_TYPEDEF_YY_SIZE_T
199 #define YY_TYPEDEF_YY_SIZE_T
200 typedef unsigned int yy_size_t;
201 #endif
202
203 #ifndef YY_STRUCT_YY_BUFFER_STATE
204 #define YY_STRUCT_YY_BUFFER_STATE
205 struct yy_buffer_state
206 {
207 FILE *yy_input_file;
208
209 char *yy_ch_buf; /* input buffer */
210 char *yy_buf_pos; /* current position in input buffer */
211
212 /* Size of input buffer in bytes, not including room for EOB
213 * characters.
214 */
215 yy_size_t yy_buf_size;
216
217 /* Number of characters read into yy_ch_buf, not including EOB
218 * characters.
219 */
220 int yy_n_chars;
221
222 /* Whether we "own" the buffer - i.e., we know we created it,
223 * and can realloc() it to grow it, and should free() it to
224 * delete it.
225 */
226 int yy_is_our_buffer;
227
228 /* Whether this is an "interactive" input source; if so, and
229 * if we're using stdio for input, then we want to use getc()
230 * instead of fread(), to make sure we stop fetching input after
231 * each newline.
232 */
233 int yy_is_interactive;
234
235 /* Whether we're considered to be at the beginning of a line.
236 * If so, '^' rules will be active on the next match, otherwise
237 * not.
238 */
239 int yy_at_bol;
240
241 int yy_bs_lineno; /**< The line count. */
242 int yy_bs_column; /**< The column count. */
243
244 /* Whether to try to fill the input buffer when we reach the
245 * end of it.
246 */
247 int yy_fill_buffer;
248
249 int yy_buffer_status;
250
251 #define YY_BUFFER_NEW 0
252 #define YY_BUFFER_NORMAL 1
253 /* When an EOF's been seen but there's still some text to process
254 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
255 * shouldn't try reading from the input source any more. We might
256 * still have a bunch of tokens to match, though, because of
257 * possible backing-up.
258 *
259 * When we actually see the EOF, we change the status to "new"
260 * (via typ_restart()), so that the user can continue scanning by
261 * just pointing typ_in at a new input file.
262 */
263 #define YY_BUFFER_EOF_PENDING 2
264
265 };
266 #endif /* !YY_STRUCT_YY_BUFFER_STATE */
267
268 /* Stack of input buffers. */
269 static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
270 static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
271 static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
272
273 /* We provide macros for accessing buffer states in case in the
274 * future we want to put the buffer states in a more general
275 * "scanner state".
276 *
277 * Returns the top of the stack, or NULL.
278 */
279 #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
280 ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
281 : NULL)
282
283 /* Same as previous macro, but useful when we know that the buffer stack is not
284 * NULL or when we need an lvalue. For internal use only.
285 */
286 #define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
287
288 /* yy_hold_char holds the character lost when typ_text is formed. */
289 static char yy_hold_char;
290 static int yy_n_chars; /* number of characters read into yy_ch_buf */
291 int typ_leng;
292
293 /* Points to current character in buffer. */
294 static char *yy_c_buf_p = (char *) 0;
295 static int yy_init = 0; /* whether we need to initialize */
296 static int yy_start = 0; /* start state number */
297
298 /* Flag which is used to allow typ_wrap()'s to do buffer switches
299 * instead of setting up a fresh typ_in. A bit of a hack ...
300 */
301 static int yy_did_buffer_switch_on_eof;
302
303 void typ_restart (FILE *input_file );
304 void typ__switch_to_buffer (YY_BUFFER_STATE new_buffer );
305 YY_BUFFER_STATE typ__create_buffer (FILE *file,int size );
306 void typ__delete_buffer (YY_BUFFER_STATE b );
307 void typ__flush_buffer (YY_BUFFER_STATE b );
308 void typ_push_buffer_state (YY_BUFFER_STATE new_buffer );
309 void typ_pop_buffer_state (void );
310
311 static void typ_ensure_buffer_stack (void );
312 static void typ__load_buffer_state (void );
313 static void typ__init_buffer (YY_BUFFER_STATE b,FILE *file );
314
315 #define YY_FLUSH_BUFFER typ__flush_buffer(YY_CURRENT_BUFFER )
316
317 YY_BUFFER_STATE typ__scan_buffer (char *base,yy_size_t size );
318 YY_BUFFER_STATE typ__scan_string (yyconst char *yy_str );
319 YY_BUFFER_STATE typ__scan_bytes (yyconst char *bytes,int len );
320
321 void *typ_alloc (yy_size_t );
322 void *typ_realloc (void *,yy_size_t );
323 void typ_free (void * );
324
325 #define yy_new_buffer typ__create_buffer
326
327 #define yy_set_interactive(is_interactive) \
328 { \
329 if ( ! YY_CURRENT_BUFFER ){ \
330 typ_ensure_buffer_stack (); \
331 YY_CURRENT_BUFFER_LVALUE = \
332 typ__create_buffer(typ_in,YY_BUF_SIZE ); \
333 } \
334 YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
335 }
336
337 #define yy_set_bol(at_bol) \
338 { \
339 if ( ! YY_CURRENT_BUFFER ){\
340 typ_ensure_buffer_stack (); \
341 YY_CURRENT_BUFFER_LVALUE = \
342 typ__create_buffer(typ_in,YY_BUF_SIZE ); \
343 } \
344 YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
345 }
346
347 #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
348
349 /* Begin user sect3 */
350
351 typedef unsigned char YY_CHAR;
352
353 FILE *typ_in = (FILE *) 0, *typ_out = (FILE *) 0;
354
355 typedef int yy_state_type;
356
357 #define YY_FLEX_LEX_COMPAT
358 extern int typ_lineno;
359
360 int typ_lineno = 1;
361
362 extern char typ_text[];
363
364 static yy_state_type yy_get_previous_state (void );
365 static yy_state_type yy_try_NUL_trans (yy_state_type current_state );
366 static int yy_get_next_buffer (void );
367 static void yy_fatal_error (yyconst char msg[] );
368
369 /* Done after the current pattern has been matched and before the
370 * corresponding action - sets up typ_text.
371 */
372 #define YY_DO_BEFORE_ACTION \
373 (yytext_ptr) = yy_bp; \
374 typ_leng = (size_t) (yy_cp - yy_bp); \
375 (yy_hold_char) = *yy_cp; \
376 *yy_cp = '\0'; \
377 if ( typ_leng + (yy_more_offset) >= YYLMAX ) \
378 YY_FATAL_ERROR( "token too large, exceeds YYLMAX" ); \
379 yy_flex_strncpy( &typ_text[(yy_more_offset)], (yytext_ptr), typ_leng + 1 ); \
380 typ_leng += (yy_more_offset); \
381 (yy_prev_more_offset) = (yy_more_offset); \
382 (yy_more_offset) = 0; \
383 (yy_c_buf_p) = yy_cp;
384
385 #define YY_NUM_RULES 34
386 #define YY_END_OF_BUFFER 35
387 /* This struct is not used in this scanner,
388 but its presence is necessary. */
389 struct yy_trans_info
390 {
391 flex_int32_t yy_verify;
392 flex_int32_t yy_nxt;
393 };
394 static yyconst flex_int16_t yy_acclist[156] =
395 { 0,
396 6, 6, 16, 16, 35, 31, 34, 32, 34, 33,
397 34, 33, 34, 33, 34, 33, 34, 33, 34, 33,
398 34, 31, 33, 34, 9, 34, 6, 34, 7, 34,
399 8, 34, 16, 34, 34, 14, 34, 15, 34, 20,
400 34, 21, 34, 22, 34, 22, 34, 20, 22, 34,
401 10, 34, 24, 34, 25, 34, 23, 34, 11, 34,
402 18, 34, 34, 17, 18, 34, 31, 32, 32, 1,
403 33, 33, 33, 33, 33, 33, 33, 33, 31, 33,
404 31, 33, 31, 33, 6, 7, 7, 4, 8, 5,
405 8, 16, 15, 12, 13, 14, 20, 21, 21, 2,
406
407 22, 22, 22, 22, 20, 22, 20, 22, 20, 22,
408 24, 25, 25, 3, 17, 33, 33, 33, 33, 33,
409 4, 22, 33, 33, 33, 33, 33, 19, 22, 28,
410 33, 33, 33, 33, 33, 33, 33, 27, 33, 33,
411 33, 33, 33, 33, 33, 33, 30, 33, 33, 33,
412 33, 26, 33, 29, 33
413 } ;
414
415 static yyconst flex_int16_t yy_accept[125] =
416 { 0,
417 1, 1, 1, 2, 3, 4, 5, 5, 5, 5,
418 5, 5, 5, 6, 8, 10, 12, 14, 16, 18,
419 20, 22, 25, 27, 29, 31, 33, 35, 36, 38,
420 40, 42, 44, 46, 48, 51, 53, 55, 57, 59,
421 61, 63, 64, 67, 68, 69, 70, 71, 72, 73,
422 74, 75, 76, 77, 78, 79, 81, 83, 85, 86,
423 86, 87, 88, 89, 90, 91, 92, 93, 93, 94,
424 95, 96, 97, 98, 99, 100, 101, 102, 103, 104,
425 105, 107, 109, 111, 112, 113, 114, 115, 116, 117,
426 118, 119, 120, 121, 122, 123, 124, 125, 126, 127,
427
428 128, 130, 132, 133, 134, 135, 136, 137, 138, 140,
429 141, 142, 143, 144, 145, 146, 147, 149, 150, 151,
430 152, 154, 156, 156
431 } ;
432
433 static yyconst flex_int32_t yy_ec[256] =
434 { 0,
435 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
436 2, 2, 2, 1, 1, 1, 1, 1, 1, 1,
437 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
438 1, 2, 1, 1, 1, 1, 1, 1, 1, 4,
439 5, 6, 1, 1, 1, 1, 1, 7, 7, 7,
440 7, 7, 7, 7, 7, 7, 7, 1, 8, 1,
441 1, 1, 1, 1, 9, 10, 11, 12, 13, 14,
442 10, 10, 15, 10, 10, 16, 17, 18, 19, 10,
443 10, 20, 21, 22, 23, 24, 10, 10, 10, 10,
444 1, 25, 1, 1, 26, 1, 27, 27, 27, 27,
445
446 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
447 27, 27, 27, 27, 27, 27, 27, 27, 27, 27,
448 27, 27, 28, 1, 29, 1, 1, 1, 1, 1,
449 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
450 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
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, 1, 1, 1, 1, 1, 1, 1, 1,
455 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
456
457 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
458 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
459 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
460 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
461 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
462 1, 1, 1, 1, 1
463 } ;
464
465 static yyconst flex_int32_t yy_meta[30] =
466 { 0,
467 1, 2, 1, 3, 1, 4, 5, 6, 7, 7,
468 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
469 7, 7, 7, 7, 8, 9, 5, 10, 8
470 } ;
471
472 static yyconst flex_int16_t yy_base[143] =
473 { 0,
474 0, 0, 26, 27, 9, 11, 40, 0, 66, 67,
475 95, 0, 343, 0, 72, 71, 75, 123, 78, 124,
476 126, 144, 467, 333, 78, 82, 56, 327, 0, 467,
477 0, 86, 125, 146, 173, 467, 0, 131, 467, 467,
478 467, 467, 0, 0, 132, 322, 467, 289, 287, 151,
479 153, 175, 154, 155, 180, 286, 285, 0, 280, 124,
480 135, 154, 0, 160, 467, 179, 161, 277, 467, 467,
481 467, 0, 0, 183, 264, 467, 261, 256, 189, 199,
482 254, 229, 0, 0, 188, 199, 467, 0, 202, 204,
483 206, 207, 214, 0, 215, 216, 224, 225, 226, 227,
484
485 211, 194, 228, 237, 239, 242, 246, 247, 138, 249,
486 251, 259, 263, 258, 273, 274, 87, 275, 276, 277,
487 70, 33, 467, 293, 303, 313, 323, 332, 340, 349,
488 359, 369, 379, 388, 398, 407, 416, 424, 433, 442,
489 447, 456
490 } ;
491
492 static yyconst flex_int16_t yy_def[143] =
493 { 0,
494 123, 1, 124, 124, 125, 125, 123, 7, 126, 126,
495 123, 11, 123, 127, 128, 129, 129, 129, 129, 129,
496 129, 129, 123, 130, 131, 132, 133, 134, 135, 123,
497 136, 137, 138, 138, 138, 123, 139, 140, 123, 123,
498 123, 123, 141, 127, 128, 45, 123, 123, 123, 129,
499 129, 129, 129, 129, 129, 127, 127, 22, 130, 123,
500 131, 131, 142, 132, 123, 132, 133, 134, 123, 123,
501 123, 135, 136, 137, 74, 123, 123, 123, 138, 138,
502 136, 136, 35, 139, 140, 140, 123, 141, 129, 129,
503 129, 129, 129, 142, 138, 129, 129, 129, 129, 129,
504
505 123, 123, 129, 129, 129, 129, 129, 129, 123, 129,
506 129, 129, 129, 129, 129, 129, 123, 129, 129, 129,
507 123, 123, 0, 123, 123, 123, 123, 123, 123, 123,
508 123, 123, 123, 123, 123, 123, 123, 123, 123, 123,
509 123, 123
510 } ;
511
512 static yyconst flex_int16_t yy_nxt[497] =
513 { 0,
514 14, 14, 14, 15, 14, 14, 14, 14, 16, 17,
515 18, 19, 17, 17, 17, 17, 20, 17, 17, 17,
516 17, 17, 21, 17, 14, 22, 14, 23, 14, 25,
517 25, 26, 26, 28, 122, 28, 29, 30, 29, 30,
518 31, 31, 31, 32, 31, 31, 31, 31, 33, 33,
519 33, 33, 34, 33, 33, 33, 33, 33, 33, 33,
520 33, 33, 33, 33, 31, 35, 31, 36, 31, 38,
521 38, 121, 48, 39, 39, 46, 48, 47, 49, 48,
522 68, 62, 49, 63, 69, 49, 65, 66, 117, 75,
523 53, 76, 51, 40, 40, 41, 41, 42, 41, 41,
524
525 41, 41, 41, 43, 43, 43, 43, 43, 43, 43,
526 43, 43, 43, 43, 43, 43, 43, 43, 43, 41,
527 41, 43, 41, 41, 48, 48, 77, 48, 65, 60,
528 49, 49, 78, 49, 86, 123, 87, 123, 123, 109,
529 123, 52, 54, 55, 44, 56, 44, 77, 44, 44,
530 44, 57, 48, 78, 48, 48, 48, 62, 49, 123,
531 49, 49, 49, 80, 123, 123, 92, 91, 44, 58,
532 44, 89, 44, 73, 81, 73, 48, 73, 73, 73,
533 82, 48, 49, 65, 66, 68, 123, 49, 123, 69,
534 77, 123, 90, 123, 93, 102, 78, 73, 83, 73,
535
536 77, 73, 86, 48, 123, 48, 78, 48, 48, 49,
537 95, 49, 101, 49, 49, 48, 101, 102, 96, 99,
538 98, 49, 78, 49, 97, 48, 48, 48, 48, 48,
539 81, 49, 49, 49, 49, 49, 107, 100, 48, 106,
540 109, 105, 104, 48, 49, 103, 49, 48, 48, 49,
541 48, 108, 48, 49, 49, 81, 49, 77, 49, 117,
542 48, 110, 77, 111, 48, 49, 49, 75, 112, 113,
543 49, 116, 114, 115, 48, 48, 48, 121, 122, 71,
544 49, 49, 49, 49, 49, 60, 56, 56, 48, 119,
545 48, 118, 120, 24, 24, 24, 24, 24, 24, 24,
546
547 24, 24, 24, 27, 27, 27, 27, 27, 27, 27,
548 27, 27, 27, 37, 37, 37, 37, 37, 37, 37,
549 37, 37, 37, 44, 44, 46, 44, 44, 44, 71,
550 44, 44, 45, 45, 45, 45, 45, 45, 60, 45,
551 45, 50, 123, 123, 123, 50, 50, 123, 50, 59,
552 59, 123, 59, 59, 59, 59, 59, 59, 59, 61,
553 61, 61, 61, 61, 61, 61, 61, 61, 61, 64,
554 64, 123, 64, 64, 64, 64, 64, 64, 64, 67,
555 67, 67, 67, 67, 67, 67, 67, 67, 70, 70,
556 70, 70, 70, 70, 70, 70, 70, 70, 72, 72,
557
558 72, 72, 72, 72, 72, 123, 72, 73, 73, 123,
559 73, 73, 73, 123, 73, 73, 74, 74, 74, 74,
560 74, 74, 123, 74, 74, 79, 123, 123, 123, 79,
561 79, 123, 79, 84, 84, 123, 84, 84, 123, 84,
562 84, 84, 85, 85, 85, 85, 85, 123, 85, 85,
563 85, 88, 123, 88, 123, 88, 94, 94, 123, 123,
564 94, 94, 94, 94, 94, 94, 13, 123, 123, 123,
565 123, 123, 123, 123, 123, 123, 123, 123, 123, 123,
566 123, 123, 123, 123, 123, 123, 123, 123, 123, 123,
567 123, 123, 123, 123, 123, 123
568
569 } ;
570
571 static yyconst flex_int16_t yy_chk[497] =
572 { 0,
573 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
574 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
575 1, 1, 1, 1, 1, 1, 1, 1, 1, 3,
576 4, 3, 4, 5, 122, 6, 5, 5, 6, 6,
577 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
578 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
579 7, 7, 7, 7, 7, 7, 7, 7, 7, 9,
580 10, 121, 16, 9, 10, 15, 17, 15, 16, 19,
581 27, 25, 17, 25, 27, 19, 26, 26, 117, 32,
582 19, 32, 16, 9, 10, 11, 11, 11, 11, 11,
583
584 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
585 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
586 11, 11, 11, 11, 18, 20, 33, 21, 60, 60,
587 18, 20, 33, 21, 38, 45, 38, 45, 61, 109,
588 61, 18, 20, 21, 22, 22, 22, 34, 22, 22,
589 22, 22, 50, 34, 51, 53, 54, 62, 50, 62,
590 51, 53, 54, 34, 64, 64, 54, 53, 22, 22,
591 22, 51, 22, 35, 35, 35, 52, 35, 35, 35,
592 35, 55, 52, 66, 66, 67, 74, 55, 74, 67,
593 79, 85, 52, 85, 55, 102, 79, 35, 35, 35,
594
595 80, 35, 86, 89, 86, 90, 80, 91, 92, 89,
596 80, 90, 101, 91, 92, 93, 95, 96, 89, 92,
597 91, 93, 95, 96, 90, 97, 98, 99, 100, 103,
598 82, 97, 98, 99, 100, 103, 103, 93, 104, 100,
599 105, 99, 98, 106, 104, 97, 105, 107, 108, 106,
600 110, 104, 111, 107, 108, 81, 110, 78, 111, 114,
601 112, 106, 77, 107, 113, 114, 112, 75, 108, 110,
602 113, 113, 111, 112, 115, 116, 118, 119, 120, 68,
603 115, 116, 118, 119, 120, 59, 57, 56, 49, 116,
604 48, 115, 118, 124, 124, 124, 124, 124, 124, 124,
605
606 124, 124, 124, 125, 125, 125, 125, 125, 125, 125,
607 125, 125, 125, 126, 126, 126, 126, 126, 126, 126,
608 126, 126, 126, 127, 127, 46, 127, 127, 127, 28,
609 127, 127, 128, 128, 128, 128, 128, 128, 24, 128,
610 128, 129, 13, 0, 0, 129, 129, 0, 129, 130,
611 130, 0, 130, 130, 130, 130, 130, 130, 130, 131,
612 131, 131, 131, 131, 131, 131, 131, 131, 131, 132,
613 132, 0, 132, 132, 132, 132, 132, 132, 132, 133,
614 133, 133, 133, 133, 133, 133, 133, 133, 134, 134,
615 134, 134, 134, 134, 134, 134, 134, 134, 135, 135,
616
617 135, 135, 135, 135, 135, 0, 135, 136, 136, 0,
618 136, 136, 136, 0, 136, 136, 137, 137, 137, 137,
619 137, 137, 0, 137, 137, 138, 0, 0, 0, 138,
620 138, 0, 138, 139, 139, 0, 139, 139, 0, 139,
621 139, 139, 140, 140, 140, 140, 140, 0, 140, 140,
622 140, 141, 0, 141, 0, 141, 142, 142, 0, 0,
623 142, 142, 142, 142, 142, 142, 123, 123, 123, 123,
624 123, 123, 123, 123, 123, 123, 123, 123, 123, 123,
625 123, 123, 123, 123, 123, 123, 123, 123, 123, 123,
626 123, 123, 123, 123, 123, 123
627
628 } ;
629
630 /* Table of booleans, true if rule could match eol. */
631 static yyconst flex_int32_t yy_rule_can_match_eol[35] =
632 { 0,
633 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 1, 1, 0, 0, 0,
634 1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 0, 1, 1, 1, 0, };
635
636 extern int typ__flex_debug;
637 int typ__flex_debug = 0;
638
639 static yy_state_type *yy_state_buf=0, *yy_state_ptr=0;
640 static char *yy_full_match;
641 static int yy_lp;
642 #define REJECT \
643 { \
644 *yy_cp = (yy_hold_char); /* undo effects of setting up typ_text */ \
645 yy_cp = (yy_full_match); /* restore poss. backed-over text */ \
646 ++(yy_lp); \
647 goto find_rule; \
648 }
649
650 static int yy_more_offset = 0;
651 static int yy_prev_more_offset = 0;
652 #define yymore() ((yy_more_offset) = yy_flex_strlen( typ_text ))
653 #define YY_NEED_STRLEN
654 #define YY_MORE_ADJ 0
655 #define YY_RESTORE_YY_MORE_OFFSET \
656 { \
657 (yy_more_offset) = (yy_prev_more_offset); \
658 typ_leng -= (yy_more_offset); \
659 }
660 #ifndef YYLMAX
661 #define YYLMAX 8192
662 #endif
663
664 char typ_text[YYLMAX];
665 char *yytext_ptr;
666 #line 1 "tcltk/generic/interface/typelex.l"
667 #line 2 "tcltk/generic/interface/typelex.l"
668 /*
669 * TypeExtractor.l
670 * by Kirk Abbott and Ben Allan
671 * Created: 1/94
672 * Version: $Revision: 1.20 $
673 * Version control file: $RCSfile: typelex.l,v $
674 * Date last modified: $Date: 2003/08/23 18:43:09 $
675 * Last modified by: $Author: ballan $
676 *
677 * This file is part of the ASCEND Tcl/Tk interface
678 *
679 * Copyright 1997, Carnegie Mellon University
680 *
681 * The ASCEND Tcl/Tk interface is free software; you can redistribute
682 * it and/or modify it under the terms of the GNU General Public License as
683 * published by the Free Software Foundation; either version 2 of the
684 * License, or (at your option) any later version.
685 *
686 * The ASCEND Tcl/Tk interface is distributed in hope that it will be
687 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
688 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
689 * General Public License for more details.
690 *
691 * You should have received a copy of the GNU General Public License
692 * along with the program; if not, write to the Free Software Foundation,
693 * Inc., 675 Mass Ave, Cambridge, MA 02139 USA. Check the file named
694 * COPYING. COPYING is found in ../compiler.
695 */
696
697 /*
698 * ASCEND Type Retriever 1.2
699 *
700 * Purpose:
701 * To extract a type definition from an input file.
702 * Usage:
703 * See the header file for use from within ASCEND.
704 * For stand-alone use:
705 * typer [flags] ascend_type_name input_file output_file
706 * flags: -c show comments
707 * If no -c given, strip out comments.
708 * Features:
709 * --Does not descend into REQUIREd files. Only examines input_file
710 * for definitions of ascend_type_name.
711 * --This version DOES handle the UNIVERSAL quantifier.
712 *
713 */
714
715 #define MY_YYMORE() yymore()
716
717 #include <tcl.h>
718 #include <utilities/ascConfig.h>
719 #include <general/list.h>
720 #ifndef TYPER_TEST
721 /* for handling string modules and results in interp */
722 #include <compiler/compiler.h>
723 #include <compiler/symtab.h>
724 #include <compiler/fractions.h>
725 #include <compiler/dimen.h>
726 #include <compiler/child.h>
727 #include <compiler/type_desc.h>
728 #include <compiler/library.h>
729 #include <compiler/module.h>
730 #include "HelpProc.h" /* help is not necessary for test */
731 #endif /*!typertest*/
732
733 #include "typelex.h"
734
735
736 #ifndef lint
737 static const char TyperID[] = "$Id: typelex.l,v 1.20 2003/08/23 18:43:09 ballan Exp $";
738 #endif
739
740 #define YY_BREAK
741 /*
742 * Defining yybreak as above (empty) means that all of our matches must end
743 * in break or return because the normal flex supplied yybreak will
744 * be preempted by our empty one.
745 * In cases where matches contain a conditional return, make sure a
746 * break follows in the failure case.
747 */
748
749 static int CommentNestLevel = 0;
750 /*
751 * Nesting level of (* comments *)
752 */
753
754 static int BracesNestLevel = 0;
755 /*
756 * Nesting level of {braced} expressions
757 */
758
759 enum keyword_tokens {
760 NONE, /* Nothing to match, we're in the initial state */
761 MODEL, /* We've just read a MODEL or ATOM keyword */
762 MODEL_END, /* We've just read an END keyword inside a MODEL,
763 * an ATOM, or a DEFINITION. */
764 CONSTANT /* We've just read a CONSTANT keyword */
765 };
766 static enum keyword_tokens MatchedToken = NONE;
767 /*
768 * The recognized token we've most recently read. This usually implies
769 * that we're either in that state or we need to check the next keyword
770 * to see if we should enter (or leave, in the case of MODEL_END) that
771 * state. MODEL, ATOM, and DEFINITION state are equivalent.
772 */
773
774 static int ShowComments = 0;
775 /*
776 * Should we print comments? (1 = yes, 0 = no)
777 * This is set to 1 with `-c' on the command line
778 */
779
780 static unsigned long StartId = 0;
781 /*
782 * The location in the `typ_text' array where the MODEL, ATOM, or CONSTANT
783 * identifierbegins. We save this value and call MY_YYMORE() when we find
784 * a MODEL, ATOM, or CONSTANT keyword; StartId tells us where the
785 * Identifier will go.
786 */
787
788 static char *reqType = "";
789 /*
790 * The type we are looking for. This is one of the arguments passed
791 * to Asc_ExtractType() in the argv vector.
792 */
793
794 static void Asc_PutCode(char *s,FILE *fp);
795
796 static Tcl_Interp *g_typ__interp;
797 /* during parse, set to caller's interp if string result is wanted
798 * instead of file.
799 */
800
801 #ifdef TYPER_TEST
802 /*
803 * Specify ASCERR, ASCWAR when building stand alone.
804 */
805 #ifdef REIMPLEMENT_STREAM
806 FILE *ASCERR = stderr;
807 FILE *ASCWAR = stderr;
808 #endif
809 #endif /* TYPER_TEST */
810
811
812
813
814
815
816 #line 817 "<stdout>"
817
818 #define INITIAL 0
819 #define Comment 1
820 #define BracedText 2
821 #define Model 3
822 #define Constant 4
823 #define CheckID 5
824
825 #ifndef YY_NO_UNISTD_H
826 /* Special case for "unistd.h", since it is non-ANSI. We include it way
827 * down here because we want the user's section 1 to have been scanned first.
828 * The user has a chance to override it with an option.
829 */
830 #include <unistd.h>
831 #endif
832
833 #ifndef YY_EXTRA_TYPE
834 #define YY_EXTRA_TYPE void *
835 #endif
836
837 static int yy_init_globals (void );
838
839 /* Macros after this point can all be overridden by user definitions in
840 * section 1.
841 */
842
843 #ifndef YY_SKIP_YYWRAP
844 #ifdef __cplusplus
845 extern "C" int typ_wrap (void );
846 #else
847 extern int typ_wrap (void );
848 #endif
849 #endif
850
851 static void yyunput (int c,char *buf_ptr );
852
853 #ifndef yytext_ptr
854 static void yy_flex_strncpy (char *,yyconst char *,int );
855 #endif
856
857 #ifdef YY_NEED_STRLEN
858 static int yy_flex_strlen (yyconst char * );
859 #endif
860
861 #ifndef YY_NO_INPUT
862
863 #ifdef __cplusplus
864 static int yyinput (void );
865 #else
866 static int input (void );
867 #endif
868
869 #endif
870
871 /* Amount of stuff to slurp up with each read. */
872 #ifndef YY_READ_BUF_SIZE
873 #define YY_READ_BUF_SIZE 8192
874 #endif
875
876 /* Copy whatever the last rule matched to the standard output. */
877 #ifndef ECHO
878 /* This used to be an fputs(), but since the string might contain NUL's,
879 * we now use fwrite().
880 */
881 #define ECHO (void) fwrite( typ_text, typ_leng, 1, typ_out )
882 #endif
883
884 /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
885 * is returned in "result".
886 */
887 #ifndef YY_INPUT
888 #define YY_INPUT(buf,result,max_size) \
889 if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
890 { \
891 int c = '*'; \
892 size_t n; \
893 for ( n = 0; n < max_size && \
894 (c = getc( typ_in )) != EOF && c != '\n'; ++n ) \
895 buf[n] = (char) c; \
896 if ( c == '\n' ) \
897 buf[n++] = (char) c; \
898 if ( c == EOF && ferror( typ_in ) ) \
899 YY_FATAL_ERROR( "input in flex scanner failed" ); \
900 result = n; \
901 } \
902 else \
903 { \
904 errno=0; \
905 while ( (result = fread(buf, 1, max_size, typ_in))==0 && ferror(typ_in)) \
906 { \
907 if( errno != EINTR) \
908 { \
909 YY_FATAL_ERROR( "input in flex scanner failed" ); \
910 break; \
911 } \
912 errno=0; \
913 clearerr(typ_in); \
914 } \
915 }\
916 \
917
918 #endif
919
920 /* No semi-colon after return; correct usage is to write "yyterminate();" -
921 * we don't want an extra ';' after the "return" because that will cause
922 * some compilers to complain about unreachable statements.
923 */
924 #ifndef yyterminate
925 #define yyterminate() return YY_NULL
926 #endif
927
928 /* Number of entries by which start-condition stack grows. */
929 #ifndef YY_START_STACK_INCR
930 #define YY_START_STACK_INCR 25
931 #endif
932
933 /* Report a fatal error. */
934 #ifndef YY_FATAL_ERROR
935 #define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
936 #endif
937
938 /* end tables serialization structures and prototypes */
939
940 /* Default declaration of generated scanner - a define so the user can
941 * easily add parameters.
942 */
943 #ifndef YY_DECL
944 #define YY_DECL_IS_OURS 1
945
946 extern int typ_lex (void);
947
948 #define YY_DECL int typ_lex (void)
949 #endif /* !YY_DECL */
950
951 /* Code executed at the beginning of each rule, after typ_text and typ_leng
952 * have been set up.
953 */
954 #ifndef YY_USER_ACTION
955 #define YY_USER_ACTION
956 #endif
957
958 /* Code executed at the end of each rule. */
959 #ifndef YY_BREAK
960 #define YY_BREAK break;
961 #endif
962
963 #define YY_RULE_SETUP \
964 YY_USER_ACTION
965
966 /** The main scanner function which does all the work.
967 */
968 YY_DECL
969 {
970 register yy_state_type yy_current_state;
971 register char *yy_cp, *yy_bp;
972 register int yy_act;
973
974 #line 167 "tcltk/generic/interface/typelex.l"
975
976
977 /*
978 * Code to handle (* Comments *)
979 *
980 * "(*" puts us into the Comment state. Comments nest, so in the
981 * Comment state we need to look for "(*" that increases the nesting
982 * level and "*)" that will lower it.
983 * Do NOT try to match \(\*+ since that causes "(****)" to parse
984 * incorrectly.
985 */
986
987 #line 988 "<stdout>"
988
989 if ( !(yy_init) )
990 {
991 (yy_init) = 1;
992
993 #ifdef YY_USER_INIT
994 YY_USER_INIT;
995 #endif
996
997 /* Create the reject buffer large enough to save one state per allowed character. */
998 if ( ! (yy_state_buf) )
999 (yy_state_buf) = (yy_state_type *)typ_alloc(YY_STATE_BUF_SIZE );
1000
1001 if ( ! (yy_start) )
1002 (yy_start) = 1; /* first start state */
1003
1004 if ( ! typ_in )
1005 typ_in = stdin;
1006
1007 if ( ! typ_out )
1008 typ_out = stdout;
1009
1010 if ( ! YY_CURRENT_BUFFER ) {
1011 typ_ensure_buffer_stack ();
1012 YY_CURRENT_BUFFER_LVALUE =
1013 typ__create_buffer(typ_in,YY_BUF_SIZE );
1014 }
1015
1016 typ__load_buffer_state( );
1017 }
1018
1019 while ( 1 ) /* loops until end-of-file is reached */
1020 {
1021 yy_cp = (yy_c_buf_p);
1022
1023 /* Support of typ_text. */
1024 *yy_cp = (yy_hold_char);
1025
1026 /* yy_bp points to the position in yy_ch_buf of the start of
1027 * the current run.
1028 */
1029 yy_bp = yy_cp;
1030
1031 yy_current_state = (yy_start);
1032
1033 (yy_state_ptr) = (yy_state_buf);
1034 *(yy_state_ptr)++ = yy_current_state;
1035
1036 yy_match:
1037 do
1038 {
1039 register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
1040 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1041 {
1042 yy_current_state = (int) yy_def[yy_current_state];
1043 if ( yy_current_state >= 124 )
1044 yy_c = yy_meta[(unsigned int) yy_c];
1045 }
1046 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1047 *(yy_state_ptr)++ = yy_current_state;
1048 ++yy_cp;
1049 }
1050 while ( yy_base[yy_current_state] != 467 );
1051
1052 yy_find_action:
1053 yy_current_state = *--(yy_state_ptr);
1054 (yy_lp) = yy_accept[yy_current_state];
1055 find_rule: /* we branch to this label when backing up */
1056 for ( ; ; ) /* until we find what rule we matched */
1057 {
1058 if ( (yy_lp) && (yy_lp) < yy_accept[yy_current_state + 1] )
1059 {
1060 yy_act = yy_acclist[(yy_lp)];
1061 {
1062 (yy_full_match) = yy_cp;
1063 break;
1064 }
1065 }
1066 --yy_cp;
1067 yy_current_state = *--(yy_state_ptr);
1068 (yy_lp) = yy_accept[yy_current_state];
1069 }
1070
1071 YY_DO_BEFORE_ACTION;
1072
1073 if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] )
1074 {
1075 int yyl;
1076 for ( yyl = (yy_prev_more_offset); yyl < typ_leng; ++yyl )
1077 if ( typ_text[yyl] == '\n' )
1078
1079 typ_lineno++;
1080 ;
1081 }
1082
1083 do_action: /* This label is used only to access EOF actions. */
1084
1085 switch ( yy_act )
1086 { /* beginning of action switch */
1087 case 1:
1088 #line 180 "tcltk/generic/interface/typelex.l"
1089 case 2:
1090 #line 181 "tcltk/generic/interface/typelex.l"
1091 case 3:
1092 YY_RULE_SETUP
1093 #line 181 "tcltk/generic/interface/typelex.l"
1094 {
1095 /* Match "(" followed by "*" puts us into
1096 * the COMMENT state. Don't use \*+ since
1097 * that will parse "(***)" incorrectly.
1098 * Initialize the nesting level.
1099 * Print if ShowComments is TRUE and
1100 * MatchedToken is not NONE
1101 */
1102 BEGIN(Comment);
1103 CommentNestLevel = 1;
1104 if( ShowComments && MatchedToken!=NONE ) {
1105 Asc_PutCode( typ_text, typ_out );
1106 }
1107 break;
1108 }
1109 YY_BREAK
1110 case 4:
1111 /* rule 4 can match eol */
1112 YY_RULE_SETUP
1113 #line 196 "tcltk/generic/interface/typelex.l"
1114 {
1115 /* Match "(" followed "*" followed by
1116 * anything that's not "(" nor "*".
1117 * `anything' includes newlines.
1118 * Increase the commment nesting level.
1119 * Print if ShowComments is TRUE and
1120 * MatchedToken is not NONE.
1121 */
1122 CommentNestLevel++;
1123 if( ShowComments && MatchedToken!=NONE ) {
1124 Asc_PutCode( typ_text, typ_out );
1125 }
1126 break;
1127 }
1128 YY_BREAK
1129 case 5:
1130 /* rule 5 can match eol */
1131 YY_RULE_SETUP
1132 #line 210 "tcltk/generic/interface/typelex.l"
1133 {
1134 /* Match anything not "*" or "(" followed
1135 * by one or more "*"s followed by ")".
1136 * `anything' includes newlines.
1137 * This decreases the comment nesting level
1138 * and kicks us out if we're back to zero.
1139 * Print if ShowComments is TRUE and
1140 * MatchedToken is not NONE.
1141 */
1142 CommentNestLevel--;
1143 if( CommentNestLevel > 0 ) {
1144 /* more comments */
1145 break;
1146 }
1147 if( MatchedToken == NONE ) {
1148 BEGIN(INITIAL);
1149 break;
1150 }
1151 if( ShowComments ) {
1152 Asc_PutCode( typ_text, typ_out );
1153 }
1154 switch( MatchedToken ) {
1155 case MODEL:
1156 BEGIN(Model);
1157 break;
1158 case CONSTANT:
1159 BEGIN(Constant);
1160 break;
1161 default:
1162 BEGIN(INITIAL);
1163 break;
1164 }
1165 break;
1166 }
1167 YY_BREAK
1168 case 6:
1169 /* rule 6 can match eol */
1170 #line 245 "tcltk/generic/interface/typelex.l"
1171 case 7:
1172 /* rule 7 can match eol */
1173 #line 246 "tcltk/generic/interface/typelex.l"
1174 case 8:
1175 /* rule 8 can match eol */
1176 YY_RULE_SETUP
1177 #line 246 "tcltk/generic/interface/typelex.l"
1178 {
1179 /*
1180 * These three rules eat:
1181 * -- anything that's not a "*" or a "("
1182 * -- "("s not followed by "*"
1183 * -- "*"s not followed by ")"
1184 * `anything' includes newlines.
1185 * Print if ShowComments is TRUE and
1186 * MatchedToken is not NONE
1187 */
1188 if( ShowComments && MatchedToken!=NONE ) {
1189 Asc_PutCode( typ_text, typ_out );
1190 }
1191 break;
1192 }
1193 YY_BREAK
1194 /*
1195 * Code to handle { Text in Braces }
1196 *
1197 * "{" puts us into the BracedText state. Braces nest, so
1198 * in the BracedText state we need to look for "{" that increases
1199 * the nesting level and "}" that will lower it.
1200 */
1201 case 9:
1202 #line 272 "tcltk/generic/interface/typelex.l"
1203 case 10:
1204 #line 273 "tcltk/generic/interface/typelex.l"
1205 case 11:
1206 YY_RULE_SETUP
1207 #line 273 "tcltk/generic/interface/typelex.l"
1208 {
1209 /* A "{" puts us into the BracedText state.
1210 * Initialize the nesting level.
1211 * Print if MatchedToken is not NONE.
1212 *
1213 */
1214 BEGIN(BracedText);
1215 BracesNestLevel = 1;
1216 if( MatchedToken != NONE ) {
1217 Asc_PutCode( typ_text, typ_out );
1218 }
1219 break;
1220 }
1221 YY_BREAK
1222 case 12:
1223 /* rule 12 can match eol */
1224 YY_RULE_SETUP
1225 #line 286 "tcltk/generic/interface/typelex.l"
1226 {
1227 /* A backslash \ in the BracedText state
1228 * protects any character---even a
1229 * newline---and does not affect the
1230 * Nesting Level.
1231 * Print if MatchedToken is not NONE.
1232 */
1233 if( MatchedToken != NONE ) {
1234 Asc_PutCode( typ_text, typ_out );
1235 }
1236 break;
1237 }
1238 YY_BREAK
1239 case 13:
1240 /* rule 13 can match eol */
1241 YY_RULE_SETUP
1242 #line 298 "tcltk/generic/interface/typelex.l"
1243 {
1244 /* A backslash \ in the BracedText state
1245 * protects any character---even a
1246 * newline---and does not affect the
1247 * Nesting Level.
1248 * Print if MatchedToken is not NONE.
1249 */
1250 if( MatchedToken != NONE ) {
1251 Asc_PutCode( typ_text, typ_out );
1252 }
1253 break;
1254 }
1255 YY_BREAK
1256 case 14:
1257 /* rule 14 can match eol */
1258 YY_RULE_SETUP
1259 #line 310 "tcltk/generic/interface/typelex.l"
1260 {
1261 /* A "{" in the braces state gets added to
1262 * the text and increase the nesting level.
1263 * Match any non-brace character---including
1264 * newlines---that follows the open brace.
1265 * Print if MatchedToken is not NONE.
1266 */
1267 BracesNestLevel++;
1268 if( MatchedToken != NONE ) {
1269 Asc_PutCode( typ_text, typ_out );
1270 }
1271 break;
1272 }
1273 YY_BREAK
1274 case 15:
1275 /* rule 15 can match eol */
1276 YY_RULE_SETUP
1277 #line 323 "tcltk/generic/interface/typelex.l"
1278 {
1279 /* A "}" will reduce the nesting level.
1280 * If the nesting level is zero, go back to
1281 * the previous state. Match any
1282 * non-brace character---including
1283 * newlines---that precedes the close brace.
1284 * Print if MatchedToken is not NONE.
1285 */
1286 BracesNestLevel--;
1287 if (BracesNestLevel > 0) {
1288 /* more braced text */
1289 break;
1290 }
1291 if( MatchedToken == NONE ) {
1292 BEGIN(INITIAL);
1293 break;
1294 }
1295 Asc_PutCode( typ_text, typ_out );
1296 switch( MatchedToken ) {
1297 case MODEL:
1298 BEGIN(Model);
1299 break;
1300 case CONSTANT:
1301 BEGIN(Constant);
1302 break;
1303 default:
1304 BEGIN(INITIAL);
1305 break;
1306 }
1307 break;
1308 }
1309 YY_BREAK
1310 case 16:
1311 /* rule 16 can match eol */
1312 YY_RULE_SETUP
1313 #line 354 "tcltk/generic/interface/typelex.l"
1314 {
1315 /* Match anything that is not "{" nor "}"
1316 * nor "\\"(backslash).
1317 * `anything' includes newlines.
1318 * Print if MatchedToken is not NONE.
1319 */
1320 if( MatchedToken != NONE ) {
1321 Asc_PutCode( typ_text, typ_out );
1322 }
1323 break;
1324 }
1325 YY_BREAK
1326 /*
1327 * Code to check an identifier.
1328 *
1329 * When we are looking for a MODEL, ATOM, CONSTANT, or DEFIITION
1330 * and we find the text [UNIVERSAL]{MODEL|ATOM|CONSTANT|DEFINITION},
1331 * we enter this state.
1332 *
1333 * When we are insided MODEL, ATOM, or DEFINITION and we find
1334 * the text END, we enter this state.
1335 *
1336 * This state checks to see if the text following the MODEL,
1337 * ATOM, CONSTANT, DEFINITION, or END keyword matches
1338 * `reqType'---the type requested by the user. If so, we are
1339 * at the beginning or end of a type, and should change states
1340 * accordingly. If not, we should stay in our current state.
1341 */
1342 case 17:
1343 YY_RULE_SETUP
1344 #line 385 "tcltk/generic/interface/typelex.l"
1345 {
1346 /*
1347 * Found an identifier.
1348 * Identify the correct state.
1349 */
1350 if( MatchedToken == MODEL_END ) {
1351 /*
1352 * We're in the Model state, print the
1353 * text and see if matches reqType, if
1354 * so, we're at the end of the MODEL
1355 * (or ATOM or DEFINITION)
1356 * and should exit typ_lex()---return to
1357 * our caller, else stay in the Model
1358 * state.
1359 */
1360 Asc_PutCode( typ_text, typ_out );
1361 if(strcmp((typ_text+StartId),reqType) == 0) {
1362 return 0;
1363 } else {
1364 MatchedToken = MODEL;
1365 BEGIN(Model);
1366 }
1367 break;
1368 }
1369 if(strcmp((typ_text+StartId),reqType)==0){
1370 /*
1371 * We're in the INITIAL state, and we
1372 * found the beginning of the
1373 * requested MODEL, ATOM, CONSTANT,
1374 * or DEFINITION.
1375 * Print the text and set OutputState to
1376 * say we are printing. Start the
1377 * appropriate State by checking
1378 * MatchedToken.
1379 */
1380 Asc_PutCode( typ_text, typ_out );
1381 switch( MatchedToken ) {
1382 case MODEL:
1383 BEGIN(Model);
1384 break;
1385 case CONSTANT:
1386 BEGIN(Constant);
1387 break;
1388 default:
1389 /* something is wrong */
1390 BEGIN(INITIAL);
1391 break;
1392 }
1393 break;
1394 }
1395 /*
1396 * We're in the INITIAL state; we found
1397 * an MODEL, ATOM, CONSTANT, or
1398 * DEFINITION, but it wasn't the right
1399 * one. Stay in the INITIAL state.
1400 */
1401 MatchedToken = NONE;
1402 BEGIN(INITIAL);
1403 break;
1404 }
1405 YY_BREAK
1406 case 18:
1407 YY_RULE_SETUP
1408 #line 445 "tcltk/generic/interface/typelex.l"
1409 {
1410 /*
1411 * Some text other than an identifier
1412 * was found. Print the text if
1413 * MatchedToken is not NONE,
1414 * and return to the correct state.
1415 */
1416 if( MatchedToken == NONE ) {
1417 BEGIN(INITIAL);
1418 break;
1419 }
1420 Asc_PutCode( typ_text, typ_out );
1421 switch( MatchedToken ) {
1422 case MODEL:
1423 BEGIN(Model);
1424 break;
1425 case CONSTANT:
1426 BEGIN(Constant);
1427 break;
1428 default:
1429 /* something is wrong */
1430 BEGIN(INITIAL);
1431 break;
1432 }
1433 break;
1434 }
1435 YY_BREAK
1436 /*
1437 * Code to handle the model/atom/definition we want.
1438 *
1439 * Once we've found the start of the matching MODEL, ATOM, or
1440 * DEFINITION, print the text until we find the END token.
1441 * When we find END, save the current length of typ_text and use
1442 * MY_YYMORE() to append the identifier, then check the identifier
1443 * (in the CheckID state) to see if it is what we want. If so,
1444 * this is the end of this MODEL, ATOM, or DEFINITION.
1445 */
1446 case 19:
1447 YY_RULE_SETUP
1448 #line 485 "tcltk/generic/interface/typelex.l"
1449 {
1450 /*
1451 * Found the END keyword. Save the
1452 * current location in the typ_text array,
1453 * then enter the CheckID state to see if
1454 * the identifier matches what we want.
1455 */
1456 StartId = typ_leng;
1457 MatchedToken = MODEL_END;
1458 BEGIN(CheckID);
1459 MY_YYMORE();
1460 break;
1461 }
1462 YY_BREAK
1463 case 20:
1464 /* rule 20 can match eol */
1465 #line 499 "tcltk/generic/interface/typelex.l"
1466 case 21:
1467 /* rule 21 can match eol */
1468 #line 500 "tcltk/generic/interface/typelex.l"
1469 case 22:
1470 /* rule 22 can match eol */
1471 YY_RULE_SETUP
1472 #line 500 "tcltk/generic/interface/typelex.l"
1473 {
1474 /*
1475 * These rules match
1476 * -- any character except that which
1477 * would cause us to change states
1478 * -- "("s not followed by "*"s
1479 * -- uppercase keywords and following
1480 * semicolon or whitespace.
1481 * Print the text.
1482 */
1483 Asc_PutCode( typ_text, typ_out );
1484 break;
1485 }
1486 YY_BREAK
1487 /*
1488 * Code to handle the constant definition we want.
1489 *
1490 * Once we've found the start of the matching CONSTANT, print
1491 * the text until we find a semicolon ";".
1492 */
1493 case 23:
1494 YY_RULE_SETUP
1495 #line 523 "tcltk/generic/interface/typelex.l"
1496 {
1497 /*
1498 * Found the ";" which ends the CONSTANT.
1499 * Do NOT print it since that will be
1500 * added below. Return 0.
1501 */
1502 return 0;
1503 }
1504 YY_BREAK
1505 case 24:
1506 /* rule 24 can match eol */
1507 #line 532 "tcltk/generic/interface/typelex.l"
1508 case 25:
1509 /* rule 25 can match eol */
1510 YY_RULE_SETUP
1511 #line 532 "tcltk/generic/interface/typelex.l"
1512 {
1513 /*
1514 * These rules match
1515 * -- any character except that which
1516 * would cause us to change states
1517 * -- "("s not followed by "*"s
1518 * Print the text.
1519 */
1520 Asc_PutCode( typ_text, typ_out );
1521 break;
1522 }
1523 YY_BREAK
1524 /*
1525 * Code to look for [UNIVERSAL ]{MODEL|ATOM|CONSTANT|DEFINITION}.
1526 *
1527 * If we find UNIVERSAL, use yymore() to append the next
1528 * keyword---probably MODEL, ATOM, or CONSTANT.
1529 * If we find MODEL, ATOM, CONSTANT, or DEFINITION save the
1530 * current length and use yymore() to append the identifier,
1531 * then check the identifier (in the CheckID state) to see if
1532 * it is what we're looking for.
1533 */
1534 case 26:
1535 YY_RULE_SETUP
1536 #line 557 "tcltk/generic/interface/typelex.l"
1537 {
1538 /*
1539 * Found the UNIVERSAL keyword. Append
1540 * the following ATOM/MODEL/CONSTANT
1541 * keyword.
1542 */
1543 MY_YYMORE();
1544 break;
1545 }
1546 YY_BREAK
1547 case 27:
1548 #line 567 "tcltk/generic/interface/typelex.l"
1549 case 28:
1550 #line 568 "tcltk/generic/interface/typelex.l"
1551 case 29:
1552 YY_RULE_SETUP
1553 #line 568 "tcltk/generic/interface/typelex.l"
1554 {
1555 /*
1556 * Found an MODEL, ATOM, or DEFINITION
1557 * keyword--perhaps with a UNIVERSAL
1558 * modifier. Save the current location
1559 * in the typ_text array, then enter the
1560 * CheckID state to see if the identifier
1561 * matches what we want.
1562 */
1563 StartId = typ_leng;
1564 MatchedToken = MODEL;
1565 BEGIN(CheckID);
1566 MY_YYMORE();
1567 break;
1568 }
1569 YY_BREAK
1570 case 30:
1571 YY_RULE_SETUP
1572 #line 583 "tcltk/generic/interface/typelex.l"
1573 {
1574 /*
1575 * Found a CONSTANT keyword--perhaps
1576 * with a UNIVERSAL modifier. Save the
1577 * current location in the typ_text array,
1578 * then enter the CheckID state to see if
1579 * the identifier matches what we want.
1580 */
1581 StartId = typ_leng;
1582 MatchedToken = CONSTANT;
1583 BEGIN(CheckID);
1584 MY_YYMORE();
1585 break;
1586 }
1587 YY_BREAK
1588 /*
1589 * Rules to match other text.
1590 */
1591 case 31:
1592 /* rule 31 can match eol */
1593 #line 606 "tcltk/generic/interface/typelex.l"
1594 case 32:
1595 /* rule 32 can match eol */
1596 #line 607 "tcltk/generic/interface/typelex.l"
1597 case 33:
1598 /* rule 33 can match eol */
1599 YY_RULE_SETUP
1600 #line 607 "tcltk/generic/interface/typelex.l"
1601 {
1602 /*
1603 * These rules match
1604 * -- any character except that which
1605 * would cause us to change states
1606 * -- "("s not followed by "*"s
1607 * -- uppercase keywords and following
1608 * semicolon or whitespace.
1609 * Do nothing.
1610 */
1611 break;
1612 }
1613 YY_BREAK
1614 case YY_STATE_EOF(INITIAL):
1615 #line 619 "tcltk/generic/interface/typelex.l"
1616 {
1617 /*
1618 * Reached End of file without a match
1619 */
1620 return 1;
1621 }
1622 YY_BREAK
1623 case 34:
1624 YY_RULE_SETUP
1625 #line 627 "tcltk/generic/interface/typelex.l"
1626 ECHO;
1627 YY_BREAK
1628 #line 1629 "<stdout>"
1629 case YY_STATE_EOF(Comment):
1630 case YY_STATE_EOF(BracedText):
1631 case YY_STATE_EOF(Model):
1632 case YY_STATE_EOF(Constant):
1633 case YY_STATE_EOF(CheckID):
1634 yyterminate();
1635
1636 case YY_END_OF_BUFFER:
1637 {
1638 /* Amount of text matched not including the EOB char. */
1639 int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
1640
1641 /* Undo the effects of YY_DO_BEFORE_ACTION. */
1642 *yy_cp = (yy_hold_char);
1643 YY_RESTORE_YY_MORE_OFFSET
1644
1645 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
1646 {
1647 /* We're scanning a new file or input source. It's
1648 * possible that this happened because the user
1649 * just pointed typ_in at a new source and called
1650 * typ_lex(). If so, then we have to assure
1651 * consistency between YY_CURRENT_BUFFER and our
1652 * globals. Here is the right place to do so, because
1653 * this is the first action (other than possibly a
1654 * back-up) that will match for the new input source.
1655 */
1656 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1657 YY_CURRENT_BUFFER_LVALUE->yy_input_file = typ_in;
1658 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
1659 }
1660
1661 /* Note that here we test for yy_c_buf_p "<=" to the position
1662 * of the first EOB in the buffer, since yy_c_buf_p will
1663 * already have been incremented past the NUL character
1664 * (since all states make transitions on EOB to the
1665 * end-of-buffer state). Contrast this with the test
1666 * in input().
1667 */
1668 if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
1669 { /* This was really a NUL. */
1670 yy_state_type yy_next_state;
1671
1672 (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
1673
1674 yy_current_state = yy_get_previous_state( );
1675
1676 /* Okay, we're now positioned to make the NUL
1677 * transition. We couldn't have
1678 * yy_get_previous_state() go ahead and do it
1679 * for us because it doesn't know how to deal
1680 * with the possibility of jamming (and we don't
1681 * want to build jamming into it because then it
1682 * will run more slowly).
1683 */
1684
1685 yy_next_state = yy_try_NUL_trans( yy_current_state );
1686
1687 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1688
1689 if ( yy_next_state )
1690 {
1691 /* Consume the NUL. */
1692 yy_cp = ++(yy_c_buf_p);
1693 yy_current_state = yy_next_state;
1694 goto yy_match;
1695 }
1696
1697 else
1698 {
1699 yy_cp = (yy_c_buf_p);
1700 goto yy_find_action;
1701 }
1702 }
1703
1704 else switch ( yy_get_next_buffer( ) )
1705 {
1706 case EOB_ACT_END_OF_FILE:
1707 {
1708 (yy_did_buffer_switch_on_eof) = 0;
1709
1710 if ( typ_wrap( ) )
1711 {
1712 /* Note: because we've taken care in
1713 * yy_get_next_buffer() to have set up
1714 * typ_text, we can now set up
1715 * yy_c_buf_p so that if some total
1716 * hoser (like flex itself) wants to
1717 * call the scanner after we return the
1718 * YY_NULL, it'll still work - another
1719 * YY_NULL will get returned.
1720 */
1721 (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
1722
1723 yy_act = YY_STATE_EOF(YY_START);
1724 goto do_action;
1725 }
1726
1727 else
1728 {
1729 if ( ! (yy_did_buffer_switch_on_eof) )
1730 YY_NEW_FILE;
1731 }
1732 break;
1733 }
1734
1735 case EOB_ACT_CONTINUE_SCAN:
1736 (yy_c_buf_p) =
1737 (yytext_ptr) + yy_amount_of_matched_text;
1738
1739 yy_current_state = yy_get_previous_state( );
1740
1741 yy_cp = (yy_c_buf_p);
1742 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1743 goto yy_match;
1744
1745 case EOB_ACT_LAST_MATCH:
1746 (yy_c_buf_p) =
1747 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
1748
1749 yy_current_state = yy_get_previous_state( );
1750
1751 yy_cp = (yy_c_buf_p);
1752 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1753 goto yy_find_action;
1754 }
1755 break;
1756 }
1757
1758 default:
1759 YY_FATAL_ERROR(
1760 "fatal flex scanner internal error--no action found" );
1761 } /* end of action switch */
1762 } /* end of scanning one token */
1763 } /* end of typ_lex */
1764
1765 /* yy_get_next_buffer - try to read in a new buffer
1766 *
1767 * Returns a code representing an action:
1768 * EOB_ACT_LAST_MATCH -
1769 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1770 * EOB_ACT_END_OF_FILE - end of file
1771 */
1772 static int yy_get_next_buffer (void)
1773 {
1774 register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
1775 register char *source = (yytext_ptr);
1776 register int number_to_move, i;
1777 int ret_val;
1778
1779 if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
1780 YY_FATAL_ERROR(
1781 "fatal flex scanner internal error--end of buffer missed" );
1782
1783 if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
1784 { /* Don't try to fill the buffer, so this is an EOF. */
1785 if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
1786 {
1787 /* We matched a single character, the EOB, so
1788 * treat this as a final EOF.
1789 */
1790 return EOB_ACT_END_OF_FILE;
1791 }
1792
1793 else
1794 {
1795 /* We matched some text prior to the EOB, first
1796 * process it.
1797 */
1798 return EOB_ACT_LAST_MATCH;
1799 }
1800 }
1801
1802 /* Try to read more data. */
1803
1804 /* First move last chars to start of buffer. */
1805 number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
1806
1807 for ( i = 0; i < number_to_move; ++i )
1808 *(dest++) = *(source++);
1809
1810 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
1811 /* don't do the read, it's not guaranteed to return an EOF,
1812 * just force an EOF
1813 */
1814 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
1815
1816 else
1817 {
1818 int num_to_read =
1819 YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
1820
1821 while ( num_to_read <= 0 )
1822 { /* Not enough room in the buffer - grow it. */
1823
1824 YY_FATAL_ERROR(
1825 "input buffer overflow, can't enlarge buffer because scanner uses REJECT" );
1826
1827 }
1828
1829 if ( num_to_read > YY_READ_BUF_SIZE )
1830 num_to_read = YY_READ_BUF_SIZE;
1831
1832 /* Read in more data. */
1833 YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
1834 (yy_n_chars), (size_t) num_to_read );
1835
1836 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1837 }
1838
1839 if ( (yy_n_chars) == 0 )
1840 {
1841 if ( number_to_move == YY_MORE_ADJ )
1842 {
1843 ret_val = EOB_ACT_END_OF_FILE;
1844 typ_restart(typ_in );
1845 }
1846
1847 else
1848 {
1849 ret_val = EOB_ACT_LAST_MATCH;
1850 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
1851 YY_BUFFER_EOF_PENDING;
1852 }
1853 }
1854
1855 else
1856 ret_val = EOB_ACT_CONTINUE_SCAN;
1857
1858 (yy_n_chars) += number_to_move;
1859 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
1860 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
1861
1862 (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
1863
1864 return ret_val;
1865 }
1866
1867 /* yy_get_previous_state - get the state just before the EOB char was reached */
1868
1869 static yy_state_type yy_get_previous_state (void)
1870 {
1871 register yy_state_type yy_current_state;
1872 register char *yy_cp;
1873
1874 yy_current_state = (yy_start);
1875
1876 (yy_state_ptr) = (yy_state_buf);
1877 *(yy_state_ptr)++ = yy_current_state;
1878
1879 for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
1880 {
1881 register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1882 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1883 {
1884 yy_current_state = (int) yy_def[yy_current_state];
1885 if ( yy_current_state >= 124 )
1886 yy_c = yy_meta[(unsigned int) yy_c];
1887 }
1888 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1889 *(yy_state_ptr)++ = yy_current_state;
1890 }
1891
1892 return yy_current_state;
1893 }
1894
1895 /* yy_try_NUL_trans - try to make a transition on the NUL character
1896 *
1897 * synopsis
1898 * next_state = yy_try_NUL_trans( current_state );
1899 */
1900 static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
1901 {
1902 register int yy_is_jam;
1903
1904 register YY_CHAR yy_c = 1;
1905 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1906 {
1907 yy_current_state = (int) yy_def[yy_current_state];
1908 if ( yy_current_state >= 124 )
1909 yy_c = yy_meta[(unsigned int) yy_c];
1910 }
1911 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1912 yy_is_jam = (yy_current_state == 123);
1913 if ( ! yy_is_jam )
1914 *(yy_state_ptr)++ = yy_current_state;
1915
1916 return yy_is_jam ? 0 : yy_current_state;
1917 }
1918
1919 static void yyunput (int c, register char * yy_bp )
1920 {
1921 register char *yy_cp;
1922
1923 yy_cp = (yy_c_buf_p);
1924
1925 /* undo effects of setting up typ_text */
1926 *yy_cp = (yy_hold_char);
1927
1928 if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
1929 { /* need to shift things up to make room */
1930 /* +2 for EOB chars. */
1931 register int number_to_move = (yy_n_chars) + 2;
1932 register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
1933 YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
1934 register char *source =
1935 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
1936
1937 while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1938 *--dest = *--source;
1939
1940 yy_cp += (int) (dest - source);
1941 yy_bp += (int) (dest - source);
1942 YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
1943 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
1944
1945 if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
1946 YY_FATAL_ERROR( "flex scanner push-back overflow" );
1947 }
1948
1949 *--yy_cp = (char) c;
1950
1951 if ( c == '\n' ){
1952 --typ_lineno;
1953 }
1954
1955 (yytext_ptr) = yy_bp;
1956 (yy_hold_char) = *yy_cp;
1957 (yy_c_buf_p) = yy_cp;
1958 }
1959
1960 #ifndef YY_NO_INPUT
1961 #ifdef __cplusplus
1962 static int yyinput (void)
1963 #else
1964 static int input (void)
1965 #endif
1966
1967 {
1968 int c;
1969
1970 *(yy_c_buf_p) = (yy_hold_char);
1971
1972 if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
1973 {
1974 /* yy_c_buf_p now points to the character we want to return.
1975 * If this occurs *before* the EOB characters, then it's a
1976 * valid NUL; if not, then we've hit the end of the buffer.
1977 */
1978 if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
1979 /* This was really a NUL. */
1980 *(yy_c_buf_p) = '\0';
1981
1982 else
1983 { /* need more input */
1984 int offset = (yy_c_buf_p) - (yytext_ptr);
1985 ++(yy_c_buf_p);
1986
1987 switch ( yy_get_next_buffer( ) )
1988 {
1989 case EOB_ACT_LAST_MATCH:
1990 /* This happens because yy_g_n_b()
1991 * sees that we've accumulated a
1992 * token and flags that we need to
1993 * try matching the token before
1994 * proceeding. But for input(),
1995 * there's no matching to consider.
1996 * So convert the EOB_ACT_LAST_MATCH
1997 * to EOB_ACT_END_OF_FILE.
1998 */
1999
2000 /* Reset buffer status. */
2001 typ_restart(typ_in );
2002
2003 /*FALLTHROUGH*/
2004
2005 case EOB_ACT_END_OF_FILE:
2006 {
2007 if ( typ_wrap( ) )
2008 return EOF;
2009
2010 if ( ! (yy_did_buffer_switch_on_eof) )
2011 YY_NEW_FILE;
2012 #ifdef __cplusplus
2013 return yyinput();
2014 #else
2015 return input();
2016 #endif
2017 }
2018
2019 case EOB_ACT_CONTINUE_SCAN:
2020 (yy_c_buf_p) = (yytext_ptr) + offset;
2021 break;
2022 }
2023 }
2024 }
2025
2026 c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
2027 *(yy_c_buf_p) = '\0'; /* preserve typ_text */
2028 (yy_hold_char) = *++(yy_c_buf_p);
2029
2030 if ( c == '\n' )
2031
2032 typ_lineno++;
2033 ;
2034
2035 return c;
2036 }
2037 #endif /* ifndef YY_NO_INPUT */
2038
2039 /** Immediately switch to a different input stream.
2040 * @param input_file A readable stream.
2041 *
2042 * @note This function does not reset the start condition to @c INITIAL .
2043 */
2044 void typ_restart (FILE * input_file )
2045 {
2046
2047 if ( ! YY_CURRENT_BUFFER ){
2048 typ_ensure_buffer_stack ();
2049 YY_CURRENT_BUFFER_LVALUE =
2050 typ__create_buffer(typ_in,YY_BUF_SIZE );
2051 }
2052
2053 typ__init_buffer(YY_CURRENT_BUFFER,input_file );
2054 typ__load_buffer_state( );
2055 }
2056
2057 /** Switch to a different input buffer.
2058 * @param new_buffer The new input buffer.
2059 *
2060 */
2061 void typ__switch_to_buffer (YY_BUFFER_STATE new_buffer )
2062 {
2063
2064 /* TODO. We should be able to replace this entire function body
2065 * with
2066 * typ_pop_buffer_state();
2067 * typ_push_buffer_state(new_buffer);
2068 */
2069 typ_ensure_buffer_stack ();
2070 if ( YY_CURRENT_BUFFER == new_buffer )
2071 return;
2072
2073 if ( YY_CURRENT_BUFFER )
2074 {
2075 /* Flush out information for old buffer. */
2076 *(yy_c_buf_p) = (yy_hold_char);
2077 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
2078 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
2079 }
2080
2081 YY_CURRENT_BUFFER_LVALUE = new_buffer;
2082 typ__load_buffer_state( );
2083
2084 /* We don't actually know whether we did this switch during
2085 * EOF (typ_wrap()) processing, but the only time this flag
2086 * is looked at is after typ_wrap() is called, so it's safe
2087 * to go ahead and always set it.
2088 */
2089 (yy_did_buffer_switch_on_eof) = 1;
2090 }
2091
2092 static void typ__load_buffer_state (void)
2093 {
2094 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
2095 (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
2096 typ_in = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
2097 (yy_hold_char) = *(yy_c_buf_p);
2098 }
2099
2100 /** Allocate and initialize an input buffer state.
2101 * @param file A readable stream.
2102 * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
2103 *
2104 * @return the allocated buffer state.
2105 */
2106 YY_BUFFER_STATE typ__create_buffer (FILE * file, int size )
2107 {
2108 YY_BUFFER_STATE b;
2109
2110 b = (YY_BUFFER_STATE) typ_alloc(sizeof( struct yy_buffer_state ) );
2111 if ( ! b )
2112 YY_FATAL_ERROR( "out of dynamic memory in typ__create_buffer()" );
2113
2114 b->yy_buf_size = size;
2115
2116 /* yy_ch_buf has to be 2 characters longer than the size given because
2117 * we need to put in 2 end-of-buffer characters.
2118 */
2119 b->yy_ch_buf = (char *) typ_alloc(b->yy_buf_size + 2 );
2120 if ( ! b->yy_ch_buf )
2121 YY_FATAL_ERROR( "out of dynamic memory in typ__create_buffer()" );
2122
2123 b->yy_is_our_buffer = 1;
2124
2125 typ__init_buffer(b,file );
2126
2127 return b;
2128 }
2129
2130 /** Destroy the buffer.
2131 * @param b a buffer created with typ__create_buffer()
2132 *
2133 */
2134 void typ__delete_buffer (YY_BUFFER_STATE b )
2135 {
2136
2137 if ( ! b )
2138 return;
2139
2140 if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
2141 YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
2142
2143 if ( b->yy_is_our_buffer )
2144 typ_free((void *) b->yy_ch_buf );
2145
2146 typ_free((void *) b );
2147 }
2148
2149 #ifndef __cplusplus
2150 extern int isatty (int );
2151 #endif /* __cplusplus */
2152
2153 /* Initializes or reinitializes a buffer.
2154 * This function is sometimes called more than once on the same buffer,
2155 * such as during a typ_restart() or at EOF.
2156 */
2157 static void typ__init_buffer (YY_BUFFER_STATE b, FILE * file )
2158
2159 {
2160 int oerrno = errno;
2161
2162 typ__flush_buffer(b );
2163
2164 b->yy_input_file = file;
2165 b->yy_fill_buffer = 1;
2166
2167 /* If b is the current buffer, then typ__init_buffer was _probably_
2168 * called from typ_restart() or through yy_get_next_buffer.
2169 * In that case, we don't want to reset the lineno or column.
2170 */
2171 if (b != YY_CURRENT_BUFFER){
2172 b->yy_bs_lineno = 1;
2173 b->yy_bs_column = 0;
2174 }
2175
2176 b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
2177
2178 errno = oerrno;
2179 }
2180
2181 /** Discard all buffered characters. On the next scan, YY_INPUT will be called.
2182 * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
2183 *
2184 */
2185 void typ__flush_buffer (YY_BUFFER_STATE b )
2186 {
2187 if ( ! b )
2188 return;
2189
2190 b->yy_n_chars = 0;
2191
2192 /* We always need two end-of-buffer characters. The first causes
2193 * a transition to the end-of-buffer state. The second causes
2194 * a jam in that state.
2195 */
2196 b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
2197 b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
2198
2199 b->yy_buf_pos = &b->yy_ch_buf[0];
2200
2201 b->yy_at_bol = 1;
2202 b->yy_buffer_status = YY_BUFFER_NEW;
2203
2204 if ( b == YY_CURRENT_BUFFER )
2205 typ__load_buffer_state( );
2206 }
2207
2208 /** Pushes the new state onto the stack. The new state becomes
2209 * the current state. This function will allocate the stack
2210 * if necessary.
2211 * @param new_buffer The new state.
2212 *
2213 */
2214 void typ_push_buffer_state (YY_BUFFER_STATE new_buffer )
2215 {
2216 if (new_buffer == NULL)
2217 return;
2218
2219 typ_ensure_buffer_stack();
2220
2221 /* This block is copied from typ__switch_to_buffer. */
2222 if ( YY_CURRENT_BUFFER )
2223 {
2224 /* Flush out information for old buffer. */
2225 *(yy_c_buf_p) = (yy_hold_char);
2226 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
2227 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
2228 }
2229
2230 /* Only push if top exists. Otherwise, replace top. */
2231 if (YY_CURRENT_BUFFER)
2232 (yy_buffer_stack_top)++;
2233 YY_CURRENT_BUFFER_LVALUE = new_buffer;
2234
2235 /* copied from typ__switch_to_buffer. */
2236 typ__load_buffer_state( );
2237 (yy_did_buffer_switch_on_eof) = 1;
2238 }
2239
2240 /** Removes and deletes the top of the stack, if present.
2241 * The next element becomes the new top.
2242 *
2243 */
2244 void typ_pop_buffer_state (void)
2245 {
2246 if (!YY_CURRENT_BUFFER)
2247 return;
2248
2249 typ__delete_buffer(YY_CURRENT_BUFFER );
2250 YY_CURRENT_BUFFER_LVALUE = NULL;
2251 if ((yy_buffer_stack_top) > 0)
2252 --(yy_buffer_stack_top);
2253
2254 if (YY_CURRENT_BUFFER) {
2255 typ__load_buffer_state( );
2256 (yy_did_buffer_switch_on_eof) = 1;
2257 }
2258 }
2259
2260 /* Allocates the stack if it does not exist.
2261 * Guarantees space for at least one push.
2262 */
2263 static void typ_ensure_buffer_stack (void)
2264 {
2265 int num_to_alloc;
2266
2267 if (!(yy_buffer_stack)) {
2268
2269 /* First allocation is just for 2 elements, since we don't know if this
2270 * scanner will even need a stack. We use 2 instead of 1 to avoid an
2271 * immediate realloc on the next call.
2272 */
2273 num_to_alloc = 1;
2274 (yy_buffer_stack) = (struct yy_buffer_state**)typ_alloc
2275 (num_to_alloc * sizeof(struct yy_buffer_state*)
2276 );
2277
2278 memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
2279
2280 (yy_buffer_stack_max) = num_to_alloc;
2281 (yy_buffer_stack_top) = 0;
2282 return;
2283 }
2284
2285 if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
2286
2287 /* Increase the buffer to prepare for a possible push. */
2288 int grow_size = 8 /* arbitrary grow size */;
2289
2290 num_to_alloc = (yy_buffer_stack_max) + grow_size;
2291 (yy_buffer_stack) = (struct yy_buffer_state**)typ_realloc
2292 ((yy_buffer_stack),
2293 num_to_alloc * sizeof(struct yy_buffer_state*)
2294 );
2295
2296 /* zero only the new slots.*/
2297 memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
2298 (yy_buffer_stack_max) = num_to_alloc;
2299 }
2300 }
2301
2302 /** Setup the input buffer state to scan directly from a user-specified character buffer.
2303 * @param base the character buffer
2304 * @param size the size in bytes of the character buffer
2305 *
2306 * @return the newly allocated buffer state object.
2307 */
2308 YY_BUFFER_STATE typ__scan_buffer (char * base, yy_size_t size )
2309 {
2310 YY_BUFFER_STATE b;
2311
2312 if ( size < 2 ||
2313 base[size-2] != YY_END_OF_BUFFER_CHAR ||
2314 base[size-1] != YY_END_OF_BUFFER_CHAR )
2315 /* They forgot to leave room for the EOB's. */
2316 return 0;
2317
2318 b = (YY_BUFFER_STATE) typ_alloc(sizeof( struct yy_buffer_state ) );
2319 if ( ! b )
2320 YY_FATAL_ERROR( "out of dynamic memory in typ__scan_buffer()" );
2321
2322 b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
2323 b->yy_buf_pos = b->yy_ch_buf = base;
2324 b->yy_is_our_buffer = 0;
2325 b->yy_input_file = 0;
2326 b->yy_n_chars = b->yy_buf_size;
2327 b->yy_is_interactive = 0;
2328 b->yy_at_bol = 1;
2329 b->yy_fill_buffer = 0;
2330 b->yy_buffer_status = YY_BUFFER_NEW;
2331
2332 typ__switch_to_buffer(b );
2333
2334 return b;
2335 }
2336
2337 /** Setup the input buffer state to scan a string. The next call to typ_lex() will
2338 * scan from a @e copy of @a str.
2339 * @param yystr a NUL-terminated string to scan
2340 *
2341 * @return the newly allocated buffer state object.
2342 * @note If you want to scan bytes that may contain NUL values, then use
2343 * typ__scan_bytes() instead.
2344 */
2345 YY_BUFFER_STATE typ__scan_string (yyconst char * yystr )
2346 {
2347
2348 return typ__scan_bytes(yystr,strlen(yystr) );
2349 }
2350
2351 /** Setup the input buffer state to scan the given bytes. The next call to typ_lex() will
2352 * scan from a @e copy of @a bytes.
2353 * @param bytes the byte buffer to scan
2354 * @param len the number of bytes in the buffer pointed to by @a bytes.
2355 *
2356 * @return the newly allocated buffer state object.
2357 */
2358 YY_BUFFER_STATE typ__scan_bytes (yyconst char * yybytes, int _yybytes_len )
2359 {
2360 YY_BUFFER_STATE b;
2361 char *buf;
2362 yy_size_t n;
2363 int i;
2364
2365 /* Get memory for full buffer, including space for trailing EOB's. */
2366 n = _yybytes_len + 2;
2367 buf = (char *) typ_alloc(n );
2368 if ( ! buf )
2369 YY_FATAL_ERROR( "out of dynamic memory in typ__scan_bytes()" );
2370
2371 for ( i = 0; i < _yybytes_len; ++i )
2372 buf[i] = yybytes[i];
2373
2374 buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
2375
2376 b = typ__scan_buffer(buf,n );
2377 if ( ! b )
2378 YY_FATAL_ERROR( "bad buffer in typ__scan_bytes()" );
2379
2380 /* It's okay to grow etc. this buffer, and we should throw it
2381 * away when we're done.
2382 */
2383 b->yy_is_our_buffer = 1;
2384
2385 return b;
2386 }
2387
2388 #ifndef YY_EXIT_FAILURE
2389 #define YY_EXIT_FAILURE 2
2390 #endif
2391
2392 static void yy_fatal_error (yyconst char* msg )
2393 {
2394 (void) fprintf( stderr, "%s\n", msg );
2395 exit( YY_EXIT_FAILURE );
2396 }
2397
2398 /* Redefine yyless() so it works in section 3 code. */
2399
2400 #undef yyless
2401 #define yyless(n) \
2402 do \
2403 { \
2404 /* Undo effects of setting up typ_text. */ \
2405 int yyless_macro_arg = (n); \
2406 YY_LESS_LINENO(yyless_macro_arg);\
2407 typ_text[typ_leng] = (yy_hold_char); \
2408 (yy_c_buf_p) = typ_text + yyless_macro_arg; \
2409 (yy_hold_char) = *(yy_c_buf_p); \
2410 *(yy_c_buf_p) = '\0'; \
2411 typ_leng = yyless_macro_arg; \
2412 } \
2413 while ( 0 )
2414
2415 /* Accessor methods (get/set functions) to struct members. */
2416
2417 /** Get the current line number.
2418 *
2419 */
2420 int typ_get_lineno (void)
2421 {
2422
2423 return typ_lineno;
2424 }
2425
2426 /** Get the input stream.
2427 *
2428 */
2429 FILE *typ_get_in (void)
2430 {
2431 return typ_in;
2432 }
2433
2434 /** Get the output stream.
2435 *
2436 */
2437 FILE *typ_get_out (void)
2438 {
2439 return typ_out;
2440 }
2441
2442 /** Get the length of the current token.
2443 *
2444 */
2445 int typ_get_leng (void)
2446 {
2447 return typ_leng;
2448 }
2449
2450 /** Get the current token.
2451 *
2452 */
2453
2454 char *typ_get_text (void)
2455 {
2456 return typ_text;
2457 }
2458
2459 /** Set the current line number.
2460 * @param line_number
2461 *
2462 */
2463 void typ_set_lineno (int line_number )
2464 {
2465
2466 typ_lineno = line_number;
2467 }
2468
2469 /** Set the input stream. This does not discard the current
2470 * input buffer.
2471 * @param in_str A readable stream.
2472 *
2473 * @see typ__switch_to_buffer
2474 */
2475 void typ_set_in (FILE * in_str )
2476 {
2477 typ_in = in_str ;
2478 }
2479
2480 void typ_set_out (FILE * out_str )
2481 {
2482 typ_out = out_str ;
2483 }
2484
2485 int typ_get_debug (void)
2486 {
2487 return typ__flex_debug;
2488 }
2489
2490 void typ_set_debug (int bdebug )
2491 {
2492 typ__flex_debug = bdebug ;
2493 }
2494
2495 static int yy_init_globals (void)
2496 {
2497 /* Initialization is the same as for the non-reentrant scanner.
2498 * This function is called from typ_lex_destroy(), so don't allocate here.
2499 */
2500
2501 /* We do not touch typ_lineno unless the option is enabled. */
2502 typ_lineno = 1;
2503
2504 (yy_buffer_stack) = 0;
2505 (yy_buffer_stack_top) = 0;
2506 (yy_buffer_stack_max) = 0;
2507 (yy_c_buf_p) = (char *) 0;
2508 (yy_init) = 0;
2509 (yy_start) = 0;
2510
2511 (yy_state_buf) = 0;
2512 (yy_state_ptr) = 0;
2513 (yy_full_match) = 0;
2514 (yy_lp) = 0;
2515
2516 /* Defined in main.c */
2517 #ifdef YY_STDINIT
2518 typ_in = stdin;
2519 typ_out = stdout;
2520 #else
2521 typ_in = (FILE *) 0;
2522 typ_out = (FILE *) 0;
2523 #endif
2524
2525 /* For future reference: Set errno on error, since we are called by
2526 * typ_lex_init()
2527 */
2528 return 0;
2529 }
2530
2531 /* typ_lex_destroy is for both reentrant and non-reentrant scanners. */
2532 int typ_lex_destroy (void)
2533 {
2534
2535 /* Pop the buffer stack, destroying each element. */
2536 while(YY_CURRENT_BUFFER){
2537 typ__delete_buffer(YY_CURRENT_BUFFER );
2538 YY_CURRENT_BUFFER_LVALUE = NULL;
2539 typ_pop_buffer_state();
2540 }
2541
2542 /* Destroy the stack itself. */
2543 typ_free((yy_buffer_stack) );
2544 (yy_buffer_stack) = NULL;
2545
2546 typ_free ( (yy_state_buf) );
2547 (yy_state_buf) = NULL;
2548
2549 /* Reset the globals. This is important in a non-reentrant scanner so the next time
2550 * typ_lex() is called, initialization will occur. */
2551 yy_init_globals( );
2552
2553 return 0;
2554 }
2555
2556 /*
2557 * Internal utility routines.
2558 */
2559
2560 #ifndef yytext_ptr
2561 static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
2562 {
2563 register int i;
2564 for ( i = 0; i < n; ++i )
2565 s1[i] = s2[i];
2566 }
2567 #endif
2568
2569 #ifdef YY_NEED_STRLEN
2570 static int yy_flex_strlen (yyconst char * s )
2571 {
2572 register int n;
2573 for ( n = 0; s[n]; ++n )
2574 ;
2575
2576 return n;
2577 }
2578 #endif
2579
2580 void *typ_alloc (yy_size_t size )
2581 {
2582 return (void *) malloc( size );
2583 }
2584
2585 void *typ_realloc (void * ptr, yy_size_t size )
2586 {
2587 /* The cast to (char *) in the following accommodates both
2588 * implementations that use char* generic pointers, and those
2589 * that use void* generic pointers. It works with the latter
2590 * because both ANSI C and C++ allow castless assignment from
2591 * any pointer type to void*, and deal with argument conversions
2592 * as though doing an assignment.
2593 */
2594 return (void *) realloc( (char *) ptr, size );
2595 }
2596
2597 void typ_free (void * ptr )
2598 {
2599 free( (char *) ptr ); /* see typ_realloc() for (char *) cast */
2600 }
2601
2602 #define YYTABLES_NAME "yytables"
2603
2604 #line 627 "tcltk/generic/interface/typelex.l"
2605
2606
2607 /*
2608 * int typ_wrap(void);
2609 *
2610 * This returns 1 if the scanner should stop parsing, or 0 if
2611 * the scanner should continue. Flex requires this function
2612 * unless the flex directive `%option nozzwrap' is given, but
2613 * `%option' directives are a recent addition to flex and for
2614 * maximum portability should not be used.
2615 */
2616 int typ_wrap(void)
2617 {
2618 return 1;
2619 }
2620
2621
2622 #ifndef TYPER_TEST
2623 STDHLF(Asc_ExtractType,(Asc_ExtractTypeHL1,Asc_ExtractTypeHL2,HLFSTOP));
2624 #endif
2625
2626 /*
2627 * int Asc_ExtractType(cdata, interp, argc, argv)
2628 * ClientData cdata; --Tcl information, not used
2629 * Tcl_Interp *interp; --Tcl interpreter, not used in standalone use
2630 * int argc; --the number of arguments
2631 * char **argv; --the array of arguments
2632 *
2633 * When running as part of ASCEND, returns TCL_OK or TCL_ERROR.
2634 * When running as a stand alone tool (CPP macro TYPER_TEST is defined)
2635 * we return:
2636 * 0 --success
2637 * 1 --problems with arguments
2638 * 2 --problems opening file
2639 * -1 --no errors occurred but the requested type was not found
2640 *
2641 */
2642 extern int Asc_ExtractType(ClientData cdata, Tcl_Interp *interp,
2643 int argc, CONST84 char **argv)
2644 {
2645 int ndx = 1; /* index into the argv array */
2646 int result; /* result from typ_lex and value to return to caller */
2647 #ifndef TYPER_TEST
2648 struct TypeDescription *desc=NULL;
2649 struct module_t *mod=NULL;
2650 CONST char *scanstring=NULL;
2651 YY_BUFFER_STATE oldbuf=NULL;
2652 YY_BUFFER_STATE scanbuf=NULL;
2653 #endif /*!typertest*/
2654
2655 (void)cdata; /* stop gcc whining about unused parameter */
2656 #ifdef TYPER_TEST
2657 (void)interp; /* stop gcc whining about unused parameter */
2658 #endif
2659
2660
2661 /*
2662 * Reset our global set
2663 */
2664 BEGIN( INITIAL );
2665 MatchedToken = NONE;
2666 ShowComments = 0;
2667 reqType = "";
2668 CommentNestLevel = 0;
2669 BracesNestLevel = 0;
2670
2671
2672 /*
2673 * Process the arguments
2674 */
2675 if (( argc < 2 ) || ( argc > 5 )) {
2676 #ifdef TYPER_TEST
2677 FPRINTF(ASCERR,
2678 "Wrong number of arguments\n"
2679 "Usage: %s [-c] type [source_file] [destination_file]\n",
2680 argv[0]);
2681 return 1;
2682 #else /* ! TYPER_TEST */
2683 Tcl_AppendResult(interp, "Wrong number of arguments\nUsage: ",
2684 argv[0], "[-c] type [source_file] "
2685 "[-s,destination_file]",
2686 (char*)NULL);
2687 return TCL_ERROR;
2688 #endif /* TYPER_TYPER */
2689 }
2690
2691 if(( argc > ndx ) && ( argv[ndx][0] == '-' )) {
2692 switch( argv[ndx][1] ) {
2693 case 'c':
2694 ShowComments = 1;
2695 ndx++;
2696 break;
2697 default:
2698 #ifdef TYPER_TEST
2699 FPRINTF(ASCERR, "Unknown switch %s\n", argv[ndx]);
2700 return 1;
2701 #else /* ! TYPER_TEST */
2702 Tcl_AppendResult(interp, "Unknown switch ", argv[ndx], (char*)NULL);
2703 return TCL_ERROR;
2704 #endif /* TYPER_TEST */
2705 }
2706 }
2707
2708 if( argc > ndx ) {
2709 /* The type of MODEL/ATOM to get */
2710 reqType = QUIET(argv[ndx++]);
2711 } else {
2712 #ifdef TYPER_TEST
2713 FPRINTF(ASCERR,
2714 "Wrong number of arguments\n"
2715 "Usage: %s [-c] type [source_file] [destination_file]\n",
2716 argv[0]);
2717 return 1;
2718 #else /* ! TYPER_TEST */
2719 Tcl_AppendResult(interp, "Wrong number of arguments\nUsage: ",
2720 argv[0], "[-c] type [source_file] "
2721 "[-s,destination_file]",
2722 (char*)NULL);
2723 return TCL_ERROR;
2724 #endif /* TYPER_TEST */
2725 }
2726
2727 if( argc > ndx ) {
2728 /* The source file; stdin if not specified. */
2729 #ifndef TYPER_TEST
2730 /* in ascend, find source module if possible for string module name */
2731 desc = FindType(AddSymbol(reqType));
2732 if (desc != NULL) {
2733 mod = GetModule(desc);
2734 assert(mod!=NULL);
2735 scanstring = Asc_ModuleString(mod);
2736 if (scanstring == NULL) {
2737 mod = NULL;
2738 }
2739 }
2740 #endif /*!typertest*/
2741 if(scanstring == NULL && (typ_in = fopen(argv[ndx],"r")) == NULL) {
2742 #ifdef TYPER_TEST
2743 FPRINTF(ASCERR, "Error opening source file \'%s\'\n", argv[ndx]);
2744 return 2;
2745 #else /* ! TYPER_TEST */
2746 Tcl_AppendResult(interp, "Error opening source file \'",
2747 argv[ndx], "\'", (char*)NULL);
2748 return TCL_ERROR;
2749 #endif /* TYPER_TEST */
2750 }
2751 ndx++;
2752 } else {
2753 typ_in = stdin;
2754 }
2755
2756 if( argc > ndx ) {
2757 #ifndef TYPER_TEST
2758 if (argv[ndx][0] == '-' && argv[ndx][1] == 's') {
2759 g_typ__interp = interp;
2760 typ_out = NULL;
2761 } else {
2762 #endif /* !typertest*/
2763 g_typ__interp = NULL;
2764 /* The destination file; stdout if not specified */
2765 if((typ_out = fopen(argv[ndx],"a+")) == NULL) {
2766 #ifdef TYPER_TEST
2767 FPRINTF(ASCERR, "Error opening destination file \'%s\'\n", argv[ndx]);
2768 return 2;
2769 #else /* ! TYPER_TEST */
2770 Tcl_AppendResult(interp, "Error opening destination file \'",
2771 argv[ndx], "\'", (char*)NULL);
2772 return TCL_ERROR;
2773 #endif /* TYPER_TEST */
2774 }
2775 #ifndef TYPER_TEST
2776 }
2777 #endif /* !typertest*/
2778 ndx++;
2779 } else {
2780 typ_out = stdout;
2781 }
2782
2783
2784 /*
2785 * Call typ_lex() to process the input
2786 */
2787 #ifndef TYPER_TEST
2788 if (scanstring != NULL) {
2789 oldbuf = YY_CURRENT_BUFFER;
2790 scanbuf = typ__scan_string(scanstring);
2791 typ__switch_to_buffer(scanbuf);
2792 BEGIN(INITIAL);
2793 /* typ_restart((FILE *)NULL); */
2794 }
2795 #else
2796 typ_restart(typ_in);
2797 #endif /* !typertest */
2798 if( (result = typ_lex()) != 0 ) {
2799 #ifdef TYPER_TEST
2800 FPRINTF(ASCERR, "Could not find type \'%s\'\n", reqType);
2801 #else /* ! TYPER_TEST */
2802 if (g_typ__interp!=NULL) {
2803 Tcl_ResetResult(interp);
2804 }
2805 Tcl_AppendResult(interp, "Could not find type \'", reqType, "\'",
2806 (char*)NULL);
2807 result = TCL_ERROR;
2808 #endif /* TYPER_TEST */
2809 } else {
2810 /* add a closing semicolon and newline */
2811 Asc_PutCode( ";\n", typ_out );
2812 #ifndef TYPER_TEST
2813 result = TCL_OK;
2814 #endif /* ! TYPER_TEST */
2815 }
2816
2817 /*
2818 * Close any files/buffers we opened and exit.
2819 */
2820 #ifndef TYPER_TEST
2821 if (scanstring != NULL) {
2822 typ__delete_buffer(YY_CURRENT_BUFFER);
2823 typ__switch_to_buffer(oldbuf);
2824 BEGIN(INITIAL);
2825 }
2826 #endif
2827 if ( typ_in != stdin && typ_in != NULL) {
2828 fclose(typ_in);
2829 }
2830 if ( typ_out != stdout && typ_out != NULL) {
2831 fclose(typ_out);
2832 }
2833
2834 return result;
2835 }
2836
2837 static void Asc_PutCode(char *s,FILE *fp)
2838 /** into string or screen */
2839 {
2840 #ifndef TYPER_TEST
2841 if (g_typ__interp != NULL) {
2842 Tcl_AppendResult(g_typ__interp,s,(char *)NULL);
2843 } else {
2844 #endif /* typertest */
2845 fputs(s,fp);
2846 #ifndef TYPER_TEST
2847 }
2848 #endif /* typertest */
2849 }
2850
2851 #ifdef TYPER_TEST
2852 int main(int argc, char **argv)
2853 {
2854 return Asc_ExtractType((ClientData)NULL, (Tcl_Interp*)NULL, argc, argv);
2855 }
2856 #endif /* TYPER_TEST */
2857

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22