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
13
14 /* cfront 1.2 defines "c_plusplus" instead of "__cplusplus" */
15 #ifdef c_plusplus
16 #ifndef __cplusplus
17 #define __cplusplus
18 #endif
19 #endif
20
21
22 #ifdef __cplusplus
23
24 #include <stdlib.h>
25
26 /* Use prototypes in function declarations. */
27 #define YY_USE_PROTOS
28
29 /* The "const" storage-class-modifier is valid. */
30 #define YY_USE_CONST
31
32 #else /* ! __cplusplus */
33
34 #if __STDC__
35
36 #define YY_USE_PROTOS
37 #define YY_USE_CONST
38
39 #endif /* __STDC__ */
40 #endif /* ! __cplusplus */
41
42 #ifdef __TURBOC__
43 #pragma warn -rch
44 #pragma warn -use
45 #include <io.h>
46 #include <stdlib.h>
47 #define YY_USE_CONST
48 #define YY_USE_PROTOS
49 #endif
50
51 #ifdef YY_USE_CONST
52 #define nidrconst const
53 #else
54 #define nidrconst
55 #endif
56
57
58 #ifdef YY_USE_PROTOS
59 #define YY_PROTO(proto) proto
60 #else
61 #define YY_PROTO(proto) ()
62 #endif
63
64 /* Returned upon end-of-file. */
65 #define YY_NULL 0
66
67 /* Promotes a possibly negative, possibly signed char to an unsigned
68 * integer for use as an array index. If the signed char is negative,
69 * we want to instead treat it as an 8-bit unsigned char, hence the
70 * double cast.
71 */
72 #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
73
74 /* Enter a start condition. This macro really ought to take a parameter,
75 * but we do it the disgusting crufty way forced on us by the ()-less
76 * definition of BEGIN.
77 */
78 #define BEGIN nidr_start = 1 + 2 *
79
80 /* Translate the current start state into a value that can be later handed
81 * to BEGIN to return to the state. The YYSTATE alias is for lex
82 * compatibility.
83 */
84 #define YY_START ((nidr_start - 1) / 2)
85 #define YYSTATE YY_START
86
87 /* Action number for EOF rule of a given start state. */
88 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
89
90 /* Special action meaning "start processing a new file". */
91 #define YY_NEW_FILE nidrrestart( nidrin )
92
93 #define YY_END_OF_BUFFER_CHAR 0
94
95 /* Size of default input buffer. */
96 #define YY_BUF_SIZE 16384
97
98 typedef struct nidr_buffer_state *YY_BUFFER_STATE;
99
100 extern int nidrleng;
101 extern FILE *nidrin, *nidrout;
102
103 #define EOB_ACT_CONTINUE_SCAN 0
104 #define EOB_ACT_END_OF_FILE 1
105 #define EOB_ACT_LAST_MATCH 2
106
107 /* The funky do-while in the following #define is used to turn the definition
108 * int a single C statement (which needs a semi-colon terminator). This
109 * avoids problems with code like:
110 *
111 * if ( condition_holds )
112 * nidrless( 5 );
113 * else
114 * do_something_else();
115 *
116 * Prior to using the do-while the compiler would get upset at the
117 * "else" because it interpreted the "if" statement as being all
118 * done when it reached the ';' after the nidrless() call.
119 */
120
121 /* Return all but the first 'n' matched characters back to the input stream. */
122
123 #define nidrless(n) \
124 do \
125 { \
126 /* Undo effects of setting up nidrtext. */ \
127 *nidr_cp = nidr_hold_char; \
128 YY_RESTORE_YY_MORE_OFFSET \
129 nidr_c_buf_p = nidr_cp = nidr_bp + n - YY_MORE_ADJ; \
130 YY_DO_BEFORE_ACTION; /* set up nidrtext again */ \
131 } \
132 while ( 0 )
133
134 #define unput(c) nidrunput( c, nidrtext_ptr )
135
136 /* Some routines like nidr_flex_realloc() are emitted as static but are
137 not called by all lexers. This generates warnings in some compilers,
138 notably GCC. Arrange to suppress these. */
139 #ifdef __GNUC__
140 #define YY_MAY_BE_UNUSED __attribute__((unused))
141 #else
142 #define YY_MAY_BE_UNUSED
143 #endif
144
145 /* The following is because we cannot portably get our hands on size_t
146 * (without autoconf's help, which isn't available because we want
147 * flex-generated scanners to compile on their own).
148 */
149 typedef unsigned int nidr_size_t;
150
151
152 struct nidr_buffer_state
153 {
154 FILE *nidr_input_file;
155
156 char *nidr_ch_buf; /* input buffer */
157 char *nidr_buf_pos; /* current position in input buffer */
158
159 /* Size of input buffer in bytes, not including room for EOB
160 * characters.
161 */
162 nidr_size_t nidr_buf_size;
163
164 /* Number of characters read into nidr_ch_buf, not including EOB
165 * characters.
166 */
167 int nidr_n_chars;
168
169 /* Whether we "own" the buffer - i.e., we know we created it,
170 * and can realloc() it to grow it, and should free() it to
171 * delete it.
172 */
173 int nidr_is_our_buffer;
174
175 /* Whether this is an "interactive" input source; if so, and
176 * if we're using stdio for input, then we want to use getc()
177 * instead of fread(), to make sure we stop fetching input after
178 * each newline.
179 */
180 int nidr_is_interactive;
181
182 /* Whether we're considered to be at the beginning of a line.
183 * If so, '^' rules will be active on the next match, otherwise
184 * not.
185 */
186 int nidr_at_bol;
187
188 /* Whether to try to fill the input buffer when we reach the
189 * end of it.
190 */
191 int nidr_fill_buffer;
192
193 int nidr_buffer_status;
194 #define YY_BUFFER_NEW 0
195 #define YY_BUFFER_NORMAL 1
196 /* When an EOF's been seen but there's still some text to process
197 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
198 * shouldn't try reading from the input source any more. We might
199 * still have a bunch of tokens to match, though, because of
200 * possible backing-up.
201 *
202 * When we actually see the EOF, we change the status to "new"
203 * (via nidrrestart()), so that the user can continue scanning by
204 * just pointing nidrin at a new input file.
205 */
206 #define YY_BUFFER_EOF_PENDING 2
207 };
208
209 static YY_BUFFER_STATE nidr_current_buffer = 0;
210
211 /* We provide macros for accessing buffer states in case in the
212 * future we want to put the buffer states in a more general
213 * "scanner state".
214 */
215 #define YY_CURRENT_BUFFER nidr_current_buffer
216
217
218 /* nidr_hold_char holds the character lost when nidrtext is formed. */
219 static char nidr_hold_char;
220
221 static int nidr_n_chars; /* number of characters read into nidr_ch_buf */
222
223
224 int nidrleng;
225
226 /* Points to current character in buffer. */
227 static char *nidr_c_buf_p = (char *) 0;
228 static int nidr_init = 1; /* whether we need to initialize */
229 static int nidr_start = 0; /* start state number */
230
231 /* Flag which is used to allow nidrwrap()'s to do buffer switches
232 * instead of setting up a fresh nidrin. A bit of a hack ...
233 */
234 static int nidr_did_buffer_switch_on_eof;
235
236 void nidrrestart YY_PROTO(( FILE *input_file ));
237
238 void nidr_switch_to_buffer YY_PROTO(( YY_BUFFER_STATE new_buffer ));
239 void nidr_load_buffer_state YY_PROTO(( void ));
240 YY_BUFFER_STATE nidr_create_buffer YY_PROTO(( FILE *file, int size ));
241 void nidr_delete_buffer YY_PROTO(( YY_BUFFER_STATE b ));
242 void nidr_init_buffer YY_PROTO(( YY_BUFFER_STATE b, FILE *file ));
243 void nidr_flush_buffer YY_PROTO(( YY_BUFFER_STATE b ));
244 #define YY_FLUSH_BUFFER nidr_flush_buffer( nidr_current_buffer )
245
246 YY_BUFFER_STATE nidr_scan_buffer YY_PROTO(( char *base, nidr_size_t size ));
247 YY_BUFFER_STATE nidr_scan_string YY_PROTO(( nidrconst char *nidr_str ));
248 YY_BUFFER_STATE nidr_scan_bytes YY_PROTO(( nidrconst char *bytes, int len ));
249
250 static void *nidr_flex_alloc YY_PROTO(( nidr_size_t ));
251 static void *nidr_flex_realloc YY_PROTO(( void *, nidr_size_t )) YY_MAY_BE_UNUSED;
252 static void nidr_flex_free YY_PROTO(( void * ));
253
254 #define nidr_new_buffer nidr_create_buffer
255
256 #define nidr_set_interactive(is_interactive) \
257 { \
258 if ( ! nidr_current_buffer ) \
259 nidr_current_buffer = nidr_create_buffer( nidrin, YY_BUF_SIZE ); \
260 nidr_current_buffer->nidr_is_interactive = is_interactive; \
261 }
262
263 #define nidr_set_bol(at_bol) \
264 { \
265 if ( ! nidr_current_buffer ) \
266 nidr_current_buffer = nidr_create_buffer( nidrin, YY_BUF_SIZE ); \
267 nidr_current_buffer->nidr_at_bol = at_bol; \
268 }
269
270 #define YY_AT_BOL() (nidr_current_buffer->nidr_at_bol)
271
272 typedef unsigned char YY_CHAR;
273 FILE *nidrin = (FILE *) 0, *nidrout = (FILE *) 0;
274 typedef int nidr_state_type;
275 extern char *nidrtext;
276 #define nidrtext_ptr nidrtext
277
278 static nidr_state_type nidr_get_previous_state YY_PROTO(( void ));
279 static nidr_state_type nidr_try_NUL_trans YY_PROTO(( nidr_state_type current_state ));
280 static int nidr_get_next_buffer YY_PROTO(( void ));
281 static void nidr_fatal_error YY_PROTO(( nidrconst char msg[] ));
282
283 /* Done after the current pattern has been matched and before the
284 * corresponding action - sets up nidrtext.
285 */
286 #define YY_DO_BEFORE_ACTION \
287 nidrtext_ptr = nidr_bp; \
288 nidrtext_ptr -= nidr_more_len; \
289 nidrleng = (int) (nidr_cp - nidrtext_ptr); \
290 nidr_hold_char = *nidr_cp; \
291 *nidr_cp = '\0'; \
292 nidr_c_buf_p = nidr_cp;
293
294 #define YY_NUM_RULES 27
295 #define YY_END_OF_BUFFER 28
296 static nidrconst short int nidr_accept[125] =
297 { 0,
298 0, 0, 0, 0, 21, 21, 18, 18, 28, 6,
299 5, 2, 25, 4, 3, 3, 6, 16, 12, 2,
300 15, 25, 13, 26, 16, 8, 16, 9, 14, 7,
301 11, 11, 11, 16, 21, 21, 22, 22, 21, 21,
302 18, 18, 19, 18, 19, 18, 5, 25, 0, 25,
303 25, 4, 24, 3, 3, 0, 23, 12, 8, 7,
304 0, 9, 0, 0, 10, 9, 9, 9, 7, 11,
305 11, 11, 21, 21, 21, 21, 20, 21, 21, 21,
306 18, 18, 18, 18, 18, 18, 17, 18, 24, 3,
307 0, 0, 10, 10, 9, 10, 9, 9, 10, 10,
308
309 10, 21, 18, 1, 10, 10, 10, 10, 10, 9,
310 10, 11, 0, 10, 10, 11, 0, 11, 0, 11,
311 0, 10, 10, 0
312 } ;
313
314 static nidrconst int nidr_ec[256] =
315 { 0,
316 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
317 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
318 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
319 1, 2, 1, 4, 5, 1, 1, 1, 6, 1,
320 1, 7, 8, 9, 10, 11, 1, 12, 12, 12,
321 12, 12, 12, 12, 12, 12, 12, 7, 13, 1,
322 14, 1, 1, 15, 16, 17, 17, 17, 18, 19,
323 17, 17, 20, 17, 17, 17, 17, 21, 17, 17,
324 17, 17, 17, 22, 17, 17, 17, 23, 24, 17,
325 1, 25, 1, 1, 26, 1, 16, 17, 17, 17,
326
327 18, 19, 17, 17, 20, 17, 17, 17, 17, 21,
328 17, 17, 17, 17, 17, 22, 17, 17, 17, 23,
329 24, 17, 1, 1, 1, 15, 1, 1, 1, 1,
330 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
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, 1, 1, 1, 1, 1,
337
338 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
339 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
340 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
341 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
342 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
343 1, 1, 1, 1, 1
344 } ;
345
346 static nidrconst int nidr_meta[27] =
347 { 0,
348 1, 1, 2, 3, 1, 4, 1, 5, 1, 6,
349 6, 6, 1, 1, 7, 6, 6, 6, 6, 6,
350 6, 6, 6, 6, 1, 6
351 } ;
352
353 static nidrconst short int nidr_base[137] =
354 { 0,
355 0, 0, 26, 0, 51, 75, 99, 123, 263, 264,
356 56, 264, 57, 264, 0, 239, 57, 264, 147, 264,
357 264, 236, 264, 264, 162, 264, 248, 53, 264, 257,
358 0, 237, 241, 64, 0, 67, 264, 252, 59, 71,
359 0, 81, 264, 62, 249, 86, 88, 229, 92, 228,
360 86, 227, 249, 0, 230, 94, 264, 0, 264, 247,
361 236, 96, 226, 230, 91, 233, 98, 107, 242, 0,
362 224, 212, 0, 116, 108, 120, 264, 126, 226, 129,
363 0, 132, 114, 133, 121, 224, 264, 140, 217, 191,
364 193, 178, 169, 150, 168, 126, 155, 167, 166, 157,
365
366 0, 174, 173, 0, 151, 264, 158, 157, 156, 147,
367 143, 133, 132, 138, 135, 125, 120, 76, 63, 51,
368 33, 0, 264, 264, 183, 190, 197, 199, 202, 203,
369 210, 217, 224, 231, 234, 236
370 } ;
371
372 static nidrconst short int nidr_def[137] =
373 { 0,
374 124, 1, 124, 3, 125, 125, 126, 126, 124, 124,
375 124, 124, 127, 124, 128, 128, 124, 124, 124, 124,
376 124, 127, 124, 124, 124, 124, 124, 129, 124, 124,
377 130, 130, 130, 124, 131, 131, 124, 124, 132, 131,
378 133, 133, 124, 134, 124, 133, 124, 127, 124, 127,
379 127, 127, 124, 128, 128, 124, 124, 19, 124, 124,
380 124, 129, 124, 124, 135, 129, 136, 129, 124, 130,
381 130, 130, 131, 131, 132, 131, 124, 132, 131, 131,
382 133, 133, 134, 133, 134, 133, 124, 133, 124, 128,
383 124, 124, 135, 135, 136, 135, 136, 129, 135, 130,
384
385 130, 131, 133, 128, 124, 124, 135, 135, 135, 136,
386 135, 130, 124, 135, 135, 130, 124, 130, 124, 130,
387 124, 130, 124, 0, 124, 124, 124, 124, 124, 124,
388 124, 124, 124, 124, 124, 124
389 } ;
390
391 static nidrconst short int nidr_nxt[291] =
392 { 0,
393 10, 11, 12, 10, 13, 10, 10, 10, 10, 10,
394 10, 10, 14, 10, 10, 15, 15, 16, 15, 15,
395 15, 15, 15, 15, 17, 10, 18, 19, 20, 21,
396 22, 23, 24, 25, 26, 25, 27, 28, 29, 30,
397 18, 31, 31, 31, 31, 32, 33, 31, 31, 31,
398 34, 18, 36, 37, 38, 39, 123, 47, 56, 57,
399 48, 51, 50, 67, 62, 56, 57, 50, 74, 52,
400 68, 75, 80, 57, 122, 40, 36, 37, 38, 39,
401 49, 53, 82, 79, 121, 83, 86, 88, 57, 47,
402 51, 76, 48, 56, 57, 56, 57, 120, 52, 40,
403
404 42, 43, 65, 44, 45, 84, 67, 62, 94, 96,
405 53, 50, 49, 68, 98, 97, 98, 74, 99, 50,
406 75, 80, 57, 46, 42, 43, 50, 44, 45, 50,
407 80, 57, 79, 82, 88, 57, 83, 96, 86, 119,
408 76, 88, 57, 109, 118, 86, 115, 46, 58, 115,
409 79, 48, 117, 116, 111, 59, 84, 107, 111, 107,
410 60, 108, 110, 114, 110, 114, 111, 115, 108, 108,
411 113, 49, 61, 62, 103, 102, 112, 99, 99, 124,
412 124, 63, 64, 35, 35, 35, 35, 35, 35, 35,
413 41, 41, 41, 41, 41, 41, 41, 50, 106, 50,
414
415 50, 50, 50, 50, 54, 54, 66, 66, 70, 70,
416 73, 105, 104, 73, 73, 73, 73, 78, 89, 78,
417 78, 78, 78, 78, 81, 103, 81, 102, 81, 81,
418 81, 85, 101, 85, 85, 85, 85, 85, 93, 93,
419 95, 95, 100, 69, 124, 92, 91, 65, 69, 90,
420 89, 53, 53, 53, 87, 77, 72, 71, 69, 65,
421 53, 55, 124, 9, 124, 124, 124, 124, 124, 124,
422 124, 124, 124, 124, 124, 124, 124, 124, 124, 124,
423 124, 124, 124, 124, 124, 124, 124, 124, 124, 124
424 } ;
425
426 static nidrconst short int nidr_chk[291] =
427 { 0,
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, 1, 1, 1, 3, 3, 3, 3,
431 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
432 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
433 3, 3, 5, 5, 5, 5, 121, 11, 17, 17,
434 11, 13, 39, 28, 28, 34, 34, 44, 36, 13,
435 28, 36, 40, 40, 120, 5, 6, 6, 6, 6,
436 11, 13, 42, 39, 119, 42, 44, 46, 46, 47,
437 51, 36, 47, 49, 49, 56, 56, 118, 51, 6,
438
439 7, 7, 65, 7, 7, 42, 62, 62, 65, 67,
440 51, 75, 47, 62, 68, 67, 68, 74, 68, 83,
441 74, 76, 76, 7, 8, 8, 85, 8, 8, 78,
442 80, 80, 75, 82, 84, 84, 82, 96, 83, 117,
443 74, 88, 88, 96, 116, 85, 115, 8, 19, 114,
444 78, 19, 113, 112, 111, 19, 82, 94, 110, 94,
445 19, 94, 97, 109, 97, 109, 97, 109, 108, 107,
446 105, 19, 25, 25, 103, 102, 100, 99, 98, 95,
447 93, 25, 25, 125, 125, 125, 125, 125, 125, 125,
448 126, 126, 126, 126, 126, 126, 126, 127, 92, 127,
449
450 127, 127, 127, 127, 128, 128, 129, 129, 130, 130,
451 131, 91, 90, 131, 131, 131, 131, 132, 89, 132,
452 132, 132, 132, 132, 133, 86, 133, 79, 133, 133,
453 133, 134, 72, 134, 134, 134, 134, 134, 135, 135,
454 136, 136, 71, 69, 66, 64, 63, 61, 60, 55,
455 53, 52, 50, 48, 45, 38, 33, 32, 30, 27,
456 22, 16, 9, 124, 124, 124, 124, 124, 124, 124,
457 124, 124, 124, 124, 124, 124, 124, 124, 124, 124,
458 124, 124, 124, 124, 124, 124, 124, 124, 124, 124
459 } ;
460
461 static nidr_state_type nidr_last_accepting_state;
462 static char *nidr_last_accepting_cpos;
463
464 /* The intent behind this definition is that it'll catch
465 * any uses of REJECT which flex missed.
466 */
467 #define REJECT reject_used_but_not_detected
468 static int nidr_more_flag = 0;
469 static int nidr_more_len = 0;
470 #define nidrmore() (nidr_more_flag = 1)
471 #define YY_MORE_ADJ nidr_more_len
472 #define YY_RESTORE_YY_MORE_OFFSET
473 char *nidrtext;
474 /* #line 1 "nidrscan.l" */
475 #define INITIAL 0
476 /* #line 2 "nidrscan.l" */
477 /*********************************************************************
478 Copyright 2008, 2010 Sandia Corporation. Under the terms of Contract
479 DE-AC04-94AL85000 with Sandia Corporation, the U.S. Government
480 retains certain rights in this software.
481
482 Redistribution and use in source and binary forms, with or without
483 modification, are permitted provided that the following conditions
484 are met:
485
486 * Redistributions of source code must retain the above copyright
487 notice, this list of conditions and the following disclaimer.
488
489 * Redistributions in binary form must reproduce the above copyright
490 notice, this list of conditions and the following disclaimer in the
491 documentation and/or other materials provided with the distribution.
492
493 * Neither the name of Sandia Corporation nor the names of its
494 contributors may be used to endorse or promote products derived from
495 this software without specific prior written permission.
496
497 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
498 "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
499 LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
500 A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
501 OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
502 SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
503 LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
504 DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
505 THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
506 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
507 OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
508 ***********************************************************************/
509
510 #ifndef NIDR_H
511 #include "nidr.h"
512 #endif
513 #ifndef NIDR_PARSER_H
514 #include "nidr-parser.h"
515 #endif
516 #include <stdlib.h> /* possibly redundant, but necessary for strtod on some systems */
517
518 static int my_nidr_input(char*, int);
519 extern char *nidr_KWscopy(const char*);
520
521 #ifdef IDR_DEBUG
522 static void print_token( char*, char*, char* );
523 #else
524 #define print_token(a,b,c) /*nothing*/
525 #endif
526
527
528 #define YY_INPUT(buf,result,maxsize) result = my_nidr_input(buf,maxsize)
529
530 int nidrLineNumber = 1;
531
532 extern void nidr_abort(void);
533 extern void (*nidr_comment)(const char*);
534 extern KeyWord *(*nidr_identifier)(const char*);
535 extern KeyWord *nidr_keyword(const char*);
536 extern const char *nidr_keyword_name(void);
537 /* Hardwire the now rarely used help text. It truly is something the
538 application should provide, not NIDR, but had trouble with the
539 declaration/definition w.r.t. MSVS when building DAKOTA source.
540 Ultimately would want to pass it into nidr_parse(...)
541 extern char nidr_please_refer[];
542 */
543 char nidr_please_refer[] =
544 "Please refer to the input specification reference for this application.";
545 extern void nidr_tolower(char*);
546 static void bad_number(const char*);
547 static void unput_string(char *, int);
548 #define DATA 1
549
550 #define DQ_STRING 2
551
552 #define Q_STRING 3
553
554 /* #line 545 "nidr-scanner.c" */
555
556 /* Macros after this point can all be overridden by user definitions in
557 * section 1.
558 */
559
560 #ifndef YY_SKIP_YYWRAP
561 #ifdef __cplusplus
562 extern "C" int nidrwrap YY_PROTO(( void ));
563 #else
564 extern int nidrwrap YY_PROTO(( void ));
565 #endif
566 #endif
567
568 #ifndef YY_NO_UNPUT
569 static void nidrunput YY_PROTO(( int c, char *buf_ptr ));
570 #endif
571
572 #ifndef nidrtext_ptr
573 static void nidr_flex_strncpy YY_PROTO(( char *, nidrconst char *, int ));
574 #endif
575
576 #ifdef YY_NEED_STRLEN
577 static int nidr_flex_strlen YY_PROTO(( nidrconst char * ));
578 #endif
579
580 #ifndef YY_NO_INPUT
581 #ifdef __cplusplus
582 static int nidrinput YY_PROTO(( void ));
583 #else
584 static int input YY_PROTO(( void ));
585 #endif
586 #endif
587
588 #if YY_STACK_USED
589 static int nidr_start_stack_ptr = 0;
590 static int nidr_start_stack_depth = 0;
591 static int *nidr_start_stack = 0;
592 #ifndef YY_NO_PUSH_STATE
593 static void nidr_push_state YY_PROTO(( int new_state ));
594 #endif
595 #ifndef YY_NO_POP_STATE
596 static void nidr_pop_state YY_PROTO(( void ));
597 #endif
598 #ifndef YY_NO_TOP_STATE
599 static int nidr_top_state YY_PROTO(( void ));
600 #endif
601
602 #else
603 #define YY_NO_PUSH_STATE 1
604 #define YY_NO_POP_STATE 1
605 #define YY_NO_TOP_STATE 1
606 #endif
607
608 #ifdef YY_MALLOC_DECL
609 YY_MALLOC_DECL
610 #else
611 #if __STDC__
612 #ifndef __cplusplus
613 #include <stdlib.h>
614 #endif
615 #else
616 /* Just try to get by without declaring the routines. This will fail
617 * miserably on non-ANSI systems for which sizeof(size_t) != sizeof(int)
618 * or sizeof(void*) != sizeof(int).
619 */
620 #endif
621 #endif
622
623 /* Amount of stuff to slurp up with each read. */
624 #ifndef YY_READ_BUF_SIZE
625 #define YY_READ_BUF_SIZE 8192
626 #endif
627
628 /* Copy whatever the last rule matched to the standard output. */
629
630 #ifndef ECHO
631 /* This used to be an fputs(), but since the string might contain NUL's,
632 * we now use fwrite().
633 */
634 #define ECHO (void) fwrite( nidrtext, nidrleng, 1, nidrout )
635 #endif
636
637 /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
638 * is returned in "result".
639 */
640 #ifndef YY_INPUT
641 #define YY_INPUT(buf,result,max_size) \
642 if ( nidr_current_buffer->nidr_is_interactive ) \
643 { \
644 int c = '*', n; \
645 for ( n = 0; n < max_size && \
646 (c = getc( nidrin )) != EOF && c != '\n'; ++n ) \
647 buf[n] = (char) c; \
648 if ( c == '\n' ) \
649 buf[n++] = (char) c; \
650 if ( c == EOF && ferror( nidrin ) ) \
651 YY_FATAL_ERROR( "input in flex scanner failed" ); \
652 result = n; \
653 } \
654 else if ( ((result = fread( buf, 1, max_size, nidrin )) == 0) \
655 && ferror( nidrin ) ) \
656 YY_FATAL_ERROR( "input in flex scanner failed" );
657 #endif
658
659 /* No semi-colon after return; correct usage is to write "nidrterminate();" -
660 * we don't want an extra ';' after the "return" because that will cause
661 * some compilers to complain about unreachable statements.
662 */
663 #ifndef nidrterminate
664 #define nidrterminate() return YY_NULL
665 #endif
666
667 /* Number of entries by which start-condition stack grows. */
668 #ifndef YY_START_STACK_INCR
669 #define YY_START_STACK_INCR 25
670 #endif
671
672 /* Report a fatal error. */
673 #ifndef YY_FATAL_ERROR
674 #define YY_FATAL_ERROR(msg) nidr_fatal_error( msg )
675 #endif
676
677 /* Default declaration of generated scanner - a define so the user can
678 * easily add parameters.
679 */
680 #ifndef YY_DECL
681 #define YY_DECL int nidrlex YY_PROTO(( void ))
682 #endif
683
684 /* Code executed at the beginning of each rule, after nidrtext and nidrleng
685 * have been set up.
686 */
687 #ifndef YY_USER_ACTION
688 #define YY_USER_ACTION
689 #endif
690
691 /* Code executed at the end of each rule. */
692 #ifndef YY_BREAK
693 #define YY_BREAK break;
694 #endif
695
696 #define YY_RULE_SETUP \
697 YY_USER_ACTION
698
699 YY_DECL
700 {
701 register nidr_state_type nidr_current_state;
702 register char *nidr_cp = NULL, *nidr_bp = NULL;
703 register int nidr_act;
704
705 /* #line 85 "nidrscan.l" */
706
707
708
709 KeyWord *identifier, *keyword;
710 char *se;
711
712
713 /* #line 704 "nidr-scanner.c" */
714
715 if ( nidr_init )
716 {
717 nidr_init = 0;
718
719 #ifdef YY_USER_INIT
720 YY_USER_INIT;
721 #endif
722
723 if ( ! nidr_start )
724 nidr_start = 1; /* first start state */
725
726 if ( ! nidrin )
727 nidrin = stdin;
728
729 if ( ! nidrout )
730 nidrout = stdout;
731
732 if ( ! nidr_current_buffer )
733 nidr_current_buffer =
734 nidr_create_buffer( nidrin, YY_BUF_SIZE );
735
736 nidr_load_buffer_state();
737 }
738
739 while ( 1 ) /* loops until end-of-file is reached */
740 {
741 nidr_more_len = 0;
742 if ( nidr_more_flag )
743 {
744 nidr_more_len = nidr_c_buf_p - nidrtext_ptr;
745 nidr_more_flag = 0;
746 }
747 nidr_cp = nidr_c_buf_p;
748
749 /* Support of nidrtext. */
750 *nidr_cp = nidr_hold_char;
751
752 /* nidr_bp points to the position in nidr_ch_buf of the start of
753 * the current run.
754 */
755 nidr_bp = nidr_cp;
756
757 nidr_current_state = nidr_start;
758 nidr_match:
759 do
760 {
761 register YY_CHAR nidr_c = nidr_ec[YY_SC_TO_UI(*nidr_cp)];
762 if ( nidr_accept[nidr_current_state] )
763 {
764 nidr_last_accepting_state = nidr_current_state;
765 nidr_last_accepting_cpos = nidr_cp;
766 }
767 while ( nidr_chk[nidr_base[nidr_current_state] + nidr_c] != nidr_current_state )
768 {
769 nidr_current_state = (int) nidr_def[nidr_current_state];
770 if ( nidr_current_state >= 125 )
771 nidr_c = nidr_meta[(unsigned int) nidr_c];
772 }
773 nidr_current_state = nidr_nxt[nidr_base[nidr_current_state] + (unsigned int) nidr_c];
774 ++nidr_cp;
775 }
776 while ( nidr_base[nidr_current_state] != 264 );
777
778 nidr_find_action:
779 nidr_act = nidr_accept[nidr_current_state];
780 if ( nidr_act == 0 )
781 { /* have to back up */
782 nidr_cp = nidr_last_accepting_cpos;
783 nidr_current_state = nidr_last_accepting_state;
784 nidr_act = nidr_accept[nidr_current_state];
785 }
786
787 YY_DO_BEFORE_ACTION;
788
789
790 do_action: /* This label is used only to access EOF actions. */
791
792
793 switch ( nidr_act )
794 { /* beginning of action switch */
795 case 0: /* must back up */
796 /* undo the effects of YY_DO_BEFORE_ACTION */
797 *nidr_cp = nidr_hold_char;
798 nidr_cp = nidr_last_accepting_cpos;
799 nidr_current_state = nidr_last_accepting_state;
800 goto nidr_find_action;
801
802 case 1:
803 YY_RULE_SETUP
804 /* #line 92 "nidrscan.l" */
805 {
806 print_token("exit", NULL, "<INITIAL>" );
807 return 0;
808 }
809 YY_BREAK
810 case 2:
811 YY_RULE_SETUP
812 /* #line 97 "nidrscan.l" */
813 {
814 if (nidr_comment)
815 nidr_comment(nidrtext);
816 nidrLineNumber++;
817 }
818 YY_BREAK
819 case 3:
820 YY_RULE_SETUP
821 /* #line 103 "nidrscan.l" */
822 {
823 nidr_tolower(nidrtext);
824 keyword = nidr_keyword(nidrtext);
825
826 if (keyword) {
827 print_token( "keyword", (char*) nidrtext, "<INITIAL>" );
828 if (keyword->kind & KWKind_Dynmult)
829 return END;
830 nidrlval.keyword = keyword;
831 BEGIN DATA;
832 return KEY_WORD;
833 }
834 print_token( "error", (char*) nidrtext, "<INITIAL>" );
835 nidrlval.string = nidrtext;
836 return KEYWORDERROR;
837 }
838 YY_BREAK
839 case 4:
840 YY_RULE_SETUP
841 /* #line 120 "nidrscan.l" */
842 {
843 if (*nidrtext == '#') {
844 if (nidr_comment)
845 nidr_comment(nidrtext);
846 }
847 else {
848 print_token( "end", NULL, "<INITIAL>" );
849 return END;
850 }
851 }
852 YY_BREAK
853 case 5:
854 YY_RULE_SETUP
855 /* #line 131 "nidrscan.l" */
856 { print_token( "whitespace", (char*) nidrtext, "<INITIAL>" ); }
857 YY_BREAK
858 case 6:
859 YY_RULE_SETUP
860 /* #line 133 "nidrscan.l" */
861 {
862 print_token( "word", (char*) nidrtext, "<INITIAL>" );
863 nidrlval.string = nidr_KWscopy(nidrtext);
864 return STRING;
865 }
866 YY_BREAK
867 case 7:
868 YY_RULE_SETUP
869 /* #line 138 "nidrscan.l" */
870 {
871 print_token( "equals", NULL, "<DATA>" );
872 return EQUALS;
873 }
874 YY_BREAK
875 case 8:
876 YY_RULE_SETUP
877 /* #line 142 "nidrscan.l" */
878 {
879 print_token( "separator", NULL, "<DATA>" );
880 return SEPARATOR;
881 }
882 YY_BREAK
883 case 9:
884 YY_RULE_SETUP
885 /* #line 146 "nidrscan.l" */
886 {
887 print_token( "integer", (char*) nidrtext, "<DATA>" );
888 /* The following, old way has trouble with */
889 /* big floating-point numbers written without */
890 /* a decimal point */
891 /* nidrlval.integer = (int) atoi( (char*) nidrtext ); */
892 /* return INTEGER; */
893 nidrlval.real = strtod(nidrtext,&se);
894 if (*se)
895 bad_number(nidrtext);
896 return REAL;
897 }
898 YY_BREAK
899 case 10:
900 YY_RULE_SETUP
901 /* #line 158 "nidrscan.l" */
902 {
903 print_token( "real", (char*) nidrtext, "<DATA>" );
904 nidrlval.real = strtod(nidrtext,&se);
905 if (*se)
906 bad_number(nidrtext);
907 return REAL;
908 }
909 YY_BREAK
910 case 11:
911 YY_RULE_SETUP
912 /* #line 165 "nidrscan.l" */
913 {
914 nidr_tolower(nidrtext);
915 if (nidr_keyword(nidrtext)) {
916 unput_string(nidrtext, nidrleng);
917 BEGIN INITIAL;
918 return END;
919 }
920 identifier = nidr_identifier(nidrtext);
921
922 if (identifier) {
923 print_token( "identifier", (char*) nidrtext, "<DATA>");
924
925 nidrlval.identifier = identifier;
926 return IDENTIFIER;
927 }
928 else {
929 print_token( "word", (char*) nidrtext, "<DATA>" );
930 fprintf(stderr,"\n\tunrecognized identifier '%s'\n", nidrtext);
931 fprintf(stderr,"\tinput line %d, within %s keyword.\n",
932 nidrLineNumber, nidr_keyword_name());
933 fprintf(stderr, "%s\n", nidr_please_refer);
934 nidr_abort();
935 nidrlval.string = nidr_KWscopy(nidrtext);
936 return STRING;
937 }
938 }
939 YY_BREAK
940 case 12:
941 YY_RULE_SETUP
942 /* #line 192 "nidrscan.l" */
943 { print_token( "whitespace", (char*) nidrtext, "<DATA>" ); }
944 YY_BREAK
945 case 13:
946 YY_RULE_SETUP
947 /* #line 194 "nidrscan.l" */
948 {
949 print_token( "opening quote", NULL, "<DATA>" );
950 BEGIN Q_STRING;
951 }
952 YY_BREAK
953 case 14:
954 YY_RULE_SETUP
955 /* #line 198 "nidrscan.l" */
956 {
957 print_token( "end", NULL, "<DATA>" );
958 BEGIN INITIAL;
959 return END;
960 }
961 YY_BREAK
962 case 15:
963 YY_RULE_SETUP
964 /* #line 203 "nidrscan.l" */
965 {
966 print_token( "double quote", NULL, "<DATA>" );
967 BEGIN DQ_STRING;
968 }
969 YY_BREAK
970 case 16:
971 YY_RULE_SETUP
972 /* #line 207 "nidrscan.l" */
973 {
974 print_token( "word", (char*) nidrtext, "<DATA>" );
975 fprintf(stderr, "Input line %d: '%s' unexpected.\n",
976 nidrLineNumber, nidrtext);
977 nidr_abort();
978 nidrlval.string = nidr_KWscopy(nidrtext);
979 return STRING;
980 }
981 YY_BREAK
982 case 17:
983 YY_RULE_SETUP
984 /* #line 215 "nidrscan.l" */
985 {
986 print_token( "q:repeated quote", NULL, "<Q_STRING>" );
987 nidrtext[--nidrleng] = 0;
988 nidrmore();
989 }
990 YY_BREAK
991 case 18:
992 YY_RULE_SETUP
993 /* #line 220 "nidrscan.l" */
994 {
995 nidrmore();
996 print_token( "q:text", (char*) nidrtext, "<Q_STRING>" );
997 }
998 YY_BREAK
999 case 19:
1000 YY_RULE_SETUP
1001 /* #line 224 "nidrscan.l" */
1002 {
1003 print_token( "closing quote", NULL, "<Q_STRING>" );
1004 if (nidrtext[--nidrleng] == '\n')
1005 unput('\n');
1006 nidrtext[nidrleng] = 0;
1007 print_token( "quoted string", (char*) nidrtext, "<Q_STRING>" );
1008 nidrlval.qstring = nidr_KWscopy(nidrtext);
1009 BEGIN DATA;
1010 return QUOTED_STRING;
1011 }
1012 YY_BREAK
1013 case 20:
1014 YY_RULE_SETUP
1015 /* #line 234 "nidrscan.l" */
1016 {
1017 print_token( "q:repeated double quote", NULL, "<DQ_STRING>" );
1018 nidrtext[--nidrleng] = 0;
1019 nidrmore();
1020 }
1021 YY_BREAK
1022 case 21:
1023 YY_RULE_SETUP
1024 /* #line 239 "nidrscan.l" */
1025 {
1026 nidrmore();
1027 print_token( "q:text", (char*) nidrtext, "<DQ_STRING>" );
1028 }
1029 YY_BREAK
1030 case 22:
1031 YY_RULE_SETUP
1032 /* #line 243 "nidrscan.l" */
1033 {
1034 print_token( "closing double quote", NULL, "<DQ_STRING>" );
1035 if (nidrtext[--nidrleng] == '\n')
1036 unput('\n');
1037 nidrtext[nidrleng] = 0;
1038 print_token( "quoted string", (char*) nidrtext, "<DQ_STRING>" );
1039 nidrlval.qstring = nidr_KWscopy(nidrtext);
1040 BEGIN DATA;
1041 return QUOTED_STRING;
1042 }
1043 YY_BREAK
1044 case 23:
1045 YY_RULE_SETUP
1046 /* #line 253 "nidrscan.l" */
1047 {
1048 print_token( "newline", NULL, NULL );
1049 if (nidr_comment)
1050 nidr_comment(nidrtext);
1051 nidrLineNumber++;
1052 }
1053 YY_BREAK
1054 case 24:
1055 YY_RULE_SETUP
1056 /* #line 259 "nidrscan.l" */
1057 {
1058 if (nidr_comment)
1059 nidr_comment(nidrtext);
1060 print_token( "comment - escaped newline", (char*) nidrtext, "<INITIAL>" );
1061 unput( '\\' );
1062 }
1063 YY_BREAK
1064 case 25:
1065 YY_RULE_SETUP
1066 /* #line 265 "nidrscan.l" */
1067 {
1068 if (nidr_comment)
1069 nidr_comment(nidrtext);
1070 print_token( "comment", (char*) nidrtext, "<INITIAL>" );
1071 }
1072 YY_BREAK
1073 case 26:
1074 YY_RULE_SETUP
1075 /* #line 270 "nidrscan.l" */
1076 { return nidrtext[0]; }
1077 YY_BREAK
1078 case 27:
1079 YY_RULE_SETUP
1080 /* #line 272 "nidrscan.l" */
1081 ECHO;
1082 YY_BREAK
1083 /* #line 1074 "nidr-scanner.c" */
1084 case YY_STATE_EOF(INITIAL):
1085 case YY_STATE_EOF(DATA):
1086 case YY_STATE_EOF(DQ_STRING):
1087 case YY_STATE_EOF(Q_STRING):
1088 nidrterminate();
1089
1090 case YY_END_OF_BUFFER:
1091 {
1092 /* Amount of text matched not including the EOB char. */
1093 int nidr_amount_of_matched_text = (int) (nidr_cp - nidrtext_ptr) - 1;
1094
1095 /* Undo the effects of YY_DO_BEFORE_ACTION. */
1096 *nidr_cp = nidr_hold_char;
1097 YY_RESTORE_YY_MORE_OFFSET
1098
1099 if ( nidr_current_buffer->nidr_buffer_status == YY_BUFFER_NEW )
1100 {
1101 /* We're scanning a new file or input source. It's
1102 * possible that this happened because the user
1103 * just pointed nidrin at a new source and called
1104 * nidrlex(). If so, then we have to assure
1105 * consistency between nidr_current_buffer and our
1106 * globals. Here is the right place to do so, because
1107 * this is the first action (other than possibly a
1108 * back-up) that will match for the new input source.
1109 */
1110 nidr_n_chars = nidr_current_buffer->nidr_n_chars;
1111 nidr_current_buffer->nidr_input_file = nidrin;
1112 nidr_current_buffer->nidr_buffer_status = YY_BUFFER_NORMAL;
1113 }
1114
1115 /* Note that here we test for nidr_c_buf_p "<=" to the position
1116 * of the first EOB in the buffer, since nidr_c_buf_p will
1117 * already have been incremented past the NUL character
1118 * (since all states make transitions on EOB to the
1119 * end-of-buffer state). Contrast this with the test
1120 * in input().
1121 */
1122 if ( nidr_c_buf_p <= &nidr_current_buffer->nidr_ch_buf[nidr_n_chars] )
1123 { /* This was really a NUL. */
1124 nidr_state_type nidr_next_state;
1125
1126 nidr_c_buf_p = nidrtext_ptr + nidr_amount_of_matched_text;
1127
1128 nidr_current_state = nidr_get_previous_state();
1129
1130 /* Okay, we're now positioned to make the NUL
1131 * transition. We couldn't have
1132 * nidr_get_previous_state() go ahead and do it
1133 * for us because it doesn't know how to deal
1134 * with the possibility of jamming (and we don't
1135 * want to build jamming into it because then it
1136 * will run more slowly).
1137 */
1138
1139 nidr_next_state = nidr_try_NUL_trans( nidr_current_state );
1140
1141 nidr_bp = nidrtext_ptr + YY_MORE_ADJ;
1142
1143 if ( nidr_next_state )
1144 {
1145 /* Consume the NUL. */
1146 nidr_cp = ++nidr_c_buf_p;
1147 nidr_current_state = nidr_next_state;
1148 goto nidr_match;
1149 }
1150
1151 else
1152 {
1153 nidr_cp = nidr_c_buf_p;
1154 goto nidr_find_action;
1155 }
1156 }
1157
1158 else switch ( nidr_get_next_buffer() )
1159 {
1160 case EOB_ACT_END_OF_FILE:
1161 {
1162 nidr_did_buffer_switch_on_eof = 0;
1163
1164 if ( nidrwrap() )
1165 {
1166 /* Note: because we've taken care in
1167 * nidr_get_next_buffer() to have set up
1168 * nidrtext, we can now set up
1169 * nidr_c_buf_p so that if some total
1170 * hoser (like flex itself) wants to
1171 * call the scanner after we return the
1172 * YY_NULL, it'll still work - another
1173 * YY_NULL will get returned.
1174 */
1175 nidr_c_buf_p = nidrtext_ptr + YY_MORE_ADJ;
1176
1177 nidr_act = YY_STATE_EOF(YY_START);
1178 goto do_action;
1179 }
1180
1181 else
1182 {
1183 if ( ! nidr_did_buffer_switch_on_eof )
1184 YY_NEW_FILE;
1185 }
1186 break;
1187 }
1188
1189 case EOB_ACT_CONTINUE_SCAN:
1190 nidr_c_buf_p =
1191 nidrtext_ptr + nidr_amount_of_matched_text;
1192
1193 nidr_current_state = nidr_get_previous_state();
1194
1195 nidr_cp = nidr_c_buf_p;
1196 nidr_bp = nidrtext_ptr + YY_MORE_ADJ;
1197 goto nidr_match;
1198
1199 case EOB_ACT_LAST_MATCH:
1200 nidr_c_buf_p =
1201 &nidr_current_buffer->nidr_ch_buf[nidr_n_chars];
1202
1203 nidr_current_state = nidr_get_previous_state();
1204
1205 nidr_cp = nidr_c_buf_p;
1206 nidr_bp = nidrtext_ptr + YY_MORE_ADJ;
1207 goto nidr_find_action;
1208 }
1209 break;
1210 }
1211
1212 default:
1213 YY_FATAL_ERROR(
1214 "fatal flex scanner internal error--no action found" );
1215 } /* end of action switch */
1216 } /* end of scanning one token */
1217 } /* end of nidrlex */
1218
1219
1220 /* nidr_get_next_buffer - try to read in a new buffer
1221 *
1222 * Returns a code representing an action:
1223 * EOB_ACT_LAST_MATCH -
1224 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1225 * EOB_ACT_END_OF_FILE - end of file
1226 */
1227
nidr_get_next_buffer()1228 static int nidr_get_next_buffer()
1229 {
1230 register char *dest = nidr_current_buffer->nidr_ch_buf;
1231 register char *source = nidrtext_ptr;
1232 register int number_to_move, i;
1233 int ret_val;
1234
1235 if ( nidr_c_buf_p > &nidr_current_buffer->nidr_ch_buf[nidr_n_chars + 1] )
1236 YY_FATAL_ERROR(
1237 "fatal flex scanner internal error--end of buffer missed" );
1238
1239 if ( nidr_current_buffer->nidr_fill_buffer == 0 )
1240 { /* Don't try to fill the buffer, so this is an EOF. */
1241 if ( nidr_c_buf_p - nidrtext_ptr - YY_MORE_ADJ == 1 )
1242 {
1243 /* We matched a single character, the EOB, so
1244 * treat this as a final EOF.
1245 */
1246 return EOB_ACT_END_OF_FILE;
1247 }
1248
1249 else
1250 {
1251 /* We matched some text prior to the EOB, first
1252 * process it.
1253 */
1254 return EOB_ACT_LAST_MATCH;
1255 }
1256 }
1257
1258 /* Try to read more data. */
1259
1260 /* First move last chars to start of buffer. */
1261 number_to_move = (int) (nidr_c_buf_p - nidrtext_ptr) - 1;
1262
1263 for ( i = 0; i < number_to_move; ++i )
1264 *(dest++) = *(source++);
1265
1266 if ( nidr_current_buffer->nidr_buffer_status == YY_BUFFER_EOF_PENDING )
1267 /* don't do the read, it's not guaranteed to return an EOF,
1268 * just force an EOF
1269 */
1270 nidr_current_buffer->nidr_n_chars = nidr_n_chars = 0;
1271
1272 else
1273 {
1274 int num_to_read =
1275 nidr_current_buffer->nidr_buf_size - number_to_move - 1;
1276
1277 while ( num_to_read <= 0 )
1278 { /* Not enough room in the buffer - grow it. */
1279 #ifdef YY_USES_REJECT
1280 YY_FATAL_ERROR(
1281 "input buffer overflow, can't enlarge buffer because scanner uses REJECT" );
1282 #else
1283
1284 /* just a shorter name for the current buffer */
1285 YY_BUFFER_STATE b = nidr_current_buffer;
1286
1287 int nidr_c_buf_p_offset =
1288 (int) (nidr_c_buf_p - b->nidr_ch_buf);
1289
1290 if ( b->nidr_is_our_buffer )
1291 {
1292 int new_size = b->nidr_buf_size * 2;
1293
1294 if ( new_size <= 0 )
1295 b->nidr_buf_size += b->nidr_buf_size / 8;
1296 else
1297 b->nidr_buf_size *= 2;
1298
1299 b->nidr_ch_buf = (char *)
1300 /* Include room in for 2 EOB chars. */
1301 nidr_flex_realloc( (void *) b->nidr_ch_buf,
1302 b->nidr_buf_size + 2 );
1303 }
1304 else
1305 /* Can't grow it, we don't own it. */
1306 b->nidr_ch_buf = 0;
1307
1308 if ( ! b->nidr_ch_buf )
1309 YY_FATAL_ERROR(
1310 "fatal error - scanner input buffer overflow" );
1311
1312 nidr_c_buf_p = &b->nidr_ch_buf[nidr_c_buf_p_offset];
1313
1314 num_to_read = nidr_current_buffer->nidr_buf_size -
1315 number_to_move - 1;
1316 #endif
1317 }
1318
1319 if ( num_to_read > YY_READ_BUF_SIZE )
1320 num_to_read = YY_READ_BUF_SIZE;
1321
1322 /* Read in more data. */
1323 YY_INPUT( (&nidr_current_buffer->nidr_ch_buf[number_to_move]),
1324 nidr_n_chars, num_to_read );
1325
1326 nidr_current_buffer->nidr_n_chars = nidr_n_chars;
1327 }
1328
1329 if ( nidr_n_chars == 0 )
1330 {
1331 if ( number_to_move == YY_MORE_ADJ )
1332 {
1333 ret_val = EOB_ACT_END_OF_FILE;
1334 nidrrestart( nidrin );
1335 }
1336
1337 else
1338 {
1339 ret_val = EOB_ACT_LAST_MATCH;
1340 nidr_current_buffer->nidr_buffer_status =
1341 YY_BUFFER_EOF_PENDING;
1342 }
1343 }
1344
1345 else
1346 ret_val = EOB_ACT_CONTINUE_SCAN;
1347
1348 nidr_n_chars += number_to_move;
1349 nidr_current_buffer->nidr_ch_buf[nidr_n_chars] = YY_END_OF_BUFFER_CHAR;
1350 nidr_current_buffer->nidr_ch_buf[nidr_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
1351
1352 nidrtext_ptr = &nidr_current_buffer->nidr_ch_buf[0];
1353
1354 return ret_val;
1355 }
1356
1357
1358 /* nidr_get_previous_state - get the state just before the EOB char was reached */
1359
nidr_get_previous_state()1360 static nidr_state_type nidr_get_previous_state()
1361 {
1362 register nidr_state_type nidr_current_state;
1363 register char *nidr_cp;
1364
1365 nidr_current_state = nidr_start;
1366
1367 for ( nidr_cp = nidrtext_ptr + YY_MORE_ADJ; nidr_cp < nidr_c_buf_p; ++nidr_cp )
1368 {
1369 register YY_CHAR nidr_c = (*nidr_cp ? nidr_ec[YY_SC_TO_UI(*nidr_cp)] : 1);
1370 if ( nidr_accept[nidr_current_state] )
1371 {
1372 nidr_last_accepting_state = nidr_current_state;
1373 nidr_last_accepting_cpos = nidr_cp;
1374 }
1375 while ( nidr_chk[nidr_base[nidr_current_state] + nidr_c] != nidr_current_state )
1376 {
1377 nidr_current_state = (int) nidr_def[nidr_current_state];
1378 if ( nidr_current_state >= 125 )
1379 nidr_c = nidr_meta[(unsigned int) nidr_c];
1380 }
1381 nidr_current_state = nidr_nxt[nidr_base[nidr_current_state] + (unsigned int) nidr_c];
1382 }
1383
1384 return nidr_current_state;
1385 }
1386
1387
1388 /* nidr_try_NUL_trans - try to make a transition on the NUL character
1389 *
1390 * synopsis
1391 * next_state = nidr_try_NUL_trans( current_state );
1392 */
1393
1394 #ifdef YY_USE_PROTOS
nidr_try_NUL_trans(nidr_state_type nidr_current_state)1395 static nidr_state_type nidr_try_NUL_trans( nidr_state_type nidr_current_state )
1396 #else
1397 static nidr_state_type nidr_try_NUL_trans( nidr_current_state )
1398 nidr_state_type nidr_current_state;
1399 #endif
1400 {
1401 register int nidr_is_jam;
1402 register char *nidr_cp = nidr_c_buf_p;
1403
1404 register YY_CHAR nidr_c = 1;
1405 if ( nidr_accept[nidr_current_state] )
1406 {
1407 nidr_last_accepting_state = nidr_current_state;
1408 nidr_last_accepting_cpos = nidr_cp;
1409 }
1410 while ( nidr_chk[nidr_base[nidr_current_state] + nidr_c] != nidr_current_state )
1411 {
1412 nidr_current_state = (int) nidr_def[nidr_current_state];
1413 if ( nidr_current_state >= 125 )
1414 nidr_c = nidr_meta[(unsigned int) nidr_c];
1415 }
1416 nidr_current_state = nidr_nxt[nidr_base[nidr_current_state] + (unsigned int) nidr_c];
1417 nidr_is_jam = (nidr_current_state == 124);
1418
1419 return nidr_is_jam ? 0 : nidr_current_state;
1420 }
1421
1422
1423 #ifndef YY_NO_UNPUT
1424 #ifdef YY_USE_PROTOS
nidrunput(int c,register char * nidr_bp)1425 static void nidrunput( int c, register char *nidr_bp )
1426 #else
1427 static void nidrunput( c, nidr_bp )
1428 int c;
1429 register char *nidr_bp;
1430 #endif
1431 {
1432 register char *nidr_cp = nidr_c_buf_p;
1433
1434 /* undo effects of setting up nidrtext */
1435 *nidr_cp = nidr_hold_char;
1436
1437 if ( nidr_cp < nidr_current_buffer->nidr_ch_buf + 2 )
1438 { /* need to shift things up to make room */
1439 /* +2 for EOB chars. */
1440 register int number_to_move = nidr_n_chars + 2;
1441 register char *dest = &nidr_current_buffer->nidr_ch_buf[
1442 nidr_current_buffer->nidr_buf_size + 2];
1443 register char *source =
1444 &nidr_current_buffer->nidr_ch_buf[number_to_move];
1445
1446 while ( source > nidr_current_buffer->nidr_ch_buf )
1447 *--dest = *--source;
1448
1449 nidr_cp += (int) (dest - source);
1450 nidr_bp += (int) (dest - source);
1451 nidr_current_buffer->nidr_n_chars =
1452 nidr_n_chars = nidr_current_buffer->nidr_buf_size;
1453
1454 if ( nidr_cp < nidr_current_buffer->nidr_ch_buf + 2 )
1455 YY_FATAL_ERROR( "flex scanner push-back overflow" );
1456 }
1457
1458 *--nidr_cp = (char) c;
1459
1460
1461 nidrtext_ptr = nidr_bp;
1462 nidr_hold_char = *nidr_cp;
1463 nidr_c_buf_p = nidr_cp;
1464 }
1465 #endif /* ifndef YY_NO_UNPUT */
1466
1467
1468 #ifndef YY_NO_INPUT
1469 #ifdef __cplusplus
nidrinput()1470 static int nidrinput()
1471 #else
1472 static int input()
1473 #endif
1474 {
1475 int c;
1476
1477 *nidr_c_buf_p = nidr_hold_char;
1478
1479 if ( *nidr_c_buf_p == YY_END_OF_BUFFER_CHAR )
1480 {
1481 /* nidr_c_buf_p now points to the character we want to return.
1482 * If this occurs *before* the EOB characters, then it's a
1483 * valid NUL; if not, then we've hit the end of the buffer.
1484 */
1485 if ( nidr_c_buf_p < &nidr_current_buffer->nidr_ch_buf[nidr_n_chars] )
1486 /* This was really a NUL. */
1487 *nidr_c_buf_p = '\0';
1488
1489 else
1490 { /* need more input */
1491 int offset = nidr_c_buf_p - nidrtext_ptr;
1492 ++nidr_c_buf_p;
1493
1494 switch ( nidr_get_next_buffer() )
1495 {
1496 case EOB_ACT_LAST_MATCH:
1497 /* This happens because nidr_g_n_b()
1498 * sees that we've accumulated a
1499 * token and flags that we need to
1500 * try matching the token before
1501 * proceeding. But for input(),
1502 * there's no matching to consider.
1503 * So convert the EOB_ACT_LAST_MATCH
1504 * to EOB_ACT_END_OF_FILE.
1505 */
1506
1507 /* Reset buffer status. */
1508 nidrrestart( nidrin );
1509
1510 /* fall through */
1511
1512 case EOB_ACT_END_OF_FILE:
1513 {
1514 if ( nidrwrap() )
1515 return EOF;
1516
1517 if ( ! nidr_did_buffer_switch_on_eof )
1518 YY_NEW_FILE;
1519 #ifdef __cplusplus
1520 return nidrinput();
1521 #else
1522 return input();
1523 #endif
1524 }
1525
1526 case EOB_ACT_CONTINUE_SCAN:
1527 nidr_c_buf_p = nidrtext_ptr + offset;
1528 break;
1529 }
1530 }
1531 }
1532
1533 c = *(unsigned char *) nidr_c_buf_p; /* cast for 8-bit char's */
1534 *nidr_c_buf_p = '\0'; /* preserve nidrtext */
1535 nidr_hold_char = *++nidr_c_buf_p;
1536
1537
1538 return c;
1539 }
1540 #endif /* YY_NO_INPUT */
1541
1542 #ifdef YY_USE_PROTOS
nidrrestart(FILE * input_file)1543 void nidrrestart( FILE *input_file )
1544 #else
1545 void nidrrestart( input_file )
1546 FILE *input_file;
1547 #endif
1548 {
1549 if ( ! nidr_current_buffer )
1550 nidr_current_buffer = nidr_create_buffer( nidrin, YY_BUF_SIZE );
1551
1552 nidr_init_buffer( nidr_current_buffer, input_file );
1553 nidr_load_buffer_state();
1554 }
1555
1556
1557 #ifdef YY_USE_PROTOS
nidr_switch_to_buffer(YY_BUFFER_STATE new_buffer)1558 void nidr_switch_to_buffer( YY_BUFFER_STATE new_buffer )
1559 #else
1560 void nidr_switch_to_buffer( new_buffer )
1561 YY_BUFFER_STATE new_buffer;
1562 #endif
1563 {
1564 if ( nidr_current_buffer == new_buffer )
1565 return;
1566
1567 if ( nidr_current_buffer )
1568 {
1569 /* Flush out information for old buffer. */
1570 *nidr_c_buf_p = nidr_hold_char;
1571 nidr_current_buffer->nidr_buf_pos = nidr_c_buf_p;
1572 nidr_current_buffer->nidr_n_chars = nidr_n_chars;
1573 }
1574
1575 nidr_current_buffer = new_buffer;
1576 nidr_load_buffer_state();
1577
1578 /* We don't actually know whether we did this switch during
1579 * EOF (nidrwrap()) processing, but the only time this flag
1580 * is looked at is after nidrwrap() is called, so it's safe
1581 * to go ahead and always set it.
1582 */
1583 nidr_did_buffer_switch_on_eof = 1;
1584 }
1585
1586
1587 #ifdef YY_USE_PROTOS
nidr_load_buffer_state(void)1588 void nidr_load_buffer_state( void )
1589 #else
1590 void nidr_load_buffer_state()
1591 #endif
1592 {
1593 nidr_n_chars = nidr_current_buffer->nidr_n_chars;
1594 nidrtext_ptr = nidr_c_buf_p = nidr_current_buffer->nidr_buf_pos;
1595 nidrin = nidr_current_buffer->nidr_input_file;
1596 nidr_hold_char = *nidr_c_buf_p;
1597 }
1598
1599
1600 #ifdef YY_USE_PROTOS
nidr_create_buffer(FILE * file,int size)1601 YY_BUFFER_STATE nidr_create_buffer( FILE *file, int size )
1602 #else
1603 YY_BUFFER_STATE nidr_create_buffer( file, size )
1604 FILE *file;
1605 int size;
1606 #endif
1607 {
1608 YY_BUFFER_STATE b;
1609
1610 b = (YY_BUFFER_STATE) nidr_flex_alloc( sizeof( struct nidr_buffer_state ) );
1611 if ( ! b )
1612 YY_FATAL_ERROR( "out of dynamic memory in nidr_create_buffer()" );
1613
1614 b->nidr_buf_size = size;
1615
1616 /* nidr_ch_buf has to be 2 characters longer than the size given because
1617 * we need to put in 2 end-of-buffer characters.
1618 */
1619 b->nidr_ch_buf = (char *) nidr_flex_alloc( b->nidr_buf_size + 2 );
1620 if ( ! b->nidr_ch_buf )
1621 YY_FATAL_ERROR( "out of dynamic memory in nidr_create_buffer()" );
1622
1623 b->nidr_is_our_buffer = 1;
1624
1625 nidr_init_buffer( b, file );
1626
1627 return b;
1628 }
1629
1630
1631 #ifdef YY_USE_PROTOS
nidr_delete_buffer(YY_BUFFER_STATE b)1632 void nidr_delete_buffer( YY_BUFFER_STATE b )
1633 #else
1634 void nidr_delete_buffer( b )
1635 YY_BUFFER_STATE b;
1636 #endif
1637 {
1638 if ( ! b )
1639 return;
1640
1641 if ( b == nidr_current_buffer )
1642 nidr_current_buffer = (YY_BUFFER_STATE) 0;
1643
1644 if ( b->nidr_is_our_buffer )
1645 nidr_flex_free( (void *) b->nidr_ch_buf );
1646
1647 nidr_flex_free( (void *) b );
1648 }
1649
1650
1651
1652 #ifdef YY_USE_PROTOS
nidr_init_buffer(YY_BUFFER_STATE b,FILE * file)1653 void nidr_init_buffer( YY_BUFFER_STATE b, FILE *file )
1654 #else
1655 void nidr_init_buffer( b, file )
1656 YY_BUFFER_STATE b;
1657 FILE *file;
1658 #endif
1659
1660
1661 {
1662 nidr_flush_buffer( b );
1663
1664 b->nidr_input_file = file;
1665 b->nidr_fill_buffer = 1;
1666
1667 #if YY_ALWAYS_INTERACTIVE
1668 b->nidr_is_interactive = 1;
1669 #else
1670 #if YY_NEVER_INTERACTIVE
1671 b->nidr_is_interactive = 0;
1672 #else
1673 b->nidr_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
1674 #endif
1675 #endif
1676 }
1677
1678
1679 #ifdef YY_USE_PROTOS
nidr_flush_buffer(YY_BUFFER_STATE b)1680 void nidr_flush_buffer( YY_BUFFER_STATE b )
1681 #else
1682 void nidr_flush_buffer( b )
1683 YY_BUFFER_STATE b;
1684 #endif
1685
1686 {
1687 if ( ! b )
1688 return;
1689
1690 b->nidr_n_chars = 0;
1691
1692 /* We always need two end-of-buffer characters. The first causes
1693 * a transition to the end-of-buffer state. The second causes
1694 * a jam in that state.
1695 */
1696 b->nidr_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1697 b->nidr_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1698
1699 b->nidr_buf_pos = &b->nidr_ch_buf[0];
1700
1701 b->nidr_at_bol = 1;
1702 b->nidr_buffer_status = YY_BUFFER_NEW;
1703
1704 if ( b == nidr_current_buffer )
1705 nidr_load_buffer_state();
1706 }
1707
1708
1709 #ifndef YY_NO_SCAN_BUFFER
1710 #ifdef YY_USE_PROTOS
nidr_scan_buffer(char * base,nidr_size_t size)1711 YY_BUFFER_STATE nidr_scan_buffer( char *base, nidr_size_t size )
1712 #else
1713 YY_BUFFER_STATE nidr_scan_buffer( base, size )
1714 char *base;
1715 nidr_size_t size;
1716 #endif
1717 {
1718 YY_BUFFER_STATE b;
1719
1720 if ( size < 2 ||
1721 base[size-2] != YY_END_OF_BUFFER_CHAR ||
1722 base[size-1] != YY_END_OF_BUFFER_CHAR )
1723 /* They forgot to leave room for the EOB's. */
1724 return 0;
1725
1726 b = (YY_BUFFER_STATE) nidr_flex_alloc( sizeof( struct nidr_buffer_state ) );
1727 if ( ! b )
1728 YY_FATAL_ERROR( "out of dynamic memory in nidr_scan_buffer()" );
1729
1730 b->nidr_buf_size = size - 2; /* "- 2" to take care of EOB's */
1731 b->nidr_buf_pos = b->nidr_ch_buf = base;
1732 b->nidr_is_our_buffer = 0;
1733 b->nidr_input_file = 0;
1734 b->nidr_n_chars = b->nidr_buf_size;
1735 b->nidr_is_interactive = 0;
1736 b->nidr_at_bol = 1;
1737 b->nidr_fill_buffer = 0;
1738 b->nidr_buffer_status = YY_BUFFER_NEW;
1739
1740 nidr_switch_to_buffer( b );
1741
1742 return b;
1743 }
1744 #endif
1745
1746
1747 #ifndef YY_NO_SCAN_STRING
1748 #ifdef YY_USE_PROTOS
nidr_scan_string(nidrconst char * nidr_str)1749 YY_BUFFER_STATE nidr_scan_string( nidrconst char *nidr_str )
1750 #else
1751 YY_BUFFER_STATE nidr_scan_string( nidr_str )
1752 nidrconst char *nidr_str;
1753 #endif
1754 {
1755 int len;
1756 for ( len = 0; nidr_str[len]; ++len )
1757 ;
1758
1759 return nidr_scan_bytes( nidr_str, len );
1760 }
1761 #endif
1762
1763
1764 #ifndef YY_NO_SCAN_BYTES
1765 #ifdef YY_USE_PROTOS
nidr_scan_bytes(nidrconst char * bytes,int len)1766 YY_BUFFER_STATE nidr_scan_bytes( nidrconst char *bytes, int len )
1767 #else
1768 YY_BUFFER_STATE nidr_scan_bytes( bytes, len )
1769 nidrconst char *bytes;
1770 int len;
1771 #endif
1772 {
1773 YY_BUFFER_STATE b;
1774 char *buf;
1775 nidr_size_t n;
1776 int i;
1777
1778 /* Get memory for full buffer, including space for trailing EOB's. */
1779 n = len + 2;
1780 buf = (char *) nidr_flex_alloc( n );
1781 if ( ! buf )
1782 YY_FATAL_ERROR( "out of dynamic memory in nidr_scan_bytes()" );
1783
1784 for ( i = 0; i < len; ++i )
1785 buf[i] = bytes[i];
1786
1787 buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;
1788
1789 b = nidr_scan_buffer( buf, n );
1790 if ( ! b )
1791 YY_FATAL_ERROR( "bad buffer in nidr_scan_bytes()" );
1792
1793 /* It's okay to grow etc. this buffer, and we should throw it
1794 * away when we're done.
1795 */
1796 b->nidr_is_our_buffer = 1;
1797
1798 return b;
1799 }
1800 #endif
1801
1802
1803 #ifndef YY_NO_PUSH_STATE
1804 #ifdef YY_USE_PROTOS
nidr_push_state(int new_state)1805 static void nidr_push_state( int new_state )
1806 #else
1807 static void nidr_push_state( new_state )
1808 int new_state;
1809 #endif
1810 {
1811 if ( nidr_start_stack_ptr >= nidr_start_stack_depth )
1812 {
1813 nidr_size_t new_size;
1814
1815 nidr_start_stack_depth += YY_START_STACK_INCR;
1816 new_size = nidr_start_stack_depth * sizeof( int );
1817
1818 if ( ! nidr_start_stack )
1819 nidr_start_stack = (int *) nidr_flex_alloc( new_size );
1820
1821 else
1822 nidr_start_stack = (int *) nidr_flex_realloc(
1823 (void *) nidr_start_stack, new_size );
1824
1825 if ( ! nidr_start_stack )
1826 YY_FATAL_ERROR(
1827 "out of memory expanding start-condition stack" );
1828 }
1829
1830 nidr_start_stack[nidr_start_stack_ptr++] = YY_START;
1831
1832 BEGIN(new_state);
1833 }
1834 #endif
1835
1836
1837 #ifndef YY_NO_POP_STATE
nidr_pop_state()1838 static void nidr_pop_state()
1839 {
1840 if ( --nidr_start_stack_ptr < 0 )
1841 YY_FATAL_ERROR( "start-condition stack underflow" );
1842
1843 BEGIN(nidr_start_stack[nidr_start_stack_ptr]);
1844 }
1845 #endif
1846
1847
1848 #ifndef YY_NO_TOP_STATE
nidr_top_state()1849 static int nidr_top_state()
1850 {
1851 return nidr_start_stack[nidr_start_stack_ptr - 1];
1852 }
1853 #endif
1854
1855 #ifndef YY_EXIT_FAILURE
1856 #define YY_EXIT_FAILURE 2
1857 #endif
1858
1859 #ifdef YY_USE_PROTOS
nidr_fatal_error(nidrconst char msg[])1860 static void nidr_fatal_error( nidrconst char msg[] )
1861 #else
1862 static void nidr_fatal_error( msg )
1863 char msg[];
1864 #endif
1865 {
1866 (void) fprintf( stderr, "%s\n", msg );
1867 exit( YY_EXIT_FAILURE );
1868 }
1869
1870
1871
1872 /* Redefine nidrless() so it works in section 3 code. */
1873
1874 #undef nidrless
1875 #define nidrless(n) \
1876 do \
1877 { \
1878 /* Undo effects of setting up nidrtext. */ \
1879 nidrtext[nidrleng] = nidr_hold_char; \
1880 nidr_c_buf_p = nidrtext + n; \
1881 nidr_hold_char = *nidr_c_buf_p; \
1882 *nidr_c_buf_p = '\0'; \
1883 nidrleng = n; \
1884 } \
1885 while ( 0 )
1886
1887
1888 /* Internal utility routines. */
1889
1890 #ifndef nidrtext_ptr
1891 #ifdef YY_USE_PROTOS
nidr_flex_strncpy(char * s1,nidrconst char * s2,int n)1892 static void nidr_flex_strncpy( char *s1, nidrconst char *s2, int n )
1893 #else
1894 static void nidr_flex_strncpy( s1, s2, n )
1895 char *s1;
1896 nidrconst char *s2;
1897 int n;
1898 #endif
1899 {
1900 register int i;
1901 for ( i = 0; i < n; ++i )
1902 s1[i] = s2[i];
1903 }
1904 #endif
1905
1906 #ifdef YY_NEED_STRLEN
1907 #ifdef YY_USE_PROTOS
nidr_flex_strlen(nidrconst char * s)1908 static int nidr_flex_strlen( nidrconst char *s )
1909 #else
1910 static int nidr_flex_strlen( s )
1911 nidrconst char *s;
1912 #endif
1913 {
1914 register int n;
1915 for ( n = 0; s[n]; ++n )
1916 ;
1917
1918 return n;
1919 }
1920 #endif
1921
1922
1923 #ifdef YY_USE_PROTOS
nidr_flex_alloc(nidr_size_t size)1924 static void *nidr_flex_alloc( nidr_size_t size )
1925 #else
1926 static void *nidr_flex_alloc( size )
1927 nidr_size_t size;
1928 #endif
1929 {
1930 return (void *) malloc( size );
1931 }
1932
1933 #ifdef YY_USE_PROTOS
nidr_flex_realloc(void * ptr,nidr_size_t size)1934 static void *nidr_flex_realloc( void *ptr, nidr_size_t size )
1935 #else
1936 static void *nidr_flex_realloc( ptr, size )
1937 void *ptr;
1938 nidr_size_t size;
1939 #endif
1940 {
1941 /* The cast to (char *) in the following accommodates both
1942 * implementations that use char* generic pointers, and those
1943 * that use void* generic pointers. It works with the latter
1944 * because both ANSI C and C++ allow castless assignment from
1945 * any pointer type to void*, and deal with argument conversions
1946 * as though doing an assignment.
1947 */
1948 return (void *) realloc( (char *) ptr, size );
1949 }
1950
1951 #ifdef YY_USE_PROTOS
nidr_flex_free(void * ptr)1952 static void nidr_flex_free( void *ptr )
1953 #else
1954 static void nidr_flex_free( ptr )
1955 void *ptr;
1956 #endif
1957 {
1958 free( ptr );
1959 }
1960
1961 #if YY_MAIN
main()1962 int main()
1963 {
1964 nidrlex();
1965 return 0;
1966 }
1967 #endif
1968 /* #line 272 "nidrscan.l" */
1969
1970
1971 static int nidr_ateof = 0;
1972 static const char *nidr_instring = 0;
1973
1974 void
bad_number(const char * s)1975 bad_number(const char *s)
1976 {
1977 fprintf(stderr, "\n*** Invalid number \"%s\" on input line %d within "
1978 "%s keyword.\n", s, nidrLineNumber, nidr_keyword_name());
1979 nidr_abort();
1980 }
1981
1982 void
nidr_set_input_string(const char * s)1983 nidr_set_input_string(const char *s)
1984 {
1985 nidr_instring = s;
1986 }
1987
1988 static int
my_nidr_input(char * buf,int bmax)1989 my_nidr_input(char *buf, int bmax)
1990 {
1991 int c, n;
1992
1993 if (nidr_ateof)
1994 return 0;
1995 n = 0;
1996 if (nidr_instring) {
1997 while(n < bmax && (c = *nidr_instring)) {
1998 ++nidr_instring;
1999 if (c != '\r')
2000 buf[n++] = c;
2001 if (c == '\n')
2002 break;
2003 }
2004 }
2005 else if (nidr_current_buffer->nidr_is_interactive)
2006 while(n < bmax) {
2007 if ((c = getc(nidrin)) == EOF)
2008 break;
2009 if (c != '\r')
2010 buf[n++] = c;
2011 if (c == '\n')
2012 break;
2013 }
2014 else
2015 while(n < bmax) {
2016 if ((c = getc(nidrin)) == EOF)
2017 break;
2018 if (c != '\r')
2019 buf[n++] = c;
2020 }
2021 if (n <= 0) {
2022 nidr_ateof = n = 1;
2023 if (c == EOF) {
2024 fclose(nidrin);
2025 nidrin = NULL;
2026 }
2027 buf[0] = ';';
2028 }
2029 return n;
2030 }
2031
2032 void
reset_nidrlex_state(void)2033 reset_nidrlex_state(void)
2034 {
2035 BEGIN INITIAL;
2036 nidr_abort();
2037 }
2038
2039 void
unput_string(char * s,int len)2040 unput_string(char *s, int len)
2041 {
2042 while(--len >= 0)
2043 unput(s[len]);
2044 }
2045
2046 void
nidr_reinit(void)2047 nidr_reinit(void)
2048 {
2049 nidr_init = 1;
2050 nidr_ateof = 0;
2051 if (nidr_current_buffer) {
2052 free(nidr_current_buffer->nidr_ch_buf);
2053 free(nidr_current_buffer);
2054 nidr_current_buffer = 0;
2055 }
2056 }
2057
2058 int
nidrwrap(void)2059 nidrwrap(void)
2060 { return 1; }
2061