1
2 #line 3 "<stdout>"
3
4 #define YY_INT_ALIGNED short int
5
6 /* A lexical scanner generated by flex */
7
8 #define FLEX_SCANNER
9 #define YY_FLEX_MAJOR_VERSION 2
10 #define YY_FLEX_MINOR_VERSION 5
11 #define YY_FLEX_SUBMINOR_VERSION 37
12 #if YY_FLEX_SUBMINOR_VERSION > 0
13 #define FLEX_BETA
14 #endif
15
16 /* First, we deal with platform-specific or compiler-specific issues. */
17
18 /* begin standard C headers. */
19 #include <stdio.h>
20 #include <string.h>
21 #include <errno.h>
22 #include <stdlib.h>
23
24 /* end standard C headers. */
25
26 /* flex integer type definitions */
27
28 #ifndef FLEXINT_H
29 #define FLEXINT_H
30
31 /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
32
33 #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
34
35 /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
36 * if you want the limit (max/min) macros for int types.
37 */
38 #ifndef __STDC_LIMIT_MACROS
39 #define __STDC_LIMIT_MACROS 1
40 #endif
41
42 #include <inttypes.h>
43 typedef int8_t flex_int8_t;
44 typedef uint8_t flex_uint8_t;
45 typedef int16_t flex_int16_t;
46 typedef uint16_t flex_uint16_t;
47 typedef int32_t flex_int32_t;
48 typedef uint32_t flex_uint32_t;
49 #else
50 typedef signed char flex_int8_t;
51 typedef short int flex_int16_t;
52 typedef int flex_int32_t;
53 typedef unsigned char flex_uint8_t;
54 typedef unsigned short int flex_uint16_t;
55 typedef unsigned int flex_uint32_t;
56
57 /* Limits of integral types. */
58 #ifndef INT8_MIN
59 #define INT8_MIN (-128)
60 #endif
61 #ifndef INT16_MIN
62 #define INT16_MIN (-32767-1)
63 #endif
64 #ifndef INT32_MIN
65 #define INT32_MIN (-2147483647-1)
66 #endif
67 #ifndef INT8_MAX
68 #define INT8_MAX (127)
69 #endif
70 #ifndef INT16_MAX
71 #define INT16_MAX (32767)
72 #endif
73 #ifndef INT32_MAX
74 #define INT32_MAX (2147483647)
75 #endif
76 #ifndef UINT8_MAX
77 #define UINT8_MAX (255U)
78 #endif
79 #ifndef UINT16_MAX
80 #define UINT16_MAX (65535U)
81 #endif
82 #ifndef UINT32_MAX
83 #define UINT32_MAX (4294967295U)
84 #endif
85
86 #endif /* ! C99 */
87
88 #endif /* ! FLEXINT_H */
89
90 #ifdef __cplusplus
91
92 /* The "const" storage-class-modifier is valid. */
93 #define YY_USE_CONST
94
95 #else /* ! __cplusplus */
96
97 /* C99 requires __STDC__ to be defined as 1. */
98 #if defined (__STDC__)
99
100 #define YY_USE_CONST
101
102 #endif /* defined (__STDC__) */
103 #endif /* ! __cplusplus */
104
105 #ifdef YY_USE_CONST
106 #define yyconst const
107 #else
108 #define yyconst
109 #endif
110
111 /* Returned upon end-of-file. */
112 #define YY_NULL 0
113
114 /* Promotes a possibly negative, possibly signed char to an unsigned
115 * integer for use as an array index. If the signed char is negative,
116 * we want to instead treat it as an 8-bit unsigned char, hence the
117 * double cast.
118 */
119 #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
120
121 /* Enter a start condition. This macro really ought to take a parameter,
122 * but we do it the disgusting crufty way forced on us by the ()-less
123 * definition of BEGIN.
124 */
125 #define BEGIN (yy_start) = 1 + 2 *
126
127 /* Translate the current start state into a value that can be later handed
128 * to BEGIN to return to the state. The YYSTATE alias is for lex
129 * compatibility.
130 */
131 #define YY_START (((yy_start) - 1) / 2)
132 #define YYSTATE YY_START
133
134 /* Action number for EOF rule of a given start state. */
135 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
136
137 /* Special action meaning "start processing a new file". */
138 #define YY_NEW_FILE yyrestart(yyin )
139
140 #define YY_END_OF_BUFFER_CHAR 0
141
142 /* Size of default input buffer. */
143 #ifndef YY_BUF_SIZE
144 #define YY_BUF_SIZE 16384
145 #endif
146
147 /* The state buf must be large enough to hold one state per character in the main buffer.
148 */
149 #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
150
151 #ifndef YY_TYPEDEF_YY_BUFFER_STATE
152 #define YY_TYPEDEF_YY_BUFFER_STATE
153 typedef struct yy_buffer_state *YY_BUFFER_STATE;
154 #endif
155
156 #ifndef YY_TYPEDEF_YY_SIZE_T
157 #define YY_TYPEDEF_YY_SIZE_T
158 typedef size_t yy_size_t;
159 #endif
160
161 extern yy_size_t yyleng;
162
163 extern FILE *yyin, *yyout;
164
165 #define EOB_ACT_CONTINUE_SCAN 0
166 #define EOB_ACT_END_OF_FILE 1
167 #define EOB_ACT_LAST_MATCH 2
168
169 #define YY_LESS_LINENO(n)
170
171 /* Return all but the first "n" matched characters back to the input stream. */
172 #define yyless(n) \
173 do \
174 { \
175 /* Undo effects of setting up yytext. */ \
176 int yyless_macro_arg = (n); \
177 YY_LESS_LINENO(yyless_macro_arg);\
178 *yy_cp = (yy_hold_char); \
179 YY_RESTORE_YY_MORE_OFFSET \
180 (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
181 YY_DO_BEFORE_ACTION; /* set up yytext again */ \
182 } \
183 while ( 0 )
184
185 #define unput(c) yyunput( c, (yytext_ptr) )
186
187 #ifndef YY_STRUCT_YY_BUFFER_STATE
188 #define YY_STRUCT_YY_BUFFER_STATE
189 struct yy_buffer_state
190 {
191 FILE *yy_input_file;
192
193 char *yy_ch_buf; /* input buffer */
194 char *yy_buf_pos; /* current position in input buffer */
195
196 /* Size of input buffer in bytes, not including room for EOB
197 * characters.
198 */
199 yy_size_t yy_buf_size;
200
201 /* Number of characters read into yy_ch_buf, not including EOB
202 * characters.
203 */
204 yy_size_t yy_n_chars;
205
206 /* Whether we "own" the buffer - i.e., we know we created it,
207 * and can realloc() it to grow it, and should free() it to
208 * delete it.
209 */
210 int yy_is_our_buffer;
211
212 /* Whether this is an "interactive" input source; if so, and
213 * if we're using stdio for input, then we want to use getc()
214 * instead of fread(), to make sure we stop fetching input after
215 * each newline.
216 */
217 int yy_is_interactive;
218
219 /* Whether we're considered to be at the beginning of a line.
220 * If so, '^' rules will be active on the next match, otherwise
221 * not.
222 */
223 int yy_at_bol;
224
225 int yy_bs_lineno; /**< The line count. */
226 int yy_bs_column; /**< The column count. */
227
228 /* Whether to try to fill the input buffer when we reach the
229 * end of it.
230 */
231 int yy_fill_buffer;
232
233 int yy_buffer_status;
234
235 #define YY_BUFFER_NEW 0
236 #define YY_BUFFER_NORMAL 1
237 /* When an EOF's been seen but there's still some text to process
238 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
239 * shouldn't try reading from the input source any more. We might
240 * still have a bunch of tokens to match, though, because of
241 * possible backing-up.
242 *
243 * When we actually see the EOF, we change the status to "new"
244 * (via yyrestart()), so that the user can continue scanning by
245 * just pointing yyin at a new input file.
246 */
247 #define YY_BUFFER_EOF_PENDING 2
248
249 };
250 #endif /* !YY_STRUCT_YY_BUFFER_STATE */
251
252 /* Stack of input buffers. */
253 static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
254 static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
255 static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
256
257 /* We provide macros for accessing buffer states in case in the
258 * future we want to put the buffer states in a more general
259 * "scanner state".
260 *
261 * Returns the top of the stack, or NULL.
262 */
263 #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
264 ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
265 : NULL)
266
267 /* Same as previous macro, but useful when we know that the buffer stack is not
268 * NULL or when we need an lvalue. For internal use only.
269 */
270 #define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
271
272 /* yy_hold_char holds the character lost when yytext is formed. */
273 static char yy_hold_char;
274 static yy_size_t yy_n_chars; /* number of characters read into yy_ch_buf */
275 yy_size_t yyleng;
276
277 /* Points to current character in buffer. */
278 static char *yy_c_buf_p = (char *) 0;
279 static int yy_init = 0; /* whether we need to initialize */
280 static int yy_start = 0; /* start state number */
281
282 /* Flag which is used to allow yywrap()'s to do buffer switches
283 * instead of setting up a fresh yyin. A bit of a hack ...
284 */
285 static int yy_did_buffer_switch_on_eof;
286
287 void yyrestart (FILE *input_file );
288 void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer );
289 YY_BUFFER_STATE yy_create_buffer (FILE *file,int size );
290 void yy_delete_buffer (YY_BUFFER_STATE b );
291 void yy_flush_buffer (YY_BUFFER_STATE b );
292 void yypush_buffer_state (YY_BUFFER_STATE new_buffer );
293 void yypop_buffer_state (void );
294
295 static void yyensure_buffer_stack (void );
296 static void yy_load_buffer_state (void );
297 static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file );
298
299 #define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER )
300
301 YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size );
302 YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str );
303 YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,yy_size_t len );
304
305 void *yyalloc (yy_size_t );
306 void *yyrealloc (void *,yy_size_t );
307 void yyfree (void * );
308
309 #define yy_new_buffer yy_create_buffer
310
311 #define yy_set_interactive(is_interactive) \
312 { \
313 if ( ! YY_CURRENT_BUFFER ){ \
314 yyensure_buffer_stack (); \
315 YY_CURRENT_BUFFER_LVALUE = \
316 yy_create_buffer(yyin,YY_BUF_SIZE ); \
317 } \
318 YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
319 }
320
321 #define yy_set_bol(at_bol) \
322 { \
323 if ( ! YY_CURRENT_BUFFER ){\
324 yyensure_buffer_stack (); \
325 YY_CURRENT_BUFFER_LVALUE = \
326 yy_create_buffer(yyin,YY_BUF_SIZE ); \
327 } \
328 YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
329 }
330
331 #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
332
333 /* Begin user sect3 */
334
335 typedef unsigned char YY_CHAR;
336
337 FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
338
339 typedef int yy_state_type;
340
341 extern int yylineno;
342
343 int yylineno = 1;
344
345 extern char *yytext;
346 #define yytext_ptr yytext
347
348 static yy_state_type yy_get_previous_state (void );
349 static yy_state_type yy_try_NUL_trans (yy_state_type current_state );
350 static int yy_get_next_buffer (void );
351 static void yy_fatal_error (yyconst char msg[] );
352
353 /* Done after the current pattern has been matched and before the
354 * corresponding action - sets up yytext.
355 */
356 #define YY_DO_BEFORE_ACTION \
357 (yytext_ptr) = yy_bp; \
358 yyleng = (size_t) (yy_cp - yy_bp); \
359 (yy_hold_char) = *yy_cp; \
360 *yy_cp = '\0'; \
361 (yy_c_buf_p) = yy_cp;
362
363 #define YY_NUM_RULES 14
364 #define YY_END_OF_BUFFER 15
365 /* This struct is not used in this scanner,
366 but its presence is necessary. */
367 struct yy_trans_info
368 {
369 flex_int32_t yy_verify;
370 flex_int32_t yy_nxt;
371 };
372 static yyconst flex_int16_t yy_accept[35] =
373 { 0,
374 0, 0, 15, 13, 1, 1, 13, 13, 13, 2,
375 2, 13, 13, 13, 13, 1, 9, 10, 12, 2,
376 0, 0, 2, 6, 4, 8, 5, 7, 11, 0,
377 2, 0, 3, 0
378 } ;
379
380 static yyconst flex_int32_t yy_ec[256] =
381 { 0,
382 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
383 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
384 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
385 1, 2, 4, 1, 1, 1, 1, 5, 1, 1,
386 1, 6, 1, 1, 1, 1, 1, 7, 8, 8,
387 8, 8, 8, 8, 8, 9, 9, 10, 1, 11,
388 12, 13, 1, 1, 14, 14, 14, 14, 14, 14,
389 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,
390 15, 16, 15, 15, 15, 15, 15, 17, 15, 15,
391 1, 1, 1, 1, 1, 1, 14, 14, 14, 14,
392
393 14, 14, 15, 15, 15, 15, 15, 15, 15, 15,
394 15, 15, 15, 16, 15, 15, 15, 15, 15, 17,
395 15, 15, 1, 18, 1, 1, 1, 1, 1, 1,
396 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
397 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
398 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
399 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
400 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
401 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
402 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
403
404 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
405 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
406 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
407 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
408 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
409 1, 1, 1, 1, 1
410 } ;
411
412 static yyconst flex_int32_t yy_meta[19] =
413 { 0,
414 1, 1, 1, 1, 1, 1, 2, 2, 2, 1,
415 1, 1, 1, 3, 4, 4, 4, 1
416 } ;
417
418 static yyconst flex_int16_t yy_base[39] =
419 { 0,
420 0, 0, 48, 49, 17, 19, 35, 41, 39, 16,
421 0, 14, 32, 15, 25, 27, 49, 49, 49, 27,
422 0, 0, 0, 49, 49, 49, 49, 49, 49, 32,
423 0, 0, 0, 49, 39, 29, 34, 36
424 } ;
425
426 static yyconst flex_int16_t yy_def[39] =
427 { 0,
428 34, 1, 34, 34, 34, 34, 34, 34, 34, 34,
429 35, 34, 34, 34, 34, 34, 34, 34, 34, 34,
430 36, 37, 35, 34, 34, 34, 34, 34, 34, 36,
431 37, 38, 38, 0, 34, 34, 34, 34
432 } ;
433
434 static yyconst flex_int16_t yy_nxt[68] =
435 { 0,
436 4, 5, 6, 7, 8, 9, 10, 11, 11, 4,
437 12, 13, 14, 4, 4, 4, 4, 15, 16, 16,
438 16, 16, 20, 20, 24, 25, 27, 28, 16, 16,
439 30, 21, 22, 20, 20, 31, 31, 33, 33, 33,
440 23, 32, 29, 26, 19, 18, 17, 34, 3, 34,
441 34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
442 34, 34, 34, 34, 34, 34, 34
443 } ;
444
445 static yyconst flex_int16_t yy_chk[68] =
446 { 0,
447 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
448 1, 1, 1, 1, 1, 1, 1, 1, 5, 5,
449 6, 6, 10, 10, 12, 12, 14, 14, 16, 16,
450 36, 10, 10, 20, 20, 37, 37, 38, 38, 38,
451 35, 30, 15, 13, 9, 8, 7, 3, 34, 34,
452 34, 34, 34, 34, 34, 34, 34, 34, 34, 34,
453 34, 34, 34, 34, 34, 34, 34
454 } ;
455
456 static yy_state_type yy_last_accepting_state;
457 static char *yy_last_accepting_cpos;
458
459 extern int yy_flex_debug;
460 int yy_flex_debug = 0;
461
462 /* The intent behind this definition is that it'll catch
463 * any uses of REJECT which flex missed.
464 */
465 #define REJECT reject_used_but_not_detected
466 #define yymore() yymore_used_but_not_detected
467 #define YY_MORE_ADJ 0
468 #define YY_RESTORE_YY_MORE_OFFSET
469 char *yytext;
470 #line 1 "/usr/src/usr.bin/m4/tokenizer.l"
471 #define YY_NO_INPUT 1
472 #line 3 "/usr/src/usr.bin/m4/tokenizer.l"
473 /* $OpenBSD: tokenizer.l,v 1.7 2010/03/22 20:40:44 espie Exp $ */
474 /*
475 * Copyright (c) 2004 Marc Espie <espie@cvs.openbsd.org>
476 *
477 * Permission to use, copy, modify, and distribute this software for any
478 * purpose with or without fee is hereby granted, provided that the above
479 * copyright notice and this permission notice appear in all copies.
480 *
481 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
482 * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
483 * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
484 * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
485 * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
486 * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
487 * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
488 *
489 * $FreeBSD: src/usr.bin/m4/tokenizer.l,v 1.3 2012/11/17 01:54:24 svnexp Exp $
490 */
491
492 #include "parser.h"
493 #include <assert.h>
494 #include <stdlib.h>
495 #include <errno.h>
496 #include <stdint.h>
497 #include <limits.h>
498 #include <sys/param.h>
499
500 extern int mimic_gnu;
501 extern int32_t yylval;
502
503 int32_t number(void);
504 int32_t parse_radix(void);
505 #line 506 "<stdout>"
506
507 #define INITIAL 0
508
509 #ifndef YY_NO_UNISTD_H
510 /* Special case for "unistd.h", since it is non-ANSI. We include it way
511 * down here because we want the user's section 1 to have been scanned first.
512 * The user has a chance to override it with an option.
513 */
514 #include <unistd.h>
515 #endif
516
517 #ifndef YY_EXTRA_TYPE
518 #define YY_EXTRA_TYPE void *
519 #endif
520
521 static int yy_init_globals (void );
522
523 /* Accessor methods to globals.
524 These are made visible to non-reentrant scanners for convenience. */
525
526 int yylex_destroy (void );
527
528 int yyget_debug (void );
529
530 void yyset_debug (int debug_flag );
531
532 YY_EXTRA_TYPE yyget_extra (void );
533
534 void yyset_extra (YY_EXTRA_TYPE user_defined );
535
536 FILE *yyget_in (void );
537
538 void yyset_in (FILE * in_str );
539
540 FILE *yyget_out (void );
541
542 void yyset_out (FILE * out_str );
543
544 yy_size_t yyget_leng (void );
545
546 char *yyget_text (void );
547
548 int yyget_lineno (void );
549
550 void yyset_lineno (int line_number );
551
552 /* Macros after this point can all be overridden by user definitions in
553 * section 1.
554 */
555
556 #ifndef YY_SKIP_YYWRAP
557 #ifdef __cplusplus
558 extern "C" int yywrap (void );
559 #else
560 extern int yywrap (void );
561 #endif
562 #endif
563
564 #ifndef yytext_ptr
565 static void yy_flex_strncpy (char *,yyconst char *,int );
566 #endif
567
568 #ifdef YY_NEED_STRLEN
569 static int yy_flex_strlen (yyconst char * );
570 #endif
571
572 #ifndef YY_NO_INPUT
573
574 #ifdef __cplusplus
575 static int yyinput (void );
576 #else
577 static int input (void );
578 #endif
579
580 #endif
581
582 /* Amount of stuff to slurp up with each read. */
583 #ifndef YY_READ_BUF_SIZE
584 #define YY_READ_BUF_SIZE 8192
585 #endif
586
587 /* Copy whatever the last rule matched to the standard output. */
588 #ifndef ECHO
589 /* This used to be an fputs(), but since the string might contain NUL's,
590 * we now use fwrite().
591 */
592 #define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0)
593 #endif
594
595 /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
596 * is returned in "result".
597 */
598 #ifndef YY_INPUT
599 #define YY_INPUT(buf,result,max_size) \
600 if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
601 { \
602 int c = '*'; \
603 size_t n; \
604 for ( n = 0; n < max_size && \
605 (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
606 buf[n] = (char) c; \
607 if ( c == '\n' ) \
608 buf[n++] = (char) c; \
609 if ( c == EOF && ferror( yyin ) ) \
610 YY_FATAL_ERROR( "input in flex scanner failed" ); \
611 result = n; \
612 } \
613 else \
614 { \
615 errno=0; \
616 while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
617 { \
618 if( errno != EINTR) \
619 { \
620 YY_FATAL_ERROR( "input in flex scanner failed" ); \
621 break; \
622 } \
623 errno=0; \
624 clearerr(yyin); \
625 } \
626 }\
627 \
628
629 #endif
630
631 /* No semi-colon after return; correct usage is to write "yyterminate();" -
632 * we don't want an extra ';' after the "return" because that will cause
633 * some compilers to complain about unreachable statements.
634 */
635 #ifndef yyterminate
636 #define yyterminate() return YY_NULL
637 #endif
638
639 /* Number of entries by which start-condition stack grows. */
640 #ifndef YY_START_STACK_INCR
641 #define YY_START_STACK_INCR 25
642 #endif
643
644 /* Report a fatal error. */
645 #ifndef YY_FATAL_ERROR
646 #define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
647 #endif
648
649 /* end tables serialization structures and prototypes */
650
651 /* Default declaration of generated scanner - a define so the user can
652 * easily add parameters.
653 */
654 #ifndef YY_DECL
655 #define YY_DECL_IS_OURS 1
656
657 extern int yylex (void);
658
659 #define YY_DECL int yylex (void)
660 #endif /* !YY_DECL */
661
662 /* Code executed at the beginning of each rule, after yytext and yyleng
663 * have been set up.
664 */
665 #ifndef YY_USER_ACTION
666 #define YY_USER_ACTION
667 #endif
668
669 /* Code executed at the end of each rule. */
670 #ifndef YY_BREAK
671 #define YY_BREAK break;
672 #endif
673
674 #define YY_RULE_SETUP \
675 YY_USER_ACTION
676
677 /** The main scanner function which does all the work.
678 */
679 YY_DECL
680 {
681 register yy_state_type yy_current_state;
682 register char *yy_cp, *yy_bp;
683 register int yy_act;
684
685 #line 44 "/usr/src/usr.bin/m4/tokenizer.l"
686
687 #line 688 "<stdout>"
688
689 if ( !(yy_init) )
690 {
691 (yy_init) = 1;
692
693 #ifdef YY_USER_INIT
694 YY_USER_INIT;
695 #endif
696
697 if ( ! (yy_start) )
698 (yy_start) = 1; /* first start state */
699
700 if ( ! yyin )
701 yyin = stdin;
702
703 if ( ! yyout )
704 yyout = stdout;
705
706 if ( ! YY_CURRENT_BUFFER ) {
707 yyensure_buffer_stack ();
708 YY_CURRENT_BUFFER_LVALUE =
709 yy_create_buffer(yyin,YY_BUF_SIZE );
710 }
711
712 yy_load_buffer_state( );
713 }
714
715 while ( 1 ) /* loops until end-of-file is reached */
716 {
717 yy_cp = (yy_c_buf_p);
718
719 /* Support of yytext. */
720 *yy_cp = (yy_hold_char);
721
722 /* yy_bp points to the position in yy_ch_buf of the start of
723 * the current run.
724 */
725 yy_bp = yy_cp;
726
727 yy_current_state = (yy_start);
728 yy_match:
729 do
730 {
731 register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
732 if ( yy_accept[yy_current_state] )
733 {
734 (yy_last_accepting_state) = yy_current_state;
735 (yy_last_accepting_cpos) = yy_cp;
736 }
737 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
738 {
739 yy_current_state = (int) yy_def[yy_current_state];
740 if ( yy_current_state >= 35 )
741 yy_c = yy_meta[(unsigned int) yy_c];
742 }
743 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
744 ++yy_cp;
745 }
746 while ( yy_base[yy_current_state] != 49 );
747
748 yy_find_action:
749 yy_act = yy_accept[yy_current_state];
750 if ( yy_act == 0 )
751 { /* have to back up */
752 yy_cp = (yy_last_accepting_cpos);
753 yy_current_state = (yy_last_accepting_state);
754 yy_act = yy_accept[yy_current_state];
755 }
756
757 YY_DO_BEFORE_ACTION;
758
759 do_action: /* This label is used only to access EOF actions. */
760
761 switch ( yy_act )
762 { /* beginning of action switch */
763 case 0: /* must back up */
764 /* undo the effects of YY_DO_BEFORE_ACTION */
765 *yy_cp = (yy_hold_char);
766 yy_cp = (yy_last_accepting_cpos);
767 yy_current_state = (yy_last_accepting_state);
768 goto yy_find_action;
769
770 case 1:
771 /* rule 1 can match eol */
772 YY_RULE_SETUP
773 #line 45 "/usr/src/usr.bin/m4/tokenizer.l"
774 {/* just skip it */}
775 YY_BREAK
776 case 2:
777 YY_RULE_SETUP
778 #line 46 "/usr/src/usr.bin/m4/tokenizer.l"
779 { yylval = number(); return(NUMBER); }
780 YY_BREAK
781 case 3:
782 YY_RULE_SETUP
783 #line 47 "/usr/src/usr.bin/m4/tokenizer.l"
784 { if (mimic_gnu) {
785 yylval = parse_radix(); return(NUMBER);
786 } else {
787 return(ERROR);
788 }
789 }
790 YY_BREAK
791 case 4:
792 YY_RULE_SETUP
793 #line 53 "/usr/src/usr.bin/m4/tokenizer.l"
794 { return(LE); }
795 YY_BREAK
796 case 5:
797 YY_RULE_SETUP
798 #line 54 "/usr/src/usr.bin/m4/tokenizer.l"
799 { return(GE); }
800 YY_BREAK
801 case 6:
802 YY_RULE_SETUP
803 #line 55 "/usr/src/usr.bin/m4/tokenizer.l"
804 { return(LSHIFT); }
805 YY_BREAK
806 case 7:
807 YY_RULE_SETUP
808 #line 56 "/usr/src/usr.bin/m4/tokenizer.l"
809 { return(RSHIFT); }
810 YY_BREAK
811 case 8:
812 YY_RULE_SETUP
813 #line 57 "/usr/src/usr.bin/m4/tokenizer.l"
814 { return(EQ); }
815 YY_BREAK
816 case 9:
817 YY_RULE_SETUP
818 #line 58 "/usr/src/usr.bin/m4/tokenizer.l"
819 { return(NE); }
820 YY_BREAK
821 case 10:
822 YY_RULE_SETUP
823 #line 59 "/usr/src/usr.bin/m4/tokenizer.l"
824 { return(LAND); }
825 YY_BREAK
826 case 11:
827 YY_RULE_SETUP
828 #line 60 "/usr/src/usr.bin/m4/tokenizer.l"
829 { return(LOR); }
830 YY_BREAK
831 case 12:
832 YY_RULE_SETUP
833 #line 61 "/usr/src/usr.bin/m4/tokenizer.l"
834 { if (mimic_gnu) { return (EXPONENT); } }
835 YY_BREAK
836 case 13:
837 YY_RULE_SETUP
838 #line 62 "/usr/src/usr.bin/m4/tokenizer.l"
839 { return yytext[0]; }
840 YY_BREAK
841 case 14:
842 YY_RULE_SETUP
843 #line 63 "/usr/src/usr.bin/m4/tokenizer.l"
844 ECHO;
845 YY_BREAK
846 #line 847 "<stdout>"
847 case YY_STATE_EOF(INITIAL):
848 yyterminate();
849
850 case YY_END_OF_BUFFER:
851 {
852 /* Amount of text matched not including the EOB char. */
853 int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
854
855 /* Undo the effects of YY_DO_BEFORE_ACTION. */
856 *yy_cp = (yy_hold_char);
857 YY_RESTORE_YY_MORE_OFFSET
858
859 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
860 {
861 /* We're scanning a new file or input source. It's
862 * possible that this happened because the user
863 * just pointed yyin at a new source and called
864 * yylex(). If so, then we have to assure
865 * consistency between YY_CURRENT_BUFFER and our
866 * globals. Here is the right place to do so, because
867 * this is the first action (other than possibly a
868 * back-up) that will match for the new input source.
869 */
870 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
871 YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
872 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
873 }
874
875 /* Note that here we test for yy_c_buf_p "<=" to the position
876 * of the first EOB in the buffer, since yy_c_buf_p will
877 * already have been incremented past the NUL character
878 * (since all states make transitions on EOB to the
879 * end-of-buffer state). Contrast this with the test
880 * in input().
881 */
882 if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
883 { /* This was really a NUL. */
884 yy_state_type yy_next_state;
885
886 (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
887
888 yy_current_state = yy_get_previous_state( );
889
890 /* Okay, we're now positioned to make the NUL
891 * transition. We couldn't have
892 * yy_get_previous_state() go ahead and do it
893 * for us because it doesn't know how to deal
894 * with the possibility of jamming (and we don't
895 * want to build jamming into it because then it
896 * will run more slowly).
897 */
898
899 yy_next_state = yy_try_NUL_trans( yy_current_state );
900
901 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
902
903 if ( yy_next_state )
904 {
905 /* Consume the NUL. */
906 yy_cp = ++(yy_c_buf_p);
907 yy_current_state = yy_next_state;
908 goto yy_match;
909 }
910
911 else
912 {
913 yy_cp = (yy_c_buf_p);
914 goto yy_find_action;
915 }
916 }
917
918 else switch ( yy_get_next_buffer( ) )
919 {
920 case EOB_ACT_END_OF_FILE:
921 {
922 (yy_did_buffer_switch_on_eof) = 0;
923
924 if ( yywrap( ) )
925 {
926 /* Note: because we've taken care in
927 * yy_get_next_buffer() to have set up
928 * yytext, we can now set up
929 * yy_c_buf_p so that if some total
930 * hoser (like flex itself) wants to
931 * call the scanner after we return the
932 * YY_NULL, it'll still work - another
933 * YY_NULL will get returned.
934 */
935 (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
936
937 yy_act = YY_STATE_EOF(YY_START);
938 goto do_action;
939 }
940
941 else
942 {
943 if ( ! (yy_did_buffer_switch_on_eof) )
944 YY_NEW_FILE;
945 }
946 break;
947 }
948
949 case EOB_ACT_CONTINUE_SCAN:
950 (yy_c_buf_p) =
951 (yytext_ptr) + yy_amount_of_matched_text;
952
953 yy_current_state = yy_get_previous_state( );
954
955 yy_cp = (yy_c_buf_p);
956 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
957 goto yy_match;
958
959 case EOB_ACT_LAST_MATCH:
960 (yy_c_buf_p) =
961 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
962
963 yy_current_state = yy_get_previous_state( );
964
965 yy_cp = (yy_c_buf_p);
966 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
967 goto yy_find_action;
968 }
969 break;
970 }
971
972 default:
973 YY_FATAL_ERROR(
974 "fatal flex scanner internal error--no action found" );
975 } /* end of action switch */
976 } /* end of scanning one token */
977 } /* end of yylex */
978
979 /* yy_get_next_buffer - try to read in a new buffer
980 *
981 * Returns a code representing an action:
982 * EOB_ACT_LAST_MATCH -
983 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
984 * EOB_ACT_END_OF_FILE - end of file
985 */
yy_get_next_buffer(void)986 static int yy_get_next_buffer (void)
987 {
988 register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
989 register char *source = (yytext_ptr);
990 register int number_to_move, i;
991 int ret_val;
992
993 if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
994 YY_FATAL_ERROR(
995 "fatal flex scanner internal error--end of buffer missed" );
996
997 if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
998 { /* Don't try to fill the buffer, so this is an EOF. */
999 if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
1000 {
1001 /* We matched a single character, the EOB, so
1002 * treat this as a final EOF.
1003 */
1004 return EOB_ACT_END_OF_FILE;
1005 }
1006
1007 else
1008 {
1009 /* We matched some text prior to the EOB, first
1010 * process it.
1011 */
1012 return EOB_ACT_LAST_MATCH;
1013 }
1014 }
1015
1016 /* Try to read more data. */
1017
1018 /* First move last chars to start of buffer. */
1019 number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
1020
1021 for ( i = 0; i < number_to_move; ++i )
1022 *(dest++) = *(source++);
1023
1024 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
1025 /* don't do the read, it's not guaranteed to return an EOF,
1026 * just force an EOF
1027 */
1028 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
1029
1030 else
1031 {
1032 yy_size_t num_to_read =
1033 YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
1034
1035 while ( num_to_read <= 0 )
1036 { /* Not enough room in the buffer - grow it. */
1037
1038 /* just a shorter name for the current buffer */
1039 YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;
1040
1041 int yy_c_buf_p_offset =
1042 (int) ((yy_c_buf_p) - b->yy_ch_buf);
1043
1044 if ( b->yy_is_our_buffer )
1045 {
1046 yy_size_t new_size = b->yy_buf_size * 2;
1047
1048 if ( new_size <= 0 )
1049 b->yy_buf_size += b->yy_buf_size / 8;
1050 else
1051 b->yy_buf_size *= 2;
1052
1053 b->yy_ch_buf = (char *)
1054 /* Include room in for 2 EOB chars. */
1055 yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 );
1056 }
1057 else
1058 /* Can't grow it, we don't own it. */
1059 b->yy_ch_buf = 0;
1060
1061 if ( ! b->yy_ch_buf )
1062 YY_FATAL_ERROR(
1063 "fatal error - scanner input buffer overflow" );
1064
1065 (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
1066
1067 num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
1068 number_to_move - 1;
1069
1070 }
1071
1072 if ( num_to_read > YY_READ_BUF_SIZE )
1073 num_to_read = YY_READ_BUF_SIZE;
1074
1075 /* Read in more data. */
1076 YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
1077 (yy_n_chars), num_to_read );
1078
1079 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1080 }
1081
1082 if ( (yy_n_chars) == 0 )
1083 {
1084 if ( number_to_move == YY_MORE_ADJ )
1085 {
1086 ret_val = EOB_ACT_END_OF_FILE;
1087 yyrestart(yyin );
1088 }
1089
1090 else
1091 {
1092 ret_val = EOB_ACT_LAST_MATCH;
1093 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
1094 YY_BUFFER_EOF_PENDING;
1095 }
1096 }
1097
1098 else
1099 ret_val = EOB_ACT_CONTINUE_SCAN;
1100
1101 if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
1102 /* Extend the array by 50%, plus the number we really need. */
1103 yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
1104 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size );
1105 if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1106 YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
1107 }
1108
1109 (yy_n_chars) += number_to_move;
1110 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
1111 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
1112
1113 (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
1114
1115 return ret_val;
1116 }
1117
1118 /* yy_get_previous_state - get the state just before the EOB char was reached */
1119
yy_get_previous_state(void)1120 static yy_state_type yy_get_previous_state (void)
1121 {
1122 register yy_state_type yy_current_state;
1123 register char *yy_cp;
1124
1125 yy_current_state = (yy_start);
1126
1127 for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
1128 {
1129 register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1130 if ( yy_accept[yy_current_state] )
1131 {
1132 (yy_last_accepting_state) = yy_current_state;
1133 (yy_last_accepting_cpos) = yy_cp;
1134 }
1135 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1136 {
1137 yy_current_state = (int) yy_def[yy_current_state];
1138 if ( yy_current_state >= 35 )
1139 yy_c = yy_meta[(unsigned int) yy_c];
1140 }
1141 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1142 }
1143
1144 return yy_current_state;
1145 }
1146
1147 /* yy_try_NUL_trans - try to make a transition on the NUL character
1148 *
1149 * synopsis
1150 * next_state = yy_try_NUL_trans( current_state );
1151 */
yy_try_NUL_trans(yy_state_type yy_current_state)1152 static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
1153 {
1154 register int yy_is_jam;
1155 register char *yy_cp = (yy_c_buf_p);
1156
1157 register YY_CHAR yy_c = 1;
1158 if ( yy_accept[yy_current_state] )
1159 {
1160 (yy_last_accepting_state) = yy_current_state;
1161 (yy_last_accepting_cpos) = yy_cp;
1162 }
1163 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1164 {
1165 yy_current_state = (int) yy_def[yy_current_state];
1166 if ( yy_current_state >= 35 )
1167 yy_c = yy_meta[(unsigned int) yy_c];
1168 }
1169 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1170 yy_is_jam = (yy_current_state == 34);
1171
1172 return yy_is_jam ? 0 : yy_current_state;
1173 }
1174
1175 #ifndef YY_NO_INPUT
1176 #ifdef __cplusplus
yyinput(void)1177 static int yyinput (void)
1178 #else
1179 static int input (void)
1180 #endif
1181
1182 {
1183 int c;
1184
1185 *(yy_c_buf_p) = (yy_hold_char);
1186
1187 if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
1188 {
1189 /* yy_c_buf_p now points to the character we want to return.
1190 * If this occurs *before* the EOB characters, then it's a
1191 * valid NUL; if not, then we've hit the end of the buffer.
1192 */
1193 if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
1194 /* This was really a NUL. */
1195 *(yy_c_buf_p) = '\0';
1196
1197 else
1198 { /* need more input */
1199 yy_size_t offset = (yy_c_buf_p) - (yytext_ptr);
1200 ++(yy_c_buf_p);
1201
1202 switch ( yy_get_next_buffer( ) )
1203 {
1204 case EOB_ACT_LAST_MATCH:
1205 /* This happens because yy_g_n_b()
1206 * sees that we've accumulated a
1207 * token and flags that we need to
1208 * try matching the token before
1209 * proceeding. But for input(),
1210 * there's no matching to consider.
1211 * So convert the EOB_ACT_LAST_MATCH
1212 * to EOB_ACT_END_OF_FILE.
1213 */
1214
1215 /* Reset buffer status. */
1216 yyrestart(yyin );
1217
1218 /*FALLTHROUGH*/
1219
1220 case EOB_ACT_END_OF_FILE:
1221 {
1222 if ( yywrap( ) )
1223 return EOF;
1224
1225 if ( ! (yy_did_buffer_switch_on_eof) )
1226 YY_NEW_FILE;
1227 #ifdef __cplusplus
1228 return yyinput();
1229 #else
1230 return input();
1231 #endif
1232 }
1233
1234 case EOB_ACT_CONTINUE_SCAN:
1235 (yy_c_buf_p) = (yytext_ptr) + offset;
1236 break;
1237 }
1238 }
1239 }
1240
1241 c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
1242 *(yy_c_buf_p) = '\0'; /* preserve yytext */
1243 (yy_hold_char) = *++(yy_c_buf_p);
1244
1245 return c;
1246 }
1247 #endif /* ifndef YY_NO_INPUT */
1248
1249 /** Immediately switch to a different input stream.
1250 * @param input_file A readable stream.
1251 *
1252 * @note This function does not reset the start condition to @c INITIAL .
1253 */
yyrestart(FILE * input_file)1254 void yyrestart (FILE * input_file )
1255 {
1256
1257 if ( ! YY_CURRENT_BUFFER ){
1258 yyensure_buffer_stack ();
1259 YY_CURRENT_BUFFER_LVALUE =
1260 yy_create_buffer(yyin,YY_BUF_SIZE );
1261 }
1262
1263 yy_init_buffer(YY_CURRENT_BUFFER,input_file );
1264 yy_load_buffer_state( );
1265 }
1266
1267 /** Switch to a different input buffer.
1268 * @param new_buffer The new input buffer.
1269 *
1270 */
yy_switch_to_buffer(YY_BUFFER_STATE new_buffer)1271 void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer )
1272 {
1273
1274 /* TODO. We should be able to replace this entire function body
1275 * with
1276 * yypop_buffer_state();
1277 * yypush_buffer_state(new_buffer);
1278 */
1279 yyensure_buffer_stack ();
1280 if ( YY_CURRENT_BUFFER == new_buffer )
1281 return;
1282
1283 if ( YY_CURRENT_BUFFER )
1284 {
1285 /* Flush out information for old buffer. */
1286 *(yy_c_buf_p) = (yy_hold_char);
1287 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1288 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1289 }
1290
1291 YY_CURRENT_BUFFER_LVALUE = new_buffer;
1292 yy_load_buffer_state( );
1293
1294 /* We don't actually know whether we did this switch during
1295 * EOF (yywrap()) processing, but the only time this flag
1296 * is looked at is after yywrap() is called, so it's safe
1297 * to go ahead and always set it.
1298 */
1299 (yy_did_buffer_switch_on_eof) = 1;
1300 }
1301
yy_load_buffer_state(void)1302 static void yy_load_buffer_state (void)
1303 {
1304 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1305 (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
1306 yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
1307 (yy_hold_char) = *(yy_c_buf_p);
1308 }
1309
1310 /** Allocate and initialize an input buffer state.
1311 * @param file A readable stream.
1312 * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
1313 *
1314 * @return the allocated buffer state.
1315 */
yy_create_buffer(FILE * file,int size)1316 YY_BUFFER_STATE yy_create_buffer (FILE * file, int size )
1317 {
1318 YY_BUFFER_STATE b;
1319
1320 b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) );
1321 if ( ! b )
1322 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1323
1324 b->yy_buf_size = size;
1325
1326 /* yy_ch_buf has to be 2 characters longer than the size given because
1327 * we need to put in 2 end-of-buffer characters.
1328 */
1329 b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2 );
1330 if ( ! b->yy_ch_buf )
1331 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1332
1333 b->yy_is_our_buffer = 1;
1334
1335 yy_init_buffer(b,file );
1336
1337 return b;
1338 }
1339
1340 /** Destroy the buffer.
1341 * @param b a buffer created with yy_create_buffer()
1342 *
1343 */
yy_delete_buffer(YY_BUFFER_STATE b)1344 void yy_delete_buffer (YY_BUFFER_STATE b )
1345 {
1346
1347 if ( ! b )
1348 return;
1349
1350 if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
1351 YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
1352
1353 if ( b->yy_is_our_buffer )
1354 yyfree((void *) b->yy_ch_buf );
1355
1356 yyfree((void *) b );
1357 }
1358
1359 /* Initializes or reinitializes a buffer.
1360 * This function is sometimes called more than once on the same buffer,
1361 * such as during a yyrestart() or at EOF.
1362 */
yy_init_buffer(YY_BUFFER_STATE b,FILE * file)1363 static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file )
1364
1365 {
1366 int oerrno = errno;
1367
1368 yy_flush_buffer(b );
1369
1370 b->yy_input_file = file;
1371 b->yy_fill_buffer = 1;
1372
1373 /* If b is the current buffer, then yy_init_buffer was _probably_
1374 * called from yyrestart() or through yy_get_next_buffer.
1375 * In that case, we don't want to reset the lineno or column.
1376 */
1377 if (b != YY_CURRENT_BUFFER){
1378 b->yy_bs_lineno = 1;
1379 b->yy_bs_column = 0;
1380 }
1381
1382 b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
1383
1384 errno = oerrno;
1385 }
1386
1387 /** Discard all buffered characters. On the next scan, YY_INPUT will be called.
1388 * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
1389 *
1390 */
yy_flush_buffer(YY_BUFFER_STATE b)1391 void yy_flush_buffer (YY_BUFFER_STATE b )
1392 {
1393 if ( ! b )
1394 return;
1395
1396 b->yy_n_chars = 0;
1397
1398 /* We always need two end-of-buffer characters. The first causes
1399 * a transition to the end-of-buffer state. The second causes
1400 * a jam in that state.
1401 */
1402 b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1403 b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1404
1405 b->yy_buf_pos = &b->yy_ch_buf[0];
1406
1407 b->yy_at_bol = 1;
1408 b->yy_buffer_status = YY_BUFFER_NEW;
1409
1410 if ( b == YY_CURRENT_BUFFER )
1411 yy_load_buffer_state( );
1412 }
1413
1414 /** Pushes the new state onto the stack. The new state becomes
1415 * the current state. This function will allocate the stack
1416 * if necessary.
1417 * @param new_buffer The new state.
1418 *
1419 */
yypush_buffer_state(YY_BUFFER_STATE new_buffer)1420 void yypush_buffer_state (YY_BUFFER_STATE new_buffer )
1421 {
1422 if (new_buffer == NULL)
1423 return;
1424
1425 yyensure_buffer_stack();
1426
1427 /* This block is copied from yy_switch_to_buffer. */
1428 if ( YY_CURRENT_BUFFER )
1429 {
1430 /* Flush out information for old buffer. */
1431 *(yy_c_buf_p) = (yy_hold_char);
1432 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1433 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1434 }
1435
1436 /* Only push if top exists. Otherwise, replace top. */
1437 if (YY_CURRENT_BUFFER)
1438 (yy_buffer_stack_top)++;
1439 YY_CURRENT_BUFFER_LVALUE = new_buffer;
1440
1441 /* copied from yy_switch_to_buffer. */
1442 yy_load_buffer_state( );
1443 (yy_did_buffer_switch_on_eof) = 1;
1444 }
1445
1446 /** Removes and deletes the top of the stack, if present.
1447 * The next element becomes the new top.
1448 *
1449 */
yypop_buffer_state(void)1450 void yypop_buffer_state (void)
1451 {
1452 if (!YY_CURRENT_BUFFER)
1453 return;
1454
1455 yy_delete_buffer(YY_CURRENT_BUFFER );
1456 YY_CURRENT_BUFFER_LVALUE = NULL;
1457 if ((yy_buffer_stack_top) > 0)
1458 --(yy_buffer_stack_top);
1459
1460 if (YY_CURRENT_BUFFER) {
1461 yy_load_buffer_state( );
1462 (yy_did_buffer_switch_on_eof) = 1;
1463 }
1464 }
1465
1466 /* Allocates the stack if it does not exist.
1467 * Guarantees space for at least one push.
1468 */
yyensure_buffer_stack(void)1469 static void yyensure_buffer_stack (void)
1470 {
1471 yy_size_t num_to_alloc;
1472
1473 if (!(yy_buffer_stack)) {
1474
1475 /* First allocation is just for 2 elements, since we don't know if this
1476 * scanner will even need a stack. We use 2 instead of 1 to avoid an
1477 * immediate realloc on the next call.
1478 */
1479 num_to_alloc = 1;
1480 (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc
1481 (num_to_alloc * sizeof(struct yy_buffer_state*)
1482 );
1483 if ( ! (yy_buffer_stack) )
1484 YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
1485
1486 memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
1487
1488 (yy_buffer_stack_max) = num_to_alloc;
1489 (yy_buffer_stack_top) = 0;
1490 return;
1491 }
1492
1493 if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
1494
1495 /* Increase the buffer to prepare for a possible push. */
1496 int grow_size = 8 /* arbitrary grow size */;
1497
1498 num_to_alloc = (yy_buffer_stack_max) + grow_size;
1499 (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc
1500 ((yy_buffer_stack),
1501 num_to_alloc * sizeof(struct yy_buffer_state*)
1502 );
1503 if ( ! (yy_buffer_stack) )
1504 YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
1505
1506 /* zero only the new slots.*/
1507 memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
1508 (yy_buffer_stack_max) = num_to_alloc;
1509 }
1510 }
1511
1512 /** Setup the input buffer state to scan directly from a user-specified character buffer.
1513 * @param base the character buffer
1514 * @param size the size in bytes of the character buffer
1515 *
1516 * @return the newly allocated buffer state object.
1517 */
yy_scan_buffer(char * base,yy_size_t size)1518 YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size )
1519 {
1520 YY_BUFFER_STATE b;
1521
1522 if ( size < 2 ||
1523 base[size-2] != YY_END_OF_BUFFER_CHAR ||
1524 base[size-1] != YY_END_OF_BUFFER_CHAR )
1525 /* They forgot to leave room for the EOB's. */
1526 return 0;
1527
1528 b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) );
1529 if ( ! b )
1530 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
1531
1532 b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
1533 b->yy_buf_pos = b->yy_ch_buf = base;
1534 b->yy_is_our_buffer = 0;
1535 b->yy_input_file = 0;
1536 b->yy_n_chars = b->yy_buf_size;
1537 b->yy_is_interactive = 0;
1538 b->yy_at_bol = 1;
1539 b->yy_fill_buffer = 0;
1540 b->yy_buffer_status = YY_BUFFER_NEW;
1541
1542 yy_switch_to_buffer(b );
1543
1544 return b;
1545 }
1546
1547 /** Setup the input buffer state to scan a string. The next call to yylex() will
1548 * scan from a @e copy of @a str.
1549 * @param yystr a NUL-terminated string to scan
1550 *
1551 * @return the newly allocated buffer state object.
1552 * @note If you want to scan bytes that may contain NUL values, then use
1553 * yy_scan_bytes() instead.
1554 */
yy_scan_string(yyconst char * yystr)1555 YY_BUFFER_STATE yy_scan_string (yyconst char * yystr )
1556 {
1557
1558 return yy_scan_bytes(yystr,strlen(yystr) );
1559 }
1560
1561 /** Setup the input buffer state to scan the given bytes. The next call to yylex() will
1562 * scan from a @e copy of @a bytes.
1563 * @param yybytes the byte buffer to scan
1564 * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
1565 *
1566 * @return the newly allocated buffer state object.
1567 */
yy_scan_bytes(yyconst char * yybytes,yy_size_t _yybytes_len)1568 YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len )
1569 {
1570 YY_BUFFER_STATE b;
1571 char *buf;
1572 yy_size_t n;
1573 yy_size_t i;
1574
1575 /* Get memory for full buffer, including space for trailing EOB's. */
1576 n = _yybytes_len + 2;
1577 buf = (char *) yyalloc(n );
1578 if ( ! buf )
1579 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
1580
1581 for ( i = 0; i < _yybytes_len; ++i )
1582 buf[i] = yybytes[i];
1583
1584 buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
1585
1586 b = yy_scan_buffer(buf,n );
1587 if ( ! b )
1588 YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
1589
1590 /* It's okay to grow etc. this buffer, and we should throw it
1591 * away when we're done.
1592 */
1593 b->yy_is_our_buffer = 1;
1594
1595 return b;
1596 }
1597
1598 #ifndef YY_EXIT_FAILURE
1599 #define YY_EXIT_FAILURE 2
1600 #endif
1601
yy_fatal_error(yyconst char * msg)1602 static void yy_fatal_error (yyconst char* msg )
1603 {
1604 (void) fprintf( stderr, "%s\n", msg );
1605 exit( YY_EXIT_FAILURE );
1606 }
1607
1608 /* Redefine yyless() so it works in section 3 code. */
1609
1610 #undef yyless
1611 #define yyless(n) \
1612 do \
1613 { \
1614 /* Undo effects of setting up yytext. */ \
1615 int yyless_macro_arg = (n); \
1616 YY_LESS_LINENO(yyless_macro_arg);\
1617 yytext[yyleng] = (yy_hold_char); \
1618 (yy_c_buf_p) = yytext + yyless_macro_arg; \
1619 (yy_hold_char) = *(yy_c_buf_p); \
1620 *(yy_c_buf_p) = '\0'; \
1621 yyleng = yyless_macro_arg; \
1622 } \
1623 while ( 0 )
1624
1625 /* Accessor methods (get/set functions) to struct members. */
1626
1627 /** Get the current line number.
1628 *
1629 */
yyget_lineno(void)1630 int yyget_lineno (void)
1631 {
1632
1633 return yylineno;
1634 }
1635
1636 /** Get the input stream.
1637 *
1638 */
yyget_in(void)1639 FILE *yyget_in (void)
1640 {
1641 return yyin;
1642 }
1643
1644 /** Get the output stream.
1645 *
1646 */
yyget_out(void)1647 FILE *yyget_out (void)
1648 {
1649 return yyout;
1650 }
1651
1652 /** Get the length of the current token.
1653 *
1654 */
yyget_leng(void)1655 yy_size_t yyget_leng (void)
1656 {
1657 return yyleng;
1658 }
1659
1660 /** Get the current token.
1661 *
1662 */
1663
yyget_text(void)1664 char *yyget_text (void)
1665 {
1666 return yytext;
1667 }
1668
1669 /** Set the current line number.
1670 * @param line_number
1671 *
1672 */
yyset_lineno(int line_number)1673 void yyset_lineno (int line_number )
1674 {
1675
1676 yylineno = line_number;
1677 }
1678
1679 /** Set the input stream. This does not discard the current
1680 * input buffer.
1681 * @param in_str A readable stream.
1682 *
1683 * @see yy_switch_to_buffer
1684 */
yyset_in(FILE * in_str)1685 void yyset_in (FILE * in_str )
1686 {
1687 yyin = in_str ;
1688 }
1689
yyset_out(FILE * out_str)1690 void yyset_out (FILE * out_str )
1691 {
1692 yyout = out_str ;
1693 }
1694
yyget_debug(void)1695 int yyget_debug (void)
1696 {
1697 return yy_flex_debug;
1698 }
1699
yyset_debug(int bdebug)1700 void yyset_debug (int bdebug )
1701 {
1702 yy_flex_debug = bdebug ;
1703 }
1704
yy_init_globals(void)1705 static int yy_init_globals (void)
1706 {
1707 /* Initialization is the same as for the non-reentrant scanner.
1708 * This function is called from yylex_destroy(), so don't allocate here.
1709 */
1710
1711 (yy_buffer_stack) = 0;
1712 (yy_buffer_stack_top) = 0;
1713 (yy_buffer_stack_max) = 0;
1714 (yy_c_buf_p) = (char *) 0;
1715 (yy_init) = 0;
1716 (yy_start) = 0;
1717
1718 /* Defined in main.c */
1719 #ifdef YY_STDINIT
1720 yyin = stdin;
1721 yyout = stdout;
1722 #else
1723 yyin = (FILE *) 0;
1724 yyout = (FILE *) 0;
1725 #endif
1726
1727 /* For future reference: Set errno on error, since we are called by
1728 * yylex_init()
1729 */
1730 return 0;
1731 }
1732
1733 /* yylex_destroy is for both reentrant and non-reentrant scanners. */
yylex_destroy(void)1734 int yylex_destroy (void)
1735 {
1736
1737 /* Pop the buffer stack, destroying each element. */
1738 while(YY_CURRENT_BUFFER){
1739 yy_delete_buffer(YY_CURRENT_BUFFER );
1740 YY_CURRENT_BUFFER_LVALUE = NULL;
1741 yypop_buffer_state();
1742 }
1743
1744 /* Destroy the stack itself. */
1745 yyfree((yy_buffer_stack) );
1746 (yy_buffer_stack) = NULL;
1747
1748 /* Reset the globals. This is important in a non-reentrant scanner so the next time
1749 * yylex() is called, initialization will occur. */
1750 yy_init_globals( );
1751
1752 return 0;
1753 }
1754
1755 /*
1756 * Internal utility routines.
1757 */
1758
1759 #ifndef yytext_ptr
yy_flex_strncpy(char * s1,yyconst char * s2,int n)1760 static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
1761 {
1762 register int i;
1763 for ( i = 0; i < n; ++i )
1764 s1[i] = s2[i];
1765 }
1766 #endif
1767
1768 #ifdef YY_NEED_STRLEN
yy_flex_strlen(yyconst char * s)1769 static int yy_flex_strlen (yyconst char * s )
1770 {
1771 register int n;
1772 for ( n = 0; s[n]; ++n )
1773 ;
1774
1775 return n;
1776 }
1777 #endif
1778
yyalloc(yy_size_t size)1779 void *yyalloc (yy_size_t size )
1780 {
1781 return (void *) malloc( size );
1782 }
1783
yyrealloc(void * ptr,yy_size_t size)1784 void *yyrealloc (void * ptr, yy_size_t size )
1785 {
1786 /* The cast to (char *) in the following accommodates both
1787 * implementations that use char* generic pointers, and those
1788 * that use void* generic pointers. It works with the latter
1789 * because both ANSI C and C++ allow castless assignment from
1790 * any pointer type to void*, and deal with argument conversions
1791 * as though doing an assignment.
1792 */
1793 return (void *) realloc( (char *) ptr, size );
1794 }
1795
yyfree(void * ptr)1796 void yyfree (void * ptr )
1797 {
1798 free( (char *) ptr ); /* see yyrealloc() for (char *) cast */
1799 }
1800
1801 #define YYTABLES_NAME "yytables"
1802
1803 #line 63 "/usr/src/usr.bin/m4/tokenizer.l"
1804
1805
1806
1807 int32_t
number(void)1808 number(void)
1809 {
1810 long l;
1811
1812 errno = 0;
1813 l = strtol(yytext, NULL, 0);
1814 if (((l == LONG_MAX || l == LONG_MIN) && errno == ERANGE) ||
1815 l > INT32_MAX || l < INT32_MIN) {
1816 fprintf(stderr, "m4: numeric overflow in expr: %s\n", yytext);
1817 }
1818 return l;
1819 }
1820
1821 int32_t
parse_radix(void)1822 parse_radix(void)
1823 {
1824 long base;
1825 char *next;
1826 long l;
1827 int d;
1828
1829 l = 0;
1830 base = strtol(yytext + 2, &next, 0);
1831 if (base > 36 || next == NULL) {
1832 fprintf(stderr, "m4: error in number %s\n", yytext);
1833 } else {
1834 next++;
1835 while (*next != 0) {
1836 if (*next >= '0' && *next <= '9')
1837 d = *next - '0';
1838 else if (*next >= 'a' && *next <= 'z')
1839 d = *next - 'a' + 10;
1840 else {
1841 assert(*next >= 'A' && *next <= 'Z');
1842 d = *next - 'A' + 10;
1843 }
1844 if (d >= base) {
1845 fprintf(stderr,
1846 "m4: error in number %s\n", yytext);
1847 return 0;
1848 }
1849 l = base * l + d;
1850 next++;
1851 }
1852 }
1853 return l;
1854 }
1855