GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: usr.bin/fgen/fgen.c Lines: 0 403 0.0 %
Date: 2017-11-07 Branches: 0 281 0.0 %

Line Branch Exec Source
1
#line 2 "fgen.c"
2
3
#line 4 "fgen.c"
4
5
#define  YY_INT_ALIGNED short int
6
7
/*	$OpenBSD: flex.skl,v 1.16 2017/05/02 19:16:19 millert Exp $	*/
8
9
/* A lexical scanner generated by flex */
10
11
#define FLEX_SCANNER
12
#define YY_FLEX_MAJOR_VERSION 2
13
#define YY_FLEX_MINOR_VERSION 5
14
#define YY_FLEX_SUBMINOR_VERSION 39
15
#if YY_FLEX_SUBMINOR_VERSION > 0
16
#define FLEX_BETA
17
#endif
18
19
/* First, we deal with  platform-specific or compiler-specific issues. */
20
21
/* begin standard C headers. */
22
#include <stdio.h>
23
#include <string.h>
24
#include <errno.h>
25
#include <stdlib.h>
26
27
/* end standard C headers. */
28
29
/* $OpenBSD: flexint.h,v 1.1 2015/11/19 19:43:40 tedu Exp $ */
30
31
/* flex integer type definitions */
32
33
#ifndef FLEXINT_H
34
#define FLEXINT_H
35
36
/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
37
38
#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
39
40
/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
41
 * if you want the limit (max/min) macros for int types.
42
 */
43
#ifndef __STDC_LIMIT_MACROS
44
#define __STDC_LIMIT_MACROS 1
45
#endif
46
47
#include <inttypes.h>
48
typedef int8_t flex_int8_t;
49
typedef uint8_t flex_uint8_t;
50
typedef int16_t flex_int16_t;
51
typedef uint16_t flex_uint16_t;
52
typedef int32_t flex_int32_t;
53
typedef uint32_t flex_uint32_t;
54
#else
55
typedef signed char flex_int8_t;
56
typedef short int flex_int16_t;
57
typedef int flex_int32_t;
58
typedef unsigned char flex_uint8_t;
59
typedef unsigned short int flex_uint16_t;
60
typedef unsigned int flex_uint32_t;
61
62
/* Limits of integral types. */
63
#ifndef INT8_MIN
64
#define INT8_MIN               (-128)
65
#endif
66
#ifndef INT16_MIN
67
#define INT16_MIN              (-32767-1)
68
#endif
69
#ifndef INT32_MIN
70
#define INT32_MIN              (-2147483647-1)
71
#endif
72
#ifndef INT8_MAX
73
#define INT8_MAX               (127)
74
#endif
75
#ifndef INT16_MAX
76
#define INT16_MAX              (32767)
77
#endif
78
#ifndef INT32_MAX
79
#define INT32_MAX              (2147483647)
80
#endif
81
#ifndef UINT8_MAX
82
#define UINT8_MAX              (255U)
83
#endif
84
#ifndef UINT16_MAX
85
#define UINT16_MAX             (65535U)
86
#endif
87
#ifndef UINT32_MAX
88
#define UINT32_MAX             (4294967295U)
89
#endif
90
91
#endif /* ! C99 */
92
93
#endif /* ! FLEXINT_H */
94
95
#ifdef __cplusplus
96
97
/* The "const" storage-class-modifier is valid. */
98
#define YY_USE_CONST
99
100
#else	/* ! __cplusplus */
101
102
/* C99 requires __STDC__ to be defined as 1. */
103
#if defined (__STDC__)
104
105
#define YY_USE_CONST
106
107
#endif	/* defined (__STDC__) */
108
#endif	/* ! __cplusplus */
109
110
#ifdef YY_USE_CONST
111
#define yyconst const
112
#else
113
#define yyconst
114
#endif
115
116
/* Returned upon end-of-file. */
117
#define YY_NULL 0
118
119
/* Promotes a possibly negative, possibly signed char to an unsigned
120
 * integer for use as an array index.  If the signed char is negative,
121
 * we want to instead treat it as an 8-bit unsigned char, hence the
122
 * double cast.
123
 */
124
#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
125
126
/* Enter a start condition.  This macro really ought to take a parameter,
127
 * but we do it the disgusting crufty way forced on us by the ()-less
128
 * definition of BEGIN.
129
 */
130
#define BEGIN (yy_start) = 1 + 2 *
131
132
/* Translate the current start state into a value that can be later handed
133
 * to BEGIN to return to the state.  The YYSTATE alias is for lex
134
 * compatibility.
135
 */
136
#define YY_START (((yy_start) - 1) / 2)
137
#define YYSTATE YY_START
138
139
/* Action number for EOF rule of a given start state. */
140
#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
141
142
/* Special action meaning "start processing a new file". */
143
#define YY_NEW_FILE yyrestart(yyin  )
144
145
#define YY_END_OF_BUFFER_CHAR 0
146
147
/* Size of default input buffer. */
148
#ifndef YY_BUF_SIZE
149
#define YY_BUF_SIZE 16384
150
#endif
151
152
/* The state buf must be large enough to hold one state per character in the main buffer.
153
 */
154
#define YY_STATE_BUF_SIZE   ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
155
156
#ifndef YY_TYPEDEF_YY_BUFFER_STATE
157
#define YY_TYPEDEF_YY_BUFFER_STATE
158
typedef struct yy_buffer_state *YY_BUFFER_STATE;
159
#endif
160
161
#ifndef YY_TYPEDEF_YY_SIZE_T
162
#define YY_TYPEDEF_YY_SIZE_T
163
typedef size_t yy_size_t;
164
#endif
165
166
extern yy_size_t yyleng;
167
168
extern FILE *yyin, *yyout;
169
170
#define EOB_ACT_CONTINUE_SCAN 0
171
#define EOB_ACT_END_OF_FILE 1
172
#define EOB_ACT_LAST_MATCH 2
173
174
    /* Note: We specifically omit the test for yy_rule_can_match_eol because it requires
175
     *       access to the local variable yy_act. Since yyless() is a macro, it would break
176
     *       existing scanners that call yyless() from OUTSIDE yylex.
177
     *       One obvious solution it to make yy_act a global. I tried that, and saw
178
     *       a 5% performance hit in a non-yylineno scanner, because yy_act is
179
     *       normally declared as a register variable-- so it is not worth it.
180
     */
181
    #define  YY_LESS_LINENO(n) \
182
            do { \
183
                int yyl;\
184
                for ( yyl = n; yyl < yyleng; ++yyl )\
185
                    if ( yytext[yyl] == '\n' )\
186
                        --yylineno;\
187
            }while(0)
188
    #define YY_LINENO_REWIND_TO(dst) \
189
            do {\
190
                const char *p;\
191
                for ( p = yy_cp-1; p >= (dst); --p)\
192
                    if ( *p == '\n' )\
193
                        --yylineno;\
194
            }while(0)
195
196
/* Return all but the first "n" matched characters back to the input stream. */
197
#define yyless(n) \
198
	do \
199
		{ \
200
		/* Undo effects of setting up yytext. */ \
201
        int yyless_macro_arg = (n); \
202
        YY_LESS_LINENO(yyless_macro_arg);\
203
		*yy_cp = (yy_hold_char); \
204
		YY_RESTORE_YY_MORE_OFFSET \
205
		(yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
206
		YY_DO_BEFORE_ACTION; /* set up yytext again */ \
207
		} \
208
	while ( 0 )
209
210
#define unput(c) yyunput( c, (yytext_ptr)  )
211
212
#ifndef YY_STRUCT_YY_BUFFER_STATE
213
#define YY_STRUCT_YY_BUFFER_STATE
214
struct yy_buffer_state
215
	{
216
	FILE *yy_input_file;
217
218
	char *yy_ch_buf;		/* input buffer */
219
	char *yy_buf_pos;		/* current position in input buffer */
220
221
	/* Size of input buffer in bytes, not including room for EOB
222
	 * characters.
223
	 */
224
	yy_size_t yy_buf_size;
225
226
	/* Number of characters read into yy_ch_buf, not including EOB
227
	 * characters.
228
	 */
229
	yy_size_t yy_n_chars;
230
231
	/* Whether we "own" the buffer - i.e., we know we created it,
232
	 * and can realloc() it to grow it, and should free() it to
233
	 * delete it.
234
	 */
235
	int yy_is_our_buffer;
236
237
	/* Whether this is an "interactive" input source; if so, and
238
	 * if we're using stdio for input, then we want to use getc()
239
	 * instead of fread(), to make sure we stop fetching input after
240
	 * each newline.
241
	 */
242
	int yy_is_interactive;
243
244
	/* Whether we're considered to be at the beginning of a line.
245
	 * If so, '^' rules will be active on the next match, otherwise
246
	 * not.
247
	 */
248
	int yy_at_bol;
249
250
    int yy_bs_lineno; /**< The line count. */
251
    int yy_bs_column; /**< The column count. */
252
253
	/* Whether to try to fill the input buffer when we reach the
254
	 * end of it.
255
	 */
256
	int yy_fill_buffer;
257
258
	int yy_buffer_status;
259
260
#define YY_BUFFER_NEW 0
261
#define YY_BUFFER_NORMAL 1
262
	/* When an EOF's been seen but there's still some text to process
263
	 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
264
	 * shouldn't try reading from the input source any more.  We might
265
	 * still have a bunch of tokens to match, though, because of
266
	 * possible backing-up.
267
	 *
268
	 * When we actually see the EOF, we change the status to "new"
269
	 * (via yyrestart()), so that the user can continue scanning by
270
	 * just pointing yyin at a new input file.
271
	 */
272
#define YY_BUFFER_EOF_PENDING 2
273
274
	};
275
#endif /* !YY_STRUCT_YY_BUFFER_STATE */
276
277
/* Stack of input buffers. */
278
static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
279
static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
280
static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
281
282
/* We provide macros for accessing buffer states in case in the
283
 * future we want to put the buffer states in a more general
284
 * "scanner state".
285
 *
286
 * Returns the top of the stack, or NULL.
287
 */
288
#define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
289
                          ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
290
                          : NULL)
291
292
/* Same as previous macro, but useful when we know that the buffer stack is not
293
 * NULL or when we need an lvalue. For internal use only.
294
 */
295
#define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
296
297
/* yy_hold_char holds the character lost when yytext is formed. */
298
static char yy_hold_char;
299
static yy_size_t yy_n_chars;		/* number of characters read into yy_ch_buf */
300
yy_size_t yyleng;
301
302
/* Points to current character in buffer. */
303
static char *yy_c_buf_p = (char *) 0;
304
static int yy_init = 0;		/* whether we need to initialize */
305
static int yy_start = 0;	/* start state number */
306
307
/* Flag which is used to allow yywrap()'s to do buffer switches
308
 * instead of setting up a fresh yyin.  A bit of a hack ...
309
 */
310
static int yy_did_buffer_switch_on_eof;
311
312
void yyrestart (FILE *input_file  );
313
void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer  );
314
YY_BUFFER_STATE yy_create_buffer (FILE *file,int size  );
315
void yy_delete_buffer (YY_BUFFER_STATE b  );
316
void yy_flush_buffer (YY_BUFFER_STATE b  );
317
void yypush_buffer_state (YY_BUFFER_STATE new_buffer  );
318
void yypop_buffer_state (void );
319
320
static void yyensure_buffer_stack (void );
321
static void yy_load_buffer_state (void );
322
static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file  );
323
324
#define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER )
325
326
YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size  );
327
YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str  );
328
YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,yy_size_t len  );
329
330
void *yyalloc (yy_size_t  );
331
void *yyrealloc (void *,yy_size_t  );
332
void yyfree (void *  );
333
334
#define yy_new_buffer yy_create_buffer
335
336
#define yy_set_interactive(is_interactive) \
337
	{ \
338
	if ( ! YY_CURRENT_BUFFER ){ \
339
        yyensure_buffer_stack (); \
340
		YY_CURRENT_BUFFER_LVALUE =    \
341
            yy_create_buffer(yyin,YY_BUF_SIZE ); \
342
	} \
343
	YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
344
	}
345
346
#define yy_set_bol(at_bol) \
347
	{ \
348
	if ( ! YY_CURRENT_BUFFER ){\
349
        yyensure_buffer_stack (); \
350
		YY_CURRENT_BUFFER_LVALUE =    \
351
            yy_create_buffer(yyin,YY_BUF_SIZE ); \
352
	} \
353
	YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
354
	}
355
356
#define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
357
358
/* Begin user sect3 */
359
360
typedef unsigned char YY_CHAR;
361
362
FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
363
364
typedef int yy_state_type;
365
366
extern int yylineno;
367
368
int yylineno = 1;
369
370
extern char *yytext;
371
#define yytext_ptr yytext
372
373
static yy_state_type yy_get_previous_state (void );
374
static yy_state_type yy_try_NUL_trans (yy_state_type current_state  );
375
static int yy_get_next_buffer (void );
376
static void yy_fatal_error (yyconst char msg[]  );
377
378
/* Done after the current pattern has been matched and before the
379
 * corresponding action - sets up yytext.
380
 */
381
#define YY_DO_BEFORE_ACTION \
382
	(yytext_ptr) = yy_bp; \
383
	yyleng = (size_t) (yy_cp - yy_bp); \
384
	(yy_hold_char) = *yy_cp; \
385
	*yy_cp = '\0'; \
386
	(yy_c_buf_p) = yy_cp;
387
388
#define YY_NUM_RULES 60
389
#define YY_END_OF_BUFFER 61
390
/* This struct is not used in this scanner,
391
   but its presence is necessary. */
392
struct yy_trans_info
393
	{
394
	flex_int32_t yy_verify;
395
	flex_int32_t yy_nxt;
396
	};
397
static yyconst flex_int16_t yy_accept[253] =
398
    {   0,
399
        6,    6,   61,   59,    6,   59,   17,   13,   14,   59,
400
       59,   59,    1,    2,    3,    4,    8,   15,   16,   59,
401
        8,    8,    8,    8,    8,    8,   59,   59,   59,   59,
402
       59,   59,   59,   59,   59,   59,   59,   59,    8,    8,
403
       59,   59,   59,    6,   59,    0,   10,   59,   59,    0,
404
       59,    8,    5,   59,   59,   59,   59,   59,   59,   59,
405
        8,   59,    8,   59,   59,   28,    8,   31,   59,   59,
406
       59,   59,   37,   59,   41,   59,   59,   44,   59,   46,
407
       59,   59,   49,   59,   59,   59,   59,   59,    0,    7,
408
       59,   59,   59,   46,   49,    0,   10,    0,   10,    9,
409
410
        9,   59,    0,   12,   59,   59,    0,   11,   59,   59,
411
       59,   59,   59,   59,   59,   59,   59,    8,    8,   59,
412
       59,   59,   59,   59,   40,   59,   59,   59,   59,   59,
413
       59,   59,   59,   59,   20,   59,   59,   59,   59,   59,
414
       10,    0,   12,    0,   12,    0,   11,    0,   59,   59,
415
       59,   59,   59,   59,   24,   59,   59,   59,   59,    8,
416
       32,   59,   59,   59,   59,   59,   59,   43,   59,   59,
417
       48,   59,   59,   59,   59,   59,   59,   59,   59,   59,
418
       12,    0,   18,   19,   21,   22,   59,   59,   59,   59,
419
       59,   30,   59,   34,   59,   36,   59,   42,   45,   59,
420
421
       50,   51,   59,   53,   59,   59,   58,   59,   59,   59,
422
       59,   59,   27,   59,   59,   59,   59,   47,   59,   59,
423
       59,   59,   59,   23,   59,   26,   29,   33,   59,   59,
424
       39,   59,   59,   59,   59,   59,   25,   35,   59,   52,
425
       59,   59,   54,   59,   59,   59,   56,   59,   38,   57,
426
       55,    0
427
    } ;
428
429
static yyconst flex_int32_t yy_ec[256] =
430
    {   0,
431
        1,    1,    1,    1,    1,    1,    1,    1,    2,    3,
432
        1,    2,    2,    1,    1,    1,    1,    1,    1,    1,
433
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
434
        1,    2,    1,    4,    5,    1,    1,    1,    6,    7,
435
        8,    1,    9,    1,   10,   11,    1,   12,   13,   14,
436
       15,   16,   16,   17,   16,   16,   16,   18,   19,    1,
437
        1,    1,   20,    1,   21,   22,   23,   24,   25,   26,
438
       27,   28,   29,    1,    1,   30,   31,   32,   33,   34,
439
        1,   35,   36,   37,   38,   39,   40,   41,    1,    1,
440
       42,   43,   44,    1,    1,    1,   45,   46,   23,   47,
441
442
       48,   49,   27,   28,   50,    1,   51,   52,   53,   54,
443
       55,   34,    1,   56,   57,   58,   38,   39,   40,   41,
444
       59,   60,    1,    1,    1,    1,    1,    1,    1,    1,
445
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
446
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
447
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
448
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
449
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
450
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
451
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
452
453
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
454
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
455
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
456
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
457
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
458
        1,    1,    1,    1,    1
459
    } ;
460
461
static yyconst flex_int32_t yy_meta[61] =
462
    {   0,
463
        1,    2,    3,    1,    1,    1,    1,    1,    1,    1,
464
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
465
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
466
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
467
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
468
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1
469
    } ;
470
471
static yyconst flex_int16_t yy_base[263] =
472
    {   0,
473
        0,    0,  518,    0,   59,   61,  515,    0,    0,   36,
474
       93,   63,  503,  502,  501,  500,  499,    0,    0,   44,
475
       98,   64,  111,   88,  117,   70,   75,   43,  104,  128,
476
       46,   48,   41,   77,  483,  504,   76,  451,  132,  147,
477
      152,   98,    0,   82,  177,  185,    0,  188,  502,  501,
478
       42,  493,  492,  191,  200,  115,  157,  151,  154,  481,
479
       59,  172,  187,  175,  184,    0,  193,    0,  176,  189,
480
      177,  190,    0,  196,    0,  201,  185,    0,  187,    0,
481
      469,  200,    0,  189,  219,  201,  458,  208,  498,  519,
482
      445,  449,  443,  448,  445,  131,  519,  223,  253,    0,
483
484
      519,  256,  259,    0,  265,  262,  270,    0,  277,  224,
485
      231,  248,  253,  257,  259,  252,  266,  287,  279,  266,
486
      289,  269,  263,  271,    0,  456,  460,  276,  276,  287,
487
      296,  455,  297,  293,    0,  441,  404,  415,  401,  409,
488
      286,  324,  519,  326,  329,  327,  519,  330,  340,  304,
489
      303,  311,  317,  326,    0,  317,  320,  319,  326,  346,
490
        0,  341,  338,  328,  341,  341,  343,    0,  348,  359,
491
        0,  355,  357,  369,  367,  408,  445,  407,  405,  398,
492
      389,  386,    0,    0,    0,    0,  360,  375,  364,  373,
493
      378,    0,  365,    0,  371,    0,  371,    0,    0,  372,
494
495
        0,    0,  388,    0,  397,  404,    0,  389,  396,  425,
496
      379,  383,    0,  387,  383,  391,  388,    0,  396,  303,
497
      293,  337,  226,    0,  391,    0,    0,    0,  407,  413,
498
        0,  416,  190,  181,  151,  117,    0,    0,  406,    0,
499
      115,  113,    0,   71,  408,   34,    0,   45,    0,    0,
500
        0,  519,   81,  465,  468,  470,  473,  476,  479,  482,
501
      485,  488
502
    } ;
