1 /* A lexical scanner generated by flex */
2
3 /* Scanner skeleton version:
4 * $Header: /home/daffy/u0/vern/flex/RCS/flex.skl,v 2.91 96/09/10 16:58:48 vern Exp $
5 */
6
7 #define FLEX_SCANNER
8 #define YY_FLEX_MAJOR_VERSION 2
9 #define YY_FLEX_MINOR_VERSION 5
10
11 #include <stdio.h>
12 #include <unistd.h>
13
14
15 /* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
16 #ifdef c_plusplus
17 #ifndef __cplusplus
18 #define __cplusplus
19 #endif
20 #endif
21
22
23 #ifdef __cplusplus
24
25 #include <stdlib.h>
26
27 /* Use prototypes in function declarations. */
28 #define YY_USE_PROTOS
29
30 /* The "const" storage-class-modifier is valid. */
31 #define YY_USE_CONST
32
33 #else /* ! __cplusplus */
34
35 #if __STDC__
36
37 #define YY_USE_PROTOS
38 #define YY_USE_CONST
39
40 #endif /* __STDC__ */
41 #endif /* ! __cplusplus */
42
43 #ifdef __TURBOC__
44 #pragma warn -rch
45 #pragma warn -use
46 #include <io.h>
47 #include <stdlib.h>
48 #define YY_USE_CONST
49 #define YY_USE_PROTOS
50 #endif
51
52 #ifdef YY_USE_CONST
53 #define yyconst const
54 #else
55 #define yyconst
56 #endif
57
58
59 #ifdef YY_USE_PROTOS
60 #define YY_PROTO(proto) proto
61 #else
62 #define YY_PROTO(proto) ()
63 #endif
64
65 /* Returned upon end-of-file. */
66 #define YY_NULL 0
67
68 /* Promotes a possibly negative, possibly signed char to an unsigned
69 * integer for use as an array index. If the signed char is negative,
70 * we want to instead treat it as an 8-bit unsigned char, hence the
71 * double cast.
72 */
73 #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
74
75 /* Enter a start condition. This macro really ought to take a parameter,
76 * but we do it the disgusting crufty way forced on us by the ()-less
77 * definition of BEGIN.
78 */
79 #define BEGIN yy_start = 1 + 2 *
80
81 /* Translate the current start state into a value that can be later handed
82 * to BEGIN to return to the state. The YYSTATE alias is for lex
83 * compatibility.
84 */
85 #define YY_START ((yy_start - 1) / 2)
86 #define YYSTATE YY_START
87
88 /* Action number for EOF rule of a given start state. */
89 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
90
91 /* Special action meaning "start processing a new file". */
92 #define YY_NEW_FILE yyrestart( yyin )
93
94 #define YY_END_OF_BUFFER_CHAR 0
95
96 /* Size of default input buffer. */
97 #define YY_BUF_SIZE 16384
98
99 typedef struct yy_buffer_state *YY_BUFFER_STATE;
100
101 extern int yyleng;
102 extern FILE *yyin, *yyout;
103
104 #define EOB_ACT_CONTINUE_SCAN 0
105 #define EOB_ACT_END_OF_FILE 1
106 #define EOB_ACT_LAST_MATCH 2
107
108 /* The funky do-while in the following #define is used to turn the definition
109 * int a single C statement (which needs a semi-colon terminator). This
110 * avoids problems with code like:
111 *
112 * if ( condition_holds )
113 * yyless( 5 );
114 * else
115 * do_something_else();
116 *
117 * Prior to using the do-while the compiler would get upset at the
118 * "else" because it interpreted the "if" statement as being all
119 * done when it reached the ';' after the yyless() call.
120 */
121
122 /* Return all but the first 'n' matched characters back to the input stream. */
123
124 #define yyless(n) \
125 do \
126 { \
127 /* Undo effects of setting up yytext. */ \
128 *yy_cp = yy_hold_char; \
129 YY_RESTORE_YY_MORE_OFFSET \
130 yy_c_buf_p = yy_cp = yy_bp + n - YY_MORE_ADJ; \
131 YY_DO_BEFORE_ACTION; /* set up yytext again */ \
132 } \
133 while ( 0 )
134
135 #define unput(c) yyunput( c, yytext_ptr )
136
137 /* The following is because we cannot portably get our hands on size_t
138 * (without autoconf's help, which isn't available because we want
139 * flex-generated scanners to compile on their own).
140 */
141 typedef unsigned int yy_size_t;
142
143
144 struct yy_buffer_state
145 {
146 FILE *yy_input_file;
147
148 char *yy_ch_buf; /* input buffer */
149 char *yy_buf_pos; /* current position in input buffer */
150
151 /* Size of input buffer in bytes, not including room for EOB
152 * characters.
153 */
154 yy_size_t yy_buf_size;
155
156 /* Number of characters read into yy_ch_buf, not including EOB
157 * characters.
158 */
159 int yy_n_chars;
160
161 /* Whether we "own" the buffer - i.e., we know we created it,
162 * and can realloc() it to grow it, and should free() it to
163 * delete it.
164 */
165 int yy_is_our_buffer;
166
167 /* Whether this is an "interactive" input source; if so, and
168 * if we're using stdio for input, then we want to use getc()
169 * instead of fread(), to make sure we stop fetching input after
170 * each newline.
171 */
172 int yy_is_interactive;
173
174 /* Whether we're considered to be at the beginning of a line.
175 * If so, '^' rules will be active on the next match, otherwise
176 * not.
177 */
178 int yy_at_bol;
179
180 /* Whether to try to fill the input buffer when we reach the
181 * end of it.
182 */
183 int yy_fill_buffer;
184
185 int yy_buffer_status;
186 #define YY_BUFFER_NEW 0
187 #define YY_BUFFER_NORMAL 1
188 /* When an EOF's been seen but there's still some text to process
189 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
190 * shouldn't try reading from the input source any more. We might
191 * still have a bunch of tokens to match, though, because of
192 * possible backing-up.
193 *
194 * When we actually see the EOF, we change the status to "new"
195 * (via yyrestart()), so that the user can continue scanning by
196 * just pointing yyin at a new input file.
197 */
198 #define YY_BUFFER_EOF_PENDING 2
199 };
200
201 static YY_BUFFER_STATE yy_current_buffer = 0;
202
203 /* We provide macros for accessing buffer states in case in the
204 * future we want to put the buffer states in a more general
205 * "scanner state".
206 */
207 #define YY_CURRENT_BUFFER yy_current_buffer
208
209
210 /* yy_hold_char holds the character lost when yytext is formed. */
211 static char yy_hold_char;
212
213 static int yy_n_chars; /* number of characters read into yy_ch_buf */
214
215
216 int yyleng;
217
218 /* Points to current character in buffer. */
219 static char *yy_c_buf_p = (char *) 0;
220 static int yy_init = 1; /* whether we need to initialize */
221 static int yy_start = 0; /* start state number */
222
223 /* Flag which is used to allow yywrap()'s to do buffer switches
224 * instead of setting up a fresh yyin. A bit of a hack ...
225 */
226 static int yy_did_buffer_switch_on_eof;
227
228 void yyrestart YY_PROTO(( FILE *input_file ));
229
230 void yy_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer ));
231 void yy_load_buffer_state YY_PROTO(( void ));
232 YY_BUFFER_STATE yy_create_buffer YY_PROTO(( FILE *file, int size ));
233 void yy_delete_buffer YY_PROTO(( YY_BUFFER_STATE b ));
234 void yy_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file ));
235 void yy_flush_buffer YY_PROTO(( YY_BUFFER_STATE b ));
236 #define YY_FLUSH_BUFFER yy_flush_buffer( yy_current_buffer )
237
238 YY_BUFFER_STATE yy_scan_buffer YY_PROTO(( char *base, yy_size_t size ));
239 YY_BUFFER_STATE yy_scan_string YY_PROTO(( yyconst char *yy_str ));
240 YY_BUFFER_STATE yy_scan_bytes YY_PROTO(( yyconst char *bytes, int len ));
241
242 static void *yy_flex_alloc YY_PROTO(( yy_size_t ));
243 static void *yy_flex_realloc YY_PROTO(( void *, yy_size_t ));
244 static void yy_flex_free YY_PROTO(( void * ));
245
246 #define yy_new_buffer yy_create_buffer
247
248 #define yy_set_interactive(is_interactive) \
249 { \
250 if ( ! yy_current_buffer ) \
251 yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
252 yy_current_buffer->yy_is_interactive = is_interactive; \
253 }
254
255 #define yy_set_bol(at_bol) \
256 { \
257 if ( ! yy_current_buffer ) \
258 yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE ); \
259 yy_current_buffer->yy_at_bol = at_bol; \
260 }
261
262 #define YY_AT_BOL() (yy_current_buffer->yy_at_bol)
263
264 typedef unsigned char YY_CHAR;
265 FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
266 typedef int yy_state_type;
267 extern char *yytext;
268 #define yytext_ptr yytext
269
270 static yy_state_type yy_get_previous_state YY_PROTO(( void ));
271 static yy_state_type yy_try_NUL_trans YY_PROTO(( yy_state_type current_state ));
272 static int yy_get_next_buffer YY_PROTO(( void ));
273 static void yy_fatal_error YY_PROTO(( yyconst char msg[] ));
274
275 /* Done after the current pattern has been matched and before the
276 * corresponding action - sets up yytext.
277 */
278 #define YY_DO_BEFORE_ACTION \
279 yytext_ptr = yy_bp; \
280 yyleng = (int) (yy_cp - yy_bp); \
281 yy_hold_char = *yy_cp; \
282 *yy_cp = '\0'; \
283 yy_c_buf_p = yy_cp;
284
285 #define YY_NUM_RULES 44
286 #define YY_END_OF_BUFFER 45
287 static yyconst short int yy_accept[148] =
288 { 0,
289 20, 20, 0, 0, 32, 32, 45, 43, 25, 20,
290 24, 29, 20, 26, 34, 40, 42, 24, 33, 41,
291 24, 27, 23, 35, 24, 26, 26, 43, 26, 26,
292 26, 26, 26, 26, 26, 26, 26, 26, 26, 39,
293 44, 1, 32, 31, 44, 25, 35, 20, 20, 15,
294 26, 36, 38, 28, 27, 0, 0, 22, 0, 0,
295 26, 0, 19, 0, 26, 26, 26, 26, 26, 26,
296 3, 11, 26, 26, 26, 26, 26, 26, 37, 0,
297 1, 32, 31, 0, 32, 30, 32, 28, 0, 0,
298 28, 0, 0, 21, 0, 26, 0, 26, 26, 26,
299
300 26, 10, 26, 26, 26, 26, 16, 26, 26, 30,
301 32, 31, 0, 0, 28, 0, 2, 26, 26, 26,
302 4, 26, 26, 26, 14, 18, 26, 0, 32, 32,
303 7, 17, 26, 26, 26, 13, 26, 6, 26, 5,
304 26, 12, 26, 26, 8, 9, 0
305 } ;
306
307 static yyconst int yy_ec[256] =
308 { 0,
309 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
310 2, 2, 2, 1, 1, 1, 1, 1, 1, 1,
311 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
312 1, 2, 4, 5, 6, 7, 8, 9, 10, 11,
313 11, 8, 12, 13, 12, 14, 8, 15, 15, 15,
314 15, 15, 15, 15, 15, 15, 15, 11, 16, 17,
315 18, 17, 16, 8, 19, 19, 19, 19, 20, 19,
316 19, 19, 19, 19, 19, 21, 19, 22, 19, 19,
317 19, 19, 19, 19, 23, 19, 19, 19, 19, 19,
318 11, 24, 11, 11, 19, 1, 25, 26, 27, 19,
319
320 28, 29, 19, 30, 31, 19, 32, 33, 19, 34,
321 35, 19, 19, 36, 37, 38, 39, 40, 41, 19,
322 42, 19, 11, 43, 11, 1, 1, 1, 1, 1,
323 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
324 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
325 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
326 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
327 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
328 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
329 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
330
331 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
332 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
333 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
334 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
335 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
336 1, 1, 1, 1, 1
337 } ;
338
339 static yyconst int yy_meta[44] =
340 { 0,
341 1, 1, 1, 1, 1, 1, 2, 1, 1, 1,
342 1, 1, 1, 1, 2, 1, 1, 1, 2, 2,
343 2, 2, 2, 1, 2, 2, 2, 2, 2, 2,
344 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
345 2, 2, 1
346 } ;
347
348 static yyconst short int yy_base[159] =
349 { 0,
350 0, 0, 224, 223, 41, 42, 225, 228, 222, 228,
351 205, 228, 219, 214, 202, 210, 228, 228, 200, 228,
352 202, 34, 49, 198, 197, 0, 191, 54, 177, 28,
353 179, 29, 38, 176, 182, 181, 172, 179, 176, 162,
354 201, 228, 56, 228, 68, 201, 228, 199, 228, 0,
355 0, 228, 228, 61, 63, 67, 82, 228, 198, 84,
356 179, 90, 228, 196, 170, 159, 162, 158, 158, 159,
357 0, 0, 165, 153, 157, 147, 157, 156, 228, 183,
358 228, 92, 228, 96, 98, 228, 102, 93, 97, 170,
359 169, 180, 108, 228, 179, 160, 177, 154, 151, 139,
360
361 148, 0, 148, 149, 134, 143, 0, 138, 116, 228,
362 112, 145, 117, 132, 130, 141, 0, 111, 112, 110,
363 109, 101, 105, 101, 0, 0, 107, 131, 122, 126,
364 0, 0, 99, 103, 99, 0, 84, 0, 55, 0,
365 40, 0, 41, 24, 0, 0, 228, 150, 152, 154,
366 48, 156, 158, 160, 162, 164, 166, 168
367 } ;
368
369 static yyconst short int yy_def[159] =
370 { 0,
371 147, 1, 148, 148, 149, 149, 147, 147, 147, 147,
372 147, 147, 150, 151, 147, 147, 147, 147, 147, 147,
373 147, 147, 147, 147, 147, 151, 151, 147, 151, 151,
374 151, 151, 151, 151, 151, 151, 151, 151, 151, 147,
375 152, 147, 153, 147, 153, 147, 147, 150, 147, 151,
376 151, 147, 147, 147, 147, 147, 147, 147, 154, 147,
377 151, 147, 147, 155, 151, 151, 151, 151, 151, 151,
378 151, 151, 151, 151, 151, 151, 151, 151, 147, 152,
379 147, 153, 147, 153, 153, 147, 156, 147, 147, 147,
380 147, 154, 147, 147, 157, 151, 155, 151, 151, 151,
381
382 151, 151, 151, 151, 151, 151, 151, 151, 151, 147,
383 156, 158, 156, 147, 147, 157, 151, 151, 151, 151,
384 151, 151, 151, 151, 151, 151, 151, 158, 156, 156,
385 151, 151, 151, 151, 151, 151, 151, 151, 151, 151,
386 151, 151, 151, 151, 151, 151, 0, 147, 147, 147,
387 147, 147, 147, 147, 147, 147, 147, 147
388 } ;
389
390 static yyconst short int yy_nxt[272] =
391 { 0,
392 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
393 18, 19, 20, 21, 22, 23, 24, 25, 26, 26,
394 26, 27, 26, 28, 26, 29, 30, 31, 32, 26,
395 33, 26, 34, 26, 26, 35, 36, 37, 26, 38,
396 39, 26, 40, 44, 44, 44, 44, 54, 55, 51,
397 57, 58, 66, 56, 59, 62, 63, 146, 83, 64,
398 83, 56, 67, 69, 45, 45, 71, 70, 145, 85,
399 86, 72, 60, 87, 144, 88, 54, 55, 90, 84,
400 89, 91, 56, 57, 58, 93, 94, 59, 89, 95,
401 56, 62, 63, 143, 83, 64, 83, 85, 86, 85,
402
403 110, 87, 83, 87, 110, 60, 112, 88, 114, 93,
404 94, 115, 89, 95, 110, 84, 112, 142, 129, 86,
405 89, 84, 130, 129, 110, 113, 112, 130, 110, 141,
406 112, 140, 139, 86, 138, 113, 137, 136, 135, 134,
407 133, 132, 131, 94, 115, 113, 115, 86, 127, 113,
408 41, 41, 43, 43, 48, 48, 80, 80, 82, 82,
409 92, 92, 97, 97, 111, 111, 116, 116, 128, 128,
410 126, 125, 124, 123, 122, 121, 120, 119, 118, 63,
411 117, 94, 58, 91, 91, 81, 109, 108, 107, 106,
412 105, 104, 103, 102, 101, 100, 99, 98, 63, 96,
413
414 58, 49, 46, 81, 79, 78, 77, 76, 75, 74,
415 73, 68, 65, 61, 47, 47, 54, 52, 53, 52,
416 50, 49, 47, 46, 147, 42, 42, 7, 147, 147,
417 147, 147, 147, 147, 147, 147, 147, 147, 147, 147,
418 147, 147, 147, 147, 147, 147, 147, 147, 147, 147,
419 147, 147, 147, 147, 147, 147, 147, 147, 147, 147,
420 147, 147, 147, 147, 147, 147, 147, 147, 147, 147,
421 147
422 } ;
423
424 static yyconst short int yy_chk[272] =
425 { 0,
426 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
427 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
428 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
429 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
430 1, 1, 1, 5, 6, 5, 6, 22, 22, 151,
431 23, 23, 30, 22, 23, 28, 28, 144, 43, 28,
432 43, 22, 30, 32, 5, 6, 33, 32, 143, 45,
433 45, 33, 23, 45, 141, 54, 55, 55, 56, 43,
434 54, 56, 55, 57, 57, 60, 60, 57, 54, 60,
435 55, 62, 62, 139, 82, 62, 82, 84, 84, 85,
436
437 85, 84, 85, 85, 87, 57, 87, 88, 89, 93,
438 93, 89, 88, 93, 111, 82, 111, 137, 113, 113,
439 88, 85, 113, 129, 129, 87, 129, 129, 130, 135,
440 130, 134, 133, 128, 127, 111, 124, 123, 122, 121,
441 120, 119, 118, 116, 115, 129, 114, 112, 109, 130,
442 148, 148, 149, 149, 150, 150, 152, 152, 153, 153,
443 154, 154, 155, 155, 156, 156, 157, 157, 158, 158,
444 108, 106, 105, 104, 103, 101, 100, 99, 98, 97,
445 96, 95, 92, 91, 90, 80, 78, 77, 76, 75,
446 74, 73, 70, 69, 68, 67, 66, 65, 64, 61,
447
448 59, 48, 46, 41, 40, 39, 38, 37, 36, 35,
449 34, 31, 29, 27, 25, 24, 21, 19, 16, 15,
450 14, 13, 11, 9, 7, 4, 3, 147, 147, 147,
451 147, 147, 147, 147, 147, 147, 147, 147, 147, 147,
452 147, 147, 147, 147, 147, 147, 147, 147, 147, 147,
453 147, 147, 147, 147, 147, 147, 147, 147, 147, 147,
454 147, 147, 147, 147, 147, 147, 147, 147, 147, 147,
455 147
456 } ;
457
458 static yy_state_type yy_last_accepting_state;
459 static char *yy_last_accepting_cpos;
460
461 /* The intent behind this definition is that it'll catch
462 * any uses of REJECT which flex missed.
463 */
464 #define REJECT reject_used_but_not_detected
465 #define yymore() yymore_used_but_not_detected
466 #define YY_MORE_ADJ 0
467 #define YY_RESTORE_YY_MORE_OFFSET
468 char *yytext;
469 #line 1 "scan.l"
470 #define INITIAL 0
471 /*
472 scan.l -- Algae lexical scanner.
473
474 Copyright (C) 1994-2002 K. Scott Hunziker.
475 Copyright (C) 1990-1994 The Boeing Company.
476
477 See the file COPYING for license, warranty, and permission details.
478 */
479 /* $Id: scan.l,v 1.12 2003/08/07 02:34:09 ksh Exp $ */
480 #line 13 "scan.l"
481
482 #define PSR_DATA_HERE
483
484 #include "algae.h"
485 #include <string.h>
486 #include <ctype.h>
487 #include "entity.h"
488 #include "psr.h"
489 #include "code.h"
490 #include "parse.h"
491 #include "mem.h"
492 #include "pmem.h"
493 #include "exception.h"
494 #include "message.h"
495 #include "print.h"
496 #include "printf.h"
497 #include "error.h"
498
499 int PROTO(yylex, (YYSTYPE *lexval)) ;
500 #define YY_DECL int yylex( lexval ) YYSTYPE *lexval;
501
502 static int PROTO( line_input, ( char *buff, int buffer_size ) );
503
504 #if HAVE_LIBREADLINE
505 extern int use_readline;
506
507 char *PROTO( readline, ( char *prompt ) );
508 char *PROTO( readline_fgets, ( char *s, int n, char *prompt ) );
509 #endif /* HAVE_LIBREADLINE */
510
511 int issue_prompt; /* Give prompt if set. */
512
513 extern double atof() ;
514 static char *PROTO(rm_escape, (char *)) ;
515 static void PROTO(add_to_string, (char *,int)) ;
516 static char *PROTO(get_string, (void)) ;
517
518
519 static int next_offset ;
520 static int max_size ; /* max size string curr_line will hold */
521 static int continuing ; /* helps with prompt */
522 static int eof_flag ; /* only used when non-interactive,
523 to help when last line lacks a newline */
524
525
526
527
528 #define ADJ_OFFSET() curr_offset = next_offset ;\
529 next_offset += yyleng
530
yywrap()531 int yywrap() { return 1; }
532
533 /* this needs to be expanded for non-interactive input */
534 #undef YY_INPUT
535 #define YY_INPUT(buff, result, max_size) \
536 do {\
537 result = line_input((char *)buff, max_size) ; \
538 if ( flush_flag )\
539 { flush_flag = 0 ; BEGIN(0) ; }}while(0)
540
541 static char *input_string; /* input, if commands not coming from file */
542
543 #define FGETS(s, n, stream) \
544 ((stream) ? fgets (s, n, stream) : sgets (s, n, &input_string))
545
546 /*
547 * Like fgets(3), except it reads from the string pointed to by `c' and
548 * then modifies that string to point to the remainder.
549 */
550 static char *
sgets(s,n,c)551 sgets (s, n, c)
552 char *s;
553 int n;
554 char **c;
555 {
556 char *e, *p;
557 int i;
558
559 p = *c;
560 if (!*p) return NULL;
561
562 e = strchr (p, '\n');
563 i = e ? e-p+1 : strlen (p);
564 n--;
565 if (i > n) i = n;
566 memcpy (s, p, i);
567 s[i] = '\0';
568 *c = p+i;
569 return s;
570 }
571
572 static int
line_input(buff,buffer_size)573 line_input (buff, buffer_size)
574 char *buff;
575 int buffer_size;
576 {
577 int len;
578 char *prompt, *more_input;
579
580 SIGINT_RAISE_ON ();
581
582 again:
583 if (issue_prompt && yyin)
584 {
585 if (continuing)
586 {
587 prompt = get_prompt (1);
588 continuing = 0;
589 }
590 else
591 prompt = get_prompt (brace_cnt || flow_cnt);
592
593 #if HAVE_LIBREADLINE
594 if (use_readline)
595 more_input = readline_fgets (buff, buffer_size, prompt);
596 else
597 #endif
598 {
599 #ifdef VAX_VMS
600 xputc ('\n', stderr);
601 #endif
602 xfputs (prompt, stderr);
603 more_input = fgets (buff, buffer_size, yyin);
604 }
605 FREE (prompt);
606 }
607 else
608 more_input = FGETS (buff, buffer_size, yyin);
609
610 if (more_input)
611 {
612 curr_line_no++;
613 len = strlen (buff);
614
615 if (len > max_size)
616 {
617 if (max_size)
618 FREE (curr_line);
619 curr_line = MALLOC (len + 1);
620 max_size = len;
621 }
622
623 (void) strcpy (curr_line, buff);
624 next_offset = 0;
625 }
626 else
627 {
628 if (errno == EINTR)
629 {
630 errno = 0;
631 goto again;
632 }
633 else if (yyin && ferror (yyin))
634 {
635 p_error ("%s", strerror (errno));
636 exit (1);
637 }
638 else /* EOF */
639 len = 0;
640 }
641
642 SIGINT_RAISE_OFF ();
643 return len;
644 }
645
646
647 #if HAVE_LIBREADLINE
648 extern void PROTO (add_history, (char * string));
649
650 char *
readline_fgets(s,n,prompt)651 readline_fgets( s, n, prompt )
652 char *s;
653 int n;
654 char *prompt;
655 {
656 char *line_read = readline( prompt );
657 if ( line_read ) {
658 if ( *line_read ) add_history( line_read );
659 strncpy( s, line_read, n-2 );
660 s[n-2] = '\0';
661 n = strlen( s );
662 s[n] = '\n';
663 s[n+1] = '\0';
664 free( line_read );
665 line_read = s;
666 }
667
668 return line_read;
669 }
670 #endif /* HAVE_LIBREADLINE */
671
672
673 #define FLUSH 1
674
675 #define STRINGING 2
676
677 #line 678 "lex.yy.c"
678
679 /* Macros after this point can all be overridden by user definitions in
680 * section 1.
681 */
682
683 #ifndef YY_SKIP_YYWRAP
684 #ifdef __cplusplus
685 extern "C" int yywrap YY_PROTO(( void ));
686 #else
687 extern int yywrap YY_PROTO(( void ));
688 #endif
689 #endif
690
691 #ifndef YY_NO_UNPUT
692 static void yyunput YY_PROTO(( int c, char *buf_ptr ));
693 #endif
694
695 #ifndef yytext_ptr
696 static void yy_flex_strncpy YY_PROTO(( char *, yyconst char *, int ));
697 #endif
698
699 #ifdef YY_NEED_STRLEN
700 static int yy_flex_strlen YY_PROTO(( yyconst char * ));
701 #endif
702
703 #ifndef YY_NO_INPUT
704 #ifdef __cplusplus
705 static int yyinput YY_PROTO(( void ));
706 #else
707 static int input YY_PROTO(( void ));
708 #endif
709 #endif
710
711 #if YY_STACK_USED
712 static int yy_start_stack_ptr = 0;
713 static int yy_start_stack_depth = 0;
714 static int *yy_start_stack = 0;
715 #ifndef YY_NO_PUSH_STATE
716 static void yy_push_state YY_PROTO(( int new_state ));
717 #endif
718 #ifndef YY_NO_POP_STATE
719 static void yy_pop_state YY_PROTO(( void ));
720 #endif
721 #ifndef YY_NO_TOP_STATE
722 static int yy_top_state YY_PROTO(( void ));
723 #endif
724
725 #else
726 #define YY_NO_PUSH_STATE 1
727 #define YY_NO_POP_STATE 1
728 #define YY_NO_TOP_STATE 1
729 #endif
730
731 #ifdef YY_MALLOC_DECL
732 YY_MALLOC_DECL
733 #else
734 #if __STDC__
735 #ifndef __cplusplus
736 #include <stdlib.h>
737 #endif
738 #else
739 /* Just try to get by without declaring the routines. This will fail
740 * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int)
741 * or sizeof(void*) != sizeof(int).
742 */
743 #endif
744 #endif
745
746 /* Amount of stuff to slurp up with each read. */
747 #ifndef YY_READ_BUF_SIZE
748 #define YY_READ_BUF_SIZE 8192
749 #endif
750
751 /* Copy whatever the last rule matched to the standard output. */
752
753 #ifndef ECHO
754 /* This used to be an fputs(), but since the string might contain NUL's,
755 * we now use fwrite().
756 */
757 #define ECHO (void) fwrite( yytext, yyleng, 1, yyout )
758 #endif
759
760 /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
761 * is returned in "result".
762 */
763 #ifndef YY_INPUT
764 #define YY_INPUT(buf,result,max_size) \
765 if ( yy_current_buffer->yy_is_interactive ) \
766 { \
767 int c = '*', n; \
768 for ( n = 0; n < max_size && \
769 (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
770 buf[n] = (char) c; \
771 if ( c == '\n' ) \
772 buf[n++] = (char) c; \
773 if ( c == EOF && ferror( yyin ) ) \
774 YY_FATAL_ERROR( "input in flex scanner failed" ); \
775 result = n; \
776 } \
777 else if ( ((result = fread( buf, 1, max_size, yyin )) == 0) \
778 && ferror( yyin ) ) \
779 YY_FATAL_ERROR( "input in flex scanner failed" );
780 #endif
781
782 /* No semi-colon after return; correct usage is to write "yyterminate();" -
783 * we don't want an extra ';' after the "return" because that will cause
784 * some compilers to complain about unreachable statements.
785 */
786 #ifndef yyterminate
787 #define yyterminate() return YY_NULL
788 #endif
789
790 /* Number of entries by which start-condition stack grows. */
791 #ifndef YY_START_STACK_INCR
792 #define YY_START_STACK_INCR 25
793 #endif
794
795 /* Report a fatal error. */
796 #ifndef YY_FATAL_ERROR
797 #define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
798 #endif
799
800 /* Default declaration of generated scanner - a define so the user can
801 * easily add parameters.
802 */
803 #ifndef YY_DECL
804 #define YY_DECL int yylex YY_PROTO(( void ))
805 #endif
806
807 /* Code executed at the beginning of each rule, after yytext and yyleng
808 * have been set up.
809 */
810 #ifndef YY_USER_ACTION
811 #define YY_USER_ACTION
812 #endif
813
814 /* Code executed at the end of each rule. */
815 #ifndef YY_BREAK
816 #define YY_BREAK break;
817 #endif
818
819 #define YY_RULE_SETUP \
820 YY_USER_ACTION
821
822 YY_DECL
823 {
824 register yy_state_type yy_current_state;
825 register char *yy_cp = NULL, *yy_bp = NULL;
826 register int yy_act;
827
828 #line 232 "scan.l"
829
830
831 /* this always gets done */
832 if ( flush_flag )
833 { continuing = 0 ; BEGIN(FLUSH) ; }
834
835 #line 836 "lex.yy.c"
836
837 if ( yy_init )
838 {
839 yy_init = 0;
840
841 #ifdef YY_USER_INIT
842 YY_USER_INIT;
843 #endif
844
845 if ( ! yy_start )
846 yy_start = 1; /* first start state */
847
848 if ( ! yyin )
849 yyin = stdin;
850
851 if ( ! yyout )
852 yyout = stdout;
853
854 if ( ! yy_current_buffer )
855 yy_current_buffer =
856 yy_create_buffer( yyin, YY_BUF_SIZE );
857
858 yy_load_buffer_state();
859 }
860
861 while ( 1 ) /* loops until end-of-file is reached */
862 {
863 yy_cp = yy_c_buf_p;
864
865 /* Support of yytext. */
866 *yy_cp = yy_hold_char;
867
868 /* yy_bp points to the position in yy_ch_buf of the start of
869 * the current run.
870 */
871 yy_bp = yy_cp;
872
873 yy_current_state = yy_start;
874 yy_match:
875 do
876 {
877 register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
878 if ( yy_accept[yy_current_state] )
879 {
880 yy_last_accepting_state = yy_current_state;
881 yy_last_accepting_cpos = yy_cp;
882 }
883 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
884 {
885 yy_current_state = (int) yy_def[yy_current_state];
886 if ( yy_current_state >= 148 )
887 yy_c = yy_meta[(unsigned int) yy_c];
888 }
889 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
890 ++yy_cp;
891 }
892 while ( yy_base[yy_current_state] != 228 );
893
894 yy_find_action:
895 yy_act = yy_accept[yy_current_state];
896 if ( yy_act == 0 )
897 { /* have to back up */
898 yy_cp = yy_last_accepting_cpos;
899 yy_current_state = yy_last_accepting_state;
900 yy_act = yy_accept[yy_current_state];
901 }
902
903 YY_DO_BEFORE_ACTION;
904
905
906 do_action: /* This label is used only to access EOF actions. */
907
908
909 switch ( yy_act )
910 { /* beginning of action switch */
911 case 0: /* must back up */
912 /* undo the effects of YY_DO_BEFORE_ACTION */
913 *yy_cp = yy_hold_char;
914 yy_cp = yy_last_accepting_cpos;
915 yy_current_state = yy_last_accepting_state;
916 goto yy_find_action;
917
918 case 1:
919 YY_RULE_SETUP
920 #line 238 "scan.l"
921 { /* eat the line */
922 BEGIN(0) ;
923 }
924 YY_BREAK
925 /*----------------------------------------*/
926 /* keywords are hardwired into the scanner */
927 case 2:
928 YY_RULE_SETUP
929 #line 248 "scan.l"
930 { ADJ_OFFSET() ; return _NULL ; }
931 YY_BREAK
932 case 3:
933 YY_RULE_SETUP
934 #line 249 "scan.l"
935 { ADJ_OFFSET() ; return IF ; }
936 YY_BREAK
937 case 4:
938 YY_RULE_SETUP
939 #line 250 "scan.l"
940 { ADJ_OFFSET() ; return ELSE ; }
941 YY_BREAK
942 case 5:
943 YY_RULE_SETUP
944 #line 251 "scan.l"
945 { ADJ_OFFSET() ; return ELSEIF ; }
946 YY_BREAK
947 case 6:
948 YY_RULE_SETUP
949 #line 252 "scan.l"
950 { ADJ_OFFSET() ; return WHILE ; }
951 YY_BREAK
952 case 7:
953 YY_RULE_SETUP
954 #line 253 "scan.l"
955 { ADJ_OFFSET() ; return BREAK ; }
956 YY_BREAK
957 case 8:
958 YY_RULE_SETUP
959 #line 254 "scan.l"
960 { ADJ_OFFSET() ; return CONTINUE ; }
961 YY_BREAK
962 case 9:
963 YY_RULE_SETUP
964 #line 255 "scan.l"
965 { ADJ_OFFSET() ; return FUNCTION_ ; }
966 YY_BREAK
967 case 10:
968 YY_RULE_SETUP
969 #line 256 "scan.l"
970 { ADJ_OFFSET() ; return FOR ; }
971 YY_BREAK
972 case 11:
973 YY_RULE_SETUP
974 #line 257 "scan.l"
975 { ADJ_OFFSET() ; return IN ; }
976 YY_BREAK
977 case 12:
978 YY_RULE_SETUP
979 #line 258 "scan.l"
980 { ADJ_OFFSET() ; return RETURN ; }
981 YY_BREAK
982 case 13:
983 YY_RULE_SETUP
984 #line 259 "scan.l"
985 { ADJ_OFFSET() ; return LOCAL ; }
986 YY_BREAK
987 case 14:
988 YY_RULE_SETUP
989 #line 260 "scan.l"
990 { ADJ_OFFSET() ; return SELF ; }
991 YY_BREAK
992 case 15:
993 YY_RULE_SETUP
994 #line 261 "scan.l"
995 { ADJ_OFFSET() ; return SYMBOL_TABLE ; }
996 YY_BREAK
997 case 16:
998 YY_RULE_SETUP
999 #line 262 "scan.l"
1000 { ADJ_OFFSET() ; return TRY ; }
1001 YY_BREAK
1002 case 17:
1003 YY_RULE_SETUP
1004 #line 263 "scan.l"
1005 { ADJ_OFFSET() ; return CATCH ; }
1006 YY_BREAK
1007 case 18:
1008 YY_RULE_SETUP
1009 #line 264 "scan.l"
1010 { ADJ_OFFSET() ; return VEIL ; }
1011 YY_BREAK
1012 case 19:
1013 YY_RULE_SETUP
1014 #line 266 "scan.l"
1015 { continuing = 1 ; }
1016 YY_BREAK
1017 case 20:
1018 YY_RULE_SETUP
1019 #line 268 "scan.l"
1020 { ADJ_OFFSET() ;
1021 if ( brace_cnt == 0 ) return '\n' ;
1022 }
1023 YY_BREAK
1024 case 21:
1025 YY_RULE_SETUP
1026 #line 272 "scan.l"
1027 { ADJ_OFFSET() ;
1028 continuing = 1 ;
1029 lexval->ival = 0 ;
1030 return *yytext ;
1031 }
1032 YY_BREAK
1033 case 22:
1034 YY_RULE_SETUP
1035 #line 278 "scan.l"
1036 { ADJ_OFFSET() ;
1037 lexval->ival = 1 ;
1038 return *yytext ;
1039 }
1040 YY_BREAK
1041 case 23:
1042 YY_RULE_SETUP
1043 #line 283 "scan.l"
1044 { ADJ_OFFSET() ;
1045 lexval->ival = 0 ;
1046 return *yytext ;
1047 }
1048 YY_BREAK
1049 case 24:
1050 YY_RULE_SETUP
1051 #line 288 "scan.l"
1052 { ADJ_OFFSET() ; return *yytext ; }
1053 YY_BREAK
1054 case 25:
1055 YY_RULE_SETUP
1056 #line 290 "scan.l"
1057 { ADJ_OFFSET() ; }
1058 YY_BREAK
1059 case 26:
1060 YY_RULE_SETUP
1061 #line 292 "scan.l"
1062 { ADJ_OFFSET() ;
1063 lexval->id_name = strcpy(MALLOC(yyleng+1),yytext) ;
1064 return ID ;
1065 }
1066 YY_BREAK
1067 case 27:
1068 YY_RULE_SETUP
1069 #line 297 "scan.l"
1070 { ADJ_OFFSET() ;
1071 errno = 0;
1072 lexval->datum = new_INT(atoi(yytext)) ;
1073 if ( errno ) {
1074 p_error( "Value out of range." );
1075 raise_exception();
1076 }
1077 return CONSTANT ;
1078 }
1079 YY_BREAK
1080 case 28:
1081 YY_RULE_SETUP
1082 #line 307 "scan.l"
1083 { ADJ_OFFSET() ;
1084 errno = 0;
1085 lexval->datum = new_REAL(atof(yytext)) ;
1086 if ( errno ) {
1087 p_error( "Value out of range." );
1088 raise_exception();
1089 }
1090 return CONSTANT ;
1091 }
1092 YY_BREAK
1093 case 29:
1094 YY_RULE_SETUP
1095 #line 317 "scan.l"
1096 { ADJ_OFFSET() ;
1097 BEGIN(STRINGING) ;
1098 }
1099 YY_BREAK
1100 case 30:
1101 YY_RULE_SETUP
1102 #line 321 "scan.l"
1103 {
1104 char *s = yytext + yyleng - 2 ;
1105
1106 continuing = 1 ;
1107 assert(s>=yytext) ;
1108 while ( *s != '\\')
1109 {
1110 assert(s>yytext) ;
1111 s-- ;
1112 }
1113 *s = 0 ;
1114 add_to_string(yytext,s-yytext) ;
1115 }
1116 YY_BREAK
1117 case 31:
1118 YY_RULE_SETUP
1119 #line 335 "scan.l"
1120 { char * s ;
1121 int last ;
1122
1123 ADJ_OFFSET() ;
1124 last = yytext[yyleng-1] ;
1125 yytext[yyleng-1] = 0 ;
1126 add_to_string(yytext,yyleng-1) ;
1127 s = rm_escape(get_string()) ;
1128
1129 if ( last == '\n' )
1130 {
1131 p_error("Unterminated character scalar:\n\"%s", s) ;
1132 FREE(s) ;
1133 raise_exception() ;
1134 }
1135 /* found end of string */
1136 lexval->cs = strcpy(pmem( strlen(s) + 1 ),s) ;
1137 FREE(s) ;
1138 BEGIN(0) ;
1139 return STRING ;
1140 }
1141 YY_BREAK
1142 case 32:
1143 YY_RULE_SETUP
1144 #line 357 "scan.l"
1145 { /* EOF */
1146 char *s ;
1147
1148 ADJ_OFFSET() ;
1149 add_to_string(yytext,yyleng) ;
1150 p_error("Unterminated character scalar at EOF:\n\"%s",
1151 s = rm_escape(get_string())) ;
1152 FREE(s) ;
1153 raise_exception() ;
1154 }
1155 YY_BREAK
1156 case 33:
1157 YY_RULE_SETUP
1158 #line 369 "scan.l"
1159 { ADJ_OFFSET() ;
1160 lexval->ival = *yytext == '+' ? OP_ADD : OP_SUB ;
1161 return ADDOP ;
1162 }
1163 YY_BREAK
1164 case 34:
1165 YY_RULE_SETUP
1166 #line 374 "scan.l"
1167 { ADJ_OFFSET() ;
1168 lexval->ival = *yytext == '*' ? OP_MUL :
1169 *yytext == '/' ? OP_DIV :
1170 *yytext == '%' ? OP_MOD :
1171 OP_PROD;
1172 return MULOP ;
1173 }
1174 YY_BREAK
1175 case 35:
1176 YY_RULE_SETUP
1177 #line 382 "scan.l"
1178 { ADJ_OFFSET() ;
1179
1180 switch( yytext[0] )
1181 {
1182 case '=' :
1183 lexval->ival = OP_EQ ;
1184 break ;
1185
1186 case '<' :
1187 lexval->ival = yytext[1] ? OP_LTE : OP_LT ;
1188 break ;
1189
1190 case '>' :
1191 lexval->ival = yytext[1] ? OP_GTE : OP_GT ;
1192 break ;
1193
1194 case '!' :
1195 lexval->ival = OP_NE ;
1196 break ;
1197
1198 default :
1199 wipeout("scanner relop") ;
1200 }
1201 return RELOP ;
1202 }
1203 YY_BREAK
1204 case 36:
1205 YY_RULE_SETUP
1206 #line 409 "scan.l"
1207 { ADJ_OFFSET() ;
1208
1209 switch (yytext[0])
1210 {
1211 case '-':
1212 lexval->ival = OP_SUB;
1213 break;
1214 case '+':
1215 lexval->ival = OP_ADD;
1216 break;
1217 case '*':
1218 lexval->ival = OP_MUL;
1219 break;
1220 case '/':
1221 lexval->ival = OP_DIV;
1222 break;
1223 case '@':
1224 lexval->ival = OP_PROD;
1225 break;
1226 case '%':
1227 lexval->ival = OP_MOD;
1228 break;
1229 default:
1230 wipeout ("scanner binop_assign");
1231 }
1232
1233 return BINOP_ASSIGN ;
1234 }
1235 YY_BREAK
1236 case 37:
1237 YY_RULE_SETUP
1238 #line 439 "scan.l"
1239 { ADJ_OFFSET() ; return SHORT_OR ; }
1240 YY_BREAK
1241 case 38:
1242 YY_RULE_SETUP
1243 #line 440 "scan.l"
1244 { ADJ_OFFSET() ; return SHORT_AND ; }
1245 YY_BREAK
1246 case 39:
1247 YY_RULE_SETUP
1248 #line 442 "scan.l"
1249 { ADJ_OFFSET() ; return OR ; }
1250 YY_BREAK
1251 case 40:
1252 YY_RULE_SETUP
1253 #line 443 "scan.l"
1254 { ADJ_OFFSET() ; return AND ; }
1255 YY_BREAK
1256 case 41:
1257 YY_RULE_SETUP
1258 #line 444 "scan.l"
1259 { ADJ_OFFSET() ; return CAT ; }
1260 YY_BREAK
1261 case 42:
1262 YY_RULE_SETUP
1263 #line 445 "scan.l"
1264 { ADJ_OFFSET() ; return TRANS ; }
1265 YY_BREAK
1266 case 43:
1267 YY_RULE_SETUP
1268 #line 448 "scan.l"
1269 { /* anything not covered */
1270 ADJ_OFFSET() ;
1271 if ( yytext[0] )
1272 yyerror("unexpected input character -- ignored") ;
1273 }
1274 YY_BREAK
1275 case YY_STATE_EOF(INITIAL):
1276 case YY_STATE_EOF(FLUSH):
1277 case YY_STATE_EOF(STRINGING):
1278 #line 455 "scan.l"
1279 { if ( !interactive && eof_flag == 0 )
1280 { eof_flag = 1 ; return '\n' /* phoney */ ; }
1281 else return EOF ;
1282 }
1283 YY_BREAK
1284 case 44:
1285 YY_RULE_SETUP
1286 #line 460 "scan.l"
1287 ECHO;
1288 YY_BREAK
1289 #line 1290 "lex.yy.c"
1290
1291 case YY_END_OF_BUFFER:
1292 {
1293 /* Amount of text matched not including the EOB char. */
1294 int yy_amount_of_matched_text = (int) (yy_cp - yytext_ptr) - 1;
1295
1296 /* Undo the effects of YY_DO_BEFORE_ACTION. */
1297 *yy_cp = yy_hold_char;
1298 YY_RESTORE_YY_MORE_OFFSET
1299
1300 if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_NEW )
1301 {
1302 /* We're scanning a new file or input source. It's
1303 * possible that this happened because the user
1304 * just pointed yyin at a new source and called
1305 * yylex(). If so, then we have to assure
1306 * consistency between yy_current_buffer and our
1307 * globals. Here is the right place to do so, because
1308 * this is the first action (other than possibly a
1309 * back-up) that will match for the new input source.
1310 */
1311 yy_n_chars = yy_current_buffer->yy_n_chars;
1312 yy_current_buffer->yy_input_file = yyin;
1313 yy_current_buffer->yy_buffer_status = YY_BUFFER_NORMAL;
1314 }
1315
1316 /* Note that here we test for yy_c_buf_p "<=" to the position
1317 * of the first EOB in the buffer, since yy_c_buf_p will
1318 * already have been incremented past the NUL character
1319 * (since all states make transitions on EOB to the
1320 * end-of-buffer state). Contrast this with the test
1321 * in input().
1322 */
1323 if ( yy_c_buf_p <= &yy_current_buffer->yy_ch_buf[yy_n_chars] )
1324 { /* This was really a NUL. */
1325 yy_state_type yy_next_state;
1326
1327 yy_c_buf_p = yytext_ptr + yy_amount_of_matched_text;
1328
1329 yy_current_state = yy_get_previous_state();
1330
1331 /* Okay, we're now positioned to make the NUL
1332 * transition. We couldn't have
1333 * yy_get_previous_state() go ahead and do it
1334 * for us because it doesn't know how to deal
1335 * with the possibility of jamming (and we don't
1336 * want to build jamming into it because then it
1337 * will run more slowly).
1338 */
1339
1340 yy_next_state = yy_try_NUL_trans( yy_current_state );
1341
1342 yy_bp = yytext_ptr + YY_MORE_ADJ;
1343
1344 if ( yy_next_state )
1345 {
1346 /* Consume the NUL. */
1347 yy_cp = ++yy_c_buf_p;
1348 yy_current_state = yy_next_state;
1349 goto yy_match;
1350 }
1351
1352 else
1353 {
1354 yy_cp = yy_c_buf_p;
1355 goto yy_find_action;
1356 }
1357 }
1358
1359 else switch ( yy_get_next_buffer() )
1360 {
1361 case EOB_ACT_END_OF_FILE:
1362 {
1363 yy_did_buffer_switch_on_eof = 0;
1364
1365 if ( yywrap() )
1366 {
1367 /* Note: because we've taken care in
1368 * yy_get_next_buffer() to have set up
1369 * yytext, we can now set up
1370 * yy_c_buf_p so that if some total
1371 * hoser (like flex itself) wants to
1372 * call the scanner after we return the
1373 * YY_NULL, it'll still work - another
1374 * YY_NULL will get returned.
1375 */
1376 yy_c_buf_p = yytext_ptr + YY_MORE_ADJ;
1377
1378 yy_act = YY_STATE_EOF(YY_START);
1379 goto do_action;
1380 }
1381
1382 else
1383 {
1384 if ( ! yy_did_buffer_switch_on_eof )
1385 YY_NEW_FILE;
1386 }
1387 break;
1388 }
1389
1390 case EOB_ACT_CONTINUE_SCAN:
1391 yy_c_buf_p =
1392 yytext_ptr + yy_amount_of_matched_text;
1393
1394 yy_current_state = yy_get_previous_state();
1395
1396 yy_cp = yy_c_buf_p;
1397 yy_bp = yytext_ptr + YY_MORE_ADJ;
1398 goto yy_match;
1399
1400 case EOB_ACT_LAST_MATCH:
1401 yy_c_buf_p =
1402 &yy_current_buffer->yy_ch_buf[yy_n_chars];
1403
1404 yy_current_state = yy_get_previous_state();
1405
1406 yy_cp = yy_c_buf_p;
1407 yy_bp = yytext_ptr + YY_MORE_ADJ;
1408 goto yy_find_action;
1409 }
1410 break;
1411 }
1412
1413 default:
1414 YY_FATAL_ERROR(
1415 "fatal flex scanner internal error--no action found" );
1416 } /* end of action switch */
1417 } /* end of scanning one token */
1418 } /* end of yylex */
1419
1420
1421 /* yy_get_next_buffer - try to read in a new buffer
1422 *
1423 * Returns a code representing an action:
1424 * EOB_ACT_LAST_MATCH -
1425 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1426 * EOB_ACT_END_OF_FILE - end of file
1427 */
1428
yy_get_next_buffer()1429 static int yy_get_next_buffer()
1430 {
1431 register char *dest = yy_current_buffer->yy_ch_buf;
1432 register char *source = yytext_ptr;
1433 register int number_to_move, i;
1434 int ret_val;
1435
1436 if ( yy_c_buf_p > &yy_current_buffer->yy_ch_buf[yy_n_chars + 1] )
1437 YY_FATAL_ERROR(
1438 "fatal flex scanner internal error--end of buffer missed" );
1439
1440 if ( yy_current_buffer->yy_fill_buffer == 0 )
1441 { /* Don't try to fill the buffer, so this is an EOF. */
1442 if ( yy_c_buf_p - yytext_ptr - YY_MORE_ADJ == 1 )
1443 {
1444 /* We matched a single character, the EOB, so
1445 * treat this as a final EOF.
1446 */
1447 return EOB_ACT_END_OF_FILE;
1448 }
1449
1450 else
1451 {
1452 /* We matched some text prior to the EOB, first
1453 * process it.
1454 */
1455 return EOB_ACT_LAST_MATCH;
1456 }
1457 }
1458
1459 /* Try to read more data. */
1460
1461 /* First move last chars to start of buffer. */
1462 number_to_move = (int) (yy_c_buf_p - yytext_ptr) - 1;
1463
1464 for ( i = 0; i < number_to_move; ++i )
1465 *(dest++) = *(source++);
1466
1467 if ( yy_current_buffer->yy_buffer_status == YY_BUFFER_EOF_PENDING )
1468 /* don't do the read, it's not guaranteed to return an EOF,
1469 * just force an EOF
1470 */
1471 yy_current_buffer->yy_n_chars = yy_n_chars = 0;
1472
1473 else
1474 {
1475 int num_to_read =
1476 yy_current_buffer->yy_buf_size - number_to_move - 1;
1477
1478 while ( num_to_read <= 0 )
1479 { /* Not enough room in the buffer - grow it. */
1480 #ifdef YY_USES_REJECT
1481 YY_FATAL_ERROR(
1482 "input buffer overflow, can't enlarge buffer because scanner uses REJECT" );
1483 #else
1484
1485 /* just a shorter name for the current buffer */
1486 YY_BUFFER_STATE b = yy_current_buffer;
1487
1488 int yy_c_buf_p_offset =
1489 (int) (yy_c_buf_p - b->yy_ch_buf);
1490
1491 if ( b->yy_is_our_buffer )
1492 {
1493 int new_size = b->yy_buf_size * 2;
1494
1495 if ( new_size <= 0 )
1496 b->yy_buf_size += b->yy_buf_size / 8;
1497 else
1498 b->yy_buf_size *= 2;
1499
1500 b->yy_ch_buf = (char *)
1501 /* Include room in for 2 EOB chars. */
1502 yy_flex_realloc( (void *) b->yy_ch_buf,
1503 b->yy_buf_size + 2 );
1504 }
1505 else
1506 /* Can't grow it, we don't own it. */
1507 b->yy_ch_buf = 0;
1508
1509 if ( ! b->yy_ch_buf )
1510 YY_FATAL_ERROR(
1511 "fatal error - scanner input buffer overflow" );
1512
1513 yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
1514
1515 num_to_read = yy_current_buffer->yy_buf_size -
1516 number_to_move - 1;
1517 #endif
1518 }
1519
1520 if ( num_to_read > YY_READ_BUF_SIZE )
1521 num_to_read = YY_READ_BUF_SIZE;
1522
1523 /* Read in more data. */
1524 YY_INPUT( (&yy_current_buffer->yy_ch_buf[number_to_move]),
1525 yy_n_chars, num_to_read );
1526
1527 yy_current_buffer->yy_n_chars = yy_n_chars;
1528 }
1529
1530 if ( yy_n_chars == 0 )
1531 {
1532 if ( number_to_move == YY_MORE_ADJ )
1533 {
1534 ret_val = EOB_ACT_END_OF_FILE;
1535 yyrestart( yyin );
1536 }
1537
1538 else
1539 {
1540 ret_val = EOB_ACT_LAST_MATCH;
1541 yy_current_buffer->yy_buffer_status =
1542 YY_BUFFER_EOF_PENDING;
1543 }
1544 }
1545
1546 else
1547 ret_val = EOB_ACT_CONTINUE_SCAN;
1548
1549 yy_n_chars += number_to_move;
1550 yy_current_buffer->yy_ch_buf[yy_n_chars] = YY_END_OF_BUFFER_CHAR;
1551 yy_current_buffer->yy_ch_buf[yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
1552
1553 yytext_ptr = &yy_current_buffer->yy_ch_buf[0];
1554
1555 return ret_val;
1556 }
1557
1558
1559 /* yy_get_previous_state - get the state just before the EOB char was reached */
1560
yy_get_previous_state()1561 static yy_state_type yy_get_previous_state()
1562 {
1563 register yy_state_type yy_current_state;
1564 register char *yy_cp;
1565
1566 yy_current_state = yy_start;
1567
1568 for ( yy_cp = yytext_ptr + YY_MORE_ADJ; yy_cp < yy_c_buf_p; ++yy_cp )
1569 {
1570 register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1571 if ( yy_accept[yy_current_state] )
1572 {
1573 yy_last_accepting_state = yy_current_state;
1574 yy_last_accepting_cpos = yy_cp;
1575 }
1576 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1577 {
1578 yy_current_state = (int) yy_def[yy_current_state];
1579 if ( yy_current_state >= 148 )
1580 yy_c = yy_meta[(unsigned int) yy_c];
1581 }
1582 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1583 }
1584
1585 return yy_current_state;
1586 }
1587
1588
1589 /* yy_try_NUL_trans - try to make a transition on the NUL character
1590 *
1591 * synopsis
1592 * next_state = yy_try_NUL_trans( current_state );
1593 */
1594
1595 #ifdef YY_USE_PROTOS
yy_try_NUL_trans(yy_state_type yy_current_state)1596 static yy_state_type yy_try_NUL_trans( yy_state_type yy_current_state )
1597 #else
1598 static yy_state_type yy_try_NUL_trans( yy_current_state )
1599 yy_state_type yy_current_state;
1600 #endif
1601 {
1602 register int yy_is_jam;
1603 register char *yy_cp = yy_c_buf_p;
1604
1605 register YY_CHAR yy_c = 1;
1606 if ( yy_accept[yy_current_state] )
1607 {
1608 yy_last_accepting_state = yy_current_state;
1609 yy_last_accepting_cpos = yy_cp;
1610 }
1611 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1612 {
1613 yy_current_state = (int) yy_def[yy_current_state];
1614 if ( yy_current_state >= 148 )
1615 yy_c = yy_meta[(unsigned int) yy_c];
1616 }
1617 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1618 yy_is_jam = (yy_current_state == 147);
1619
1620 return yy_is_jam ? 0 : yy_current_state;
1621 }
1622
1623
1624 #ifndef YY_NO_UNPUT
1625 #ifdef YY_USE_PROTOS
yyunput(int c,register char * yy_bp)1626 static void yyunput( int c, register char *yy_bp )
1627 #else
1628 static void yyunput( c, yy_bp )
1629 int c;
1630 register char *yy_bp;
1631 #endif
1632 {
1633 register char *yy_cp = yy_c_buf_p;
1634
1635 /* undo effects of setting up yytext */
1636 *yy_cp = yy_hold_char;
1637
1638 if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
1639 { /* need to shift things up to make room */
1640 /* +2 for EOB chars. */
1641 register int number_to_move = yy_n_chars + 2;
1642 register char *dest = &yy_current_buffer->yy_ch_buf[
1643 yy_current_buffer->yy_buf_size + 2];
1644 register char *source =
1645 &yy_current_buffer->yy_ch_buf[number_to_move];
1646
1647 while ( source > yy_current_buffer->yy_ch_buf )
1648 *--dest = *--source;
1649
1650 yy_cp += (int) (dest - source);
1651 yy_bp += (int) (dest - source);
1652 yy_current_buffer->yy_n_chars =
1653 yy_n_chars = yy_current_buffer->yy_buf_size;
1654
1655 if ( yy_cp < yy_current_buffer->yy_ch_buf + 2 )
1656 YY_FATAL_ERROR( "flex scanner push-back overflow" );
1657 }
1658
1659 *--yy_cp = (char) c;
1660
1661
1662 yytext_ptr = yy_bp;
1663 yy_hold_char = *yy_cp;
1664 yy_c_buf_p = yy_cp;
1665 }
1666 #endif /* ifndef YY_NO_UNPUT */
1667
1668
1669 #ifndef YY_NO_INPUT
1670 #ifdef __cplusplus
yyinput()1671 static int yyinput()
1672 #else
1673 static int input()
1674 #endif
1675 {
1676 int c;
1677
1678 *yy_c_buf_p = yy_hold_char;
1679
1680 if ( *yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
1681 {
1682 /* yy_c_buf_p now points to the character we want to return.
1683 * If this occurs *before* the EOB characters, then it's a
1684 * valid NUL; if not, then we've hit the end of the buffer.
1685 */
1686 if ( yy_c_buf_p < &yy_current_buffer->yy_ch_buf[yy_n_chars] )
1687 /* This was really a NUL. */
1688 *yy_c_buf_p = '\0';
1689
1690 else
1691 { /* need more input */
1692 int offset = yy_c_buf_p - yytext_ptr;
1693 ++yy_c_buf_p;
1694
1695 switch ( yy_get_next_buffer() )
1696 {
1697 case EOB_ACT_LAST_MATCH:
1698 /* This happens because yy_g_n_b()
1699 * sees that we've accumulated a
1700 * token and flags that we need to
1701 * try matching the token before
1702 * proceeding. But for input(),
1703 * there's no matching to consider.
1704 * So convert the EOB_ACT_LAST_MATCH
1705 * to EOB_ACT_END_OF_FILE.
1706 */
1707
1708 /* Reset buffer status. */
1709 yyrestart( yyin );
1710
1711 /* fall through */
1712
1713 case EOB_ACT_END_OF_FILE:
1714 {
1715 if ( yywrap() )
1716 return EOF;
1717
1718 if ( ! yy_did_buffer_switch_on_eof )
1719 YY_NEW_FILE;
1720 #ifdef __cplusplus
1721 return yyinput();
1722 #else
1723 return input();
1724 #endif
1725 }
1726
1727 case EOB_ACT_CONTINUE_SCAN:
1728 yy_c_buf_p = yytext_ptr + offset;
1729 break;
1730 }
1731 }
1732 }
1733
1734 c = *(unsigned char *) yy_c_buf_p; /* cast for 8-bit char's */
1735 *yy_c_buf_p = '\0'; /* preserve yytext */
1736 yy_hold_char = *++yy_c_buf_p;
1737
1738
1739 return c;
1740 }
1741 #endif /* YY_NO_INPUT */
1742
1743 #ifdef YY_USE_PROTOS
yyrestart(FILE * input_file)1744 void yyrestart( FILE *input_file )
1745 #else
1746 void yyrestart( input_file )
1747 FILE *input_file;
1748 #endif
1749 {
1750 if ( ! yy_current_buffer )
1751 yy_current_buffer = yy_create_buffer( yyin, YY_BUF_SIZE );
1752
1753 yy_init_buffer( yy_current_buffer, input_file );
1754 yy_load_buffer_state();
1755 }
1756
1757
1758 #ifdef YY_USE_PROTOS
yy_switch_to_buffer(YY_BUFFER_STATE new_buffer)1759 void yy_switch_to_buffer( YY_BUFFER_STATE new_buffer )
1760 #else
1761 void yy_switch_to_buffer( new_buffer )
1762 YY_BUFFER_STATE new_buffer;
1763 #endif
1764 {
1765 if ( yy_current_buffer == new_buffer )
1766 return;
1767
1768 if ( yy_current_buffer )
1769 {
1770 /* Flush out information for old buffer. */
1771 *yy_c_buf_p = yy_hold_char;
1772 yy_current_buffer->yy_buf_pos = yy_c_buf_p;
1773 yy_current_buffer->yy_n_chars = yy_n_chars;
1774 }
1775
1776 yy_current_buffer = new_buffer;
1777 yy_load_buffer_state();
1778
1779 /* We don't actually know whether we did this switch during
1780 * EOF (yywrap()) processing, but the only time this flag
1781 * is looked at is after yywrap() is called, so it's safe
1782 * to go ahead and always set it.
1783 */
1784 yy_did_buffer_switch_on_eof = 1;
1785 }
1786
1787
1788 #ifdef YY_USE_PROTOS
yy_load_buffer_state(void)1789 void yy_load_buffer_state( void )
1790 #else
1791 void yy_load_buffer_state()
1792 #endif
1793 {
1794 yy_n_chars = yy_current_buffer->yy_n_chars;
1795 yytext_ptr = yy_c_buf_p = yy_current_buffer->yy_buf_pos;
1796 yyin = yy_current_buffer->yy_input_file;
1797 yy_hold_char = *yy_c_buf_p;
1798 }
1799
1800
1801 #ifdef YY_USE_PROTOS
yy_create_buffer(FILE * file,int size)1802 YY_BUFFER_STATE yy_create_buffer( FILE *file, int size )
1803 #else
1804 YY_BUFFER_STATE yy_create_buffer( file, size )
1805 FILE *file;
1806 int size;
1807 #endif
1808 {
1809 YY_BUFFER_STATE b;
1810
1811 b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
1812 if ( ! b )
1813 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1814
1815 b->yy_buf_size = size;
1816
1817 /* yy_ch_buf has to be 2 characters longer than the size given because
1818 * we need to put in 2 end-of-buffer characters.
1819 */
1820 b->yy_ch_buf = (char *) yy_flex_alloc( b->yy_buf_size + 2 );
1821 if ( ! b->yy_ch_buf )
1822 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1823
1824 b->yy_is_our_buffer = 1;
1825
1826 yy_init_buffer( b, file );
1827
1828 return b;
1829 }
1830
1831
1832 #ifdef YY_USE_PROTOS
yy_delete_buffer(YY_BUFFER_STATE b)1833 void yy_delete_buffer( YY_BUFFER_STATE b )
1834 #else
1835 void yy_delete_buffer( b )
1836 YY_BUFFER_STATE b;
1837 #endif
1838 {
1839 if ( ! b )
1840 return;
1841
1842 if ( b == yy_current_buffer )
1843 yy_current_buffer = (YY_BUFFER_STATE) 0;
1844
1845 if ( b->yy_is_our_buffer )
1846 yy_flex_free( (void *) b->yy_ch_buf );
1847
1848 yy_flex_free( (void *) b );
1849 }
1850
1851
1852
1853 #ifdef YY_USE_PROTOS
yy_init_buffer(YY_BUFFER_STATE b,FILE * file)1854 void yy_init_buffer( YY_BUFFER_STATE b, FILE *file )
1855 #else
1856 void yy_init_buffer( b, file )
1857 YY_BUFFER_STATE b;
1858 FILE *file;
1859 #endif
1860
1861
1862 {
1863 yy_flush_buffer( b );
1864
1865 b->yy_input_file = file;
1866 b->yy_fill_buffer = 1;
1867
1868 #if YY_ALWAYS_INTERACTIVE
1869 b->yy_is_interactive = 1;
1870 #else
1871 #if YY_NEVER_INTERACTIVE
1872 b->yy_is_interactive = 0;
1873 #else
1874 b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
1875 #endif
1876 #endif
1877 }
1878
1879
1880 #ifdef YY_USE_PROTOS
yy_flush_buffer(YY_BUFFER_STATE b)1881 void yy_flush_buffer( YY_BUFFER_STATE b )
1882 #else
1883 void yy_flush_buffer( b )
1884 YY_BUFFER_STATE b;
1885 #endif
1886
1887 {
1888 if ( ! b )
1889 return;
1890
1891 b->yy_n_chars = 0;
1892
1893 /* We always need two end-of-buffer characters. The first causes
1894 * a transition to the end-of-buffer state. The second causes
1895 * a jam in that state.
1896 */
1897 b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1898 b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1899
1900 b->yy_buf_pos = &b->yy_ch_buf[0];
1901
1902 b->yy_at_bol = 1;
1903 b->yy_buffer_status = YY_BUFFER_NEW;
1904
1905 if ( b == yy_current_buffer )
1906 yy_load_buffer_state();
1907 }
1908
1909
1910 #ifndef YY_NO_SCAN_BUFFER
1911 #ifdef YY_USE_PROTOS
yy_scan_buffer(char * base,yy_size_t size)1912 YY_BUFFER_STATE yy_scan_buffer( char *base, yy_size_t size )
1913 #else
1914 YY_BUFFER_STATE yy_scan_buffer( base, size )
1915 char *base;
1916 yy_size_t size;
1917 #endif
1918 {
1919 YY_BUFFER_STATE b;
1920
1921 if ( size < 2 ||
1922 base[size-2] != YY_END_OF_BUFFER_CHAR ||
1923 base[size-1] != YY_END_OF_BUFFER_CHAR )
1924 /* They forgot to leave room for the EOB's. */
1925 return 0;
1926
1927 b = (YY_BUFFER_STATE) yy_flex_alloc( sizeof( struct yy_buffer_state ) );
1928 if ( ! b )
1929 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
1930
1931 b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
1932 b->yy_buf_pos = b->yy_ch_buf = base;
1933 b->yy_is_our_buffer = 0;
1934 b->yy_input_file = 0;
1935 b->yy_n_chars = b->yy_buf_size;
1936 b->yy_is_interactive = 0;
1937 b->yy_at_bol = 1;
1938 b->yy_fill_buffer = 0;
1939 b->yy_buffer_status = YY_BUFFER_NEW;
1940
1941 yy_switch_to_buffer( b );
1942
1943 return b;
1944 }
1945 #endif
1946
1947
1948 #ifndef YY_NO_SCAN_STRING
1949 #ifdef YY_USE_PROTOS
yy_scan_string(yyconst char * yy_str)1950 YY_BUFFER_STATE yy_scan_string( yyconst char *yy_str )
1951 #else
1952 YY_BUFFER_STATE yy_scan_string( yy_str )
1953 yyconst char *yy_str;
1954 #endif
1955 {
1956 int len;
1957 for ( len = 0; yy_str[len]; ++len )
1958 ;
1959
1960 return yy_scan_bytes( yy_str, len );
1961 }
1962 #endif
1963
1964
1965 #ifndef YY_NO_SCAN_BYTES
1966 #ifdef YY_USE_PROTOS
yy_scan_bytes(yyconst char * bytes,int len)1967 YY_BUFFER_STATE yy_scan_bytes( yyconst char *bytes, int len )
1968 #else
1969 YY_BUFFER_STATE yy_scan_bytes( bytes, len )
1970 yyconst char *bytes;
1971 int len;
1972 #endif
1973 {
1974 YY_BUFFER_STATE b;
1975 char *buf;
1976 yy_size_t n;
1977 int i;
1978
1979 /* Get memory for full buffer, including space for trailing EOB's. */
1980 n = len + 2;
1981 buf = (char *) yy_flex_alloc( n );
1982 if ( ! buf )
1983 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
1984
1985 for ( i = 0; i < len; ++i )
1986 buf[i] = bytes[i];
1987
1988 buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;
1989
1990 b = yy_scan_buffer( buf, n );
1991 if ( ! b )
1992 YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
1993
1994 /* It's okay to grow etc. this buffer, and we should throw it
1995 * away when we're done.
1996 */
1997 b->yy_is_our_buffer = 1;
1998
1999 return b;
2000 }
2001 #endif
2002
2003
2004 #ifndef YY_NO_PUSH_STATE
2005 #ifdef YY_USE_PROTOS
yy_push_state(int new_state)2006 static void yy_push_state( int new_state )
2007 #else
2008 static void yy_push_state( new_state )
2009 int new_state;
2010 #endif
2011 {
2012 if ( yy_start_stack_ptr >= yy_start_stack_depth )
2013 {
2014 yy_size_t new_size;
2015
2016 yy_start_stack_depth += YY_START_STACK_INCR;
2017 new_size = yy_start_stack_depth * sizeof( int );
2018
2019 if ( ! yy_start_stack )
2020 yy_start_stack = (int *) yy_flex_alloc( new_size );
2021
2022 else
2023 yy_start_stack = (int *) yy_flex_realloc(
2024 (void *) yy_start_stack, new_size );
2025
2026 if ( ! yy_start_stack )
2027 YY_FATAL_ERROR(
2028 "out of memory expanding start-condition stack" );
2029 }
2030
2031 yy_start_stack[yy_start_stack_ptr++] = YY_START;
2032
2033 BEGIN(new_state);
2034 }
2035 #endif
2036
2037
2038 #ifndef YY_NO_POP_STATE
yy_pop_state()2039 static void yy_pop_state()
2040 {
2041 if ( --yy_start_stack_ptr < 0 )
2042 YY_FATAL_ERROR( "start-condition stack underflow" );
2043
2044 BEGIN(yy_start_stack[yy_start_stack_ptr]);
2045 }
2046 #endif
2047
2048
2049 #ifndef YY_NO_TOP_STATE
yy_top_state()2050 static int yy_top_state()
2051 {
2052 return yy_start_stack[yy_start_stack_ptr - 1];
2053 }
2054 #endif
2055
2056 #ifndef YY_EXIT_FAILURE
2057 #define YY_EXIT_FAILURE 2
2058 #endif
2059
2060 #ifdef YY_USE_PROTOS
yy_fatal_error(yyconst char msg[])2061 static void yy_fatal_error( yyconst char msg[] )
2062 #else
2063 static void yy_fatal_error( msg )
2064 char msg[];
2065 #endif
2066 {
2067 (void) fprintf( stderr, "%s\n", msg );
2068 exit( YY_EXIT_FAILURE );
2069 }
2070
2071
2072
2073 /* Redefine yyless() so it works in section 3 code. */
2074
2075 #undef yyless
2076 #define yyless(n) \
2077 do \
2078 { \
2079 /* Undo effects of setting up yytext. */ \
2080 yytext[yyleng] = yy_hold_char; \
2081 yy_c_buf_p = yytext + n; \
2082 yy_hold_char = *yy_c_buf_p; \
2083 *yy_c_buf_p = '\0'; \
2084 yyleng = n; \
2085 } \
2086 while ( 0 )
2087
2088
2089 /* Internal utility routines. */
2090
2091 #ifndef yytext_ptr
2092 #ifdef YY_USE_PROTOS
yy_flex_strncpy(char * s1,yyconst char * s2,int n)2093 static void yy_flex_strncpy( char *s1, yyconst char *s2, int n )
2094 #else
2095 static void yy_flex_strncpy( s1, s2, n )
2096 char *s1;
2097 yyconst char *s2;
2098 int n;
2099 #endif
2100 {
2101 register int i;
2102 for ( i = 0; i < n; ++i )
2103 s1[i] = s2[i];
2104 }
2105 #endif
2106
2107 #ifdef YY_NEED_STRLEN
2108 #ifdef YY_USE_PROTOS
yy_flex_strlen(yyconst char * s)2109 static int yy_flex_strlen( yyconst char *s )
2110 #else
2111 static int yy_flex_strlen( s )
2112 yyconst char *s;
2113 #endif
2114 {
2115 register int n;
2116 for ( n = 0; s[n]; ++n )
2117 ;
2118
2119 return n;
2120 }
2121 #endif
2122
2123
2124 #ifdef YY_USE_PROTOS
yy_flex_alloc(yy_size_t size)2125 static void *yy_flex_alloc( yy_size_t size )
2126 #else
2127 static void *yy_flex_alloc( size )
2128 yy_size_t size;
2129 #endif
2130 {
2131 return (void *) malloc( size );
2132 }
2133
2134 #ifdef YY_USE_PROTOS
yy_flex_realloc(void * ptr,yy_size_t size)2135 static void *yy_flex_realloc( void *ptr, yy_size_t size )
2136 #else
2137 static void *yy_flex_realloc( ptr, size )
2138 void *ptr;
2139 yy_size_t size;
2140 #endif
2141 {
2142 /* The cast to (char *) in the following accommodates both
2143 * implementations that use char* generic pointers, and those
2144 * that use void* generic pointers. It works with the latter
2145 * because both ANSI C and C++ allow castless assignment from
2146 * any pointer type to void*, and deal with argument conversions
2147 * as though doing an assignment.
2148 */
2149 return (void *) realloc( (char *) ptr, size );
2150 }
2151
2152 #ifdef YY_USE_PROTOS
yy_flex_free(void * ptr)2153 static void yy_flex_free( void *ptr )
2154 #else
2155 static void yy_flex_free( ptr )
2156 void *ptr;
2157 #endif
2158 {
2159 free( ptr );
2160 }
2161
2162 #if YY_MAIN
main()2163 int main()
2164 {
2165 yylex();
2166 return 0;
2167 }
2168 #endif
2169 #line 460 "scan.l"
2170
2171
2172
2173 typedef struct ps_state
2174 {
2175 struct ps_state *link;
2176 YY_BUFFER_STATE buffer_state;
2177 FILE *yyin;
2178 char *input_string;
2179 char *curr_line;
2180 int curr_line_no;
2181 char *curr_file;
2182 int max_size;
2183 int eof_flag;
2184
2185 int flush_flag;
2186 int interaction;
2187 int prompting;
2188 int brace_cnt;
2189 int flow_cnt;
2190 CODE_BLOCK code_block;
2191 struct pm saved_pmem;
2192 void *jmp_top;
2193 void *bc_top;
2194 }
2195 PS_STATE;
2196
2197 extern int interactive;
2198
2199 /*
2200 * The `stdin_is_interactive' flag may be set in `initialize'. If it's set,
2201 * then we use interactive mode for stdin whether it looks like a terminal
2202 * or not.
2203 */
2204 extern int stdin_is_interactive;
2205
2206 static PS_STATE *ps_state_list;
2207
2208 /*
2209 * Use `push_parser_scanner_state' to save the parser's state (the file
2210 * from which it's reading, along with globals like `interactive', etc.)
2211 * and change to a new one.
2212 */
2213
2214 void
push_parser_scanner_state(fp,file_name)2215 push_parser_scanner_state (fp, file_name)
2216 FILE *fp;
2217 char *file_name;
2218 {
2219 /*
2220 * If `fp' is NULL, then `file_name' is a pointer to a command string.
2221 * Otherwise, `fp' points to the input file, and `file_name' is its name.
2222 * The `file_name' string is not FREE'd.
2223 */
2224
2225 PS_STATE *p = MALLOC (sizeof (PS_STATE));
2226
2227 p->link = ps_state_list;
2228 ps_state_list = p;
2229
2230 p->buffer_state = YY_CURRENT_BUFFER;
2231 p->yyin = yyin;
2232 yyin = fp;
2233 p->input_string = input_string;
2234 input_string = fp ? NULL : file_name;
2235 yy_switch_to_buffer (yy_create_buffer (yyin, YY_BUF_SIZE));
2236
2237 p->interaction = interactive;
2238 p->prompting = issue_prompt;
2239
2240 issue_prompt = fp && isatty (fileno (fp));
2241 interactive = issue_prompt || stdin_is_interactive && fp == stdin;
2242
2243 continuing = 0;
2244
2245 p->curr_line = curr_line;
2246 curr_line = (char *) 0;
2247 p->max_size = max_size;
2248 max_size = 0;
2249 p->curr_line_no = curr_line_no;
2250 curr_line_no = 0;
2251 p->curr_file = curr_file;
2252 curr_file = file_name;
2253
2254 p->eof_flag = eof_flag;
2255 eof_flag = 0;
2256 p->flush_flag = flush_flag;
2257 flush_flag = 0;
2258 p->brace_cnt = brace_cnt;
2259 brace_cnt = 0;
2260 p->flow_cnt = flow_cnt;
2261 flow_cnt = 0;
2262
2263 p->code_block = the_code_block;
2264 new_code_block ();
2265
2266 p->saved_pmem = active_pmem;
2267 (void) memset (&active_pmem, 0, sizeof (active_pmem));
2268
2269 p->jmp_top = jmp_top_push ();
2270 p->bc_top = bc_top_push ();
2271 }
2272
2273 void
pop_parser_scanner_state()2274 pop_parser_scanner_state ()
2275 {
2276 PS_STATE *p;
2277
2278 assert (ps_state_list);
2279
2280 p = ps_state_list;
2281 ps_state_list = p->link;
2282
2283 yyin = p->yyin;
2284 input_string = p->input_string;
2285 yy_delete_buffer (YY_CURRENT_BUFFER);
2286 if (p->buffer_state)
2287 yy_switch_to_buffer (p->buffer_state);
2288
2289 interactive = p->interaction;
2290 issue_prompt = p->prompting;
2291
2292 continuing = 0;
2293
2294 if (curr_line)
2295 FREE (curr_line);
2296 curr_line = p->curr_line;
2297 max_size = p->max_size;
2298 curr_line_no = p->curr_line_no;
2299 curr_file = p->curr_file;
2300
2301 flush_flag = p->flush_flag;
2302 eof_flag = p->eof_flag;
2303 brace_cnt = p->brace_cnt;
2304 flow_cnt = p->flow_cnt;
2305
2306 FREE (code_base);
2307 the_code_block = p->code_block;
2308
2309 free_all_pmem ();
2310 active_pmem = p->saved_pmem;
2311
2312 jmp_top_pop (p->jmp_top);
2313 bc_top_pop (p->bc_top);
2314
2315 FREE (p);
2316 }
2317
2318
2319 /*---------- process escape characters in strings ----*/
2320
2321
2322 #define isoctal(x) ((x)>='0'&&(x)<='7')
2323
2324 #define hex_value(x) ((x)<='F'?(x)-'A'+10:(x)-'a'+10)
2325
2326
2327 /* process one , two or three octal digits
2328 moving a pointer forward by reference */
octal(start_p)2329 static int octal( start_p )
2330 char **start_p ;
2331 { register char *p = *start_p ;
2332 register unsigned x ;
2333
2334 x = *p++ - '0' ;
2335 if ( isoctal(*p) )
2336 {
2337 x = (x<<3) + *p++ - '0' ;
2338 if ( isoctal(*p) ) x = (x<<3) + *p++ - '0' ;
2339 }
2340 *start_p = p ;
2341 return x & 0xff ;
2342 }
2343
2344 /* process one or two hex digits
2345 moving a pointer forward by reference */
2346
hex(start_p)2347 static int hex( start_p )
2348 char **start_p ;
2349 { register unsigned char *p = (unsigned char*) *start_p ;
2350 register unsigned x ;
2351
2352 if ( isdigit(*p) ) x = *p - '0' ;
2353 else x = hex_value(*p) ;
2354 p++ ;
2355
2356 if ( isdigit(*p) ) x = (x<<4) + *p++ - '0' ;
2357 else
2358 if ( isxdigit(*p) )
2359 { x = (x<<4) + hex_value(*p) ; p++ ; }
2360
2361 *start_p = (char *) p ;
2362 return x ;
2363 }
2364
2365 #define NUM_ESCAPE_CHARS 8
2366
2367 static struct { char in , out ; }
2368 escape_test[NUM_ESCAPE_CHARS+1] = {
2369 'n' , '\n', /* newline */
2370 't' , '\t', /* tab */
2371 'f' , '\f', /* formfeed */
2372 'b' , '\b', /* backspace */
2373 'r' , '\r', /* carriage return */
2374 'a' , '\07', /* bell */
2375 'v' , '\013', /* vertical tab */
2376 'e' , '\033', /* escape */
2377 0 , 0
2378 };
2379
2380 /* all other escaped chars stand for themselves */
2381
2382
2383 /* process the escape characters in a string, in place . */
2384
rm_escape(s)2385 static char *rm_escape(s)
2386 char *s ;
2387 { char *p, *q ;
2388 char *t ;
2389 int i ;
2390
2391 q = p = s ;
2392
2393 while ( *p )
2394 if ( *p == '\\' )
2395 {
2396 escape_test[NUM_ESCAPE_CHARS].in = * ++p ; /* sentinel */
2397 i = 0 ;
2398 while ( escape_test[i].in != *p ) i++ ;
2399
2400 if ( i != NUM_ESCAPE_CHARS ) /* in table */
2401 {
2402 p++ ; *q++ = escape_test[i].out ;
2403 }
2404 else
2405 if ( isoctal(*p) )
2406 { /* keep p in register */
2407 t = p ; *q++ = octal(&t) ; p = t ;
2408 }
2409 else
2410 if ( *p == 'x' && isxdigit(*(unsigned char*)(p+1)) )
2411 {
2412 t = p+1 ; *q++ = hex(&t) ; p = t ;
2413 }
2414 else
2415 if ( *p == 0 ) *q++ = '\\' ;
2416 else /* not an escape sequence */
2417 *q++ = *p++ ;
2418 }
2419 else *q++ = *p++ ;
2420
2421 *q = 0 ;
2422 return s ;
2423 }
2424
2425
2426 /* stuff to put multiple line strings together */
2427
2428 static char *the_string ; /* built it here */
2429 static int len ; /* strlen(the_string) */
2430
get_string()2431 static char *get_string()
2432 {
2433 char *s = the_string ;
2434 the_string = (char *) 0 ;
2435 len = 0 ;
2436 return s ;
2437 }
2438
2439 static void
add_to_string(s,slen)2440 add_to_string( s, slen)
2441 char *s ;
2442 int slen ;
2443 {
2444 char *new = MALLOC(len+slen+1) ;
2445 if ( the_string )
2446 { (void) memcpy(new, the_string, len) ;
2447 FREE(the_string) ;
2448 }
2449 (void) strcpy(new+len,s) ;
2450 len += slen ;
2451 the_string = new ;
2452 }
2453