syscons - Untangle device attachement from isa?, attach to nexus? instead.
[dragonfly.git] / lib / libevtr / ktrfmt.yy.c
blob24ac1dc0802b402a7f878791b1364cdc0da5fc64
1 #line 2 "ktrfmt.yy.c"
3 #line 4 "ktrfmt.yy.c"
5 #define YY_INT_ALIGNED short int
7 /* A lexical scanner generated by flex */
9 #define yy_create_buffer __ktrfmt_create_buffer
10 #define yy_delete_buffer __ktrfmt_delete_buffer
11 #define yy_flex_debug __ktrfmt_flex_debug
12 #define yy_init_buffer __ktrfmt_init_buffer
13 #define yy_flush_buffer __ktrfmt_flush_buffer
14 #define yy_load_buffer_state __ktrfmt_load_buffer_state
15 #define yy_switch_to_buffer __ktrfmt_switch_to_buffer
16 #define yyin __ktrfmtin
17 #define yyleng __ktrfmtleng
18 #define yylex __ktrfmtlex
19 #define yylineno __ktrfmtlineno
20 #define yyout __ktrfmtout
21 #define yyrestart __ktrfmtrestart
22 #define yytext __ktrfmttext
23 #define yywrap __ktrfmtwrap
24 #define yyalloc __ktrfmtalloc
25 #define yyrealloc __ktrfmtrealloc
26 #define yyfree __ktrfmtfree
28 #define FLEX_SCANNER
29 #define YY_FLEX_MAJOR_VERSION 2
30 #define YY_FLEX_MINOR_VERSION 5
31 #define YY_FLEX_SUBMINOR_VERSION 37
32 #if YY_FLEX_SUBMINOR_VERSION > 0
33 #define FLEX_BETA
34 #endif
36 /* First, we deal with platform-specific or compiler-specific issues. */
38 /* begin standard C headers. */
39 #include <stdio.h>
40 #include <string.h>
41 #include <errno.h>
42 #include <stdlib.h>
44 /* end standard C headers. */
46 /* flex integer type definitions */
48 #ifndef FLEXINT_H
49 #define FLEXINT_H
51 /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
53 #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
55 /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
56 * if you want the limit (max/min) macros for int types.
58 #ifndef __STDC_LIMIT_MACROS
59 #define __STDC_LIMIT_MACROS 1
60 #endif
62 #include <inttypes.h>
63 typedef int8_t flex_int8_t;
64 typedef uint8_t flex_uint8_t;
65 typedef int16_t flex_int16_t;
66 typedef uint16_t flex_uint16_t;
67 typedef int32_t flex_int32_t;
68 typedef uint32_t flex_uint32_t;
69 #else
70 typedef signed char flex_int8_t;
71 typedef short int flex_int16_t;
72 typedef int flex_int32_t;
73 typedef unsigned char flex_uint8_t;
74 typedef unsigned short int flex_uint16_t;
75 typedef unsigned int flex_uint32_t;
77 /* Limits of integral types. */
78 #ifndef INT8_MIN
79 #define INT8_MIN (-128)
80 #endif
81 #ifndef INT16_MIN
82 #define INT16_MIN (-32767-1)
83 #endif
84 #ifndef INT32_MIN
85 #define INT32_MIN (-2147483647-1)
86 #endif
87 #ifndef INT8_MAX
88 #define INT8_MAX (127)
89 #endif
90 #ifndef INT16_MAX
91 #define INT16_MAX (32767)
92 #endif
93 #ifndef INT32_MAX
94 #define INT32_MAX (2147483647)
95 #endif
96 #ifndef UINT8_MAX
97 #define UINT8_MAX (255U)
98 #endif
99 #ifndef UINT16_MAX
100 #define UINT16_MAX (65535U)
101 #endif
102 #ifndef UINT32_MAX
103 #define UINT32_MAX (4294967295U)
104 #endif
106 #endif /* ! C99 */
108 #endif /* ! FLEXINT_H */
110 #ifdef __cplusplus
112 /* The "const" storage-class-modifier is valid. */
113 #define YY_USE_CONST
115 #else /* ! __cplusplus */
117 /* C99 requires __STDC__ to be defined as 1. */
118 #if defined (__STDC__)
120 #define YY_USE_CONST
122 #endif /* defined (__STDC__) */
123 #endif /* ! __cplusplus */
125 #ifdef YY_USE_CONST
126 #define yyconst const
127 #else
128 #define yyconst
129 #endif
131 /* Returned upon end-of-file. */
132 #define YY_NULL 0
134 /* Promotes a possibly negative, possibly signed char to an unsigned
135 * integer for use as an array index. If the signed char is negative,
136 * we want to instead treat it as an 8-bit unsigned char, hence the
137 * double cast.
139 #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
141 /* Enter a start condition. This macro really ought to take a parameter,
142 * but we do it the disgusting crufty way forced on us by the ()-less
143 * definition of BEGIN.
145 #define BEGIN (yy_start) = 1 + 2 *
147 /* Translate the current start state into a value that can be later handed
148 * to BEGIN to return to the state. The YYSTATE alias is for lex
149 * compatibility.
151 #define YY_START (((yy_start) - 1) / 2)
152 #define YYSTATE YY_START
154 /* Action number for EOF rule of a given start state. */
155 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
157 /* Special action meaning "start processing a new file". */
158 #define YY_NEW_FILE __ktrfmtrestart(__ktrfmtin )
160 #define YY_END_OF_BUFFER_CHAR 0
162 /* Size of default input buffer. */
163 #ifndef YY_BUF_SIZE
164 #define YY_BUF_SIZE 16384
165 #endif
167 /* The state buf must be large enough to hold one state per character in the main buffer.
169 #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
171 #ifndef YY_TYPEDEF_YY_BUFFER_STATE
172 #define YY_TYPEDEF_YY_BUFFER_STATE
173 typedef struct yy_buffer_state *YY_BUFFER_STATE;
174 #endif
176 #ifndef YY_TYPEDEF_YY_SIZE_T
177 #define YY_TYPEDEF_YY_SIZE_T
178 typedef size_t yy_size_t;
179 #endif
181 extern yy_size_t __ktrfmtleng;
183 extern FILE *__ktrfmtin, *__ktrfmtout;
185 #define EOB_ACT_CONTINUE_SCAN 0
186 #define EOB_ACT_END_OF_FILE 1
187 #define EOB_ACT_LAST_MATCH 2
189 #define YY_LESS_LINENO(n)
191 /* Return all but the first "n" matched characters back to the input stream. */
192 #define yyless(n) \
193 do \
195 /* Undo effects of setting up __ktrfmttext. */ \
196 int yyless_macro_arg = (n); \
197 YY_LESS_LINENO(yyless_macro_arg);\
198 *yy_cp = (yy_hold_char); \
199 YY_RESTORE_YY_MORE_OFFSET \
200 (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
201 YY_DO_BEFORE_ACTION; /* set up __ktrfmttext again */ \
203 while ( 0 )
205 #define unput(c) yyunput( c, (yytext_ptr) )
207 #ifndef YY_STRUCT_YY_BUFFER_STATE
208 #define YY_STRUCT_YY_BUFFER_STATE
209 struct yy_buffer_state
211 FILE *yy_input_file;
213 char *yy_ch_buf; /* input buffer */
214 char *yy_buf_pos; /* current position in input buffer */
216 /* Size of input buffer in bytes, not including room for EOB
217 * characters.
219 yy_size_t yy_buf_size;
221 /* Number of characters read into yy_ch_buf, not including EOB
222 * characters.
224 yy_size_t yy_n_chars;
226 /* Whether we "own" the buffer - i.e., we know we created it,
227 * and can realloc() it to grow it, and should free() it to
228 * delete it.
230 int yy_is_our_buffer;
232 /* Whether this is an "interactive" input source; if so, and
233 * if we're using stdio for input, then we want to use getc()
234 * instead of fread(), to make sure we stop fetching input after
235 * each newline.
237 int yy_is_interactive;
239 /* Whether we're considered to be at the beginning of a line.
240 * If so, '^' rules will be active on the next match, otherwise
241 * not.
243 int yy_at_bol;
245 int yy_bs_lineno; /**< The line count. */
246 int yy_bs_column; /**< The column count. */
248 /* Whether to try to fill the input buffer when we reach the
249 * end of it.
251 int yy_fill_buffer;
253 int yy_buffer_status;
255 #define YY_BUFFER_NEW 0
256 #define YY_BUFFER_NORMAL 1
257 /* When an EOF's been seen but there's still some text to process
258 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
259 * shouldn't try reading from the input source any more. We might
260 * still have a bunch of tokens to match, though, because of
261 * possible backing-up.
263 * When we actually see the EOF, we change the status to "new"
264 * (via __ktrfmtrestart()), so that the user can continue scanning by
265 * just pointing __ktrfmtin at a new input file.
267 #define YY_BUFFER_EOF_PENDING 2
270 #endif /* !YY_STRUCT_YY_BUFFER_STATE */
272 /* Stack of input buffers. */
273 static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
274 static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
275 static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
277 /* We provide macros for accessing buffer states in case in the
278 * future we want to put the buffer states in a more general
279 * "scanner state".
281 * Returns the top of the stack, or NULL.
283 #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
284 ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
285 : NULL)
287 /* Same as previous macro, but useful when we know that the buffer stack is not
288 * NULL or when we need an lvalue. For internal use only.
290 #define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
292 /* yy_hold_char holds the character lost when __ktrfmttext is formed. */
293 static char yy_hold_char;
294 static yy_size_t yy_n_chars; /* number of characters read into yy_ch_buf */
295 yy_size_t __ktrfmtleng;
297 /* Points to current character in buffer. */
298 static char *yy_c_buf_p = (char *) 0;
299 static int yy_init = 0; /* whether we need to initialize */
300 static int yy_start = 0; /* start state number */
302 /* Flag which is used to allow __ktrfmtwrap()'s to do buffer switches
303 * instead of setting up a fresh __ktrfmtin. A bit of a hack ...
305 static int yy_did_buffer_switch_on_eof;
307 void __ktrfmtrestart (FILE *input_file );
308 void __ktrfmt_switch_to_buffer (YY_BUFFER_STATE new_buffer );
309 YY_BUFFER_STATE __ktrfmt_create_buffer (FILE *file,int size );
310 void __ktrfmt_delete_buffer (YY_BUFFER_STATE b );
311 void __ktrfmt_flush_buffer (YY_BUFFER_STATE b );
312 void __ktrfmtpush_buffer_state (YY_BUFFER_STATE new_buffer );
313 void __ktrfmtpop_buffer_state (void );
315 static void __ktrfmtensure_buffer_stack (void );
316 static void __ktrfmt_load_buffer_state (void );
317 static void __ktrfmt_init_buffer (YY_BUFFER_STATE b,FILE *file );
319 #define YY_FLUSH_BUFFER __ktrfmt_flush_buffer(YY_CURRENT_BUFFER )
321 YY_BUFFER_STATE __ktrfmt_scan_buffer (char *base,yy_size_t size );
322 YY_BUFFER_STATE __ktrfmt_scan_string (yyconst char *yy_str );
323 YY_BUFFER_STATE __ktrfmt_scan_bytes (yyconst char *bytes,yy_size_t len );
325 void *__ktrfmtalloc (yy_size_t );
326 void *__ktrfmtrealloc (void *,yy_size_t );
327 void __ktrfmtfree (void * );
329 #define yy_new_buffer __ktrfmt_create_buffer
331 #define yy_set_interactive(is_interactive) \
333 if ( ! YY_CURRENT_BUFFER ){ \
334 __ktrfmtensure_buffer_stack (); \
335 YY_CURRENT_BUFFER_LVALUE = \
336 __ktrfmt_create_buffer(__ktrfmtin,YY_BUF_SIZE ); \
338 YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
341 #define yy_set_bol(at_bol) \
343 if ( ! YY_CURRENT_BUFFER ){\
344 __ktrfmtensure_buffer_stack (); \
345 YY_CURRENT_BUFFER_LVALUE = \
346 __ktrfmt_create_buffer(__ktrfmtin,YY_BUF_SIZE ); \
348 YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
351 #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
353 /* Begin user sect3 */
355 #define __ktrfmtwrap() 1
356 #define YY_SKIP_YYWRAP
358 typedef unsigned char YY_CHAR;
360 FILE *__ktrfmtin = (FILE *) 0, *__ktrfmtout = (FILE *) 0;
362 typedef int yy_state_type;
364 extern int __ktrfmtlineno;
366 int __ktrfmtlineno = 1;
368 extern char *__ktrfmttext;
369 #define yytext_ptr __ktrfmttext
371 static yy_state_type yy_get_previous_state (void );
372 static yy_state_type yy_try_NUL_trans (yy_state_type current_state );
373 static int yy_get_next_buffer (void );
374 static void yy_fatal_error (yyconst char msg[] );
376 /* Done after the current pattern has been matched and before the
377 * corresponding action - sets up __ktrfmttext.
379 #define YY_DO_BEFORE_ACTION \
380 (yytext_ptr) = yy_bp; \
381 __ktrfmtleng = (size_t) (yy_cp - yy_bp); \
382 (yy_hold_char) = *yy_cp; \
383 *yy_cp = '\0'; \
384 (yy_c_buf_p) = yy_cp;
386 #define YY_NUM_RULES 11
387 #define YY_END_OF_BUFFER 12
388 /* This struct is not used in this scanner,
389 but its presence is necessary. */
390 struct yy_trans_info
392 flex_int32_t yy_verify;
393 flex_int32_t yy_nxt;
395 static yyconst flex_int16_t yy_accept[26] =
396 { 0,
397 0, 0, 12, 11, 1, 11, 3, 8, 5, 5,
398 7, 4, 9, 10, 1, 0, 0, 3, 5, 0,
399 4, 2, 2, 6, 0
402 static yyconst flex_int32_t yy_ec[256] =
403 { 0,
404 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
405 1, 1, 2, 1, 1, 1, 1, 1, 1, 1,
406 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
407 1, 2, 1, 4, 1, 5, 1, 1, 1, 1,
408 1, 1, 1, 1, 1, 6, 1, 7, 8, 8,
409 8, 8, 8, 8, 8, 8, 8, 1, 1, 1,
410 9, 1, 1, 1, 10, 10, 10, 10, 10, 10,
411 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
412 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,
413 12, 13, 14, 1, 15, 1, 16, 16, 16, 16,
415 16, 16, 15, 15, 15, 15, 15, 15, 15, 15,
416 15, 15, 15, 15, 15, 15, 15, 15, 15, 17,
417 15, 15, 1, 1, 1, 1, 1, 1, 1, 1,
418 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
419 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
420 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
421 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
422 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
423 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
424 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
426 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
427 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
428 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
429 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
430 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
431 1, 1, 1, 1, 1
434 static yyconst flex_int32_t yy_meta[18] =
435 { 0,
436 1, 1, 2, 2, 1, 1, 3, 3, 1, 4,
437 5, 1, 1, 1, 5, 4, 6
440 static yyconst flex_int16_t yy_base[31] =
441 { 0,
442 0, 0, 31, 54, 26, 14, 0, 54, 9, 11,
443 54, 0, 54, 54, 23, 16, 17, 0, 15, 0,
444 0, 54, 20, 0, 54, 33, 37, 41, 45, 49
447 static yyconst flex_int16_t yy_def[31] =
448 { 0,
449 25, 1, 25, 25, 25, 26, 27, 25, 28, 25,
450 25, 29, 25, 25, 25, 26, 26, 27, 25, 30,
451 29, 25, 26, 30, 0, 25, 25, 25, 25, 25
454 static yyconst flex_int16_t yy_nxt[72] =
455 { 0,
456 4, 5, 4, 6, 7, 8, 9, 10, 11, 12,
457 12, 13, 4, 14, 7, 7, 7, 19, 19, 22,
458 23, 19, 19, 22, 15, 20, 17, 15, 17, 17,
459 25, 25, 17, 16, 25, 16, 16, 16, 16, 18,
460 18, 18, 18, 19, 25, 25, 19, 21, 21, 21,
461 21, 24, 24, 3, 25, 25, 25, 25, 25, 25,
462 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
466 static yyconst flex_int16_t yy_chk[72] =
467 { 0,
468 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
469 1, 1, 1, 1, 1, 1, 1, 10, 10, 16,
470 17, 19, 19, 23, 15, 9, 6, 5, 16, 17,
471 3, 0, 23, 26, 0, 26, 26, 26, 26, 27,
472 27, 27, 27, 28, 0, 0, 28, 29, 29, 29,
473 29, 30, 30, 25, 25, 25, 25, 25, 25, 25,
474 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
478 static yy_state_type yy_last_accepting_state;
479 static char *yy_last_accepting_cpos;
481 extern int __ktrfmt_flex_debug;
482 int __ktrfmt_flex_debug = 0;
484 /* The intent behind this definition is that it'll catch
485 * any uses of REJECT which flex missed.
487 #define REJECT reject_used_but_not_detected
488 #define yymore() yymore_used_but_not_detected
489 #define YY_MORE_ADJ 0
490 #define YY_RESTORE_YY_MORE_OFFSET
491 char *__ktrfmttext;
492 #line 1 "ktrfmt.l"
493 #line 2 "ktrfmt.l"
495 #include <assert.h>
496 //#define YYSTYPE struct token
497 #define YY_NO_INPUT
498 #include <stdlib.h>
499 #include "internal.h"
500 #include "ktrfmt.tab.h"
501 #include "tok.h"
503 enum {
504 NR_TOKENS = 18,
507 /* XXX: need to switch to reentrant lexer */
508 static struct token tokens[NR_TOKENS];
509 static int curr_tok;
510 static struct symtab *strtab;
512 static
513 struct token *
514 tok_new(void)
516 ++curr_tok;
517 if (curr_tok == NR_TOKENS) {
518 /* can't happen */
519 fprintf(stderr, "Reached max number of tokens\n");
520 abort();
522 return &tokens[curr_tok];
525 void
526 tok_free(struct token *tok)
528 assert(&tokens[curr_tok] == tok);
529 --curr_tok;
533 * We keep track of strings we've seen before so string comparison
534 * can be done w/ a simple pointer comparison
536 static
537 char *
538 newstr(const char *s)
540 void *r;
541 if (!strtab)
542 strtab = symtab_new();
543 if ((r = symtab_find(strtab, s)))
544 return r;
545 if (!(r = strdup(s)))
546 return r;
547 symtab_insert(strtab, r, r);
548 return r;
551 #line 552 "ktrfmt.yy.c"
553 #define INITIAL 0
555 #ifndef YY_NO_UNISTD_H
556 /* Special case for "unistd.h", since it is non-ANSI. We include it way
557 * down here because we want the user's section 1 to have been scanned first.
558 * The user has a chance to override it with an option.
560 #include <unistd.h>
561 #endif
563 #ifndef YY_EXTRA_TYPE
564 #define YY_EXTRA_TYPE void *
565 #endif
567 static int yy_init_globals (void );
569 /* Accessor methods to globals.
570 These are made visible to non-reentrant scanners for convenience. */
572 int __ktrfmtlex_destroy (void );
574 int __ktrfmtget_debug (void );
576 void __ktrfmtset_debug (int debug_flag );
578 YY_EXTRA_TYPE __ktrfmtget_extra (void );
580 void __ktrfmtset_extra (YY_EXTRA_TYPE user_defined );
582 FILE *__ktrfmtget_in (void );
584 void __ktrfmtset_in (FILE * in_str );
586 FILE *__ktrfmtget_out (void );
588 void __ktrfmtset_out (FILE * out_str );
590 yy_size_t __ktrfmtget_leng (void );
592 char *__ktrfmtget_text (void );
594 int __ktrfmtget_lineno (void );
596 void __ktrfmtset_lineno (int line_number );
598 YYSTYPE * __ktrfmtget_lval (void );
600 void __ktrfmtset_lval (YYSTYPE * yylval_param );
602 /* Macros after this point can all be overridden by user definitions in
603 * section 1.
606 #ifndef YY_SKIP_YYWRAP
607 #ifdef __cplusplus
608 extern "C" int __ktrfmtwrap (void );
609 #else
610 extern int __ktrfmtwrap (void );
611 #endif
612 #endif
614 #ifndef yytext_ptr
615 static void yy_flex_strncpy (char *,yyconst char *,int );
616 #endif
618 #ifdef YY_NEED_STRLEN
619 static int yy_flex_strlen (yyconst char * );
620 #endif
622 #ifndef YY_NO_INPUT
624 #ifdef __cplusplus
625 static int yyinput (void );
626 #else
627 static int input (void );
628 #endif
630 #endif
632 /* Amount of stuff to slurp up with each read. */
633 #ifndef YY_READ_BUF_SIZE
634 #define YY_READ_BUF_SIZE 8192
635 #endif
637 /* Copy whatever the last rule matched to the standard output. */
638 #ifndef ECHO
639 /* This used to be an fputs(), but since the string might contain NUL's,
640 * we now use fwrite().
642 #define ECHO do { if (fwrite( __ktrfmttext, __ktrfmtleng, 1, __ktrfmtout )) {} } while (0)
643 #endif
645 /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
646 * is returned in "result".
648 #ifndef YY_INPUT
649 #define YY_INPUT(buf,result,max_size) \
650 if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
652 int c = '*'; \
653 size_t n; \
654 for ( n = 0; n < max_size && \
655 (c = getc( __ktrfmtin )) != EOF && c != '\n'; ++n ) \
656 buf[n] = (char) c; \
657 if ( c == '\n' ) \
658 buf[n++] = (char) c; \
659 if ( c == EOF && ferror( __ktrfmtin ) ) \
660 YY_FATAL_ERROR( "input in flex scanner failed" ); \
661 result = n; \
663 else \
665 errno=0; \
666 while ( (result = fread(buf, 1, max_size, __ktrfmtin))==0 && ferror(__ktrfmtin)) \
668 if( errno != EINTR) \
670 YY_FATAL_ERROR( "input in flex scanner failed" ); \
671 break; \
673 errno=0; \
674 clearerr(__ktrfmtin); \
679 #endif
681 /* No semi-colon after return; correct usage is to write "yyterminate();" -
682 * we don't want an extra ';' after the "return" because that will cause
683 * some compilers to complain about unreachable statements.
685 #ifndef yyterminate
686 #define yyterminate() return YY_NULL
687 #endif
689 /* Number of entries by which start-condition stack grows. */
690 #ifndef YY_START_STACK_INCR
691 #define YY_START_STACK_INCR 25
692 #endif
694 /* Report a fatal error. */
695 #ifndef YY_FATAL_ERROR
696 #define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
697 #endif
699 /* end tables serialization structures and prototypes */
701 /* Default declaration of generated scanner - a define so the user can
702 * easily add parameters.
704 #ifndef YY_DECL
705 #define YY_DECL_IS_OURS 1
707 extern int __ktrfmtlex \
708 (YYSTYPE * yylval_param );
710 #define YY_DECL int __ktrfmtlex \
711 (YYSTYPE * yylval_param )
712 #endif /* !YY_DECL */
714 /* Code executed at the beginning of each rule, after __ktrfmttext and __ktrfmtleng
715 * have been set up.
717 #ifndef YY_USER_ACTION
718 #define YY_USER_ACTION
719 #endif
721 /* Code executed at the end of each rule. */
722 #ifndef YY_BREAK
723 #define YY_BREAK break;
724 #endif
726 #define YY_RULE_SETUP \
727 YY_USER_ACTION
729 /** The main scanner function which does all the work.
731 YY_DECL
733 register yy_state_type yy_current_state;
734 register char *yy_cp, *yy_bp;
735 register int yy_act;
737 YYSTYPE * yylval;
739 #line 73 "ktrfmt.l"
741 #line 742 "ktrfmt.yy.c"
743 yylval = yylval_param;
745 if ( !(yy_init) )
747 (yy_init) = 1;
749 #ifdef YY_USER_INIT
750 YY_USER_INIT;
751 #endif
753 if ( ! (yy_start) )
754 (yy_start) = 1; /* first start state */
756 if ( ! __ktrfmtin )
757 __ktrfmtin = stdin;
759 if ( ! __ktrfmtout )
760 __ktrfmtout = stdout;
762 if ( ! YY_CURRENT_BUFFER ) {
763 __ktrfmtensure_buffer_stack ();
764 YY_CURRENT_BUFFER_LVALUE =
765 __ktrfmt_create_buffer(__ktrfmtin,YY_BUF_SIZE );
768 __ktrfmt_load_buffer_state( );
771 while ( 1 ) /* loops until end-of-file is reached */
773 yy_cp = (yy_c_buf_p);
775 /* Support of __ktrfmttext. */
776 *yy_cp = (yy_hold_char);
778 /* yy_bp points to the position in yy_ch_buf of the start of
779 * the current run.
781 yy_bp = yy_cp;
783 yy_current_state = (yy_start);
784 yy_match:
787 register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
788 if ( yy_accept[yy_current_state] )
790 (yy_last_accepting_state) = yy_current_state;
791 (yy_last_accepting_cpos) = yy_cp;
793 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
795 yy_current_state = (int) yy_def[yy_current_state];
796 if ( yy_current_state >= 26 )
797 yy_c = yy_meta[(unsigned int) yy_c];
799 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
800 ++yy_cp;
802 while ( yy_base[yy_current_state] != 54 );
804 yy_find_action:
805 yy_act = yy_accept[yy_current_state];
806 if ( yy_act == 0 )
807 { /* have to back up */
808 yy_cp = (yy_last_accepting_cpos);
809 yy_current_state = (yy_last_accepting_state);
810 yy_act = yy_accept[yy_current_state];
813 YY_DO_BEFORE_ACTION;
815 do_action: /* This label is used only to access EOF actions. */
817 switch ( yy_act )
818 { /* beginning of action switch */
819 case 0: /* must back up */
820 /* undo the effects of YY_DO_BEFORE_ACTION */
821 *yy_cp = (yy_hold_char);
822 yy_cp = (yy_last_accepting_cpos);
823 yy_current_state = (yy_last_accepting_state);
824 goto yy_find_action;
826 case 1:
827 YY_RULE_SETUP
828 #line 74 "ktrfmt.l"
829 { /* ignore */ }
830 YY_BREAK
831 case 2:
832 YY_RULE_SETUP
833 #line 75 "ktrfmt.l"
835 size_t len;
836 yylval->tok = tok_new();
837 yylval->tok->type = TOK_STR;
838 len = strlen(__ktrfmttext);
839 assert(__ktrfmttext[len - 1] == '"');
840 __ktrfmttext[len - 1] = '\0'; /* kill trailing quote */
841 printd(LEX, "newstr(\"%s\")\n", __ktrfmttext + 1);
842 yylval->tok->str = newstr(__ktrfmttext + 1); /* parser detects oom */
843 __ktrfmttext[len - 1] = '"'; /* restore quote */
844 printd(LEX, "TOK_STR: \"%s\"\n", yylval->tok->str);
845 return TOK_STR;
847 YY_BREAK
848 case 3:
849 YY_RULE_SETUP
850 #line 88 "ktrfmt.l"
852 yylval->tok = tok_new();
853 yylval->tok->type = TOK_ID;
854 printd(LEX, "tok %p TOK_ID %p:%s\n", yylval->tok, __ktrfmttext, __ktrfmttext);
855 yylval->tok->str = newstr(__ktrfmttext); /* parser detects oom */
856 return TOK_ID;
858 YY_BREAK
859 case 4:
860 YY_RULE_SETUP
861 #line 95 "ktrfmt.l"
863 yylval->tok = tok_new();
864 yylval->tok->type = TOK_CTOR;
865 printd(LEX, "tok %p TOK_CTOR %p:%s\n", yylval->tok, __ktrfmttext, __ktrfmttext);
866 yylval->tok->str = newstr(__ktrfmttext); /* parser detects oom */
867 return TOK_CTOR;
869 YY_BREAK
870 case 5:
871 YY_RULE_SETUP
872 #line 102 "ktrfmt.l"
874 yylval->tok = tok_new();
875 yylval->tok->type = TOK_INT;
876 yylval->tok->str = strdup(__ktrfmttext); /* parser detects oom */
877 printd(LEX, "TOK_INT\n");
878 return TOK_INT;
880 YY_BREAK
881 case 6:
882 YY_RULE_SETUP
883 #line 109 "ktrfmt.l"
885 yylval->tok = tok_new();
886 yylval->tok->type = TOK_INT;
887 yylval->tok->str = strdup(__ktrfmttext); /* parser detects oom */
888 printd(LEX, "TOK_INT\n");
889 return TOK_INT;
891 YY_BREAK
892 case 7:
893 YY_RULE_SETUP
894 #line 116 "ktrfmt.l"
896 yylval = NULL;
897 printd(LEX, "TOK_EQ\n");
898 return TOK_EQ;
900 YY_BREAK
901 case 8:
902 YY_RULE_SETUP
903 #line 121 "ktrfmt.l"
905 yylval = NULL;
906 printd(LEX, "TOK_DOT\n");
907 return TOK_DOT;
909 YY_BREAK
910 case 9:
911 YY_RULE_SETUP
912 #line 126 "ktrfmt.l"
914 yylval = NULL;
915 printd(LEX, "TOK_LEFT_BRACK\n");
916 return TOK_LEFT_BRACK;
918 YY_BREAK
919 case 10:
920 YY_RULE_SETUP
921 #line 131 "ktrfmt.l"
923 yylval = NULL;
924 printd(LEX, "TOK_RIGHT_BRACK\n");
925 return TOK_RIGHT_BRACK;
927 YY_BREAK
928 case 11:
929 YY_RULE_SETUP
930 #line 137 "ktrfmt.l"
931 ECHO;
932 YY_BREAK
933 #line 934 "ktrfmt.yy.c"
934 case YY_STATE_EOF(INITIAL):
935 yyterminate();
937 case YY_END_OF_BUFFER:
939 /* Amount of text matched not including the EOB char. */
940 int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
942 /* Undo the effects of YY_DO_BEFORE_ACTION. */
943 *yy_cp = (yy_hold_char);
944 YY_RESTORE_YY_MORE_OFFSET
946 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
948 /* We're scanning a new file or input source. It's
949 * possible that this happened because the user
950 * just pointed __ktrfmtin at a new source and called
951 * __ktrfmtlex(). If so, then we have to assure
952 * consistency between YY_CURRENT_BUFFER and our
953 * globals. Here is the right place to do so, because
954 * this is the first action (other than possibly a
955 * back-up) that will match for the new input source.
957 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
958 YY_CURRENT_BUFFER_LVALUE->yy_input_file = __ktrfmtin;
959 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
962 /* Note that here we test for yy_c_buf_p "<=" to the position
963 * of the first EOB in the buffer, since yy_c_buf_p will
964 * already have been incremented past the NUL character
965 * (since all states make transitions on EOB to the
966 * end-of-buffer state). Contrast this with the test
967 * in input().
969 if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
970 { /* This was really a NUL. */
971 yy_state_type yy_next_state;
973 (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
975 yy_current_state = yy_get_previous_state( );
977 /* Okay, we're now positioned to make the NUL
978 * transition. We couldn't have
979 * yy_get_previous_state() go ahead and do it
980 * for us because it doesn't know how to deal
981 * with the possibility of jamming (and we don't
982 * want to build jamming into it because then it
983 * will run more slowly).
986 yy_next_state = yy_try_NUL_trans( yy_current_state );
988 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
990 if ( yy_next_state )
992 /* Consume the NUL. */
993 yy_cp = ++(yy_c_buf_p);
994 yy_current_state = yy_next_state;
995 goto yy_match;
998 else
1000 yy_cp = (yy_c_buf_p);
1001 goto yy_find_action;
1005 else switch ( yy_get_next_buffer( ) )
1007 case EOB_ACT_END_OF_FILE:
1009 (yy_did_buffer_switch_on_eof) = 0;
1011 if ( __ktrfmtwrap( ) )
1013 /* Note: because we've taken care in
1014 * yy_get_next_buffer() to have set up
1015 * __ktrfmttext, we can now set up
1016 * yy_c_buf_p so that if some total
1017 * hoser (like flex itself) wants to
1018 * call the scanner after we return the
1019 * YY_NULL, it'll still work - another
1020 * YY_NULL will get returned.
1022 (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
1024 yy_act = YY_STATE_EOF(YY_START);
1025 goto do_action;
1028 else
1030 if ( ! (yy_did_buffer_switch_on_eof) )
1031 YY_NEW_FILE;
1033 break;
1036 case EOB_ACT_CONTINUE_SCAN:
1037 (yy_c_buf_p) =
1038 (yytext_ptr) + yy_amount_of_matched_text;
1040 yy_current_state = yy_get_previous_state( );
1042 yy_cp = (yy_c_buf_p);
1043 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1044 goto yy_match;
1046 case EOB_ACT_LAST_MATCH:
1047 (yy_c_buf_p) =
1048 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
1050 yy_current_state = yy_get_previous_state( );
1052 yy_cp = (yy_c_buf_p);
1053 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1054 goto yy_find_action;
1056 break;
1059 default:
1060 YY_FATAL_ERROR(
1061 "fatal flex scanner internal error--no action found" );
1062 } /* end of action switch */
1063 } /* end of scanning one token */
1064 } /* end of __ktrfmtlex */
1066 /* yy_get_next_buffer - try to read in a new buffer
1068 * Returns a code representing an action:
1069 * EOB_ACT_LAST_MATCH -
1070 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1071 * EOB_ACT_END_OF_FILE - end of file
1073 static int yy_get_next_buffer (void)
1075 register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
1076 register char *source = (yytext_ptr);
1077 register int number_to_move, i;
1078 int ret_val;
1080 if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
1081 YY_FATAL_ERROR(
1082 "fatal flex scanner internal error--end of buffer missed" );
1084 if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
1085 { /* Don't try to fill the buffer, so this is an EOF. */
1086 if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
1088 /* We matched a single character, the EOB, so
1089 * treat this as a final EOF.
1091 return EOB_ACT_END_OF_FILE;
1094 else
1096 /* We matched some text prior to the EOB, first
1097 * process it.
1099 return EOB_ACT_LAST_MATCH;
1103 /* Try to read more data. */
1105 /* First move last chars to start of buffer. */
1106 number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
1108 for ( i = 0; i < number_to_move; ++i )
1109 *(dest++) = *(source++);
1111 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
1112 /* don't do the read, it's not guaranteed to return an EOF,
1113 * just force an EOF
1115 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
1117 else
1119 yy_size_t num_to_read =
1120 YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
1122 while ( num_to_read <= 0 )
1123 { /* Not enough room in the buffer - grow it. */
1125 /* just a shorter name for the current buffer */
1126 YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;
1128 int yy_c_buf_p_offset =
1129 (int) ((yy_c_buf_p) - b->yy_ch_buf);
1131 if ( b->yy_is_our_buffer )
1133 yy_size_t new_size = b->yy_buf_size * 2;
1135 if ( new_size <= 0 )
1136 b->yy_buf_size += b->yy_buf_size / 8;
1137 else
1138 b->yy_buf_size *= 2;
1140 b->yy_ch_buf = (char *)
1141 /* Include room in for 2 EOB chars. */
1142 __ktrfmtrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 );
1144 else
1145 /* Can't grow it, we don't own it. */
1146 b->yy_ch_buf = 0;
1148 if ( ! b->yy_ch_buf )
1149 YY_FATAL_ERROR(
1150 "fatal error - scanner input buffer overflow" );
1152 (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
1154 num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
1155 number_to_move - 1;
1159 if ( num_to_read > YY_READ_BUF_SIZE )
1160 num_to_read = YY_READ_BUF_SIZE;
1162 /* Read in more data. */
1163 YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
1164 (yy_n_chars), num_to_read );
1166 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1169 if ( (yy_n_chars) == 0 )
1171 if ( number_to_move == YY_MORE_ADJ )
1173 ret_val = EOB_ACT_END_OF_FILE;
1174 __ktrfmtrestart(__ktrfmtin );
1177 else
1179 ret_val = EOB_ACT_LAST_MATCH;
1180 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
1181 YY_BUFFER_EOF_PENDING;
1185 else
1186 ret_val = EOB_ACT_CONTINUE_SCAN;
1188 if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
1189 /* Extend the array by 50%, plus the number we really need. */
1190 yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
1191 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) __ktrfmtrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size );
1192 if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1193 YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
1196 (yy_n_chars) += number_to_move;
1197 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
1198 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
1200 (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
1202 return ret_val;
1205 /* yy_get_previous_state - get the state just before the EOB char was reached */
1207 static yy_state_type yy_get_previous_state (void)
1209 register yy_state_type yy_current_state;
1210 register char *yy_cp;
1212 yy_current_state = (yy_start);
1214 for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
1216 register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1217 if ( yy_accept[yy_current_state] )
1219 (yy_last_accepting_state) = yy_current_state;
1220 (yy_last_accepting_cpos) = yy_cp;
1222 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1224 yy_current_state = (int) yy_def[yy_current_state];
1225 if ( yy_current_state >= 26 )
1226 yy_c = yy_meta[(unsigned int) yy_c];
1228 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1231 return yy_current_state;
1234 /* yy_try_NUL_trans - try to make a transition on the NUL character
1236 * synopsis
1237 * next_state = yy_try_NUL_trans( current_state );
1239 static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
1241 register int yy_is_jam;
1242 register char *yy_cp = (yy_c_buf_p);
1244 register YY_CHAR yy_c = 1;
1245 if ( yy_accept[yy_current_state] )
1247 (yy_last_accepting_state) = yy_current_state;
1248 (yy_last_accepting_cpos) = yy_cp;
1250 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1252 yy_current_state = (int) yy_def[yy_current_state];
1253 if ( yy_current_state >= 26 )
1254 yy_c = yy_meta[(unsigned int) yy_c];
1256 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1257 yy_is_jam = (yy_current_state == 25);
1259 return yy_is_jam ? 0 : yy_current_state;
1262 #ifndef YY_NO_INPUT
1263 #ifdef __cplusplus
1264 static int yyinput (void)
1265 #else
1266 static int input (void)
1267 #endif
1270 int c;
1272 *(yy_c_buf_p) = (yy_hold_char);
1274 if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
1276 /* yy_c_buf_p now points to the character we want to return.
1277 * If this occurs *before* the EOB characters, then it's a
1278 * valid NUL; if not, then we've hit the end of the buffer.
1280 if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
1281 /* This was really a NUL. */
1282 *(yy_c_buf_p) = '\0';
1284 else
1285 { /* need more input */
1286 yy_size_t offset = (yy_c_buf_p) - (yytext_ptr);
1287 ++(yy_c_buf_p);
1289 switch ( yy_get_next_buffer( ) )
1291 case EOB_ACT_LAST_MATCH:
1292 /* This happens because yy_g_n_b()
1293 * sees that we've accumulated a
1294 * token and flags that we need to
1295 * try matching the token before
1296 * proceeding. But for input(),
1297 * there's no matching to consider.
1298 * So convert the EOB_ACT_LAST_MATCH
1299 * to EOB_ACT_END_OF_FILE.
1302 /* Reset buffer status. */
1303 __ktrfmtrestart(__ktrfmtin );
1305 /*FALLTHROUGH*/
1307 case EOB_ACT_END_OF_FILE:
1309 if ( __ktrfmtwrap( ) )
1310 return EOF;
1312 if ( ! (yy_did_buffer_switch_on_eof) )
1313 YY_NEW_FILE;
1314 #ifdef __cplusplus
1315 return yyinput();
1316 #else
1317 return input();
1318 #endif
1321 case EOB_ACT_CONTINUE_SCAN:
1322 (yy_c_buf_p) = (yytext_ptr) + offset;
1323 break;
1328 c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
1329 *(yy_c_buf_p) = '\0'; /* preserve __ktrfmttext */
1330 (yy_hold_char) = *++(yy_c_buf_p);
1332 return c;
1334 #endif /* ifndef YY_NO_INPUT */
1336 /** Immediately switch to a different input stream.
1337 * @param input_file A readable stream.
1339 * @note This function does not reset the start condition to @c INITIAL .
1341 void __ktrfmtrestart (FILE * input_file )
1344 if ( ! YY_CURRENT_BUFFER ){
1345 __ktrfmtensure_buffer_stack ();
1346 YY_CURRENT_BUFFER_LVALUE =
1347 __ktrfmt_create_buffer(__ktrfmtin,YY_BUF_SIZE );
1350 __ktrfmt_init_buffer(YY_CURRENT_BUFFER,input_file );
1351 __ktrfmt_load_buffer_state( );
1354 /** Switch to a different input buffer.
1355 * @param new_buffer The new input buffer.
1358 void __ktrfmt_switch_to_buffer (YY_BUFFER_STATE new_buffer )
1361 /* TODO. We should be able to replace this entire function body
1362 * with
1363 * __ktrfmtpop_buffer_state();
1364 * __ktrfmtpush_buffer_state(new_buffer);
1366 __ktrfmtensure_buffer_stack ();
1367 if ( YY_CURRENT_BUFFER == new_buffer )
1368 return;
1370 if ( YY_CURRENT_BUFFER )
1372 /* Flush out information for old buffer. */
1373 *(yy_c_buf_p) = (yy_hold_char);
1374 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1375 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1378 YY_CURRENT_BUFFER_LVALUE = new_buffer;
1379 __ktrfmt_load_buffer_state( );
1381 /* We don't actually know whether we did this switch during
1382 * EOF (__ktrfmtwrap()) processing, but the only time this flag
1383 * is looked at is after __ktrfmtwrap() is called, so it's safe
1384 * to go ahead and always set it.
1386 (yy_did_buffer_switch_on_eof) = 1;
1389 static void __ktrfmt_load_buffer_state (void)
1391 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1392 (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
1393 __ktrfmtin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
1394 (yy_hold_char) = *(yy_c_buf_p);
1397 /** Allocate and initialize an input buffer state.
1398 * @param file A readable stream.
1399 * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
1401 * @return the allocated buffer state.
1403 YY_BUFFER_STATE __ktrfmt_create_buffer (FILE * file, int size )
1405 YY_BUFFER_STATE b;
1407 b = (YY_BUFFER_STATE) __ktrfmtalloc(sizeof( struct yy_buffer_state ) );
1408 if ( ! b )
1409 YY_FATAL_ERROR( "out of dynamic memory in __ktrfmt_create_buffer()" );
1411 b->yy_buf_size = size;
1413 /* yy_ch_buf has to be 2 characters longer than the size given because
1414 * we need to put in 2 end-of-buffer characters.
1416 b->yy_ch_buf = (char *) __ktrfmtalloc(b->yy_buf_size + 2 );
1417 if ( ! b->yy_ch_buf )
1418 YY_FATAL_ERROR( "out of dynamic memory in __ktrfmt_create_buffer()" );
1420 b->yy_is_our_buffer = 1;
1422 __ktrfmt_init_buffer(b,file );
1424 return b;
1427 /** Destroy the buffer.
1428 * @param b a buffer created with __ktrfmt_create_buffer()
1431 void __ktrfmt_delete_buffer (YY_BUFFER_STATE b )
1434 if ( ! b )
1435 return;
1437 if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
1438 YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
1440 if ( b->yy_is_our_buffer )
1441 __ktrfmtfree((void *) b->yy_ch_buf );
1443 __ktrfmtfree((void *) b );
1446 /* Initializes or reinitializes a buffer.
1447 * This function is sometimes called more than once on the same buffer,
1448 * such as during a __ktrfmtrestart() or at EOF.
1450 static void __ktrfmt_init_buffer (YY_BUFFER_STATE b, FILE * file )
1453 int oerrno = errno;
1455 __ktrfmt_flush_buffer(b );
1457 b->yy_input_file = file;
1458 b->yy_fill_buffer = 1;
1460 /* If b is the current buffer, then __ktrfmt_init_buffer was _probably_
1461 * called from __ktrfmtrestart() or through yy_get_next_buffer.
1462 * In that case, we don't want to reset the lineno or column.
1464 if (b != YY_CURRENT_BUFFER){
1465 b->yy_bs_lineno = 1;
1466 b->yy_bs_column = 0;
1469 b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
1471 errno = oerrno;
1474 /** Discard all buffered characters. On the next scan, YY_INPUT will be called.
1475 * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
1478 void __ktrfmt_flush_buffer (YY_BUFFER_STATE b )
1480 if ( ! b )
1481 return;
1483 b->yy_n_chars = 0;
1485 /* We always need two end-of-buffer characters. The first causes
1486 * a transition to the end-of-buffer state. The second causes
1487 * a jam in that state.
1489 b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1490 b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1492 b->yy_buf_pos = &b->yy_ch_buf[0];
1494 b->yy_at_bol = 1;
1495 b->yy_buffer_status = YY_BUFFER_NEW;
1497 if ( b == YY_CURRENT_BUFFER )
1498 __ktrfmt_load_buffer_state( );
1501 /** Pushes the new state onto the stack. The new state becomes
1502 * the current state. This function will allocate the stack
1503 * if necessary.
1504 * @param new_buffer The new state.
1507 void __ktrfmtpush_buffer_state (YY_BUFFER_STATE new_buffer )
1509 if (new_buffer == NULL)
1510 return;
1512 __ktrfmtensure_buffer_stack();
1514 /* This block is copied from __ktrfmt_switch_to_buffer. */
1515 if ( YY_CURRENT_BUFFER )
1517 /* Flush out information for old buffer. */
1518 *(yy_c_buf_p) = (yy_hold_char);
1519 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1520 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1523 /* Only push if top exists. Otherwise, replace top. */
1524 if (YY_CURRENT_BUFFER)
1525 (yy_buffer_stack_top)++;
1526 YY_CURRENT_BUFFER_LVALUE = new_buffer;
1528 /* copied from __ktrfmt_switch_to_buffer. */
1529 __ktrfmt_load_buffer_state( );
1530 (yy_did_buffer_switch_on_eof) = 1;
1533 /** Removes and deletes the top of the stack, if present.
1534 * The next element becomes the new top.
1537 void __ktrfmtpop_buffer_state (void)
1539 if (!YY_CURRENT_BUFFER)
1540 return;
1542 __ktrfmt_delete_buffer(YY_CURRENT_BUFFER );
1543 YY_CURRENT_BUFFER_LVALUE = NULL;
1544 if ((yy_buffer_stack_top) > 0)
1545 --(yy_buffer_stack_top);
1547 if (YY_CURRENT_BUFFER) {
1548 __ktrfmt_load_buffer_state( );
1549 (yy_did_buffer_switch_on_eof) = 1;
1553 /* Allocates the stack if it does not exist.
1554 * Guarantees space for at least one push.
1556 static void __ktrfmtensure_buffer_stack (void)
1558 yy_size_t num_to_alloc;
1560 if (!(yy_buffer_stack)) {
1562 /* First allocation is just for 2 elements, since we don't know if this
1563 * scanner will even need a stack. We use 2 instead of 1 to avoid an
1564 * immediate realloc on the next call.
1566 num_to_alloc = 1;
1567 (yy_buffer_stack) = (struct yy_buffer_state**)__ktrfmtalloc
1568 (num_to_alloc * sizeof(struct yy_buffer_state*)
1570 if ( ! (yy_buffer_stack) )
1571 YY_FATAL_ERROR( "out of dynamic memory in __ktrfmtensure_buffer_stack()" );
1573 memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
1575 (yy_buffer_stack_max) = num_to_alloc;
1576 (yy_buffer_stack_top) = 0;
1577 return;
1580 if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
1582 /* Increase the buffer to prepare for a possible push. */
1583 int grow_size = 8 /* arbitrary grow size */;
1585 num_to_alloc = (yy_buffer_stack_max) + grow_size;
1586 (yy_buffer_stack) = (struct yy_buffer_state**)__ktrfmtrealloc
1587 ((yy_buffer_stack),
1588 num_to_alloc * sizeof(struct yy_buffer_state*)
1590 if ( ! (yy_buffer_stack) )
1591 YY_FATAL_ERROR( "out of dynamic memory in __ktrfmtensure_buffer_stack()" );
1593 /* zero only the new slots.*/
1594 memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
1595 (yy_buffer_stack_max) = num_to_alloc;
1599 /** Setup the input buffer state to scan directly from a user-specified character buffer.
1600 * @param base the character buffer
1601 * @param size the size in bytes of the character buffer
1603 * @return the newly allocated buffer state object.
1605 YY_BUFFER_STATE __ktrfmt_scan_buffer (char * base, yy_size_t size )
1607 YY_BUFFER_STATE b;
1609 if ( size < 2 ||
1610 base[size-2] != YY_END_OF_BUFFER_CHAR ||
1611 base[size-1] != YY_END_OF_BUFFER_CHAR )
1612 /* They forgot to leave room for the EOB's. */
1613 return 0;
1615 b = (YY_BUFFER_STATE) __ktrfmtalloc(sizeof( struct yy_buffer_state ) );
1616 if ( ! b )
1617 YY_FATAL_ERROR( "out of dynamic memory in __ktrfmt_scan_buffer()" );
1619 b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
1620 b->yy_buf_pos = b->yy_ch_buf = base;
1621 b->yy_is_our_buffer = 0;
1622 b->yy_input_file = 0;
1623 b->yy_n_chars = b->yy_buf_size;
1624 b->yy_is_interactive = 0;
1625 b->yy_at_bol = 1;
1626 b->yy_fill_buffer = 0;
1627 b->yy_buffer_status = YY_BUFFER_NEW;
1629 __ktrfmt_switch_to_buffer(b );
1631 return b;
1634 /** Setup the input buffer state to scan a string. The next call to __ktrfmtlex() will
1635 * scan from a @e copy of @a str.
1636 * @param yystr a NUL-terminated string to scan
1638 * @return the newly allocated buffer state object.
1639 * @note If you want to scan bytes that may contain NUL values, then use
1640 * __ktrfmt_scan_bytes() instead.
1642 YY_BUFFER_STATE __ktrfmt_scan_string (yyconst char * yystr )
1645 return __ktrfmt_scan_bytes(yystr,strlen(yystr) );
1648 /** Setup the input buffer state to scan the given bytes. The next call to __ktrfmtlex() will
1649 * scan from a @e copy of @a bytes.
1650 * @param yybytes the byte buffer to scan
1651 * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
1653 * @return the newly allocated buffer state object.
1655 YY_BUFFER_STATE __ktrfmt_scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len )
1657 YY_BUFFER_STATE b;
1658 char *buf;
1659 yy_size_t n;
1660 int i;
1662 /* Get memory for full buffer, including space for trailing EOB's. */
1663 n = _yybytes_len + 2;
1664 buf = (char *) __ktrfmtalloc(n );
1665 if ( ! buf )
1666 YY_FATAL_ERROR( "out of dynamic memory in __ktrfmt_scan_bytes()" );
1668 for ( i = 0; i < _yybytes_len; ++i )
1669 buf[i] = yybytes[i];
1671 buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
1673 b = __ktrfmt_scan_buffer(buf,n );
1674 if ( ! b )
1675 YY_FATAL_ERROR( "bad buffer in __ktrfmt_scan_bytes()" );
1677 /* It's okay to grow etc. this buffer, and we should throw it
1678 * away when we're done.
1680 b->yy_is_our_buffer = 1;
1682 return b;
1685 #ifndef YY_EXIT_FAILURE
1686 #define YY_EXIT_FAILURE 2
1687 #endif
1689 static void yy_fatal_error (yyconst char* msg )
1691 (void) fprintf( stderr, "%s\n", msg );
1692 exit( YY_EXIT_FAILURE );
1695 /* Redefine yyless() so it works in section 3 code. */
1697 #undef yyless
1698 #define yyless(n) \
1699 do \
1701 /* Undo effects of setting up __ktrfmttext. */ \
1702 int yyless_macro_arg = (n); \
1703 YY_LESS_LINENO(yyless_macro_arg);\
1704 __ktrfmttext[__ktrfmtleng] = (yy_hold_char); \
1705 (yy_c_buf_p) = __ktrfmttext + yyless_macro_arg; \
1706 (yy_hold_char) = *(yy_c_buf_p); \
1707 *(yy_c_buf_p) = '\0'; \
1708 __ktrfmtleng = yyless_macro_arg; \
1710 while ( 0 )
1712 /* Accessor methods (get/set functions) to struct members. */
1714 /** Get the current line number.
1717 int __ktrfmtget_lineno (void)
1720 return __ktrfmtlineno;
1723 /** Get the input stream.
1726 FILE *__ktrfmtget_in (void)
1728 return __ktrfmtin;
1731 /** Get the output stream.
1734 FILE *__ktrfmtget_out (void)
1736 return __ktrfmtout;
1739 /** Get the length of the current token.
1742 yy_size_t __ktrfmtget_leng (void)
1744 return __ktrfmtleng;
1747 /** Get the current token.
1751 char *__ktrfmtget_text (void)
1753 return __ktrfmttext;
1756 /** Set the current line number.
1757 * @param line_number
1760 void __ktrfmtset_lineno (int line_number )
1763 __ktrfmtlineno = line_number;
1766 /** Set the input stream. This does not discard the current
1767 * input buffer.
1768 * @param in_str A readable stream.
1770 * @see __ktrfmt_switch_to_buffer
1772 void __ktrfmtset_in (FILE * in_str )
1774 __ktrfmtin = in_str ;
1777 void __ktrfmtset_out (FILE * out_str )
1779 __ktrfmtout = out_str ;
1782 int __ktrfmtget_debug (void)
1784 return __ktrfmt_flex_debug;
1787 void __ktrfmtset_debug (int bdebug )
1789 __ktrfmt_flex_debug = bdebug ;
1792 static int yy_init_globals (void)
1794 /* Initialization is the same as for the non-reentrant scanner.
1795 * This function is called from __ktrfmtlex_destroy(), so don't allocate here.
1798 (yy_buffer_stack) = 0;
1799 (yy_buffer_stack_top) = 0;
1800 (yy_buffer_stack_max) = 0;
1801 (yy_c_buf_p) = (char *) 0;
1802 (yy_init) = 0;
1803 (yy_start) = 0;
1805 /* Defined in main.c */
1806 #ifdef YY_STDINIT
1807 __ktrfmtin = stdin;
1808 __ktrfmtout = stdout;
1809 #else
1810 __ktrfmtin = (FILE *) 0;
1811 __ktrfmtout = (FILE *) 0;
1812 #endif
1814 /* For future reference: Set errno on error, since we are called by
1815 * __ktrfmtlex_init()
1817 return 0;
1820 /* __ktrfmtlex_destroy is for both reentrant and non-reentrant scanners. */
1821 int __ktrfmtlex_destroy (void)
1824 /* Pop the buffer stack, destroying each element. */
1825 while(YY_CURRENT_BUFFER){
1826 __ktrfmt_delete_buffer(YY_CURRENT_BUFFER );
1827 YY_CURRENT_BUFFER_LVALUE = NULL;
1828 __ktrfmtpop_buffer_state();
1831 /* Destroy the stack itself. */
1832 __ktrfmtfree((yy_buffer_stack) );
1833 (yy_buffer_stack) = NULL;
1835 /* Reset the globals. This is important in a non-reentrant scanner so the next time
1836 * __ktrfmtlex() is called, initialization will occur. */
1837 yy_init_globals( );
1839 return 0;
1843 * Internal utility routines.
1846 #ifndef yytext_ptr
1847 static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
1849 register int i;
1850 for ( i = 0; i < n; ++i )
1851 s1[i] = s2[i];
1853 #endif
1855 #ifdef YY_NEED_STRLEN
1856 static int yy_flex_strlen (yyconst char * s )
1858 register int n;
1859 for ( n = 0; s[n]; ++n )
1862 return n;
1864 #endif
1866 void *__ktrfmtalloc (yy_size_t size )
1868 return (void *) malloc( size );
1871 void *__ktrfmtrealloc (void * ptr, yy_size_t size )
1873 /* The cast to (char *) in the following accommodates both
1874 * implementations that use char* generic pointers, and those
1875 * that use void* generic pointers. It works with the latter
1876 * because both ANSI C and C++ allow castless assignment from
1877 * any pointer type to void*, and deal with argument conversions
1878 * as though doing an assignment.
1880 return (void *) realloc( (char *) ptr, size );
1883 void __ktrfmtfree (void * ptr )
1885 free( (char *) ptr ); /* see __ktrfmtrealloc() for (char *) cast */
1888 #define YYTABLES_NAME "yytables"
1890 #line 137 "ktrfmt.l"