503
504
static yyconst flex_int16_t yy_def[263] =
505
    {   0,
506
      252,    1,  252,  253,  252,  254,  255,  253,  253,  253,
507
      253,  253,   11,   11,   11,   11,   11,  253,  253,  253,
508
       11,   11,   11,   11,   11,   11,  253,  253,  253,  253,
509
      253,  253,  253,  253,  253,  253,  256,  253,   11,   11,
510
      253,  253,  253,  252,  254,  257,  253,  254,  253,  252,
511
      253,   11,   11,  258,  259,  253,  253,  253,  253,  253,
512
       11,  253,   11,  253,  253,  253,   11,  253,  253,  253,
513
      253,  253,  253,  253,  253,  253,  253,  253,  253,  253,
514
      253,  253,  253,  253,  253,  253,  253,  256,  260,  252,
515
      253,  253,  253,  253,  253,  257,  252,  257,  254,  253,
516
517
      252,  258,  261,  253,  258,  259,  262,  253,  259,  253,
518
      253,  253,  253,  253,  253,  253,  253,   11,   11,  253,
519
      253,  253,  253,  253,  253,  253,  253,  253,  253,  253,
520
      253,  253,  253,  253,  253,  253,  253,  253,  253,  253,
521
      257,  261,  252,  261,  258,  262,  252,  262,  259,  253,
522
      253,  253,  253,  253,  253,  253,  253,  253,  253,   11,
523
      253,  253,  253,  253,  253,  253,  253,  253,  253,  253,
524
      253,  253,  253,  253,  253,  253,  253,  253,  253,  253,
525
      261,  262,  253,  253,  253,  253,  253,  253,  253,  253,
526
      253,  253,  253,  253,  253,  253,  253,  253,  253,  253,
527
528
      253,  253,  253,  253,  253,  253,  253,  253,  253,  253,
529
      253,  253,  253,  253,  253,  253,  253,  253,  253,  253,
530
      253,  253,  253,  253,  253,  253,  253,  253,  253,  253,
531
      253,  253,  253,  253,  253,  253,  253,  253,  253,  253,
532
      253,  253,  253,  253,  253,  253,  253,  253,  253,  253,
533
      253,    0,  252,  252,  252,  252,  252,  252,  252,  252,
534
      252,  252
535
    } ;
536
537
static yyconst flex_int16_t yy_nxt[580] =
538
    {   0,
539
        4,    5,    5,    6,    4,    7,    8,    9,   10,   11,
540
       12,   13,   14,   15,   16,   17,   17,   18,   19,   20,
541
       21,   22,   23,   24,   25,   26,    4,   27,   28,   29,
542
        4,    4,   30,    4,   31,    4,   32,   33,   34,   35,
543
        4,   36,   37,   38,   21,   22,   24,   39,   40,   28,
544
        4,   29,    4,    4,   41,   31,    4,   42,    4,    4,
545
       44,   44,   46,   46,   47,   51,   54,   56,   75,   55,
546
       81,   52,   84,   57,   77,   82,   52,   89,   90,   73,
547
       83,   43,   52,   44,   44,  113,  251,   51,   61,  250,
548
       56,   75,   66,   81,   84,   57,   77,   85,   72,   74,
549
550
       52,   62,   83,   48,   52,   53,   52,   52,   52,   52,
551
       52,   61,   67,   52,   52,   52,   52,   52,   52,   72,
552
       68,   85,   74,   52,   58,   82,  248,   59,   76,   52,
553
       83,   63,   78,   60,   97,   67,   77,   52,   52,   52,
554
       52,   52,   68,   64,   52,   65,   69,   68,   70,   59,
555
       79,   76,   95,   80,   60,   63,   78,   71,   77,   52,
556
      247,   69,  246,   70,  244,   64,   65,  243,   69,   68,
557
       70,  110,   71,   98,   79,   72,   80,   80,   96,   96,
558
       47,   76,  111,   69,   92,   70,   46,   46,   97,   96,
559
       96,   99,  103,  103,  104,  110,   72,  114,   93,   52,
560
561
       94,  107,  107,  111,   76,   52,  116,  108,  117,   89,
562
       90,  120,  121,  122,  123,  118,  124,  127,  119,   48,
563
      114,  126,  115,  128,  130,  131,  141,   98,  116,  134,
564
       48,  117,  120,  105,  122,  121,  125,  123,  242,  127,
565
      124,  119,  109,  115,  128,  126,  131,  130,  132,  241,
566
      134,  151,  150,  133,   96,   96,   47,  142,  142,  104,
567
      103,  103,  143,  146,  146,   98,  142,  142,  145,  108,
568
      132,  107,  107,  150,  133,  151,  152,  147,  146,  146,
569
      149,  153,  154,  155,  108,  236,  158,  156,  157,   97,
570
      161,   52,  165,  164,  166,   48,  169,  152,  105,   52,
571
572
      170,  144,  153,  160,  109,  154,  155,  105,  156,  157,
573
      158,  162,  148,  161,  165,  159,  164,  166,  171,  109,
574
      169,  163,  175,  170,  172,  174,  160,  143,   98,  181,
575
      142,  142,  104,  182,  147,  183,  159,  147,  184,  185,
576
      171,  146,  146,  163,  175,  172,  174,  108,  186,  235,
577
      187,  234,  233,  188,  189,  190,  191,  183,   52,  184,
578
      185,  193,  195,  194,  196,  197,  144,  198,  144,  148,
579
      186,  105,  148,  187,  188,  189,  190,  199,  191,  200,
580
      192,  202,  109,  195,  201,  193,  194,  196,  197,  203,
581
      198,  204,  143,  147,  210,  211,  212,  213,  214,  199,
582
583
      215,  192,  216,  200,  202,  217,  201,  228,  218,  219,
584
      225,  229,  226,  203,  204,  210,  227,  230,  212,  211,
585
      213,  215,  214,  231,  216,  232,  217,  237,  148,  218,
586
      228,  144,  225,  219,  226,  229,  238,  239,  227,  230,
587
      240,  245,  224,  249,  231,  223,  222,  232,  237,  221,
588
      220,  209,  208,  207,  206,  205,  180,  179,  238,  178,
589
      239,  177,  245,  240,  249,   45,   45,   45,   49,   49,
590
       88,   88,   88,   96,   96,   96,  102,  102,  102,  106,
591
      106,  106,   89,   89,   89,  142,  142,  142,  146,  146,
592
      146,  176,  173,  168,  167,  140,  139,  138,  137,  136,
593
594
       90,  135,  129,  112,   52,   52,  101,  100,   91,   87,
595
       86,   52,   52,   52,   52,   52,   50,  252,    3,  252,
596
      252,  252,  252,  252,  252,  252,  252,  252,  252,  252,
597
      252,  252,  252,  252,  252,  252,  252,  252,  252,  252,
598
      252,  252,  252,  252,  252,  252,  252,  252,  252,  252,
599
      252,  252,  252,  252,  252,  252,  252,  252,  252,  252,
600
      252,  252,  252,  252,  252,  252,  252,  252,  252,  252,
601
      252,  252,  252,  252,  252,  252,  252,  252,  252
602
    } ;
603
604
static yyconst flex_int16_t yy_chk[580] =
605
    {   0,
606
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
607
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
608
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
609
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
610
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
611
        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
612
        5,    5,    6,    6,    6,   10,   12,   20,   28,   12,
613
       31,   61,   33,   20,   51,   32,   22,   37,   37,   27,
614
       32,  253,   26,   44,   44,   61,  248,   10,   22,  246,
615
       20,   28,   24,   31,   33,   20,   51,   34,   26,   27,
616
617
       24,   22,   32,    6,   11,   11,   11,   11,   11,   11,
618
       21,   22,   24,   11,   11,   11,   11,   11,   11,   26,
619
       24,   34,   27,   23,   21,   42,  244,   21,   29,   25,
620
       42,   23,   30,   21,   96,   24,   29,   11,   11,   11,
621
       11,   11,   24,   23,   39,   23,   25,   56,   25,   21,
622
       30,   29,   42,   30,   21,   23,   41,   25,   29,   40,
623
      242,   39,  241,   39,  236,   23,   23,  235,   25,   56,
624
       25,   58,   39,   96,   41,   40,   30,   41,   45,   45,
625
       45,   57,   59,   39,   39,   39,   46,   46,   46,   48,
626
       48,   48,   54,   54,   54,   58,   40,   62,   40,   63,
627
628
       41,   55,   55,   59,   57,   67,   64,   55,   65,   88,
629
       88,   69,   70,   71,   72,   67,   74,   77,   67,   45,
630
       62,   76,   63,   79,   82,   84,   98,   46,   64,   86,
631
       48,   65,   69,   54,   71,   70,   74,   72,  234,   77,
632
       74,   67,   55,   63,   79,   76,   84,   82,   85,  233,
633
       86,  111,  110,   85,   99,   99,   99,  102,  102,  102,
634
      103,  103,  103,  106,  106,   98,  105,  105,  105,  106,
635
       85,  107,  107,  110,   85,  111,  112,  107,  109,  109,
636
      109,  113,  114,  115,  109,  223,  117,  116,  116,  141,
637
      120,  119,  123,  122,  124,   99,  128,  112,  102,  118,
638
639
      129,  103,  113,  119,  106,  114,  115,  105,  116,  116,
640
      117,  121,  107,  120,  123,  118,  122,  124,  130,  109,
641
      128,  121,  134,  129,  131,  133,  119,  142,  141,  144,
642
      145,  145,  145,  148,  146,  150,  118,  148,  151,  152,
643
      130,  149,  149,  121,  134,  131,  133,  149,  153,  222,
644
      154,  221,  220,  156,  157,  158,  159,  150,  160,  151,
645
      152,  162,  164,  163,  165,  166,  142,  167,  144,  146,
646
      153,  145,  148,  154,  156,  157,  158,  169,  159,  170,
647
      160,  173,  149,  164,  172,  162,  163,  165,  166,  174,
648
      167,  175,  181,  182,  187,  188,  189,  190,  191,  169,
649
650
      193,  160,  195,  170,  173,  197,  172,  215,  200,  203,
651
      211,  216,  212,  174,  175,  187,  214,  217,  189,  188,
652
      190,  193,  191,  217,  195,  219,  197,  225,  182,  200,
653
      215,  181,  211,  203,  212,  216,  229,  230,  214,  217,
654
      232,  239,  210,  245,  217,  209,  208,  219,  225,  206,
655
      205,  180,  179,  178,  177,  176,  140,  139,  229,  138,
656
      230,  137,  239,  232,  245,  254,  254,  254,  255,  255,
657
      256,  256,  256,  257,  257,  257,  258,  258,  258,  259,
658
      259,  259,  260,  260,  260,  261,  261,  261,  262,  262,
659
      262,  136,  132,  127,  126,   95,   94,   93,   92,   91,
660
661
       89,   87,   81,   60,   53,   52,   50,   49,   38,   36,
662
       35,   17,   16,   15,   14,   13,    7,    3,  252,  252,
663
      252,  252,  252,  252,  252,  252,  252,  252,  252,  252,
664
      252,  252,  252,  252,  252,  252,  252,  252,  252,  252,
665
      252,  252,  252,  252,  252,  252,  252,  252,  252,  252,
666
      252,  252,  252,  252,  252,  252,  252,  252,  252,  252,
667
      252,  252,  252,  252,  252,  252,  252,  252,  252,  252,
668
      252,  252,  252,  252,  252,  252,  252,  252,  252
669
    } ;
670
671
/* Table of booleans, true if rule could match eol. */
672
static yyconst flex_int32_t yy_rule_can_match_eol[61] =
673
    {   0,
674
0, 0, 0, 0, 0, 1, 1, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0,
675
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
676
    0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
677
    0,     };
678
679
static yy_state_type yy_last_accepting_state;
680
static char *yy_last_accepting_cpos;
681
682
extern int yy_flex_debug;
683
int yy_flex_debug = 0;
684
685
/* The intent behind this definition is that it'll catch
686
 * any uses of REJECT which flex missed.
687
 */
688
#define REJECT reject_used_but_not_detected
689
#define yymore() yymore_used_but_not_detected
690
#define YY_MORE_ADJ 0
691
#define YY_RESTORE_YY_MORE_OFFSET
692
char *yytext;
693
#line 1 "fgen.l"
694
#line 2 "fgen.l"
695
/*	$OpenBSD: fgen.l,v 1.12 2015/10/09 01:37:07 deraadt Exp $	*/
696
/*	$NetBSD: fgen.l,v 1.12 2001/06/13 10:46:05 wiz Exp $	*/
697
/* FLEX input for FORTH input file scanner */
698
/*
699
 * Copyright (c) 1998 Eduardo Horvath.
700
 * All rights reserved.
701
 *
702
 * Redistribution and use in source and binary forms, with or without
703
 * modification, are permitted provided that the following conditions
704
 * are met:
705
 * 1. Redistributions of source code must retain the above copyright
706
 *    notice, this list of conditions and the following disclaimer.
707
 * 2. Redistributions in binary form must reproduce the above copyright
708
 *    notice, this list of conditions and the following disclaimer in the
709
 *    documentation and/or other materials provided with the distribution.
710
 * 3. All advertising materials mentioning features or use of this software
711
 *    must display the following acknowledgement:
712
 *      This product includes software developed by Eduardo Horvath.
713
 * 4. The name of the author may not be used to endorse or promote products
714
 *    derived from this software without specific prior written permission
715
 *
716
 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
717
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
718
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
719
 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
720
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
721
 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
722
 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
723
 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
724
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
725
 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
726
 */
727
/*
728
	Specifications are as follows:
729
730
	The function "yylex()" always returns a pointer to a structure:
731
732
	    struct tok {
733
		int type;
734
		char *text;
735
	    }
736
	    #define TOKEN struct tok
737
*/
738
#line 56 "fgen.l"
739
#include <sys/types.h>
740
741
#include <assert.h>
742
#include <err.h>
743
#include <errno.h>
744
#include <fcntl.h>
745
#include <stdarg.h>
746
#include <stdio.h>
747
#include <string.h>
748
#include <unistd.h>
749
750
#include "fgen.h"
751
TOKEN token;
752
753
/*
754
 * Global variables that control the parse state.
755
 */
756
757
struct fcode *dictionary = NULL;
758
struct macro *aliases = NULL;
759
int outf = 1; /* stdout */
760
int state = 0;
761
int nextfcode = 0x800;
762
int base = TOK_HEX;
763
long outpos;
764
char *outbuf = NULL;
765
char *outfile, *infile;
766
#define BUFCLICK	(1024*1024)
767
size_t outbufsiz = 0;
768
char *myname = NULL;
769
int offsetsize = 8;
770
int defining = 0;
771
int tokenizer = 0;
772
773
#define PSTKSIZ		1024
774
Cell parse_stack[PSTKSIZ];
775
int parse_stack_ptr = 0;
776
777
void	token_err(int, char *, char *, char *, ...)
778
	__attribute__((__format__(__printf__, 4, 5)));
779
YY_DECL;
780
781
int debug = 0;
782
#define ASSERT if (debug) assert
783
#define STATE(y, x)	do { if (debug) printf( "%ld State %s: token `%s'\n", outpos, x, y); } while (0)
784
785
#define YY_NO_UNPUT
786
#line 787 "fgen.c"
787
788
#define INITIAL 0
789
790
#ifndef YY_NO_UNISTD_H
791
/* Special case for "unistd.h", since it is non-ANSI. We include it way
792
 * down here because we want the user's section 1 to have been scanned first.
793
 * The user has a chance to override it with an option.
794
 */
795
#include <unistd.h>
796
#endif
797
798
#ifndef YY_EXTRA_TYPE
799
#define YY_EXTRA_TYPE void *
800
#endif
801
802
static int yy_init_globals (void );
803
804
/* Accessor methods to globals.
805
   These are made visible to non-reentrant scanners for convenience. */
806
807
int yylex_destroy (void );
808
809
int yyget_debug (void );
810
811
void yyset_debug (int debug_flag  );
812
813
YY_EXTRA_TYPE yyget_extra (void );
814
815
void yyset_extra (YY_EXTRA_TYPE user_defined  );
816
817
FILE *yyget_in (void );
818
819
void yyset_in  (FILE * in_str  );
820
821
FILE *yyget_out (void );
822
823
void yyset_out  (FILE * out_str  );
824
825
yy_size_t yyget_leng (void );
826
827
char *yyget_text (void );
828
829
int yyget_lineno (void );
830
831
void yyset_lineno (int line_number  );
832
833
/* Macros after this point can all be overridden by user definitions in
834
 * section 1.
835
 */
836
837
#ifndef YY_SKIP_YYWRAP
838
#ifdef __cplusplus
839
extern "C" int yywrap (void );
840
#else
841
extern int yywrap (void );
842
#endif
843
#endif
844
845
    static void yyunput (int c,char *buf_ptr  );
846
847
#ifndef yytext_ptr
848
static void yy_flex_strncpy (char *,yyconst char *,int );
849
#endif
850
851
#ifdef YY_NEED_STRLEN
852
static int yy_flex_strlen (yyconst char * );
853
#endif
854
855
#ifndef YY_NO_INPUT
856
857
#ifdef __cplusplus
858
static int yyinput (void );
859
#else
860
static int input (void );
861
#endif
862
863
#endif
864
865
/* Amount of stuff to slurp up with each read. */
866
#ifndef YY_READ_BUF_SIZE
867
#define YY_READ_BUF_SIZE 8192
868
#endif
869
870
/* Copy whatever the last rule matched to the standard output. */
871
#ifndef ECHO
872
/* This used to be an fputs(), but since the string might contain NUL's,
873
 * we now use fwrite().
874
 */
875
#define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0)
876
#endif
877
878
/* Gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
879
 * is returned in "result".
880
 */
881
#ifndef YY_INPUT
882
#define YY_INPUT(buf,result,max_size) \
883
	if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
884
		{ \
885
		int c = '*'; \
886
		size_t n; \
887
		for ( n = 0; n < max_size && \
888
			     (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
889
			buf[n] = (char) c; \
890
		if ( c == '\n' ) \
891
			buf[n++] = (char) c; \
892
		if ( c == EOF && ferror( yyin ) ) \
893
			YY_FATAL_ERROR( "input in flex scanner failed" ); \
894
		result = n; \
895
		} \
896
	else \
897
		{ \
898
		errno=0; \
899
		while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
900
			{ \
901
			if( errno != EINTR) \
902
				{ \
903
				YY_FATAL_ERROR( "input in flex scanner failed" ); \
904
				break; \
905
				} \
906
			errno=0; \
907
			clearerr(yyin); \
908
			} \
909
		}\
910
\
911
912
#endif
913
914
/* No semi-colon after return; correct usage is to write "yyterminate();" -
915
 * we don't want an extra ';' after the "return" because that will cause
916
 * some compilers to complain about unreachable statements.
917
 */
918
#ifndef yyterminate
919
#define yyterminate() return YY_NULL
920
#endif
921
922
/* Number of entries by which start-condition stack grows. */
923
#ifndef YY_START_STACK_INCR
924
#define YY_START_STACK_INCR 25
925
#endif
926
927
/* Report a fatal error. */
928
#ifndef YY_FATAL_ERROR
929
#define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
930
#endif
931
932
/* end tables serialization structures and prototypes */
933
934
/* Default declaration of generated scanner - a define so the user can
935
 * easily add parameters.
936
 */
937
#ifndef YY_DECL
938
#define YY_DECL_IS_OURS 1
939
940
extern int yylex (void);
941
942
#define YY_DECL int yylex (void)
943
#endif /* !YY_DECL */
944
945
/* Code executed at the beginning of each rule, after yytext and yyleng
946
 * have been set up.
947
 */
948
#ifndef YY_USER_ACTION
949
#define YY_USER_ACTION
950
#endif
951
952
/* Code executed at the end of each rule. */
953
#ifndef YY_BREAK
954
#define YY_BREAK break;
955
#endif
956
957
#define YY_RULE_SETUP \
958
	YY_USER_ACTION
959
960
/** The main scanner function which does all the work.
961
 */
962
YY_DECL
963
{
964
	yy_state_type yy_current_state;
965
	char *yy_cp, *yy_bp;
966
	int yy_act;
967
968
	if ( !(yy_init) )
969
		{
970
		(yy_init) = 1;
971
972
#ifdef YY_USER_INIT
973
		YY_USER_INIT;
974
#endif
975
976
		if ( ! (yy_start) )
977
			(yy_start) = 1;	/* first start state */
978
979
		if ( ! yyin )
980
			yyin = stdin;
981
982
		if ( ! yyout )
983
			yyout = stdout;
984
985
		if ( ! YY_CURRENT_BUFFER ) {
986
			yyensure_buffer_stack ();
987
			YY_CURRENT_BUFFER_LVALUE =
988
				yy_create_buffer(yyin,YY_BUF_SIZE );
989
		}
990
991
		yy_load_buffer_state( );
992
		}
993
994
	{
995
#line 105 "fgen.l"
996
997
998
#line 999 "fgen.c"
999
1000
	while ( 1 )		/* loops until end-of-file is reached */
1001
		{
1002
		yy_cp = (yy_c_buf_p);
1003
1004
		/* Support of yytext. */
1005
		*yy_cp = (yy_hold_char);
1006
1007
		/* yy_bp points to the position in yy_ch_buf of the start of
1008
		 * the current run.
1009
		 */
1010
		yy_bp = yy_cp;
1011
1012
		yy_current_state = (yy_start);
1013
yy_match:
1014
		do
1015
			{
1016
			YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ;
1017
			if ( yy_accept[yy_current_state] )
1018
				{
1019
				(yy_last_accepting_state) = yy_current_state;
1020
				(yy_last_accepting_cpos) = yy_cp;
1021
				}
1022
			while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1023
				{
1024
				yy_current_state = (int) yy_def[yy_current_state];
1025
				if ( yy_current_state >= 253 )
1026
					yy_c = yy_meta[(unsigned int) yy_c];
1027
				}
1028
			yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1029
			++yy_cp;
1030
			}
1031
		while ( yy_base[yy_current_state] != 519 );
1032
1033
yy_find_action:
1034
		yy_act = yy_accept[yy_current_state];
1035
		if ( yy_act == 0 )
1036
			{ /* have to back up */
1037
			yy_cp = (yy_last_accepting_cpos);
1038
			yy_current_state = (yy_last_accepting_state);
1039
			yy_act = yy_accept[yy_current_state];
1040
			}
1041
1042
		YY_DO_BEFORE_ACTION;
1043
1044
		if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] )
1045
			{
1046
			yy_size_t yyl;
1047
			for ( yyl = 0; yyl < yyleng; ++yyl )
1048
				if ( yytext[yyl] == '\n' )
1049
1050
    yylineno++;
1051
;
1052
			}
1053
1054
do_action:	/* This label is used only to access EOF actions. */
1055
1056
		switch ( yy_act )
1057
	{ /* beginning of action switch */
1058
			case 0: /* must back up */
1059
			/* undo the effects of YY_DO_BEFORE_ACTION */
1060
			*yy_cp = (yy_hold_char);
1061
			yy_cp = (yy_last_accepting_cpos);
1062
			yy_current_state = (yy_last_accepting_state);
1063
			goto yy_find_action;
1064
1065
case 1:
1066
YY_RULE_SETUP
1067
#line 107 "fgen.l"
1068
{ token.type = TOK_OTHER; token.text = yytext;
1069
				return &token; }
1070
	YY_BREAK
1071
case 2:
1072
YY_RULE_SETUP
1073
#line 110 "fgen.l"
1074
{ token.type = TOK_OTHER; token.text = yytext;
1075
				return &token; }
1076
	YY_BREAK
1077
case 3:
1078
YY_RULE_SETUP
1079
#line 113 "fgen.l"
1080
{ token.type = TOK_OTHER; token.text = yytext;
1081
				return &token; }
1082
	YY_BREAK
1083
case 4:
1084
YY_RULE_SETUP
1085
#line 116 "fgen.l"
1086
{ token.type = TOK_OTHER; token.text = yytext;
1087
				return &token; }
1088
	YY_BREAK
1089
case 5:
1090
YY_RULE_SETUP
1091
#line 119 "fgen.l"
1092
{ token.type = TOK_OTHER; token.text = yytext;
1093
				return &token; }
1094
	YY_BREAK
1095
case 6:
1096
/* rule 6 can match eol */
1097
YY_RULE_SETUP
1098
#line 122 "fgen.l"
1099
/* whitespace -- keep looping */ ;
1100
	YY_BREAK
1101
case 7:
1102
/* rule 7 can match eol */
1103
YY_RULE_SETUP
1104
#line 124 "fgen.l"
1105
/* end of line comment -- keep looping */ { STATE(yytext, "EOL comment"); }
1106
	YY_BREAK
1107
case 8:
1108
YY_RULE_SETUP
1109
#line 126 "fgen.l"
1110
{ token.type = TOK_NUMBER; token.text = yytext;
1111
					return &token; }
1112
	YY_BREAK
1113
case 9:
1114
YY_RULE_SETUP
1115
#line 129 "fgen.l"
1116
{ token.type = TOK_C_LIT; token.text = yytext; return &token; }
1117
	YY_BREAK
1118
case 10:
1119
/* rule 10 can match eol */
1120
YY_RULE_SETUP
1121
#line 131 "fgen.l"
1122
{ token.type = TOK_STRING_LIT; token.text = yytext;
1123
				return &token; } /* String started by `"' or `."' */
1124
	YY_BREAK
1125
case 11:
1126
/* rule 11 can match eol */
1127
YY_RULE_SETUP
1128
#line 134 "fgen.l"
1129
{ token.type = TOK_PSTRING; token.text = yytext;
1130
				return &token; } /* String of type `.(.....)' */
1131
	YY_BREAK
1132
case 12:
1133
/* rule 12 can match eol */
1134
YY_RULE_SETUP
1135
#line 137 "fgen.l"
1136
{ token.type = TOK_PSTRING; token.text = yytext;
1137
				return &token; }
1138
	YY_BREAK
1139
case 13:
1140
YY_RULE_SETUP
1141
#line 140 "fgen.l"
1142
{ token.type = TOK_COMMENT; token.text = yytext;
1143
				return &token; }
1144
	YY_BREAK
1145
case 14:
1146
YY_RULE_SETUP
1147
#line 143 "fgen.l"
1148
{ token.type = TOK_ENDCOMMENT; token.text = yytext;
1149
				return &token; }
1150
	YY_BREAK
1151
case 15:
1152
YY_RULE_SETUP
1153
#line 146 "fgen.l"
1154
{ token.type = TOK_COLON; token.text = yytext;
1155
				return &token; }
1156
	YY_BREAK
1157
case 16:
1158
YY_RULE_SETUP
1159
#line 149 "fgen.l"
1160
{ token.type = TOK_SEMICOLON; token.text = yytext;
1161
				return &token; }
1162
	YY_BREAK
1163
case 17:
1164
YY_RULE_SETUP
1165
#line 152 "fgen.l"
1166
{ token.type = TOK_TOKENIZE; token.text = yytext;
1167
				return &token; }
1168
	YY_BREAK
1169
case 18:
1170
YY_RULE_SETUP
1171
#line 155 "fgen.l"
1172
{ token.type = TOK_AGAIN; token.text = yytext;
1173
				return &token; }
1174
	YY_BREAK
1175
case 19:
1176
YY_RULE_SETUP
1177
#line 158 "fgen.l"
1178
{ token.type = TOK_ALIAS; token.text = yytext;
1179
				return &token; }
1180
	YY_BREAK
1181
case 20:
1182
YY_RULE_SETUP
1183
#line 161 "fgen.l"
1184
{ token.type = TOK_GETTOKEN; token.text = yytext;
1185
				return &token; }
1186
	YY_BREAK
1187
case 21:
1188
YY_RULE_SETUP
1189
#line 164 "fgen.l"
1190
{ token.type = TOK_ASCII; token.text = yytext;
1191
				return &token; }
1192
	YY_BREAK
1193
case 22:
1194
YY_RULE_SETUP
1195
#line 167 "fgen.l"
1196
{ token.type = TOK_BEGIN; token.text = yytext;
1197
				return &token; }
1198
	YY_BREAK
1199
case 23:
1200
YY_RULE_SETUP
1201
#line 170 "fgen.l"
1202
{ token.type = TOK_BUFFER; token.text = yytext;
1203
				return &token; }
1204
	YY_BREAK
1205
case 24:
1206
YY_RULE_SETUP
1207
#line 173 "fgen.l"
1208
{ token.type = TOK_CASE; token.text = yytext;
1209
				return &token; }
1210
	YY_BREAK
1211
case 25:
1212
YY_RULE_SETUP
1213
#line 176 "fgen.l"
1214
{ token.type = TOK_CONSTANT; token.text = yytext;
1215
				return &token; }
1216
	YY_BREAK
1217
case 26:
1218
YY_RULE_SETUP
1219
#line 179 "fgen.l"
1220
{ token.type = TOK_CONTROL; token.text = yytext;
1221
				return &token; }
1222
	YY_BREAK
1223
case 27:
1224
YY_RULE_SETUP
1225
#line 182 "fgen.l"
1226
{ token.type = TOK_CREATE; token.text = yytext;
1227
				return &token; }
1228
	YY_BREAK
1229
case 28:
1230
YY_RULE_SETUP
1231
#line 185 "fgen.l"
1232
{ token.type = TOK_DECIMAL; token.text = yytext;
1233
				return &token; }
1234
	YY_BREAK
1235
case 29:
1236
YY_RULE_SETUP
1237
#line 188 "fgen.l"
1238
{ token.type = TOK_DECIMAL; token.text = yytext;
1239
				return &token; }
1240
	YY_BREAK
1241
case 30:
1242
YY_RULE_SETUP
1243
#line 191 "fgen.l"
1244
{ token.type = TOK_DEFER; token.text = yytext;
1245
				return &token; }
1246
	YY_BREAK
1247
case 31:
1248
YY_RULE_SETUP
1249
#line 194 "fgen.l"
1250
{ token.type = TOK_DO; token.text = yytext;
1251
				return &token; }
1252
	YY_BREAK
1253
case 32:
1254
YY_RULE_SETUP
1255
#line 197 "fgen.l"
1256
{ token.type = TOK_ELSE; token.text = yytext;
1257
				return &token; }
1258
	YY_BREAK
1259
case 33:
1260
YY_RULE_SETUP
1261
#line 200 "fgen.l"
1262
{ token.type = TOK_ENDCASE; token.text = yytext;
1263
				return &token; }
1264
	YY_BREAK
1265
case 34:
1266
YY_RULE_SETUP
1267
#line 203 "fgen.l"
1268
{ token.type = TOK_ENDOF; token.text = yytext;
1269
				return &token; }
1270
	YY_BREAK
1271
case 35:
1272
YY_RULE_SETUP
1273
#line 206 "fgen.l"
1274
{ token.type = TOK_EXTERNAL; token.text = yytext;
1275
				return &token; }
1276
	YY_BREAK
1277
case 36:
1278
YY_RULE_SETUP
1279
#line 209 "fgen.l"
1280
{ token.type = TOK_FIELD; token.text = yytext;
1281
				return &token; }
1282
	YY_BREAK
1283
case 37:
1284
YY_RULE_SETUP
1285
#line 212 "fgen.l"
1286
{ token.type = TOK_HEX; token.text = yytext;
1287
				return &token; }
1288
	YY_BREAK
1289
case 38:
1290
YY_RULE_SETUP
1291
#line 215 "fgen.l"
1292
{ token.type = TOK_HEADERLESS; token.text = yytext;
1293
				return &token; }
1294
	YY_BREAK
1295
case 39:
1296
YY_RULE_SETUP
1297
#line 218 "fgen.l"
1298
{ token.type = TOK_HEADERS; token.text = yytext;
1299
				return &token; }
1300
	YY_BREAK
1301
case 40:
1302
YY_RULE_SETUP
1303
#line 221 "fgen.l"
1304
{ token.type = TOK_HEX; token.text = yytext;
1305
				return &token; }
1306
	YY_BREAK
1307
case 41:
1308
YY_RULE_SETUP
1309
#line 224 "fgen.l"
1310
{ token.type = TOK_IF; token.text = yytext;
1311
				return &token; }
1312
	YY_BREAK
1313
case 42:
1314
YY_RULE_SETUP
1315
#line 227 "fgen.l"
1316
{ token.type = TOK_LEAVE; token.text = yytext;
1317
				return &token; }
1318
	YY_BREAK
1319
case 43:
1320
YY_RULE_SETUP
1321
#line 230 "fgen.l"
1322
{ token.type = TOK_LOOP; token.text = yytext;
1323
				return &token; }
1324
	YY_BREAK
1325
case 44:
1326
YY_RULE_SETUP
1327
#line 233 "fgen.l"
1328
{ token.type = TOK_OCTAL; token.text = yytext;
1329
				return &token; }
1330
	YY_BREAK
1331
case 45:
1332
YY_RULE_SETUP
1333
#line 236 "fgen.l"
1334
{ token.type = TOK_OCTAL; token.text = yytext;
1335
				return &token; }
1336
	YY_BREAK
1337
case 46:
1338
YY_RULE_SETUP
1339
#line 239 "fgen.l"
1340
{ token.type = TOK_OF; token.text = yytext;
1341
				return &token; }
1342
	YY_BREAK
1343
case 47:
1344
YY_RULE_SETUP
1345
#line 242 "fgen.l"
1346
{ token.type = TOK_REPEAT; token.text = yytext;
1347
				return &token; }
1348
	YY_BREAK
1349
case 48:
1350
YY_RULE_SETUP
1351
#line 245 "fgen.l"
1352
{ token.type = TOK_THEN; token.text = yytext;
1353
				return &token; }
1354
	YY_BREAK
1355
case 49:
1356
YY_RULE_SETUP
1357
#line 248 "fgen.l"
1358
{ token.type = TOK_TO; token.text = yytext;
1359
				return &token; }
1360
	YY_BREAK
1361
case 50:
1362
YY_RULE_SETUP
1363
#line 251 "fgen.l"
1364
{ token.type = TOK_UNTIL; token.text = yytext;
1365
				return &token; }
1366
	YY_BREAK
1367
case 51:
1368
YY_RULE_SETUP
1369
#line 254 "fgen.l"
1370
{ token.type = TOK_VALUE; token.text = yytext;
1371
				return &token; }
1372
	YY_BREAK
1373
case 52:
1374
YY_RULE_SETUP
1375
#line 257 "fgen.l"
1376
{ token.type = TOK_VARIABLE; token.text = yytext;
1377
				return &token; }
1378
	YY_BREAK
1379
case 53:
1380
YY_RULE_SETUP
1381
#line 260 "fgen.l"
1382
{ token.type = TOK_WHILE; token.text = yytext;
1383
				return &token; }
1384
	YY_BREAK
1385
case 54:
1386
YY_RULE_SETUP
1387
#line 263 "fgen.l"
1388
{ token.type = TOK_OFFSET16; token.text = yytext;
1389
				return &token; }
1390
	YY_BREAK
1391
case 55:
1392
YY_RULE_SETUP
1393
#line 266 "fgen.l"
1394
{ token.type = TOK_BEGTOK; token.text = yytext;
1395
				return &token; }
1396
	YY_BREAK
1397
case 56:
1398
YY_RULE_SETUP
1399
#line 269 "fgen.l"
1400
{ token.type = TOK_EMIT_BYTE; token.text = yytext;
1401
				return &token; }
1402
	YY_BREAK
1403
case 57:
1404
YY_RULE_SETUP
1405
#line 272 "fgen.l"
1406
{ token.type = TOK_ENDTOK; token.text = yytext;
1407
				return &token; }
1408
	YY_BREAK
1409
case 58:
1410
YY_RULE_SETUP
1411
#line 275 "fgen.l"
1412
{ token.type = TOK_FLOAD; token.text = yytext;
1413
				return &token; }
1414
	YY_BREAK
1415
case 59:
1416
YY_RULE_SETUP
1417
#line 279 "fgen.l"
1418
{ token.type = TOK_OTHER; token.text = yytext;
1419
				return &token; }
1420
	YY_BREAK
1421
case YY_STATE_EOF(INITIAL):
1422
#line 282 "fgen.l"
1423
{ return NULL; }
1424
	YY_BREAK
1425
case 60:
1426
YY_RULE_SETUP
1427
#line 283 "fgen.l"
1428
ECHO;
1429
	YY_BREAK
1430
#line 1431 "fgen.c"
1431
1432
	case YY_END_OF_BUFFER:
1433
		{
1434
		/* Amount of text matched not including the EOB char. */
1435
		int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
1436
1437
		/* Undo the effects of YY_DO_BEFORE_ACTION. */
1438
		*yy_cp = (yy_hold_char);
1439
		YY_RESTORE_YY_MORE_OFFSET
1440
1441
		if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
1442
			{
1443
			/* We're scanning a new file or input source.  It's
1444
			 * possible that this happened because the user
1445
			 * just pointed yyin at a new source and called
1446
			 * yylex().  If so, then we have to assure
1447
			 * consistency between YY_CURRENT_BUFFER and our
1448
			 * globals.  Here is the right place to do so, because
1449
			 * this is the first action (other than possibly a
1450
			 * back-up) that will match for the new input source.
1451
			 */
1452
			(yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1453
			YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
1454
			YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
1455
			}
1456
1457
		/* Note that here we test for yy_c_buf_p "<=" to the position
1458
		 * of the first EOB in the buffer, since yy_c_buf_p will
1459
		 * already have been incremented past the NUL character
1460
		 * (since all states make transitions on EOB to the
1461
		 * end-of-buffer state).  Contrast this with the test
1462
		 * in input().
1463
		 */
1464
		if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
1465
			{ /* This was really a NUL. */
1466
			yy_state_type yy_next_state;
1467
1468
			(yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
1469
1470
			yy_current_state = yy_get_previous_state(  );
1471
1472
			/* Okay, we're now positioned to make the NUL
1473
			 * transition.  We couldn't have
1474
			 * yy_get_previous_state() go ahead and do it
1475
			 * for us because it doesn't know how to deal
1476
			 * with the possibility of jamming (and we don't
1477
			 * want to build jamming into it because then it
1478
			 * will run more slowly).
1479
			 */
1480
1481
			yy_next_state = yy_try_NUL_trans( yy_current_state );
1482
1483
			yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1484
1485
			if ( yy_next_state )
1486
				{
1487
				/* Consume the NUL. */
1488
				yy_cp = ++(yy_c_buf_p);
1489
				yy_current_state = yy_next_state;
1490
				goto yy_match;
1491
				}
1492
1493
			else
1494
				{
1495
				yy_cp = (yy_c_buf_p);
1496
				goto yy_find_action;
1497
				}
1498
			}
1499
1500
		else switch ( yy_get_next_buffer(  ) )
1501
			{
1502
			case EOB_ACT_END_OF_FILE:
1503
				{
1504
				(yy_did_buffer_switch_on_eof) = 0;
1505
1506
				if ( yywrap( ) )
1507
					{
1508
					/* Note: because we've taken care in
1509
					 * yy_get_next_buffer() to have set up
1510
					 * yytext, we can now set up
1511
					 * yy_c_buf_p so that if some total
1512
					 * hoser (like flex itself) wants to
1513
					 * call the scanner after we return the
1514
					 * YY_NULL, it'll still work - another
1515
					 * YY_NULL will get returned.
1516
					 */
1517
					(yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
1518
1519
					yy_act = YY_STATE_EOF(YY_START);
1520
					goto do_action;
1521
					}
1522
1523
				else
1524
					{
1525
					if ( ! (yy_did_buffer_switch_on_eof) )
1526
						YY_NEW_FILE;
1527
					}
1528
				break;
1529
				}
1530
1531
			case EOB_ACT_CONTINUE_SCAN:
1532
				(yy_c_buf_p) =
1533
					(yytext_ptr) + yy_amount_of_matched_text;
1534
1535
				yy_current_state = yy_get_previous_state(  );
1536
1537
				yy_cp = (yy_c_buf_p);
1538
				yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1539
				goto yy_match;
1540
1541
			case EOB_ACT_LAST_MATCH:
1542
				(yy_c_buf_p) =
1543
				&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
1544
1545
				yy_current_state = yy_get_previous_state(  );
1546
1547
				yy_cp = (yy_c_buf_p);
1548
				yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1549
				goto yy_find_action;
1550
			}
1551
		break;
1552
		}
1553
1554
	default:
1555
		YY_FATAL_ERROR(
1556
			"fatal flex scanner internal error--no action found" );
1557
	} /* end of action switch */
1558
		} /* end of scanning one token */
1559
	} /* end of user's declarations */
1560
} /* end of yylex */
1561
1562
/* yy_get_next_buffer - try to read in a new buffer
1563
 *
1564
 * Returns a code representing an action:
1565
 *	EOB_ACT_LAST_MATCH -
1566
 *	EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1567
 *	EOB_ACT_END_OF_FILE - end of file
1568
 */
1569
static int yy_get_next_buffer (void)
1570
{
1571
    	char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
1572
	char *source = (yytext_ptr);
1573
	int number_to_move, i;
1574
	int ret_val;
1575
1576
	if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
1577
		YY_FATAL_ERROR(
1578
		"fatal flex scanner internal error--end of buffer missed" );
1579
1580
	if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
1581
		{ /* Don't try to fill the buffer, so this is an EOF. */
1582
		if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
1583
			{
1584
			/* We matched a single character, the EOB, so
1585
			 * treat this as a final EOF.
1586
			 */
1587
			return EOB_ACT_END_OF_FILE;
1588
			}
1589
1590
		else
1591
			{
1592
			/* We matched some text prior to the EOB, first
1593
			 * process it.
1594
			 */
1595
			return EOB_ACT_LAST_MATCH;
1596
			}
1597
		}
1598
1599
	/* Try to read more data. */
1600
1601
	/* First move last chars to start of buffer. */
1602
	number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
1603
1604
	for ( i = 0; i < number_to_move; ++i )
1605
		*(dest++) = *(source++);
1606
1607
	if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
1608
		/* don't do the read, it's not guaranteed to return an EOF,
1609
		 * just force an EOF
1610
		 */
1611
		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
1612
1613
	else
1614
		{
1615
			yy_size_t num_to_read =
1616
			YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
1617
1618
		while ( num_to_read <= 0 )
1619
			{ /* Not enough room in the buffer - grow it. */
1620
1621
			/* just a shorter name for the current buffer */
1622
			YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;
1623
1624
			int yy_c_buf_p_offset =
1625
				(int) ((yy_c_buf_p) - b->yy_ch_buf);
1626
1627
			if ( b->yy_is_our_buffer )
1628
				{
1629
				yy_size_t new_size = b->yy_buf_size * 2;
1630
1631
				if ( new_size <= 0 )
1632
					b->yy_buf_size += b->yy_buf_size / 8;
1633
				else
1634
					b->yy_buf_size *= 2;
1635
1636
				b->yy_ch_buf = (char *)
1637
					/* Include room in for 2 EOB chars. */
1638
					yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2  );
1639
				}
1640
			else
1641
				/* Can't grow it, we don't own it. */
1642
				b->yy_ch_buf = 0;
1643
1644
			if ( ! b->yy_ch_buf )
1645
				YY_FATAL_ERROR(
1646
				"fatal error - scanner input buffer overflow" );
1647
1648
			(yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
1649
1650
			num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
1651
						number_to_move - 1;
1652
1653
			}
1654
1655
		if ( num_to_read > YY_READ_BUF_SIZE )
1656
			num_to_read = YY_READ_BUF_SIZE;
1657
1658
		/* Read in more data. */
1659
		YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
1660
			(yy_n_chars), num_to_read );
1661
1662
		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1663
		}
1664
1665
	if ( (yy_n_chars) == 0 )
1666
		{
1667
		if ( number_to_move == YY_MORE_ADJ )
1668
			{
1669
			ret_val = EOB_ACT_END_OF_FILE;
1670
			yyrestart(yyin  );
1671
			}
1672
1673
		else
1674
			{
1675
			ret_val = EOB_ACT_LAST_MATCH;
1676
			YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
1677
				YY_BUFFER_EOF_PENDING;
1678
			}
1679
		}
1680
1681
	else
1682
		ret_val = EOB_ACT_CONTINUE_SCAN;
1683
1684
	if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
1685
		/* Extend the array by 50%, plus the number we really need. */
1686
		yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
1687
		YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size  );
1688
		if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1689
			YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
1690
		/* "- 2" to take care of EOB's */
1691
		YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2);
1692
	}
1693
1694
	(yy_n_chars) += number_to_move;
1695
	YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
1696
	YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
1697
1698
	(yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
1699
1700
	return ret_val;
1701
}
1702
1703
/* yy_get_previous_state - get the state just before the EOB char was reached */
1704
1705
    static yy_state_type yy_get_previous_state (void)
1706
{
1707
	yy_state_type yy_current_state;
1708
	char *yy_cp;
1709
1710
	yy_current_state = (yy_start);
1711
1712
	for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
1713
		{
1714
		YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1715
		if ( yy_accept[yy_current_state] )
1716
			{
1717
			(yy_last_accepting_state) = yy_current_state;
1718
			(yy_last_accepting_cpos) = yy_cp;
1719
			}
1720
		while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1721
			{
1722
			yy_current_state = (int) yy_def[yy_current_state];
1723
			if ( yy_current_state >= 253 )
1724
				yy_c = yy_meta[(unsigned int) yy_c];
1725
			}
1726
		yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1727
		}
1728
1729
	return yy_current_state;
1730
}
1731
1732
/* yy_try_NUL_trans - try to make a transition on the NUL character
1733
 *
1734
 * synopsis
1735
 *	next_state = yy_try_NUL_trans( current_state );
1736
 */
1737
    static yy_state_type yy_try_NUL_trans  (yy_state_type yy_current_state )
1738
{
1739
	int yy_is_jam;
1740
    	char *yy_cp = (yy_c_buf_p);
1741
1742
	YY_CHAR yy_c = 1;
1743
	if ( yy_accept[yy_current_state] )
1744
		{
1745
		(yy_last_accepting_state) = yy_current_state;
1746
		(yy_last_accepting_cpos) = yy_cp;
1747
		}
1748
	while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1749
		{
1750
		yy_current_state = (int) yy_def[yy_current_state];
1751
		if ( yy_current_state >= 253 )
1752
			yy_c = yy_meta[(unsigned int) yy_c];
1753
		}
1754
	yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1755
	yy_is_jam = (yy_current_state == 252);
1756
1757
		return yy_is_jam ? 0 : yy_current_state;
1758
}
1759
1760
    static void yyunput (int c, char * yy_bp )
1761
{
1762
	char *yy_cp;
1763
1764
    yy_cp = (yy_c_buf_p);
1765
1766
	/* undo effects of setting up yytext */
1767
	*yy_cp = (yy_hold_char);
1768
1769
	if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
1770
		{ /* need to shift things up to make room */
1771
		/* +2 for EOB chars. */
1772
		yy_size_t number_to_move = (yy_n_chars) + 2;
1773
		char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
1774
					YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
1775
		char *source =
1776
				&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
1777
1778
		while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1779
			*--dest = *--source;
1780
1781
		yy_cp += (int) (dest - source);
1782
		yy_bp += (int) (dest - source);
1783
		YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
1784
			(yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
1785
1786
		if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
1787
			YY_FATAL_ERROR( "flex scanner push-back overflow" );
1788
		}
1789
1790
	*--yy_cp = (char) c;
1791
1792
    if ( c == '\n' ){
1793
        --yylineno;
1794
    }
1795
1796
	(yytext_ptr) = yy_bp;
1797
	(yy_hold_char) = *yy_cp;
1798
	(yy_c_buf_p) = yy_cp;
1799
}
1800
1801
#ifndef YY_NO_INPUT
1802
#ifdef __cplusplus
1803
    static int yyinput (void)
1804
#else
1805
    static int input  (void)
1806
#endif
1807
1808
{
1809
	int c;
1810
1811
	*(yy_c_buf_p) = (yy_hold_char);
1812
1813
	if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
1814
		{
1815
		/* yy_c_buf_p now points to the character we want to return.
1816
		 * If this occurs *before* the EOB characters, then it's a
1817
		 * valid NUL; if not, then we've hit the end of the buffer.
1818
		 */
1819
		if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
1820
			/* This was really a NUL. */
1821
			*(yy_c_buf_p) = '\0';
1822
1823
		else
1824
			{ /* need more input */
1825
			yy_size_t offset = (yy_c_buf_p) - (yytext_ptr);
1826
			++(yy_c_buf_p);
1827
1828
			switch ( yy_get_next_buffer(  ) )
1829
				{
1830
				case EOB_ACT_LAST_MATCH:
1831
					/* This happens because yy_g_n_b()
1832
					 * sees that we've accumulated a
1833
					 * token and flags that we need to
1834
					 * try matching the token before
1835
					 * proceeding.  But for input(),
1836
					 * there's no matching to consider.
1837
					 * So convert the EOB_ACT_LAST_MATCH
1838
					 * to EOB_ACT_END_OF_FILE.
1839
					 */
1840
1841
					/* Reset buffer status. */
1842
					yyrestart(yyin );
1843
1844
					/*FALLTHROUGH*/
1845
1846
				case EOB_ACT_END_OF_FILE:
1847
					{
1848
					if ( yywrap( ) )
1849
						return EOF;
1850
1851
					if ( ! (yy_did_buffer_switch_on_eof) )
1852
						YY_NEW_FILE;
1853
#ifdef __cplusplus
1854
					return yyinput();
1855
#else
1856
					return input();
1857
#endif
1858
					}
1859
1860
				case EOB_ACT_CONTINUE_SCAN:
1861
					(yy_c_buf_p) = (yytext_ptr) + offset;
1862
					break;
1863
				}
1864
			}
1865
		}
1866
1867
	c = *(unsigned char *) (yy_c_buf_p);	/* cast for 8-bit char's */
1868
	*(yy_c_buf_p) = '\0';	/* preserve yytext */
1869
	(yy_hold_char) = *++(yy_c_buf_p);
1870
1871
	if ( c == '\n' )
1872
1873
    yylineno++;
1874
;
1875
1876
	return c;
1877
}
1878
#endif	/* ifndef YY_NO_INPUT */
1879
1880
/** Immediately switch to a different input stream.
1881
 * @param input_file A readable stream.
1882
 *
1883
 * @note This function does not reset the start condition to @c INITIAL .
1884
 */
1885
    void yyrestart  (FILE * input_file )
1886
{
1887
1888
	if ( ! YY_CURRENT_BUFFER ){
1889
        yyensure_buffer_stack ();
1890
		YY_CURRENT_BUFFER_LVALUE =
1891
            yy_create_buffer(yyin,YY_BUF_SIZE );
1892
	}
1893
1894
	yy_init_buffer(YY_CURRENT_BUFFER,input_file );
1895
	yy_load_buffer_state( );
1896
}
1897
1898
/** Switch to a different input buffer.
1899
 * @param new_buffer The new input buffer.
1900
 *
1901
 */
1902
    void yy_switch_to_buffer  (YY_BUFFER_STATE  new_buffer )
1903
{
1904
1905
	/* TODO. We should be able to replace this entire function body
1906
	 * with
1907
	 *		yypop_buffer_state();
1908
	 *		yypush_buffer_state(new_buffer);
1909
     */
1910
	yyensure_buffer_stack ();
1911
	if ( YY_CURRENT_BUFFER == new_buffer )
1912
		return;
1913
1914
	if ( YY_CURRENT_BUFFER )
1915
		{
1916
		/* Flush out information for old buffer. */
1917
		*(yy_c_buf_p) = (yy_hold_char);
1918
		YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1919
		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1920
		}
1921
1922
	YY_CURRENT_BUFFER_LVALUE = new_buffer;
1923
	yy_load_buffer_state( );
1924
1925
	/* We don't actually know whether we did this switch during
1926
	 * EOF (yywrap()) processing, but the only time this flag
1927
	 * is looked at is after yywrap() is called, so it's safe
1928
	 * to go ahead and always set it.
1929
	 */
1930
	(yy_did_buffer_switch_on_eof) = 1;
1931
}
1932
1933
static void yy_load_buffer_state  (void)
1934
{
1935
    	(yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1936
	(yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
1937
	yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
1938
	(yy_hold_char) = *(yy_c_buf_p);
1939
}
1940
1941
/** Allocate and initialize an input buffer state.
1942
 * @param file A readable stream.
1943
 * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
1944
 *
1945
 * @return the allocated buffer state.
1946
 */
1947
    YY_BUFFER_STATE yy_create_buffer  (FILE * file, int  size )
1948
{
1949
	YY_BUFFER_STATE b;
1950
1951
	b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state )  );
1952
	if ( ! b )
1953
		YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1954
1955
	b->yy_buf_size = size;
1956
1957
	/* yy_ch_buf has to be 2 characters longer than the size given because
1958
	 * we need to put in 2 end-of-buffer characters.
1959
	 */
1960
	b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2  );
1961
	if ( ! b->yy_ch_buf )
1962
		YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1963
1964
	b->yy_is_our_buffer = 1;
1965
1966
	yy_init_buffer(b,file );
1967
1968
	return b;
1969
}
1970
1971
/** Destroy the buffer.
1972
 * @param b a buffer created with yy_create_buffer()
1973
 *
1974
 */
1975
    void yy_delete_buffer (YY_BUFFER_STATE  b )
1976
{
1977
1978
	if ( ! b )
1979
		return;
1980
1981
	if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
1982
		YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
1983
1984
	if ( b->yy_is_our_buffer )
1985
		yyfree((void *) b->yy_ch_buf  );
1986
1987
	yyfree((void *) b  );
1988
}
1989
1990
/* Initializes or reinitializes a buffer.
1991
 * This function is sometimes called more than once on the same buffer,
1992
 * such as during a yyrestart() or at EOF.
1993
 */
1994
    static void yy_init_buffer  (YY_BUFFER_STATE  b, FILE * file )
1995
1996
{
1997
	int oerrno = errno;
1998
1999
	yy_flush_buffer(b );
2000
2001
	b->yy_input_file = file;
2002
	b->yy_fill_buffer = 1;
2003
2004
    /* If b is the current buffer, then yy_init_buffer was _probably_
2005
     * called from yyrestart() or through yy_get_next_buffer.
2006
     * In that case, we don't want to reset the lineno or column.
2007
     */
2008
    if (b != YY_CURRENT_BUFFER){
2009
        b->yy_bs_lineno = 1;
2010
        b->yy_bs_column = 0;
2011
    }
2012
2013
        b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
2014
2015
	errno = oerrno;
2016
}
2017
2018
/** Discard all buffered characters. On the next scan, YY_INPUT will be called.
2019
 * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
2020
 *
2021
 */
2022
    void yy_flush_buffer (YY_BUFFER_STATE  b )
2023
{
2024
    	if ( ! b )
2025
		return;
2026
2027
	b->yy_n_chars = 0;
2028
2029
	/* We always need two end-of-buffer characters.  The first causes
2030
	 * a transition to the end-of-buffer state.  The second causes
2031
	 * a jam in that state.
2032
	 */
2033
	b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
2034
	b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
2035
2036
	b->yy_buf_pos = &b->yy_ch_buf[0];
2037
2038
	b->yy_at_bol = 1;
2039
	b->yy_buffer_status = YY_BUFFER_NEW;
2040
2041
	if ( b == YY_CURRENT_BUFFER )
2042
		yy_load_buffer_state( );
2043
}
2044
2045
/** Pushes the new state onto the stack. The new state becomes
2046
 *  the current state. This function will allocate the stack
2047
 *  if necessary.
2048
 *  @param new_buffer The new state.
2049
 *
2050
 */
2051
void yypush_buffer_state (YY_BUFFER_STATE new_buffer )
2052
{
2053
    	if (new_buffer == NULL)
2054
		return;
2055
2056
	yyensure_buffer_stack();
2057
2058
	/* This block is copied from yy_switch_to_buffer. */
2059
	if ( YY_CURRENT_BUFFER )
2060
		{
2061
		/* Flush out information for old buffer. */
2062
		*(yy_c_buf_p) = (yy_hold_char);
2063
		YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
2064
		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
2065
		}
2066
2067
	/* Only push if top exists. Otherwise, replace top. */
2068
	if (YY_CURRENT_BUFFER)
2069
		(yy_buffer_stack_top)++;
2070
	YY_CURRENT_BUFFER_LVALUE = new_buffer;
2071
2072
	/* copied from yy_switch_to_buffer. */
2073
	yy_load_buffer_state( );
2074
	(yy_did_buffer_switch_on_eof) = 1;
2075
}
2076
2077
/** Removes and deletes the top of the stack, if present.
2078
 *  The next element becomes the new top.
2079
 *
2080
 */
2081
void yypop_buffer_state (void)
2082
{
2083
    	if (!YY_CURRENT_BUFFER)
2084
		return;
2085
2086
	yy_delete_buffer(YY_CURRENT_BUFFER );
2087
	YY_CURRENT_BUFFER_LVALUE = NULL;
2088
	if ((yy_buffer_stack_top) > 0)
2089
		--(yy_buffer_stack_top);
2090
2091
	if (YY_CURRENT_BUFFER) {
2092
		yy_load_buffer_state( );
2093
		(yy_did_buffer_switch_on_eof) = 1;
2094
	}
2095
}
2096
2097
/* Allocates the stack if it does not exist.
2098
 *  Guarantees space for at least one push.
2099
 */
2100
static void yyensure_buffer_stack (void)
2101
{
2102
	yy_size_t num_to_alloc;
2103
2104
	if (!(yy_buffer_stack)) {
2105
2106
		/* First allocation is just for 2 elements, since we don't know if this
2107
		 * scanner will even need a stack. We use 2 instead of 1 to avoid an
2108
		 * immediate realloc on the next call.
2109
         */
2110
		num_to_alloc = 1;
2111
		(yy_buffer_stack) = (struct yy_buffer_state**)yyalloc
2112
								(num_to_alloc * sizeof(struct yy_buffer_state*)
2113
								);
2114
		if ( ! (yy_buffer_stack) )
2115
			YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
2116
2117
		memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
2118
2119
		(yy_buffer_stack_max) = num_to_alloc;
2120
		(yy_buffer_stack_top) = 0;
2121
		return;
2122
	}
2123
2124
	if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
2125
2126
		/* Increase the buffer to prepare for a possible push. */
2127
		int grow_size = 8 /* arbitrary grow size */;
2128
2129
		num_to_alloc = (yy_buffer_stack_max) + grow_size;
2130
		(yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc
2131
								((yy_buffer_stack),
2132
								num_to_alloc * sizeof(struct yy_buffer_state*)
2133
								);
2134
		if ( ! (yy_buffer_stack) )
2135
			YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
2136
2137
		/* zero only the new slots.*/
2138
		memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
2139
		(yy_buffer_stack_max) = num_to_alloc;
2140
	}
2141
}
2142
2143
/** Setup the input buffer state to scan directly from a user-specified character buffer.
2144
 * @param base the character buffer
2145
 * @param size the size in bytes of the character buffer
2146
 *
2147
 * @return the newly allocated buffer state object.
2148
 */
2149
YY_BUFFER_STATE yy_scan_buffer  (char * base, yy_size_t  size )
2150
{
2151
	YY_BUFFER_STATE b;
2152
2153
	if ( size < 2 ||
2154
	     base[size-2] != YY_END_OF_BUFFER_CHAR ||
2155
	     base[size-1] != YY_END_OF_BUFFER_CHAR )
2156
		/* They forgot to leave room for the EOB's. */
2157
		return 0;
2158
2159
	b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state )  );
2160
	if ( ! b )
2161
		YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
2162
2163
	b->yy_buf_size = size - 2;	/* "- 2" to take care of EOB's */
2164
	b->yy_buf_pos = b->yy_ch_buf = base;
2165
	b->yy_is_our_buffer = 0;
2166
	b->yy_input_file = 0;
2167
	b->yy_n_chars = b->yy_buf_size;
2168
	b->yy_is_interactive = 0;
2169
	b->yy_at_bol = 1;
2170
	b->yy_fill_buffer = 0;
2171
	b->yy_buffer_status = YY_BUFFER_NEW;
2172
2173
	yy_switch_to_buffer(b  );
2174
2175
	return b;
2176
}
2177
2178
/** Setup the input buffer state to scan a string. The next call to yylex() will
2179
 * scan from a @e copy of @a str.
2180
 * @param yystr a NUL-terminated string to scan
2181
 *
2182
 * @return the newly allocated buffer state object.
2183
 * @note If you want to scan bytes that may contain NUL values, then use
2184
 *       yy_scan_bytes() instead.
2185
 */
2186
YY_BUFFER_STATE yy_scan_string (yyconst char * yystr )
2187
{
2188
2189
	return yy_scan_bytes(yystr,strlen(yystr) );
2190
}
2191
2192
/** Setup the input buffer state to scan the given bytes. The next call to yylex() will
2193
 * scan from a @e copy of @a bytes.
2194
 * @param yybytes the byte buffer to scan
2195
 * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
2196
 *
2197
 * @return the newly allocated buffer state object.
2198
 */
2199
YY_BUFFER_STATE yy_scan_bytes  (yyconst char * yybytes, yy_size_t  _yybytes_len )
2200
{
2201
	YY_BUFFER_STATE b;
2202
	char *buf;
2203
	yy_size_t n;
2204
	yy_size_t i;
2205
2206
	/* Get memory for full buffer, including space for trailing EOB's. */
2207
	n = _yybytes_len + 2;
2208
	buf = (char *) yyalloc(n  );
2209
	if ( ! buf )
2210
		YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
2211
2212
	for ( i = 0; i < _yybytes_len; ++i )
2213
		buf[i] = yybytes[i];
2214
2215
	buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
2216
2217
	b = yy_scan_buffer(buf,n );
2218
	if ( ! b )
2219
		YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
2220
2221
	/* It's okay to grow etc. this buffer, and we should throw it
2222
	 * away when we're done.
2223
	 */
2224
	b->yy_is_our_buffer = 1;
2225
2226
	return b;
2227
}
2228
2229
#ifndef YY_EXIT_FAILURE
2230
#define YY_EXIT_FAILURE 2
2231
#endif
2232
2233
static void yy_fatal_error (yyconst char* msg )
2234
{
2235
    	(void) fprintf( stderr, "%s\n", msg );
2236
	exit( YY_EXIT_FAILURE );
2237
}
2238
2239
/* Redefine yyless() so it works in section 3 code. */
2240
2241
#undef yyless
2242
#define yyless(n) \
2243
	do \
2244
		{ \
2245
		/* Undo effects of setting up yytext. */ \
2246
        int yyless_macro_arg = (n); \
2247
        YY_LESS_LINENO(yyless_macro_arg);\
2248
		yytext[yyleng] = (yy_hold_char); \
2249
		(yy_c_buf_p) = yytext + yyless_macro_arg; \
2250
		(yy_hold_char) = *(yy_c_buf_p); \
2251
		*(yy_c_buf_p) = '\0'; \
2252
		yyleng = yyless_macro_arg; \
2253
		} \
2254
	while ( 0 )
2255
2256
/* Accessor  methods (get/set functions) to struct members. */
2257
2258
/** Get the current line number.
2259
 *
2260
 */
2261
int yyget_lineno  (void)
2262
{
2263
2264
    return yylineno;
2265
}
2266
2267
/** Get the input stream.
2268
 *
2269
 */
2270
FILE *yyget_in  (void)
2271
{
2272
        return yyin;
2273
}
2274
2275
/** Get the output stream.
2276
 *
2277
 */
2278
FILE *yyget_out  (void)
2279
{
2280
        return yyout;
2281
}
2282
2283
/** Get the length of the current token.
2284
 *
2285
 */
2286
yy_size_t yyget_leng  (void)
2287
{
2288
        return yyleng;
2289
}
2290
2291
/** Get the current token.
2292
 *
2293
 */
2294
2295
char *yyget_text  (void)
2296
{
2297
        return yytext;
2298
}
2299
2300
/** Set the current line number.
2301
 * @param line_number
2302
 *
2303
 */
2304
void yyset_lineno (int  line_number )
2305
{
2306
2307
    yylineno = line_number;
2308
}
2309
2310
/** Set the input stream. This does not discard the current
2311
 * input buffer.
2312
 * @param in_str A readable stream.
2313
 *
2314
 * @see yy_switch_to_buffer
2315
 */
2316
void yyset_in (FILE *  in_str )
2317
{
2318
        yyin = in_str ;
2319
}
2320
2321
void yyset_out (FILE *  out_str )
2322
{
2323
        yyout = out_str ;
2324
}
2325
2326
int yyget_debug  (void)
2327
{
2328
        return yy_flex_debug;
2329
}
2330
2331
void yyset_debug (int  bdebug )
2332
{
2333
        yy_flex_debug = bdebug ;
2334
}
2335
2336
static int yy_init_globals (void)
2337
{
2338
        /* Initialization is the same as for the non-reentrant scanner.
2339
     * This function is called from yylex_destroy(), so don't allocate here.
2340
     */
2341
2342
    /* We do not touch yylineno unless the option is enabled. */
2343
    yylineno =  1;
2344
2345
    (yy_buffer_stack) = 0;
2346
    (yy_buffer_stack_top) = 0;
2347
    (yy_buffer_stack_max) = 0;
2348
    (yy_c_buf_p) = (char *) 0;
2349
    (yy_init) = 0;
2350
    (yy_start) = 0;
2351
2352
/* Defined in main.c */
2353
#ifdef YY_STDINIT
2354
    yyin = stdin;
2355
    yyout = stdout;
2356
#else
2357
    yyin = (FILE *) 0;
2358
    yyout = (FILE *) 0;
2359
#endif
2360
2361
    /* For future reference: Set errno on error, since we are called by
2362
     * yylex_init()
2363
     */
2364
    return 0;
2365
}
2366
2367
/* yylex_destroy is for both reentrant and non-reentrant scanners. */
2368
int yylex_destroy  (void)
2369
{
2370
2371
    /* Pop the buffer stack, destroying each element. */
2372
	while(YY_CURRENT_BUFFER){
2373
		yy_delete_buffer(YY_CURRENT_BUFFER  );
2374
		YY_CURRENT_BUFFER_LVALUE = NULL;
2375
		yypop_buffer_state();
2376
	}
2377
2378
	/* Destroy the stack itself. */
2379
	yyfree((yy_buffer_stack) );
2380
	(yy_buffer_stack) = NULL;
2381
2382
    /* Reset the globals. This is important in a non-reentrant scanner so the next time
2383
     * yylex() is called, initialization will occur. */
2384
    yy_init_globals( );
2385
2386
    return 0;
2387
}
2388
2389
/*
2390
 * Internal utility routines.
2391
 */
2392
2393
#ifndef yytext_ptr
2394
static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
2395
{
2396
	int i;
2397
	for ( i = 0; i < n; ++i )
2398
		s1[i] = s2[i];
2399
}
2400
#endif
2401
2402
#ifdef YY_NEED_STRLEN
2403
static int yy_flex_strlen (yyconst char * s )
2404
{
2405
	int n;
2406
	for ( n = 0; s[n]; ++n )
2407
		;
2408
2409
	return n;
2410
}
2411
#endif
2412
2413
void *yyalloc (yy_size_t  size )
2414
{
2415
	return (void *) malloc( size );
2416
}
2417
2418
void *yyrealloc  (void * ptr, yy_size_t  size )
2419
{
2420
	/* The cast to (char *) in the following accommodates both
2421
	 * implementations that use char* generic pointers, and those
2422
	 * that use void* generic pointers.  It works with the latter
2423
	 * because both ANSI C and C++ allow castless assignment from
2424
	 * any pointer type to void*, and deal with argument conversions
2425
	 * as though doing an assignment.
2426
	 */
2427
	return (void *) realloc( (char *) ptr, size );
2428
}
2429
2430
void yyfree (void * ptr )
2431
{
2432
	free( (char *) ptr );	/* see yyrealloc() for (char *) cast */
2433
}
2434
2435
#define YYTABLES_NAME "yytables"
2436
2437
#line 283 "fgen.l"
2438
2439
2440
2441
/* Function definitions */
2442
void push(Cell);
2443
Cell pop(void);
2444
int depth(void);
2445
int fadd(struct fcode *, struct fcode *);
2446
struct fcode *flookup(struct fcode *, char *);
2447
int aadd(struct macro *, struct macro *);
2448
struct macro *alookup(struct macro *, char *);
2449
void initdic(void);
2450
void usage(char *);
2451
void tokenize(YY_BUFFER_STATE);
2452
int emit(char *);
2453
int spit(long);
2454
void sspit(char *);
2455
int apply_macros(YY_BUFFER_STATE, char *);
2456
int main(int argc, char *argv[]);
2457
2458
/*
2459
 * Standard FCode names and numbers.  Includes standard
2460
 * tokenizer aliases.
2461
 */
2462
struct fcode fcodes[] = {
2463
		{ "end0",			0x0000 },
2464
		{ "b(lit)",			0x0010 },
2465
		{ "b(')",			0x0011 },
2466
		{ "b(\")",			0x0012 },
2467
		{ "bbranch",			0x0013 },
2468
		{ "b?branch",			0x0014 },
2469
		{ "b(loop)",			0x0015 },
2470
		{ "b(+loop)",			0x0016 },
2471
		{ "b(do)",			0x0017 },
2472
		{ "b(?do)",			0x0018 },
2473
		{ "i",				0x0019 },
2474
		{ "j",				0x001a },
2475
		{ "b(leave)",			0x001b },
2476
		{ "b(of)",			0x001c },
2477
		{ "execute",			0x001d },
2478
		{ "+",				0x001e },
2479
		{ "-",				0x001f },
2480
		{ "*",				0x0020 },
2481
		{ "/",				0x0021 },
2482
		{ "mod",			0x0022 },
2483
		{ "and",			0x0023 },
2484
		{ "or",				0x0024 },
2485
		{ "xor",			0x0025 },
2486
		{ "invert",			0x0026 },
2487
		{ "lshift",			0x0027 },
2488
		{ "rshift",			0x0028 },
2489
		{ ">>a",			0x0029 },
2490
		{ "/mod",			0x002a },
2491
		{ "u/mod",			0x002b },
2492
		{ "negate",			0x002c },
2493
		{ "abs",			0x002d },
2494
		{ "min",			0x002e },
2495
		{ "max",			0x002f },
2496
		{ ">r",				0x0030 },
2497
		{ "r>",				0x0031 },
2498
		{ "r@",				0x0032 },
2499
		{ "exit",			0x0033 },
2500
		{ "0=",				0x0034 },
2501
		{ "0<>",			0x0035 },
2502
		{ "0<",				0x0036 },
2503
		{ "0<=",			0x0037 },
2504
		{ "0>",				0x0038 },
2505
		{ "0>=",			0x0039 },
2506
		{ "<",				0x003a },
2507
		{ ">",				0x003b },
2508
		{ "=",				0x003c },
2509
		{ "<>",				0x003d },
2510
		{ "u>",				0x003e },
2511
		{ "u<=",			0x003f },
2512
		{ "u<",				0x0040 },
2513
		{ "u>=",			0x0041 },
2514
		{ ">=",				0x0042 },
2515
		{ "<=",				0x0043 },
2516
		{ "between",			0x0044 },
2517
		{ "within",			0x0045 },
2518
		{ "drop",			0x0046 },
2519
		{ "dup",			0x0047 },
2520
		{ "over",			0x0048 },
2521
		{ "swap",			0x0049 },
2522
		{ "rot",			0x004a },
2523
		{ "-rot",			0x004b },
2524
		{ "tuck",			0x004c },
2525
		{ "nip",			0x004d },
2526
		{ "pick",			0x004e },
2527
		{ "roll",			0x004f },
2528
		{ "?dup",			0x0050 },
2529
		{ "depth",			0x0051 },
2530
		{ "2drop",			0x0052 },
2531
		{ "2dup",			0x0053 },
2532
		{ "2over",			0x0054 },
2533
		{ "2swap",			0x0055 },
2534
		{ "2rot",			0x0056 },
2535
		{ "2/",				0x0057 },
2536
		{ "u2/",			0x0058 },
2537
		{ "2*",				0x0059 },
2538
		{ "/c",				0x005a },
2539
		{ "/w",				0x005b },
2540
		{ "/l",				0x005c },
2541
		{ "/n",				0x005d },
2542
		{ "ca+",			0x005e },
2543
		{ "wa+",			0x005f },
2544
		{ "la+",			0x0060 },
2545
		{ "na+",			0x0061 },
2546
		{ "char+",			0x0062 },
2547
		{ "wa1+",			0x0063 },
2548
		{ "la1+",			0x0064 },
2549
		{ "cell+",			0x0065 },
2550
		{ "chars",			0x0066 },
2551
		{ "/w*",			0x0067 },
2552
		{ "/l*",			0x0068 },
2553
		{ "cells",			0x0069 },
2554
		{ "on",				0x006a },
2555
		{ "off",			0x006b },
2556
		{ "+!",				0x006c },
2557
		{ "@",				0x006d },
2558
		{ "l@",				0x006e },
2559
		{ "w@",				0x006f },
2560
		{ "<w@",			0x0070 },
2561
		{ "c@",				0x0071 },
2562
		{ "!",				0x0072 },
2563
		{ "l!",				0x0073 },
2564
		{ "w!",				0x0074 },
2565
		{ "c!",				0x0075 },
2566
		{ "2@",				0x0076 },
2567
		{ "2!",				0x0077 },
2568
		{ "move",			0x0078 },
2569
		{ "fill",			0x0079 },
2570
		{ "comp",			0x007a },
2571
		{ "noop",			0x007b },
2572
		{ "lwsplit",			0x007c },
2573
		{ "wjoin",			0x007d },
2574
		{ "lbsplit",			0x007e },
2575
		{ "bljoin",			0x007f },
2576
		{ "wbflip",			0x0080 },
2577
		{ "upc",			0x0081 },
2578
		{ "lcc",			0x0082 },
2579
		{ "pack",			0x0083 },
2580
		{ "count",			0x0084 },
2581
		{ "body>",			0x0085 },
2582
		{ ">body",			0x0086 },
2583
		{ "fcode-revision",		0x0087 },
2584
		{ "span",			0x0088 },
2585
		{ "unloop",			0x0089 },
2586
		{ "expect",			0x008a },
2587
		{ "alloc-mem",			0x008b },
2588
		{ "free-mem",			0x008c },
2589
		{ "key?",			0x008d },
2590
		{ "key",			0x008e },
2591
		{ "emit",			0x008f },
2592
		{ "type",			0x0090 },
2593
		{ "(cr",			0x0091 },
2594
		{ "cr",				0x0092 },
2595
		{ "#out",			0x0093 },
2596
		{ "#line",			0x0094 },
2597
		{ "hold",			0x0095 },
2598
		{ "<#",				0x0096 },
2599
		{ "u#>",			0x0097 },
2600
		{ "sign",			0x0098 },
2601
		{ "u#",				0x0099 },
2602
		{ "u#s",			0x009a },
2603
		{ "u.",				0x009b },
2604
		{ "u.r",			0x009c },
2605
		{ ".",				0x009d },
2606
		{ ".r",				0x009e },
2607
		{ ".s",				0x009f },
2608
		{ "base",			0x00a0 },
2609
		{ "convert",			0x00a1 },
2610
		{ "$number",			0x00a2 },
2611
		{ "digit",			0x00a3 },
2612
		{ "-1",				0x00a4 },
2613
		{ "true",			0x00a4 },
2614
		{ "0",				0x00a5 },
2615
		{ "1",				0x00a6 },
2616
		{ "2",				0x00a7 },
2617
		{ "3",				0x00a8 },
2618
		{ "bl",				0x00a9 },
2619
		{ "bs",				0x00aa },
2620
		{ "bell",			0x00ab },
2621
		{ "bounds",			0x00ac },
2622
		{ "here",			0x00ad },
2623
		{ "aligned",			0x00ae },
2624
		{ "wbsplit",			0x00af },
2625
		{ "bwjoin",			0x00b0 },
2626
		{ "b(<mark)",			0x00b1 },
2627
		{ "b(>resolve)",		0x00b2 },
2628
		{ "set-token-table",		0x00b3 },
2629
		{ "set-table",			0x00b4 },
2630
		{ "new-token",			0x00b5 },
2631
		{ "named-token",		0x00b6 },
2632
		{ "b(:)",			0x00b7 },
2633
		{ "b(value)",			0x00b8 },
2634
		{ "b(variable)",		0x00b9 },
2635
		{ "b(constant)",		0x00ba },
2636
		{ "b(create)",			0x00bb },
2637
		{ "b(defer)",			0x00bc },
2638
		{ "b(buffer:)",			0x00bd },
2639
		{ "b(field)",			0x00be },
2640
		{ "b(code)",			0x00bf },
2641
		{ "instance",			0x00c0 },
2642
		{ "b(;)",			0x00c2 },
2643
		{ "b(to)",			0x00c3 },
2644
		{ "b(case)",			0x00c4 },
2645
		{ "b(endcase)",			0x00c5 },
2646
		{ "b(endof)",			0x00c6 },
2647
		{ "#",				0x00c7 },
2648
		{ "#s",				0x00c8 },
2649
		{ "#>",				0x00c9 },
2650
		{ "external-token",		0x00ca },
2651
		{ "$find",			0x00cb },
2652
		{ "offset16",			0x00cc },
2653
		{ "evaluate",			0x00cd },
2654
		{ "c,",				0x00d0 },
2655
		{ "w,",				0x00d1 },
2656
		{ "l,",				0x00d2 },
2657
		{ "'",				0x00d3 },
2658
		{ "um*",			0x00d4 },
2659
		{ "um/mod",			0x00d5 },
2660
		{ "d+",				0x00d8 },
2661
		{ "d-",				0x00d9 },
2662
		{ "get-token",			0x00da },
2663
		{ "set-token",			0x00db },
2664
		{ "state",			0x00dc },
2665
		{ "compile,",			0x00dd },
2666
		{ "behavior",			0x00de },
2667
		{ "start0",			0x00f0 },
2668
		{ "start1",			0x00f1 },
2669
		{ "start2",			0x00f2 },
2670
		{ "start4",			0x00f3 },
2671
		{ "ferror",			0x00fc },
2672
		{ "version1",			0x00fd },
2673
		{ "4-byte-id",			0x00fe },
2674
		{ "end1",			0x00ff },
2675
		{ "dma-alloc",			0x0101 },
2676
		{ "my-address",			0x0102 },
2677
		{ "my-space",			0x0103 },
2678
		{ "memmap",			0x0104 },
2679
		{ "free-virtual",		0x0105 },
2680
		{ ">physical",			0x0106 },
2681
		{ "my-params",			0x010f },
2682
		{ "property",			0x0110 },
2683
		{ "encode-int",			0x0111 },
2684
		{ "encode+",			0x0112 },
2685
		{ "encode-phys",		0x0113 },
2686
		{ "encode-string",		0x0114 },
2687
		{ "encode-bytes",		0x0115 },
2688
		{ "reg",			0x0116 },
2689
		{ "intr",			0x0117 },
2690
		{ "driver",			0x0118 },
2691
		{ "model",			0x0119 },
2692
		{ "device-type",		0x011a },
2693
		{ "parse-2int",			0x011b },
2694
		{ "is-install",			0x011c },
2695
		{ "is-remove",			0x011d },
2696
		{ "is-selftest",		0x011e },
2697
		{ "new-device",			0x011f },
2698
		{ "diagnostic-mode?",		0x0120 },
2699
		{ "display-status",		0x0121 },
2700
		{ "memory-test-suite",		0x0122 },
2701
		{ "group-code",			0x0123 },
2702
		{ "mask",			0x0124 },
2703
		{ "get-msecs",			0x0125 },
2704
		{ "ms",				0x0126 },
2705
		{ "find-device",		0x0127 },
2706
		{ "decode-phys",		0x0128 },
2707
		{ "map-low",			0x0130 },
2708
		{ "sbus-intr>cpu",		0x0131 },
2709
		{ "#lines",			0x0150 },
2710
		{ "#columns",			0x0151 },
2711
		{ "line#",			0x0152 },
2712
		{ "column#",			0x0153 },
2713
		{ "inverse?",			0x0154 },
2714
		{ "inverse-screen?",		0x0155 },
2715
		{ "frame-buffer-busy?",		0x0156 },
2716
		{ "draw-character",		0x0157 },
2717
		{ "reset-screen",		0x0158 },
2718
		{ "toggle-cursor",		0x0159 },
2719
		{ "erase-screen",		0x015a },
2720
		{ "blink-screen",		0x015b },
2721
		{ "invert-screen",		0x015c },
2722
		{ "insert-characters",		0x015d },
2723
		{ "delete-characters",		0x015e },
2724
		{ "insert-lines",		0x015f },
2725
		{ "delete-lines",		0x0160 },
2726
		{ "draw-logo",			0x0161 },
2727
		{ "frame-buffer-addr",		0x0162 },
2728
		{ "screen-height",		0x0163 },
2729
		{ "screen-width",		0x0164 },
2730
		{ "window-top",			0x0165 },
2731
		{ "window-left",		0x0166 },
2732
		{ "default-font",		0x016a },
2733
		{ "set-font",			0x016b },
2734
		{ "char-height",		0x016c },
2735
		{ "char-width",			0x016d },
2736
		{ ">font",			0x016e },
2737
		{ "fontbytes",			0x016f },
2738
		{ "fb8-draw-character",		0x0180 },
2739
		{ "fb8-reset-screen",		0x0181 },
2740
		{ "fb8-toggle-cursor",		0x0182 },
2741
		{ "fb8-erase-screen",		0x0183 },
2742
		{ "fb8-blink-screen",		0x0184 },
2743
		{ "fb8-invert-screen",		0x0185 },
2744
		{ "fb8-insert-characters",	0x0186 },
2745
		{ "fb8-delete-characters",	0x0187 },
2746
		{ "fb8-inisert-lines",		0x0188 },
2747
		{ "fb8-delete-lines",		0x0189 },
2748
		{ "fb8-draw-logo",		0x018a },
2749
		{ "fb8-install",		0x018b },
2750
		{ "return-buffer",		0x01a0 },
2751
		{ "xmit-packet",		0x01a1 },
2752
		{ "poll-packet",		0x01a2 },
2753
		{ "mac-address",		0x01a4 },
2754
		{ "device-name",		0x0201 },
2755
		{ "my-args",			0x0202 },
2756
		{ "my-self",			0x0203 },
2757
		{ "find-package",		0x0204 },
2758
		{ "open-package",		0x0205 },
2759
		{ "close-package",		0x0206 },
2760
		{ "find-method",		0x0207 },
2761
		{ "call-package",		0x0208 },
2762
		{ "$call-parent",		0x0209 },
2763
		{ "my-parent",			0x020a },
2764
		{ "ihandle>phandle",		0x020b },
2765
		{ "my-unit",			0x020d },
2766
		{ "$call-method",		0x020e },
2767
		{ "$open-package",		0x020f },
2768
		{ "processor-type",		0x0210 },
2769
		{ "firmware-version",		0x0211 },
2770
		{ "fcode-version",		0x0212 },
2771
		{ "alarm",			0x0213 },
2772
		{ "(is-user-word)",		0x0214 },
2773
		{ "suspend-fcode",		0x0215 },
2774
		{ "abort",			0x0216 },
2775
		{ "catch",			0x0217 },
2776
		{ "throw",			0x0218 },
2777
		{ "user-abort",			0x0219 },
2778
		{ "get-my-property",		0x021a },
2779
		{ "decode-int",			0x021b },
2780
		{ "decode-string",		0x021c },
2781
		{ "get-inherited-property",	0x021d },
2782
		{ "delete-property",		0x021e },
2783
		{ "get-package-property",	0x021f },
2784
		{ "cpeek",			0x0220 },
2785
		{ "wpeek",			0x0221 },
2786
		{ "lpeek",			0x0222 },
2787
		{ "cpoke",			0x0223 },
2788
		{ "wpoke",			0x0224 },
2789
		{ "lpoke",			0x0225 },
2790
		{ "lwflip",			0x0226 },
2791
		{ "lbflip",			0x0227 },
2792
		{ "lbflips",			0x0228 },
2793
		{ "adr-mask",			0x0229 },
2794
		{ "rb@",			0x0230 },
2795
		{ "rb!",			0x0231 },
2796
		{ "rw@",			0x0232 },
2797
		{ "rw!",			0x0233 },
2798
		{ "rl@",			0x0234 },
2799
		{ "rl!",			0x0235 },
2800
		{ "wbflips",			0x0236 },
2801
		{ "lwflips",			0x0237 },
2802
		{ "probe",			0x0238 },
2803
		{ "probe-virtual",		0x0239 },
2804
		{ "child",			0x023b },
2805
		{ "peer",			0x023c },
2806
		{ "next-property",		0x023d },
2807
		{ "byte-load",			0x023e },
2808
		{ "set-args",			0x023f },
2809
		{ "left-parse-string",		0x0240 },
2810
			/* 64-bit FCode extensions */
2811
		{ "bxjoin",			0x0241 },
2812
		{ "<l@",			0x0242 },
2813
		{ "lxjoin",			0x0243 },
2814
		{ "rx@",			0x022e },
2815
		{ "rx!",			0x022f },
2816
		{ "wxjoin",			0x0244 },
2817
		{ "x,",				0x0245 },
2818
		{ "x@",				0x0246 },
2819
		{ "x!",				0x0247 },
2820
		{ "/x",				0x0248 },
2821
		{ "/x*",			0x0249 },
2822
		{ "xa+",			0x024a },
2823
		{ "xa1+",			0x024b },
2824
		{ "xbflip",			0x024c },
2825
		{ "xbflips",			0x024d },
2826
		{ "xbsplit",			0x024e },
2827
		{ "xlflip",			0x024f },
2828
		{ "xlflips",			0x0250 },
2829
		{ "xlsplit",			0x0251 },
2830
		{ "xwflip",			0x0252 },
2831
		{ "xwflips",			0x0253 },
2832
		{ "xwsplit",			0x0254 },
2833
		{ NULL, 0 }
2834
};
2835
2836
/*
2837
 * Default macros -- can be overridden by colon definitions.
2838
 */
2839
struct macro macros[] = {
2840
	{ "eval",	"evaluate" }, /* Build a more balanced tree */
2841
	{ "(.)",	"dup abs <# u#s swap sign u#>" },
2842
	{ "<<",		"lshift" },
2843
	{ ">>",		"rshift" },
2844
	{ "?",		"@ ." },
2845
	{ "1+",		"1 +" },
2846
	{ "1-",		"1 -" },
2847
	{ "2+",		"2 +" },
2848
	{ "2-",		"2 -" },
2849
	{ "abort\"",	"-2 throw" },
2850
	{ "accept",	"span @ -rot expect span @ swap span !" },
2851
	{ "allot",	"0 max 0 ?do 0 c, loop" },
2852
	{ "blank",	"bl fill" },
2853
	{ "/c*",	"chars" },
2854
	{ "ca1+",	"char+" },
2855
	{ "carret",	"b(lit) 00 00 00 0x0d" },
2856
	{ ".d"		"base @ swap 0x0a base ! . base !" },
2857
	{ "decode-bytes", ">r over r@ + swap r@ - rot r>" },
2858
	{ "3drop",	"drop 2drop" },
2859
	{ "3dup",	"2 pick 2 pick 2 pick" },
2860
	{ "erase",	"0 fill" },
2861
	{ "false",	"0" },
2862
	{ ".h"		"base @ swap 0x10 base ! . base !" },
2863
	{ "linefeed",	"b(lit) 00 00 00 0x0a" },
2864
	{ "/n*",	"cells" },
2865
	{ "na1+",	"cell+", },
2866
	{ "not",	"invert", },
2867
	{ "s.",		"(.) type space" },
2868
	{ "space",	"bl emit" },
2869
	{ "spaces",	"0 max 0 ?do space loop" },
2870
	{ "struct",	"0" },
2871
	{ "true",	"-1" },
2872
	{ "(u,)",	"<# u#s u#>" },
2873
	{ NULL, NULL }
2874
};
2875
2876
/*
2877
 * Parser stack control functions.
2878
 */
2879
2880
void
2881
push(val)
2882
Cell val;
2883
{
2884
	parse_stack[parse_stack_ptr++] = val;
2885
	if (parse_stack_ptr >= PSTKSIZ) {
2886
		(void)printf( "Parse stack overflow\n");
2887
		exit(1);
2888
	}
2889
}
2890
2891
Cell
2892
pop()
2893
{
2894
	ASSERT(parse_stack_ptr);
2895
	return parse_stack[--parse_stack_ptr];
2896
}
2897
2898
int
2899
depth()
2900
{
2901
	return (parse_stack_ptr);
2902
}
2903
2904
/*
2905
 * Insert fcode into dictionary.
2906
 */
2907
int
2908
fadd(dict, new)
2909
struct fcode *dict, *new;
2910
{
2911
	int res = strcmp(dict->name, new->name);
2912
2913
#ifdef DEBUG
2914
	new->type = FCODE;
2915
	ASSERT(dict->type == FCODE);
2916
#endif
2917
	/* Don't allow duplicate entries. */
2918
	if (!res) return (0);
2919
	if (res < 0) {
2920
		if (dict->l)
2921
			return fadd(dict->l, new);
2922
		else {
2923
#ifdef DEBUG
2924
			if (debug > 1)
2925
				(void)printf( "fadd: new FCode `%s' is %lx\n",
2926
					      new->name, new->num);
2927
#endif
2928
			new->l = new->r = NULL;
2929
			dict->l = new;
2930
		}
2931
	} else {
2932
		if (dict->r)
2933
			return fadd(dict->r, new);
2934
		else {
2935
#ifdef DEBUG
2936
			if (debug > 1)
2937
				(void)printf( "fadd: new FCode `%s' is %lx\n",
2938
					      new->name, new->num);
2939
#endif
2940
			new->l = new->r = NULL;
2941
			dict->r = new;
2942
		}
2943
	}
2944
	return (1);
2945
}
2946
2947
/*
2948
 * Look for a code in the dictionary.
2949
 */
2950
struct fcode *
2951
flookup(dict, str)
2952
struct fcode *dict;
2953
char *str;
2954
{
2955
	int res;
2956
	if (!dict) return (dict);
2957
2958
	res = strcmp(dict->name, str);
2959
#ifdef DEBUG
2960
	ASSERT(dict->type == FCODE);
2961
	if (debug > 2)
2962
		(void)printf( "flookup: `%s' and `%s' %s match\n",
2963
			      str, dict->name, res?"don't":"do");
2964
#endif
2965
	if (!res) return (dict);
2966
	if (res < 0)
2967
		return (flookup(dict->l, str));
2968
	else
2969
		return (flookup(dict->r, str));
2970
2971
}
2972
2973
/*
2974
 * Insert alias into macros.
2975
 */
2976
int
2977
aadd(dict, new)
2978
	struct macro *dict, *new;
2979
{
2980
	int res = strcmp(dict->name, new->name);
2981
2982
#ifdef DEBUG
2983
	new->type = MACRO;
2984
	ASSERT(dict->type == MACRO);
2985
#endif
2986
	/* Don't allow duplicate entries. */
2987
	if (!res) return (0);
2988
	if (res < 0) {
2989
		if (dict->l)
2990
			return aadd(dict->l, new);
2991
		else {
2992
			new->l = new->r = NULL;
2993
			dict->l = new;
2994
#ifdef DEBUG
2995
			if (debug > 1)
2996
				(void)printf( "aadd: new alias `%s' to `%s'\n",
2997
					      new->name, new->equiv);
2998
#endif
2999
		}
3000
	} else {
3001
		if (dict->r)
3002
			return aadd(dict->r, new);
3003
		else {
3004
			new->l = new->r = NULL;
3005
			dict->r = new;
3006
#ifdef DEBUG
3007
			if (debug > 1)
3008
				(void)printf( "aadd: new alias `%s' to `%s'\n",
3009
					      new->name, new->equiv);
3010
#endif
3011
		}
3012
	}
3013
	return (1);
3014
}
3015
3016
/*
3017
 * Look for a macro in the aliases.
3018
 */
3019
struct macro *
3020
alookup(dict, str)
3021
struct macro *dict;
3022
char *str;
3023
{
3024
	int res;
3025
	if (!dict) return (dict);
3026
3027
#ifdef DEBUG
3028
	ASSERT(dict->type == MACRO);
3029
#endif
3030
	res = strcmp(dict->name, str);
3031
	if (!res) return (dict);
3032
	if (res < 0)
3033
		return (alookup(dict->l, str));
3034
	else
3035
		return (alookup(dict->r, str));
3036
3037
}
3038
3039
/*
3040
 * Bootstrap the dictionary and then install
3041
 * all the standard FCodes.
3042
 */
3043
void
3044
initdic()
3045
{
3046
	struct fcode *code = fcodes;
3047
	struct macro *alias = macros;
3048
3049
	ASSERT(dictionary == NULL);
3050
	code->l = code->r = NULL;
3051
	dictionary = code;
3052
#ifdef DEBUG
3053
	code->type = FCODE;
3054
#endif
3055
3056
	while ((++code)->name) {
3057
		if(!fadd(dictionary, code)) {
3058
			printf("init: duplicate dictionary entry %s\n",
3059
			       code->name);
3060
			abort();
3061
		}
3062
	}
3063
3064
	ASSERT(aliases == NULL);
3065
	aliases = alias;
3066
	alias->l = alias->r = NULL;
3067
#ifdef DEBUG
3068
	alias->type = MACRO;
3069
#endif
3070
	while ((++alias)->name) {
3071
		if(!aadd(aliases, alias)) {
3072
			printf("init: duplicate macro entry %s\n",
3073
			       alias->name);
3074
			abort();
3075
		}
3076
	}
3077
3078
}
3079
3080
int
3081
apply_macros(input, str)
3082
	YY_BUFFER_STATE input;
3083
	char *str;
3084
{
3085
	struct macro *xform = alookup(aliases, str);
3086
3087
	if (xform) {
3088
		YY_BUFFER_STATE newbuf;
3089
3090
		newbuf = yy_scan_string(xform->equiv);
3091
		yy_switch_to_buffer(newbuf);
3092
		tokenize(newbuf);
3093
		yy_switch_to_buffer(input);
3094
		yy_delete_buffer(newbuf);
3095
	}
3096
	return (xform != NULL);
3097
}
3098
3099
void
3100
usage(me)
3101
	char *me;
3102
{
3103
	(void)fprintf(stderr, "usage: %s [-d level] [-o outfile] infile\n", me);
3104
	exit(1);
3105
}
3106
3107
int
3108
main(argc, argv)
3109
	int argc;
3110
	char *argv[];
3111
{
3112
	int bflag, ch;
3113
	FILE *inf;
3114
	struct fcode_header *fheader;
3115
	YY_BUFFER_STATE inbuf;
3116
	char *hdrtype = "version1";
3117
	int i;
3118
3119
	if (pledge("stdio rpath wpath cpath", NULL) == -1)
3120
		err(1, "pledge");
3121
3122
	outf = 1; /* stdout */
3123
	myname = argv[0];
3124
3125
	bflag = 0;
3126
	while ((ch = getopt(argc, argv, "d:o:")) != -1)
3127
		switch(ch) {
3128
		case 'd':
3129
			debug = atol(optarg);
3130
			break;
3131
		case 'o':
3132
			outfile = optarg;
3133
			break;
3134
		case '?':
3135
		default:
3136
			warnx("Illegal argument: %c", ch);
3137
			usage(myname);
3138
		}
3139
	argc -= optind;
3140
	argv += optind;
3141
3142
	if (argc != 1)
3143
		usage(myname);
3144
3145
	infile = argv[0];
3146
3147
	/*
3148
	 * Initialization stuff.
3149
	 */
3150
	initdic();
3151
	outbufsiz = BUFCLICK;
3152
	outbuf = malloc(outbufsiz);
3153
	if (outbuf == NULL)
3154
		(void)err(1, "out of memory");
3155
3156
	fheader = (struct fcode_header *)outbuf;
3157
	outpos = 0;
3158
	emit(hdrtype);
3159
	outpos = sizeof(*fheader);
3160
3161
	/*
3162
	 * Do it.
3163
	 */
3164
	if ((inf = fopen(infile, "r")) == NULL)
3165
		(void)err(1, "can not open %s for reading", infile);
3166
3167
	inbuf = yy_create_buffer(inf,YY_BUF_SIZE );
3168
	yy_switch_to_buffer(inbuf);
3169
	tokenize(inbuf);
3170
	yy_delete_buffer(inbuf);
3171
	fclose(inf);
3172
	emit("end0");
3173
3174
	/* Now calculate length and checksum and stick them in the header */
3175
	fheader->format = 0x08;
3176
	fheader->length = htonl(outpos);
3177
	fheader->checksum = 0;
3178
	for (i = sizeof(*fheader); i<outpos; i++)
3179
		fheader->checksum += outbuf[i];
3180
	fheader->checksum = htons(fheader->checksum);
3181
3182
	if ((outf = open(outfile, O_WRONLY|O_CREAT|O_TRUNC, 0666)) == -1)
3183
		err(1, "can out open %s for writing", outfile);
3184
3185
	if (write(outf, outbuf, outpos) != outpos) {
3186
		close(outf);
3187
		unlink(outfile);
3188
		err(1, "write error");
3189
	}
3190
	close(outf);
3191
	return (0);
3192
};
3193
3194
/*
3195
 * Tokenize one file.  This is a separate function so it can
3196
 * be called recursively to parse multiple levels of include files.
3197
 */
3198
3199
void
3200
tokenize(input)
3201
	YY_BUFFER_STATE input;
3202
{
3203
	FILE *inf;
3204
	YY_BUFFER_STATE inbuf;
3205
	TOKEN *token;
3206
	char *last_token = "";
3207
	struct fcode *fcode;
3208
	int pos, off;
3209
3210
	while ((token = yylex()) != NULL) {
3211
		switch (token->type) {
3212
		case TOK_NUMBER:
3213
			STATE(token->text, "TOK_NUMBER");
3214
		{
3215
			char *end;
3216
			Cell value;
3217
3218
			if (tokenizer) {
3219
				push(strtol(token->text, &end, 16));
3220
				break;
3221
			}
3222
			value = strtol(token->text, &end, base);
3223
			if (*end != 0)
3224
				token_err(yylineno, infile, yytext,
3225
				    "illegal number conversion");
3226
3227
			/*
3228
			 * If this is a 64-bit value we need to store two literals
3229
			 * and issue a `lxjoin' to combine them.  But that's a future
3230
			 * project.
3231
			 */
3232
			emit("b(lit)");
3233
			spit(value>>24);
3234
			spit((value>>16)&0x0ff);
3235
			spit((value>>8)&0x0ff);
3236
			spit(value&0x0ff);
3237
		}
3238
		break;
3239
		case TOK_C_LIT:
3240
			STATE(token->text, "TOK_C_LIT");
3241
			emit("b(lit)");
3242
			spit(0);
3243
			spit(0);
3244
			spit(0);
3245
			spit(token->text[1]);
3246
		break;
3247
		case TOK_STRING_LIT:
3248
			STATE(token->text, "TOK_STRING_LIT:");
3249
		{
3250
			int len;
3251
			char *p = token->text;
3252
3253
			++p;			/* Skip the quote */
3254
			len = strlen(++p);	/* Skip the 1st space */
3255
3256
#define ERR_TOOLONG	\
3257
	token_err(yylineno, infile, yytext, "string length %d too long", len)
3258
3259
			if (len > 255)
3260
				ERR_TOOLONG;
3261
3262
			if (p[len-1] == ')' ||
3263
			    p[len-1] == '"') {
3264
				p[len-1] = 0;
3265
			}
3266
			emit("b(\")");
3267
			sspit(p);
3268
		}
3269
		break;
3270
		case TOK_PSTRING:
3271
			STATE(token->text, "TOK_PSTRING:");
3272
		{
3273
			int len;
3274
			char *p = token->text;
3275
3276
			if (*p++ == '.') p++; /* Skip over delimiter */
3277
			p++; /* Skip over space/tab */
3278
3279
			len = strlen(p);
3280
			if (len > 255)
3281
				ERR_TOOLONG;
3282
3283
			if (p[len-1] == ')' ||
3284
			    p[len-1] == '"') {
3285
				p[len-1] = 0;
3286
			}
3287
			emit("b(\")");
3288
			sspit(p);
3289
			emit("type");
3290
		}
3291
		break;
3292
		case TOK_TOKENIZE:
3293
			STATE(token->text, "TOK_TOKENIZE");
3294
			/* The next pass should tokenize the FCODE number */
3295
			emit("b(')");
3296
			break;
3297
		case TOK_COMMENT:
3298
			STATE(token->text, "TOK_COMMENT:");
3299
			while (((token = yylex()) != NULL) && token->type != TOK_ENDCOMMENT)
3300
				;
3301
			break;
3302
		case TOK_ENDCOMMENT:
3303
			STATE(token->text, "TOK_ENDCOMMENT");
3304
			token_err(yylineno, infile, NULL,
3305
			    "ENDCOMMENT encountered outside comment");
3306
			break;
3307
		case TOK_COLON:
3308
			STATE(token->text, "TOK_COLON:");
3309
3310
			token = yylex();
3311
			if (token == NULL)
3312
				token_err(yylineno, infile, yytext,
3313
				    "EOF in colon definition");
3314
3315
			/* Add new code to dictionary */
3316
			fcode = malloc(sizeof(*fcode));
3317
			if (fcode == NULL)
3318
				(void)err(1, "out of memory");
3319
3320
			fcode->num = nextfcode++;
3321
			fcode->name = strdup(token->text);
3322
			if (fcode->name == NULL)
3323
				(void)err(1, "out of memory");
3324
3325
			if (!fadd(dictionary, fcode))
3326
				token_err(yylineno, infile, NULL,
3327
				    "Duplicate definition: `%s'\n", fcode->name);
3328
#ifdef DEBUG
3329
			if (debug)
3330
				(void)printf("Adding %s to dictionary\n", token->text);
3331
#endif
3332
			if (state == 0)
3333
				emit("new-token");
3334
			else {
3335
				if (state == TOK_EXTERNAL)
3336
					emit("external-token");
3337
				else
3338
				/* Here we have a choice of new-token or named-token */
3339
					emit("named-token");
3340
				sspit(token->text);
3341
			}
3342
			spit(fcode->num);
3343
			emit("b(:)");
3344
			last_token = fcode->name;
3345
			defining = 1;
3346
 			break;
3347
		case TOK_SEMICOLON:
3348
			STATE(token->text, "TOK_SEMICOLON:");
3349
			emit("b(;)");
3350
			defining = 0;
3351
			if (depth()) {
3352
				token_err(yylineno, infile, NULL,
3353
				    "Warning: stack depth %d at end of %s\n",
3354
				    depth(), last_token);
3355
			}
3356
			last_token = "";
3357
			break;
3358
3359
			/* These are special */
3360
		case TOK_AGAIN:
3361
			STATE(token->text, "TOK_AGAIN");
3362
			emit("bbranch");
3363
			pos = pop();
3364
			pos -= outpos;
3365
			if (offsetsize == 16) {
3366
				spit((pos>>8)&0xff);
3367
			}
3368
			spit(pos&0xff);
3369
			break;
3370
		case TOK_ALIAS:
3371
			STATE(token->text, "TOK_ALIAS");
3372
		{
3373
			struct macro *alias;
3374
3375
			token = yylex();
3376
			if (token == NULL) {
3377
				(void)printf( "EOF in alias definition\n");
3378
				return;
3379
			}
3380
			if (token->type != TOK_OTHER) {
3381
				(void)printf( "ENDCOMMENT aliasing weird token type %d\n",
3382
					      token->type);
3383
			}
3384
			alias = malloc(sizeof(*alias));
3385
			if (alias == NULL)
3386
				(void)err(1, "out of memory");
3387
3388
			alias->name = strdup(token->text);
3389
			if (alias->name == NULL)
3390
				(void)err(1, "out of memory");
3391
3392
			token = yylex();
3393
			if (token == NULL) {
3394
				free(alias->name);
3395
				free(alias);
3396
				(void)printf( "EOF in alias definition\n");
3397
				return;
3398
			}
3399
			alias->equiv = strdup(token->text);
3400
			if (alias->equiv == NULL)
3401
				(void)err(1, "out of memory");
3402
3403
			if (!aadd(aliases, alias)) {
3404
				(void)printf( "ERROR: Duplicate alias %s\n",
3405
					      alias->name);
3406
				exit(1);
3407
			}
3408
		}
3409
		break;
3410
		case TOK_GETTOKEN:
3411
			STATE(token->text, "TOK_GETTOKEN");
3412
			/* This is caused by ['] */
3413
			emit("b(')");
3414
			token = yylex();
3415
			if (token == NULL) {
3416
				(void)printf( "EOF in [']\n");
3417
				return;
3418
			}
3419
			if ((fcode = flookup(dictionary, token->text)) == NULL) {
3420
				(void)printf( "[']: %s not found\n", token->text);
3421
				exit(1);
3422
			}
3423
			spit(fcode->num);
3424
			break;
3425
		case TOK_ASCII:
3426
			STATE(token->text, "TOK_ASCII");
3427
			token = yylex();
3428
			if (token == NULL) {
3429
				(void)printf( "EOF after \"ascii\"\n");
3430
				exit(1);
3431
			}
3432
			emit("b(lit)");
3433
			spit(0);
3434
			spit(0);
3435
			spit(0);
3436
			spit(token->text[0]);
3437
			break;
3438
		case TOK_BEGIN:
3439
			STATE(token->text, "TOK_BEGIN");
3440
			emit("b(<mark)");
3441
			push(outpos);
3442
			break;
3443
		case TOK_BUFFER:
3444
			STATE(token->text, "TOK_BUFFER");
3445
3446
			token = yylex();
3447
			if (token == NULL) {
3448
				(void)printf( "EOF in colon definition\n");
3449
				return;
3450
			}
3451
3452
			/* Add new code to dictionary */
3453
			fcode = malloc(sizeof(*fcode));
3454
			if (fcode == NULL)
3455
				(void)err(1, "out of memory");
3456
3457
			fcode->num = nextfcode++;
3458
			fcode->name = strdup(token->text);
3459
			if (fcode->name == NULL)
3460
				(void)err(1, "out of memory");
3461
3462
			fadd(dictionary, fcode);
3463
3464
			if (state == 0)
3465
				emit("new-token");
3466
			else {
3467
				if (state == TOK_EXTERNAL)
3468
					emit("external-token");
3469
				else
3470
				/* Here we have a choice of new-token or named-token */
3471
					emit("named-token");
3472
				sspit(token->text);
3473
			}
3474
			spit(fcode->num);
3475
			emit("b(buffer:)");
3476
			break;
3477
		case TOK_CASE:
3478
			STATE(token->text, "TOK_CASE");
3479
			emit("b(case)");
3480
			push(0);
3481
			break;
3482
		case TOK_CONSTANT:
3483
			STATE(token->text, "TOK_CONSTANT");
3484
3485
			token = yylex();
3486
			if (token == NULL) {
3487
				(void)printf( "EOF in constant definition\n");
3488
				return;
3489
			}
3490
3491
			/* Add new code to dictionary */
3492
			fcode = malloc(sizeof(*fcode));
3493
			if (fcode == NULL)
3494
				(void)err(1, "out of memory");
3495
			fcode->num = nextfcode++;
3496
			fcode->name = strdup(token->text);
3497
			if (fcode->name == NULL)
3498
				(void)err(1, "out of memory");
3499
3500
			fadd(dictionary, fcode);
3501
3502
			if (state == 0)
3503
				emit("new-token");
3504
			else {
3505
				if (state == TOK_EXTERNAL)
3506
					emit("external-token");
3507
				else
3508
				/* Here we have a choice of new-token or named-token */
3509
					emit("named-token");
3510
				sspit(token->text);
3511
			}
3512
			spit(fcode->num);
3513
			emit("b(constant)");
3514
			break;
3515
		case TOK_CONTROL:
3516
			STATE(token->text, "TOK_CONTROL");
3517
			token = yylex();
3518
			if (token == NULL) {
3519
				(void)printf( "EOF after \"ascii\"\n");
3520
				exit(1);
3521
			}
3522
			emit("b(lit)");
3523
			spit(0);
3524
			spit(0);
3525
			spit(0);
3526
			spit(token->text[0]&0x1f);
3527
			break;
3528
		case TOK_CREATE:
3529
			STATE(token->text, "TOK_CREATE");
3530
			/* Don't know what this does or if it's right */
3531
			token = yylex();
3532
			if (token == NULL) {
3533
				(void)printf( "EOF in create definition\n");
3534
				return;
3535
			}
3536
3537
			/* Add new code to dictionary */
3538
			fcode = malloc(sizeof(*fcode));
3539
			if (fcode == NULL)
3540
				err(1, "out of memory");
3541
3542
			fcode->num = nextfcode++;
3543
			fcode->name = strdup(token->text);
3544
			if (fcode->name == NULL)
3545
				(void)err(1, "out of memory");
3546
3547
			fadd(dictionary, fcode);
3548
3549
			if (state == 0)
3550
				emit("new-token");
3551
			else {
3552
				if (state == TOK_EXTERNAL)
3553
					emit("external-token");
3554
				else
3555
				/* Here we have a choice of new-token or named-token */
3556
					emit("named-token");
3557
				sspit(token->text);
3558
			}
3559
			spit(fcode->num);
3560
			emit("b(create)");
3561
			break;
3562
		case TOK_DECIMAL:
3563
			STATE(token->text, "TOK_DECIMAL");
3564
			if (token->text[1] != '#') {
3565
				if (defining) {
3566
					spit(10);
3567
					emit("base");
3568
					emit("!");
3569
				} else
3570
					base = TOK_DECIMAL;
3571
			} else {
3572
				char *end;
3573
				Cell value;
3574
3575
				token = yylex();
3576
				if (token == NULL) {
3577
					(void)printf( "EOF after d#\n");
3578
					return;
3579
				}
3580
				if (token->type == TOK_OTHER) {
3581
					if (strcmp("-1", token->text) == 0) {
3582
						emit(token->text);
3583
						break;
3584
					}
3585
				}
3586
				value = strtol(token->text, &end, 10);
3587
				if (*end != 0)
3588
					token_err(yylineno, infile, NULL,
3589
					    "Illegal number conversion: %s", token->text);
3590
3591
				/*
3592
				 * If this is a 64-bit value we need to store two literals
3593
				 * and issue a `lxjoin' to combine them.  But that's a future
3594
				 * project.
3595
				 */
3596
				emit("b(lit)");
3597
				spit(value>>24);
3598
				spit((value>>16)&0x0ff);
3599
				spit((value>>8)&0x0ff);
3600
				spit(value&0x0ff);
3601
			}
3602
			break;
3603
		case TOK_DEFER:
3604
			STATE(token->text, "TOK_DEFER");
3605
			/* Don't know what this does or if it's right */
3606
			token = yylex();
3607
			if (token == NULL) {
3608
				(void)printf( "EOF in colon definition\n");
3609
				return;
3610
			}
3611
3612
			/* Add new code to dictionary */
3613
			fcode = malloc(sizeof(*fcode));
3614
			if (fcode == NULL)
3615
				(void)err(1, "out of memory");
3616
3617
			fcode->num = nextfcode++;
3618
			fcode->name = strdup(token->text);
3619
			if (fcode->name == NULL)
3620
				(void)err(1, "out of memory");
3621
3622
			fadd(dictionary, fcode);
3623
3624
			if (state == 0)
3625
				emit("new-token");
3626
			else {
3627
				if (state == TOK_EXTERNAL)
3628
					emit("external-token");
3629
				else
3630
				/* Here we have a choice of new-token or named-token */
3631
					emit("named-token");
3632
				sspit(token->text);
3633
			}
3634
			spit(fcode->num);
3635
			emit("b(defer)");
3636
			break;
3637
		case TOK_DO:
3638
			STATE(token->text, "TOK_DO");
3639
			/*
3640
			 * From the 1275 spec.  B is branch location, T is branch target.
3641
			 *
3642
			 *	b(do)  offset1 ... b(loop)  offset2 ...
3643
			 *	b(do)  offset1 ... b(+loop) offset2 ...
3644
			 *	b(?do) offset1 ... b(loop)  offset2 ...
3645
			 *	b(?do) offset1 ... b(+loop) offset2 ...
3646
			 *            ^                            ^
3647
			 *           B1       ^            ^       T1
3648
			 *                    T2           B2
3649
			 *
3650
			 * How we do this is we generate the b(do) or b(?do), spit out a
3651
			 * zero offset while remembering b1 and t2.  Then we call tokenize()
3652
			 * to generate the body.  When tokenize() finds a b(loop) or b(+loop),
3653
			 * it generates the FCode and returns, with outpos at b2.  We then
3654
			 * calculate the offsets, put them in the right slots and finishup.
3655
			 */
3656
3657
			if (token->text[0] == '?')
3658
				emit("b(?do)");
3659
			else
3660
				emit("b(do)");
3661
			push(outpos);
3662
			if (offsetsize == 16) {
3663
				spit(0);
3664
			}
3665
			spit(0);	/* Place holder for later */
3666
			push(outpos);
3667
			break;
3668
		case TOK_ELSE:
3669
			STATE(token->text, "TOK_ELSE");
3670
			/* Get where we need to patch */
3671
			off = pop();
3672
			emit("bbranch");
3673
			/* Save where we are now. */
3674
			push(outpos);
3675
			if (offsetsize == 16) {
3676
				spit(0);	/* Place holder for later */
3677
			}
3678
			spit(0);	/* Place holder for later */
3679
			emit("b(>resolve)");
3680
			/* Rewind and patch the if branch */
3681
			pos = outpos;
3682
			outpos = off;
3683
			off = pos - off;
3684
			if (offsetsize == 16) {
3685
				spit(0);	/* Place holder for later */
3686
			}
3687
			spit(0);	/* Place holder for later */
3688
			/* revert to the end */
3689
			outpos = pos;
3690
			break;
3691
		case TOK_ENDCASE:
3692
			STATE(token->text, "TOK_ENDCASE:");
3693
			pos = outpos; /* Remember where we need to branch to */
3694
3695
			/* Thread our way backwards and install proper offsets */
3696
			off = pop();
3697
			while (off) {
3698
				int tmp;
3699
3700
				/* Move to this offset */
3701
				outpos = off;
3702
				/* Load next offset to process */
3703
				tmp = outbuf[outpos];
3704
3705
				/* process this offset */
3706
				off = pos - outpos;
3707
				if (offsetsize == 16) {
3708
					spit((off>>8)&0xff);
3709
				}
3710
				spit(off&0xff);
3711
				off = tmp;
3712
			}
3713
			outpos = pos;
3714
			emit("b(endcase)");
3715
			break;
3716
		case TOK_ENDOF:
3717
			STATE(token->text, "TOK_ENDOF");
3718
			off = pop();
3719
			emit("b(endof)");
3720
			/*
3721
			 * Save back pointer in the offset field so we can traverse
3722
			 * the linked list and patch it in the endcase.
3723
			 */
3724
			pos = pop();	/* get position of prev link. */
3725
			push(outpos);	/* save position of this link. */
3726
			spit(pos);	/* save position of prev link. */
3727
			if (offsetsize == 16) {
3728
				spit(0);
3729
			}
3730
			pos = outpos;
3731
			/* Now point the offset from b(of) here. */
3732
			outpos = off;
3733
			off = outpos - off;
3734
			if (offsetsize == 16) {
3735
				spit((off>>8)&0xff);
3736
			}
3737
			spit(off&0xff);
3738
			/* Restore position */
3739
			outpos = pos;
3740
			break;
3741
		case TOK_EXTERNAL:
3742
			STATE(token->text, "TOK_EXTERNAL");
3743
			state = TOK_EXTERNAL;
3744
			break;
3745
		case TOK_FIELD:
3746
			STATE(token->text, "TOK_FIELD");
3747
3748
			token = yylex();
3749
			if (token == NULL) {
3750
				(void)printf( "EOF in field definition\n");
3751
				return;
3752
			}
3753
3754
			/* Add new code to dictionary */
3755
			fcode = malloc(sizeof(*fcode));
3756
			if (fcode == NULL)
3757
				(void)err(1, "out of memory");
3758
3759
			fcode->num = nextfcode++;
3760
			fcode->name = strdup(token->text);
3761
			if (fcode->name == NULL)
3762
				(void)err(1, "out of memory");
3763
3764
			fadd(dictionary, fcode);
3765
3766
			if (state == 0)
3767
				emit("new-token");
3768
			else {
3769
				if (state == TOK_EXTERNAL)
3770
					emit("external-token");
3771
				else
3772
				/* Here we have a choice of new-token or named-token */
3773
					emit("named-token");
3774
				sspit(token->text);
3775
			}
3776
			spit(fcode->num);
3777
			emit("b(field)");
3778
			break;
3779
3780
		case TOK_HEX:
3781
			STATE(token->text, "TOK_HEX");
3782
			if (token->text[1] != '#') {
3783
				if (defining) {
3784
					spit(16);
3785
					emit("base");
3786
					emit("!");
3787
				} else
3788
					base = TOK_HEX;
3789
			} else {
3790
				char *end;
3791
				Cell value;
3792
3793
				token = yylex();
3794
				if (token == NULL) {
3795
					(void)printf( "EOF after h#\n");
3796
					return;
3797
				}
3798
				value = strtol(token->text, &end, 16);
3799
				if (*end != 0) {
3800
					(void)printf("Illegal number conversion:%s:%d: %s\n",
3801
					    infile, yylineno, yytext);
3802
					exit(1);
3803
				}
3804
				/*
3805
				 * If this is a 64-bit value we need to store two literals
3806
				 * and issue a `lxjoin' to combine them.  But that's a future
3807
				 * project.
3808
				 */
3809
				emit("b(lit)");
3810
				spit(value>>24);
3811
				spit((value>>16)&0x0ff);
3812
				spit((value>>8)&0x0ff);
3813
				spit(value&0x0ff);
3814
			}
3815
			break;
3816
		case TOK_HEADERLESS:
3817
			STATE(token->text, "TOK_HEADERLESS");
3818
			state = 0;
3819
			break;
3820
		case TOK_HEADERS:
3821
			STATE(token->text, "TOK_HEADERS");
3822
			state = TOK_HEADERS;
3823
			break;
3824
		case TOK_OFFSET16:
3825
			STATE(token->text, "TOK_OFFSET16");
3826
			offsetsize = 16;
3827
			emit("offset16");
3828
			break;
3829
		case TOK_IF:
3830
			STATE(token->text, "TOK_IF");
3831
			/*
3832
			 * Similar to do but simpler since we only deal w/one branch.
3833
			 */
3834
			emit("b?branch");
3835
			push(outpos);
3836
			if (offsetsize == 16) {
3837
				spit(0);	/* Place holder for later */
3838
			}
3839
			spit(0);	/* Place holder for later */
3840
			break;
3841
		case TOK_LEAVE:
3842
			STATE(token->text, "TOK_LEAVE");
3843
			emit("b(leave)");
3844
			break;
3845
		case TOK_LOOP:
3846
			STATE(token->text, "TOK_LOOP");
3847
3848
			if (token->text[0] == '+')
3849
				emit("b(+loop)");
3850
			else
3851
				emit("b(loop)");
3852
			/* First do backwards branch of loop */
3853
			pos = pop();
3854
			off = pos - outpos;
3855
			if (offsetsize == 16) {
3856
				spit((off>>8)&0xff);
3857
			}
3858
			spit(off&0xff);
3859
			/* Now do forward branch of do */
3860
			pos = outpos;
3861
			outpos = pop();
3862
			off = pos - outpos;
3863
			if (offsetsize == 16) {
3864
				spit((off>>8)&0xff);
3865
			}
3866
			spit(off&0xff);
3867
			/* Restore output position */
3868
			outpos = pos;
3869
			break;
3870
		case TOK_OCTAL:
3871
			STATE(token->text, "TOK_OCTAL");
3872
			if (token->text[1] != '#') {
3873
				if (defining) {
3874
					spit(16);
3875
					emit("base");
3876
					emit("!");
3877
				} else
3878
					base = TOK_OCTAL;
3879
			} else {
3880
				char *end;
3881
				Cell value;
3882
3883
				token = yylex();
3884
				if (token == NULL) {
3885
					(void)printf( "EOF after o#\n");
3886
					return;
3887
				}
3888
				value = strtol(token->text, &end, 8);
3889
				if (*end != 0) {
3890
					(void)printf("Illegal number conversion:%s:%d: %s\n",
3891
					    infile, yylineno, yytext);
3892
					exit(1);
3893
				}
3894
				/*
3895
				 * If this is a 64-bit value we need to store two literals
3896
				 * and issue a `lxjoin' to combine them.  But that's a future
3897
				 * project.
3898
				 */
3899
				emit("b(lit)");
3900
				spit(value>>24);
3901
				spit((value>>16)&0x0ff);
3902
				spit((value>>8)&0x0ff);
3903
				spit(value&0x0ff);
3904
			}
3905
			break;
3906
		case TOK_OF:
3907
			STATE(token->text, "TOK_OF");
3908
			/*
3909
			 * Let's hope I get the semantics right.
3910
			 *
3911
			 * The `of' behaves almost the same as an
3912
			 * `if'.  The difference is that `endof'
3913
			 * takes a branch offset to the associated
3914
			 * `endcase'.  Here we will generate a temporary
3915
			 * offset of the `of' associated with the `endof'.
3916
			 * Then in `endcase' we should be pointing just
3917
			 * after the offset of the last `endof' so we
3918
			 * calculate the offset and thread our way backwards
3919
			 * searching for the previous `b(case)' or `b(endof)'.
3920
			 */
3921
			emit("b(of)");
3922
			push(outpos);
3923
			if (offsetsize == 16) {
3924
				spit(0);
3925
			}
3926
			spit(0);	/* Place holder for later */
3927
			break;
3928
		case TOK_REPEAT:
3929
			STATE(token->text, "TOK_REPEAT");
3930
			emit("bbranch");
3931
			pos = pop();
3932
			off = pop();
3933
			/* First the offset for the branch back to the begin */
3934
			off -= outpos;
3935
			if (offsetsize == 16) {
3936
				spit((off>>8)&0xff);
3937
			}
3938
			spit(off&0xff);
3939
			emit("b(>resolve)");
3940
			/* Now point the offset of the while here. */
3941
			off = outpos;
3942
			outpos = pos;
3943
			pos = off - pos;
3944
			if (offsetsize == 16) {
3945
				spit((pos>>8)&0xff);
3946
			}
3947
			spit(pos&0xff);
3948
			/* Return to the end of the output */
3949
			outpos = off;
3950
			break;
3951
		case TOK_THEN:
3952
			STATE(token->text, "TOK_THEN");
3953
			emit("b(>resolve)");
3954
			pos = outpos;
3955
			outpos = pop();
3956
			off = pos - outpos;
3957
			if (offsetsize == 16) {
3958
				spit((off>>8)&0xff);
3959
			}
3960
			spit(off&0xff);
3961
			outpos = pos;
3962
			break;
3963
		case TOK_TO:
3964
			STATE(token->text, "TOK_TO");
3965
			/* The next pass should tokenize the FCODE number */
3966
			emit("b(to)");
3967
			break;
3968
		case TOK_UNTIL:
3969
			STATE(token->text, "TOK_UNTIL");
3970
		{
3971
			int pos;
3972
3973
			emit("b?branch");
3974
			pos = pop();
3975
			pos -= outpos;
3976
			if (offsetsize == 16) {
3977
				spit((pos>>8)&0xff);
3978
			}
3979
			spit(pos&0xff);
3980
		}
3981
		break;
3982
		case TOK_VALUE:
3983
			STATE(token->text, "TOK_VALUE");
3984
3985
			token = yylex();
3986
			if (token == NULL) {
3987
				(void)printf( "EOF in value definition\n");
3988
				return;
3989
			}
3990
3991
			/* Add new code to dictionary */
3992
			fcode = malloc(sizeof(*fcode));
3993
			if (fcode == NULL)
3994
				(void)err(1, "out of memory");
3995
3996
			fcode->num = nextfcode++;
3997
			fcode->name = strdup(token->text);
3998
			if (fcode->name == NULL)
3999
				(void)err(1, "out of memory");
4000
4001
			fadd(dictionary, fcode);
4002
4003
			if (state == 0)
4004
				emit("new-token");
4005
			else {
4006
				if (state == TOK_EXTERNAL)
4007
					emit("external-token");
4008
				else
4009
				/* Here we have a choice of new-token or named-token */
4010
					emit("named-token");
4011
				sspit(token->text);
4012
			}
4013
			spit(fcode->num);
4014
			emit("b(value)");
4015
			break;
4016
		case TOK_VARIABLE:
4017
			STATE(token->text, "TOK_VARIABLE");
4018
4019
			token = yylex();
4020
			if (token == NULL) {
4021
				(void)printf( "EOF in variable definition\n");
4022
				return;
4023
			}
4024
4025
			/* Add new code to dictionary */
4026
			fcode = malloc(sizeof(*fcode));
4027
			if (fcode == NULL)
4028
				(void)err(1, "out of memory");
4029
4030
			fcode->num = nextfcode++;
4031
			fcode->name = strdup(token->text);
4032
			if (fcode->name == NULL)
4033
				(void)err(1, "out of memory");
4034
4035
			fadd(dictionary, fcode);
4036
4037
			if (state == 0)
4038
				emit("new-token");
4039
			else {
4040
				if (state == TOK_EXTERNAL)
4041
					emit("external-token");
4042
				else
4043
				/* Here we have a choice of new-token or named-token */
4044
					emit("named-token");
4045
				sspit(token->text);
4046
			}
4047
			spit(fcode->num);
4048
			emit("b(variable)");
4049
			break;
4050
		case TOK_WHILE:
4051
			STATE(token->text, "TOK_WHILE");
4052
			emit("b?branch");
4053
			push(outpos);
4054
			if (offsetsize == 16) {
4055
				spit(0);
4056
			}
4057
			spit(0);
4058
			break;
4059
4060
			/* Tokenizer directives */
4061
		case TOK_BEGTOK:
4062
			STATE(token->text, "TOK_BEGTOK");
4063
			tokenizer = 1;
4064
			break;
4065
		case TOK_EMIT_BYTE:
4066
			STATE(token->text, "TOK_EMIT_BYTE");
4067
			spit(pop());
4068
			break;
4069
		case TOK_ENDTOK:
4070
			STATE(token->text, "TOK_ENDTOK");
4071
			tokenizer = 0;
4072
			break;
4073
		case TOK_FLOAD:
4074
			STATE(token->text, "TOK_FLOAD");
4075
			/* Parse a different file for a while */
4076
			token = yylex();
4077
			if ((inf = fopen(token->text, "r")) == NULL) {
4078
				(void)printf("%s: Could not open %s: %s\n",
4079
					      myname, token->text, strerror(errno));
4080
				break;
4081
			}
4082
			inbuf = yy_create_buffer(inf,YY_BUF_SIZE);
4083
			yy_switch_to_buffer(inbuf);
4084
			{
4085
				char *oldinfile = infile;
4086
4087
				infile = token->text;
4088
				tokenize(inbuf);
4089
				infile = oldinfile;
4090
			}
4091
			yy_switch_to_buffer(input);
4092
			yy_delete_buffer(inbuf);
4093
			fclose(inf);
4094
			break;
4095
		case TOK_OTHER:
4096
			STATE(token->text, "TOK_OTHER");
4097
			if (apply_macros(input, token->text))
4098
				break;
4099
			if (emit(token->text)) {
4100
#if 0
4101
				/*
4102
				 * Call an external command
4103
				 *
4104
				 * XXXXX assumes it will always find the command
4105
				 */
4106
				sspit(token->text);
4107
				emit("$find");
4108
				emit("drop");
4109
				emit("execute");
4110
#else
4111
				(void)printf( "%s: undefined token `%s'\n",
4112
					      myname, token->text);
4113
				fflush(stderr);
4114
				exit(1);
4115
#endif
4116
			}
4117
			break;
4118
		default:
4119
			break;
4120
		}
4121
	}
4122
	return;
4123
}
4124
4125
/*
4126
 * print a tokenizer error message
4127
 */
4128
void
4129
token_err(int lineno, char *infile, char *text, char *fmt, ...)
4130
{
4131
	va_list ap;
4132
4133
	va_start(ap, fmt);
4134
	if (infile)
4135
		(void)fprintf(stderr, "%s:%d: ", infile, lineno);
4136
	if (fmt)
4137
		(void)vfprintf(stderr, fmt, ap);
4138
	fputc('\n', stderr);
4139
	if (text)
4140
		fprintf(stderr, "\t%s", text);
4141
	va_end(ap);
4142
	exit(1);
4143
}
4144
4145
/*
4146
 * Lookup fcode string in dictionary and spit it out.
4147
 *
4148
 * Fcode must be in dictionary.  No alias conversion done.
4149
 */
4150
int
4151
emit(str)
4152
	char *str;
4153
{
4154
	struct fcode *code;
4155
	if ((code = flookup( dictionary, str)))
4156
		spit(code->num);
4157
#ifdef DEBUG
4158
	if (debug > 1) {
4159
		if (code)
4160
			(void)printf( "emitting `%s'\n", code->name);
4161
		else
4162
			(void)printf( "emit: not found `%s'\n", str);
4163
	}
4164
#endif
4165
	return (code == NULL);
4166
}
4167
4168
/*
4169
 * Spit out an integral value as a series of FCodes.
4170
 *
4171
 * It will spit out one zero byte or as many bytes as are
4172
 * non-zero.
4173
 */
4174
int
4175
spit(n)
4176
	long n;
4177
{
4178
	int count = 1;
4179
4180
	if (n >> 8)
4181
		count += spit(n >> 8);
4182
	if (outpos >= outbufsiz) {
4183
		while (outpos >= outbufsiz) outbufsiz += BUFCLICK;
4184
		if (!(outbuf = realloc(outbuf, outbufsiz))) {
4185
			(void)printf( "realloc of %ld bytes failed -- out of memory\n",
4186
				      (long)outbufsiz);
4187
			exit(1);
4188
		}
4189
	}
4190
	outbuf[outpos++] = n;
4191
	return (count);
4192
}
4193
4194
/*
4195
 * Spit out an FCode string.
4196
 */
4197
void
4198
sspit(s)
4199
	char *s;
4200
{
4201
	int len = strlen(s);
4202
4203
	if (len > 255) {
4204
		(void)printf( "string length %d too long\n", len);
4205
		return;
4206
	}
4207
#ifdef DEBUG
4208
	if (debug > 1)
4209
		(void)printf( "sspit: len %d str `%s'\n", len, s);
4210
#endif
4211
	spit(len);
4212
	while (*s)
4213
		spit(*s++);
4214
}
4215
4216
int
4217
yywrap()
4218
{
4219
	/* Always generate EOF */
4220
	return (1);
4221
}
4222