1 #line 2 "dtc-lexer.lex.c"
3 #line 4 "dtc-lexer.lex.c"
5 #define YY_INT_ALIGNED short int
7 /* A lexical scanner generated by flex */
10 #define YY_FLEX_MAJOR_VERSION 2
11 #define YY_FLEX_MINOR_VERSION 5
12 #define YY_FLEX_SUBMINOR_VERSION 35
13 #if YY_FLEX_SUBMINOR_VERSION > 0
17 /* First, we deal with platform-specific or compiler-specific issues. */
19 /* begin standard C headers. */
25 /* end standard C headers. */
27 /* flex integer type definitions */
32 /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
34 #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
36 /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
37 * if you want the limit (max/min) macros for int types.
39 #ifndef __STDC_LIMIT_MACROS
40 #define __STDC_LIMIT_MACROS 1
44 typedef int8_t flex_int8_t;
45 typedef uint8_t flex_uint8_t;
46 typedef int16_t flex_int16_t;
47 typedef uint16_t flex_uint16_t;
48 typedef int32_t flex_int32_t;
49 typedef uint32_t flex_uint32_t;
51 typedef signed char flex_int8_t;
52 typedef short int flex_int16_t;
53 typedef int flex_int32_t;
54 typedef unsigned char flex_uint8_t;
55 typedef unsigned short int flex_uint16_t;
56 typedef unsigned int flex_uint32_t;
58 /* Limits of integral types. */
60 #define INT8_MIN (-128)
63 #define INT16_MIN (-32767-1)
66 #define INT32_MIN (-2147483647-1)
69 #define INT8_MAX (127)
72 #define INT16_MAX (32767)
75 #define INT32_MAX (2147483647)
78 #define UINT8_MAX (255U)
81 #define UINT16_MAX (65535U)
84 #define UINT32_MAX (4294967295U)
89 #endif /* ! FLEXINT_H */
93 /* The "const" storage-class-modifier is valid. */
96 #else /* ! __cplusplus */
98 /* C99 requires __STDC__ to be defined as 1. */
99 #if defined (__STDC__)
103 #endif /* defined (__STDC__) */
104 #endif /* ! __cplusplus */
107 #define yyconst const
112 /* Returned upon end-of-file. */
115 /* Promotes a possibly negative, possibly signed char to an unsigned
116 * integer for use as an array index. If the signed char is negative,
117 * we want to instead treat it as an 8-bit unsigned char, hence the
120 #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
122 /* Enter a start condition. This macro really ought to take a parameter,
123 * but we do it the disgusting crufty way forced on us by the ()-less
124 * definition of BEGIN.
126 #define BEGIN (yy_start) = 1 + 2 *
128 /* Translate the current start state into a value that can be later handed
129 * to BEGIN to return to the state. The YYSTATE alias is for lex
132 #define YY_START (((yy_start) - 1) / 2)
133 #define YYSTATE YY_START
135 /* Action number for EOF rule of a given start state. */
136 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
138 /* Special action meaning "start processing a new file". */
139 #define YY_NEW_FILE yyrestart(yyin )
141 #define YY_END_OF_BUFFER_CHAR 0
143 /* Size of default input buffer. */
146 /* On IA-64, the buffer size is 16k, not 8k.
147 * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
148 * Ditto for the __ia64__ case accordingly.
150 #define YY_BUF_SIZE 32768
152 #define YY_BUF_SIZE 16384
153 #endif /* __ia64__ */
156 /* The state buf must be large enough to hold one state per character in the main buffer.
158 #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
160 #ifndef YY_TYPEDEF_YY_BUFFER_STATE
161 #define YY_TYPEDEF_YY_BUFFER_STATE
162 typedef struct yy_buffer_state *YY_BUFFER_STATE;
167 extern FILE *yyin, *yyout;
169 #define EOB_ACT_CONTINUE_SCAN 0
170 #define EOB_ACT_END_OF_FILE 1
171 #define EOB_ACT_LAST_MATCH 2
173 /* Note: We specifically omit the test for yy_rule_can_match_eol because it requires
174 * access to the local variable yy_act. Since yyless() is a macro, it would break
175 * existing scanners that call yyless() from OUTSIDE yylex.
176 * One obvious solution it to make yy_act a global. I tried that, and saw
177 * a 5% performance hit in a non-yylineno scanner, because yy_act is
178 * normally declared as a register variable-- so it is not worth it.
180 #define YY_LESS_LINENO(n) \
183 for ( yyl = n; yyl < yyleng; ++yyl )\
184 if ( yytext[yyl] == '\n' )\
188 /* Return all but the first "n" matched characters back to the input stream. */
192 /* Undo effects of setting up yytext. */ \
193 int yyless_macro_arg = (n); \
194 YY_LESS_LINENO(yyless_macro_arg);\
195 *yy_cp = (yy_hold_char); \
196 YY_RESTORE_YY_MORE_OFFSET \
197 (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
198 YY_DO_BEFORE_ACTION; /* set up yytext again */ \
202 #define unput(c) yyunput( c, (yytext_ptr) )
204 #ifndef YY_TYPEDEF_YY_SIZE_T
205 #define YY_TYPEDEF_YY_SIZE_T
206 typedef size_t yy_size_t;
209 #ifndef YY_STRUCT_YY_BUFFER_STATE
210 #define YY_STRUCT_YY_BUFFER_STATE
211 struct yy_buffer_state
215 char *yy_ch_buf; /* input buffer */
216 char *yy_buf_pos; /* current position in input buffer */
218 /* Size of input buffer in bytes, not including room for EOB
221 yy_size_t yy_buf_size;
223 /* Number of characters read into yy_ch_buf, not including EOB
228 /* Whether we "own" the buffer - i.e., we know we created it,
229 * and can realloc() it to grow it, and should free() it to
232 int yy_is_our_buffer;
234 /* Whether this is an "interactive" input source; if so, and
235 * if we're using stdio for input, then we want to use getc()
236 * instead of fread(), to make sure we stop fetching input after
239 int yy_is_interactive;
241 /* Whether we're considered to be at the beginning of a line.
242 * If so, '^' rules will be active on the next match, otherwise
247 int yy_bs_lineno; /**< The line count. */
248 int yy_bs_column; /**< The column count. */
250 /* Whether to try to fill the input buffer when we reach the
255 int yy_buffer_status;
257 #define YY_BUFFER_NEW 0
258 #define YY_BUFFER_NORMAL 1
259 /* When an EOF's been seen but there's still some text to process
260 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
261 * shouldn't try reading from the input source any more. We might
262 * still have a bunch of tokens to match, though, because of
263 * possible backing-up.
265 * When we actually see the EOF, we change the status to "new"
266 * (via yyrestart()), so that the user can continue scanning by
267 * just pointing yyin at a new input file.
269 #define YY_BUFFER_EOF_PENDING 2
272 #endif /* !YY_STRUCT_YY_BUFFER_STATE */
274 /* Stack of input buffers. */
275 static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
276 static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
277 static YY_BUFFER_STATE * yy_buffer_stack = 0; /**< Stack as an array. */
279 /* We provide macros for accessing buffer states in case in the
280 * future we want to put the buffer states in a more general
283 * Returns the top of the stack, or NULL.
285 #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
286 ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
289 /* Same as previous macro, but useful when we know that the buffer stack is not
290 * NULL or when we need an lvalue. For internal use only.
292 #define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
294 /* yy_hold_char holds the character lost when yytext is formed. */
295 static char yy_hold_char;
296 static int yy_n_chars; /* number of characters read into yy_ch_buf */
299 /* Points to current character in buffer. */
300 static char *yy_c_buf_p = (char *) 0;
301 static int yy_init = 0; /* whether we need to initialize */
302 static int yy_start = 0; /* start state number */
304 /* Flag which is used to allow yywrap()'s to do buffer switches
305 * instead of setting up a fresh yyin. A bit of a hack ...
307 static int yy_did_buffer_switch_on_eof;
309 void yyrestart (FILE *input_file );
310 void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer );
311 YY_BUFFER_STATE yy_create_buffer (FILE *file,int size );
312 void yy_delete_buffer (YY_BUFFER_STATE b );
313 void yy_flush_buffer (YY_BUFFER_STATE b );
314 void yypush_buffer_state (YY_BUFFER_STATE new_buffer );
315 void yypop_buffer_state (void );
317 static void yyensure_buffer_stack (void );
318 static void yy_load_buffer_state (void );
319 static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file );
321 #define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER )
323 YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size );
324 YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str );
325 YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,int len );
327 void *yyalloc (yy_size_t );
328 void *yyrealloc (void *,yy_size_t );
329 void yyfree (void * );
331 #define yy_new_buffer yy_create_buffer
333 #define yy_set_interactive(is_interactive) \
335 if ( ! YY_CURRENT_BUFFER ){ \
336 yyensure_buffer_stack (); \
337 YY_CURRENT_BUFFER_LVALUE = \
338 yy_create_buffer(yyin,YY_BUF_SIZE ); \
340 YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
343 #define yy_set_bol(at_bol) \
345 if ( ! YY_CURRENT_BUFFER ){\
346 yyensure_buffer_stack (); \
347 YY_CURRENT_BUFFER_LVALUE = \
348 yy_create_buffer(yyin,YY_BUF_SIZE ); \
350 YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
353 #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
355 /* Begin user sect3 */
358 #define YY_SKIP_YYWRAP
360 typedef unsigned char YY_CHAR;
362 FILE *yyin = (FILE *) 0, *yyout = (FILE *) 0;
364 typedef int yy_state_type;
371 #define yytext_ptr yytext
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[] );
378 /* Done after the current pattern has been matched and before the
379 * corresponding action - sets up yytext.
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; \
386 (yy_c_buf_p) = yy_cp;
388 #define YY_NUM_RULES 20
389 #define YY_END_OF_BUFFER 21
390 /* This struct is not used in this scanner,
391 but its presence is necessary. */
394 flex_int32_t yy_verify;
397 static yyconst flex_int16_t yy_accept[104] =
399 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
400 21, 19, 16, 16, 19, 19, 19, 7, 7, 19,
401 7, 19, 19, 19, 19, 13, 14, 14, 19, 8,
402 8, 16, 0, 2, 0, 0, 9, 0, 0, 0,
403 0, 0, 0, 7, 7, 5, 0, 6, 0, 12,
404 12, 14, 14, 8, 0, 11, 9, 0, 0, 0,
405 0, 18, 0, 0, 0, 0, 8, 0, 17, 0,
406 0, 0, 0, 0, 10, 0, 0, 0, 0, 0,
407 0, 0, 0, 0, 0, 0, 0, 0, 3, 15,
408 0, 0, 0, 0, 0, 0, 0, 0, 1, 0,
413 static yyconst flex_int32_t yy_ec[256] =
415 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
416 2, 2, 2, 1, 1, 1, 1, 1, 1, 1,
417 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
418 1, 2, 1, 4, 5, 1, 1, 6, 1, 1,
419 1, 7, 8, 8, 9, 8, 10, 11, 12, 13,
420 13, 13, 13, 13, 13, 13, 13, 14, 1, 1,
421 1, 1, 8, 8, 15, 15, 15, 15, 15, 15,
422 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
423 16, 16, 16, 16, 16, 16, 16, 17, 16, 16,
424 1, 18, 19, 1, 16, 1, 15, 20, 21, 22,
426 23, 15, 16, 24, 25, 16, 16, 26, 27, 28,
427 24, 16, 16, 29, 30, 31, 32, 33, 16, 17,
428 16, 16, 34, 1, 35, 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, 1, 1, 1, 1, 1,
432 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
433 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
434 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
435 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
437 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
438 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
439 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
440 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
441 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
445 static yyconst flex_int32_t yy_meta[36] =
447 1, 1, 1, 1, 2, 1, 2, 2, 2, 3,
448 4, 4, 4, 5, 6, 7, 7, 1, 1, 6,
449 6, 6, 6, 7, 7, 7, 7, 7, 7, 7,
453 static yyconst flex_int16_t yy_base[117] =
455 0, 0, 30, 0, 44, 0, 67, 0, 97, 105,
456 302, 303, 35, 44, 40, 94, 112, 0, 129, 152,
457 296, 295, 159, 0, 176, 303, 0, 116, 95, 165,
458 49, 46, 102, 303, 296, 0, 0, 288, 290, 293,
459 264, 266, 270, 0, 0, 303, 0, 303, 264, 303,
460 0, 0, 195, 101, 0, 0, 0, 0, 284, 125,
461 277, 265, 225, 230, 216, 218, 0, 202, 224, 221,
462 217, 107, 196, 188, 303, 206, 179, 186, 178, 185,
463 183, 162, 161, 150, 169, 160, 145, 125, 303, 303,
464 137, 109, 190, 103, 203, 167, 108, 197, 303, 123,
466 29, 303, 303, 215, 221, 226, 229, 234, 240, 246,
467 250, 257, 265, 270, 275, 282
470 static yyconst flex_int16_t yy_def[117] =
472 103, 1, 1, 3, 3, 5, 103, 7, 3, 3,
473 103, 103, 103, 103, 104, 105, 103, 106, 103, 19,
474 19, 20, 103, 107, 20, 103, 108, 109, 105, 103,
475 103, 103, 104, 103, 104, 110, 111, 103, 112, 113,
476 103, 103, 103, 106, 19, 103, 20, 103, 103, 103,
477 20, 108, 109, 103, 114, 110, 111, 115, 112, 112,
478 113, 103, 103, 103, 103, 103, 114, 115, 103, 103,
479 103, 103, 103, 103, 103, 103, 103, 103, 103, 103,
480 103, 103, 103, 103, 103, 103, 103, 103, 103, 103,
481 103, 103, 103, 103, 103, 116, 103, 116, 103, 116,
483 103, 103, 0, 103, 103, 103, 103, 103, 103, 103,
484 103, 103, 103, 103, 103, 103
487 static yyconst flex_int16_t yy_nxt[339] =
489 12, 13, 14, 15, 12, 16, 12, 12, 12, 17,
490 18, 18, 18, 12, 19, 20, 20, 12, 12, 21,
491 19, 21, 19, 22, 20, 20, 20, 20, 20, 20,
492 20, 20, 20, 12, 12, 12, 32, 32, 102, 23,
493 12, 12, 12, 34, 20, 32, 32, 32, 32, 20,
494 20, 20, 20, 20, 24, 24, 24, 35, 25, 54,
495 54, 54, 26, 25, 25, 25, 25, 12, 13, 14,
496 15, 27, 12, 27, 27, 27, 23, 27, 27, 27,
497 12, 28, 28, 28, 12, 12, 28, 28, 28, 28,
498 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
500 12, 12, 29, 36, 103, 34, 17, 30, 31, 31,
501 29, 54, 54, 54, 17, 30, 31, 31, 39, 35,
502 52, 40, 52, 52, 52, 103, 78, 38, 38, 46,
503 101, 60, 79, 41, 69, 97, 42, 94, 43, 45,
504 45, 45, 46, 45, 47, 47, 93, 92, 45, 45,
505 45, 45, 47, 47, 47, 47, 47, 47, 47, 47,
506 47, 47, 47, 47, 47, 39, 47, 91, 40, 90,
507 99, 47, 47, 47, 47, 54, 54, 54, 89, 88,
508 41, 55, 87, 49, 100, 43, 51, 51, 51, 86,
509 51, 95, 95, 96, 85, 51, 51, 51, 51, 52,
511 99, 52, 52, 52, 95, 95, 96, 84, 46, 83,
512 82, 81, 39, 79, 100, 33, 33, 33, 33, 33,
513 33, 33, 33, 37, 80, 77, 37, 37, 37, 44,
514 40, 44, 50, 76, 50, 52, 75, 52, 74, 52,
515 52, 53, 73, 53, 53, 53, 53, 56, 56, 56,
516 72, 56, 56, 57, 71, 57, 57, 59, 59, 59,
517 59, 59, 59, 59, 59, 61, 61, 61, 61, 61,
518 61, 61, 61, 67, 70, 67, 68, 68, 68, 62,
519 68, 68, 98, 98, 98, 98, 98, 98, 98, 98,
520 60, 66, 65, 64, 63, 62, 60, 58, 103, 48,
522 48, 103, 11, 103, 103, 103, 103, 103, 103, 103,
523 103, 103, 103, 103, 103, 103, 103, 103, 103, 103,
524 103, 103, 103, 103, 103, 103, 103, 103, 103, 103,
525 103, 103, 103, 103, 103, 103, 103, 103
528 static yyconst flex_int16_t yy_chk[339] =
530 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
531 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
532 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
533 1, 1, 1, 1, 1, 3, 13, 13, 101, 3,
534 3, 3, 3, 15, 3, 14, 14, 32, 32, 3,
535 3, 3, 3, 3, 5, 5, 5, 15, 5, 31,
536 31, 31, 5, 5, 5, 5, 5, 7, 7, 7,
537 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
538 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
539 7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
541 7, 7, 9, 16, 29, 33, 9, 9, 9, 9,
542 10, 54, 54, 54, 10, 10, 10, 10, 17, 33,
543 28, 17, 28, 28, 28, 100, 72, 16, 29, 28,
544 97, 60, 72, 17, 60, 94, 17, 92, 17, 19,
545 19, 19, 19, 19, 19, 19, 91, 88, 19, 19,
546 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,
547 19, 19, 20, 20, 20, 23, 20, 87, 23, 86,
548 96, 20, 20, 20, 20, 30, 30, 30, 85, 84,
549 23, 30, 83, 23, 96, 23, 25, 25, 25, 82,
550 25, 93, 93, 93, 81, 25, 25, 25, 25, 53,
552 98, 53, 53, 53, 95, 95, 95, 80, 53, 79,
553 78, 77, 76, 74, 98, 104, 104, 104, 104, 104,
554 104, 104, 104, 105, 73, 71, 105, 105, 105, 106,
555 70, 106, 107, 69, 107, 108, 68, 108, 66, 108,
556 108, 109, 65, 109, 109, 109, 109, 110, 110, 110,
557 64, 110, 110, 111, 63, 111, 111, 112, 112, 112,
558 112, 112, 112, 112, 112, 113, 113, 113, 113, 113,
559 113, 113, 113, 114, 62, 114, 115, 115, 115, 61,
560 115, 115, 116, 116, 116, 116, 116, 116, 116, 116,
561 59, 49, 43, 42, 41, 40, 39, 38, 35, 22,
563 21, 11, 103, 103, 103, 103, 103, 103, 103, 103,
564 103, 103, 103, 103, 103, 103, 103, 103, 103, 103,
565 103, 103, 103, 103, 103, 103, 103, 103, 103, 103,
566 103, 103, 103, 103, 103, 103, 103, 103
569 /* Table of booleans, true if rule could match eol. */
570 static yyconst flex_int32_t yy_rule_can_match_eol[21] =
572 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 0,
575 static yy_state_type yy_last_accepting_state;
576 static char *yy_last_accepting_cpos;
578 extern int yy_flex_debug;
579 int yy_flex_debug = 0;
581 /* The intent behind this definition is that it'll catch
582 * any uses of REJECT which flex missed.
584 #define REJECT reject_used_but_not_detected
585 #define yymore() yymore_used_but_not_detected
586 #define YY_MORE_ADJ 0
587 #define YY_RESTORE_YY_MORE_OFFSET
589 #line 1 "dtc-lexer.l"
591 * (C) Copyright David Gibson <dwg@au1.ibm.com>, IBM Corporation. 2005.
594 * This program is free software; you can redistribute it and/or
595 * modify it under the terms of the GNU General Public License as
596 * published by the Free Software Foundation; either version 2 of the
597 * License, or (at your option) any later version.
599 * This program is distributed in the hope that it will be useful,
600 * but WITHOUT ANY WARRANTY; without even the implied warranty of
601 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
602 * General Public License for more details.
604 * You should have received a copy of the GNU General Public License
605 * along with this program; if not, write to the Free Software
606 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
609 #define YY_NO_INPUT 1
614 #line 37 "dtc-lexer.l"
617 #include "dtc-parser.tab.h"
620 /*#define LEXDEBUG 1*/
623 #define DPRINT(fmt, ...) fprintf(stderr, fmt, ##__VA_ARGS__)
625 #define DPRINT(fmt, ...) do { } while (0)
628 static int dts_version; /* = 0 */
630 #define BEGIN_DEFAULT() if (dts_version == 0) { \
631 DPRINT("<INITIAL>\n"); \
638 static void push_input_file(const char *filename);
639 static int pop_input_file(void);
640 #line 641 "dtc-lexer.lex.c"
645 #define PROPNODENAME 3
648 #ifndef YY_NO_UNISTD_H
649 /* Special case for "unistd.h", since it is non-ANSI. We include it way
650 * down here because we want the user's section 1 to have been scanned first.
651 * The user has a chance to override it with an option.
656 #ifndef YY_EXTRA_TYPE
657 #define YY_EXTRA_TYPE void *
660 static int yy_init_globals (void );
662 /* Accessor methods to globals.
663 These are made visible to non-reentrant scanners for convenience. */
665 int yylex_destroy (void );
667 int yyget_debug (void );
669 void yyset_debug (int debug_flag );
671 YY_EXTRA_TYPE yyget_extra (void );
673 void yyset_extra (YY_EXTRA_TYPE user_defined );
675 FILE *yyget_in (void );
677 void yyset_in (FILE * in_str );
679 FILE *yyget_out (void );
681 void yyset_out (FILE * out_str );
683 int yyget_leng (void );
685 char *yyget_text (void );
687 int yyget_lineno (void );
689 void yyset_lineno (int line_number );
691 /* Macros after this point can all be overridden by user definitions in
695 #ifndef YY_SKIP_YYWRAP
697 extern "C" int yywrap (void );
699 extern int yywrap (void );
704 static void yy_flex_strncpy (char *,yyconst char *,int );
707 #ifdef YY_NEED_STRLEN
708 static int yy_flex_strlen (yyconst char * );
714 static int yyinput (void );
716 static int input (void );
721 /* Amount of stuff to slurp up with each read. */
722 #ifndef YY_READ_BUF_SIZE
724 /* On IA-64, the buffer size is 16k, not 8k */
725 #define YY_READ_BUF_SIZE 16384
727 #define YY_READ_BUF_SIZE 8192
728 #endif /* __ia64__ */
731 /* Copy whatever the last rule matched to the standard output. */
733 /* This used to be an fputs(), but since the string might contain NUL's,
734 * we now use fwrite().
736 #define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0)
739 /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
740 * is returned in "result".
743 #define YY_INPUT(buf,result,max_size) \
744 if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
748 for ( n = 0; n < max_size && \
749 (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
752 buf[n++] = (char) c; \
753 if ( c == EOF && ferror( yyin ) ) \
754 YY_FATAL_ERROR( "input in flex scanner failed" ); \
760 while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
762 if( errno != EINTR) \
764 YY_FATAL_ERROR( "input in flex scanner failed" ); \
775 /* No semi-colon after return; correct usage is to write "yyterminate();" -
776 * we don't want an extra ';' after the "return" because that will cause
777 * some compilers to complain about unreachable statements.
780 #define yyterminate() return YY_NULL
783 /* Number of entries by which start-condition stack grows. */
784 #ifndef YY_START_STACK_INCR
785 #define YY_START_STACK_INCR 25
788 /* Report a fatal error. */
789 #ifndef YY_FATAL_ERROR
790 #define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
793 /* end tables serialization structures and prototypes */
795 /* Default declaration of generated scanner - a define so the user can
796 * easily add parameters.
799 #define YY_DECL_IS_OURS 1
801 extern int yylex (void);
803 #define YY_DECL int yylex (void)
804 #endif /* !YY_DECL */
806 /* Code executed at the beginning of each rule, after yytext and yyleng
809 #ifndef YY_USER_ACTION
810 #define YY_USER_ACTION
813 /* Code executed at the end of each rule. */
815 #define YY_BREAK break;
818 #define YY_RULE_SETUP \
821 /** The main scanner function which does all the work.
825 register yy_state_type yy_current_state;
826 register char *yy_cp, *yy_bp;
829 #line 64 "dtc-lexer.l"
831 #line 832 "dtc-lexer.lex.c"
842 (yy_start) = 1; /* first start state */
850 if ( ! YY_CURRENT_BUFFER ) {
851 yyensure_buffer_stack ();
852 YY_CURRENT_BUFFER_LVALUE =
853 yy_create_buffer(yyin,YY_BUF_SIZE );
856 yy_load_buffer_state( );
859 while ( 1 ) /* loops until end-of-file is reached */
861 yy_cp = (yy_c_buf_p);
863 /* Support of yytext. */
864 *yy_cp = (yy_hold_char);
866 /* yy_bp points to the position in yy_ch_buf of the start of
871 yy_current_state = (yy_start);
875 register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
876 if ( yy_accept[yy_current_state] )
878 (yy_last_accepting_state) = yy_current_state;
879 (yy_last_accepting_cpos) = yy_cp;
881 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
883 yy_current_state = (int) yy_def[yy_current_state];
884 if ( yy_current_state >= 104 )
885 yy_c = yy_meta[(unsigned int) yy_c];
887 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
890 while ( yy_base[yy_current_state] != 303 );
893 yy_act = yy_accept[yy_current_state];
895 { /* have to back up */
896 yy_cp = (yy_last_accepting_cpos);
897 yy_current_state = (yy_last_accepting_state);
898 yy_act = yy_accept[yy_current_state];
903 if ( yy_act != YY_END_OF_BUFFER && yy_rule_can_match_eol[yy_act] )
906 for ( yyl = 0; yyl < yyleng; ++yyl )
907 if ( yytext[yyl] == '\n' )
913 do_action: /* This label is used only to access EOF actions. */
916 { /* beginning of action switch */
917 case 0: /* must back up */
918 /* undo the effects of YY_DO_BEFORE_ACTION */
919 *yy_cp = (yy_hold_char);
920 yy_cp = (yy_last_accepting_cpos);
921 yy_current_state = (yy_last_accepting_state);
925 /* rule 1 can match eol */
927 #line 65 "dtc-lexer.l"
929 char *name = strchr(yytext, '\"') + 1;
930 yytext[yyleng-1] = '\0';
931 push_input_file(name);
934 case YY_STATE_EOF(INITIAL):
935 case YY_STATE_EOF(INCLUDE):
936 case YY_STATE_EOF(BYTESTRING):
937 case YY_STATE_EOF(PROPNODENAME):
938 case YY_STATE_EOF(V1):
939 #line 71 "dtc-lexer.l"
941 if (!pop_input_file()) {
947 /* rule 2 can match eol */
949 #line 77 "dtc-lexer.l"
951 yylloc.file = srcpos_file;
952 yylloc.first_line = yylineno;
953 DPRINT("String: %s\n", yytext);
954 yylval.data = data_copy_escape_string(yytext+1,
956 yylloc.first_line = yylineno;
962 #line 87 "dtc-lexer.l"
964 yylloc.file = srcpos_file;
965 yylloc.first_line = yylineno;
966 DPRINT("Keyword: /dts-v1/\n");
974 #line 96 "dtc-lexer.l"
976 yylloc.file = srcpos_file;
977 yylloc.first_line = yylineno;
978 DPRINT("Keyword: /memreserve/\n");
980 return DT_MEMRESERVE;
985 #line 104 "dtc-lexer.l"
987 yylloc.file = srcpos_file;
988 yylloc.first_line = yylineno;
989 DPRINT("Label: %s\n", yytext);
990 yylval.labelref = strdup(yytext);
991 yylval.labelref[yyleng-1] = '\0';
997 #line 113 "dtc-lexer.l"
999 yylloc.file = srcpos_file;
1000 yylloc.first_line = yylineno;
1003 else if (*yytext == 'o')
1005 else if (*yytext == 'd')
1009 DPRINT("Base: %d\n", yylval.cbase);
1015 #line 128 "dtc-lexer.l"
1017 yylloc.file = srcpos_file;
1018 yylloc.first_line = yylineno;
1019 yylval.literal = strdup(yytext);
1020 DPRINT("Literal: '%s'\n", yylval.literal);
1021 return DT_LEGACYLITERAL;
1026 #line 136 "dtc-lexer.l"
1028 yylloc.file = srcpos_file;
1029 yylloc.first_line = yylineno;
1030 yylval.literal = strdup(yytext);
1031 DPRINT("Literal: '%s'\n", yylval.literal);
1037 #line 144 "dtc-lexer.l"
1038 { /* label reference */
1039 yylloc.file = srcpos_file;
1040 yylloc.first_line = yylineno;
1041 DPRINT("Ref: %s\n", yytext+1);
1042 yylval.labelref = strdup(yytext+1);
1048 #line 152 "dtc-lexer.l"
1049 { /* new-style path reference */
1050 yylloc.file = srcpos_file;
1051 yylloc.first_line = yylineno;
1052 yytext[yyleng-1] = '\0';
1053 DPRINT("Ref: %s\n", yytext+2);
1054 yylval.labelref = strdup(yytext+2);
1060 #line 161 "dtc-lexer.l"
1061 { /* old-style path reference */
1062 yylloc.file = srcpos_file;
1063 yylloc.first_line = yylineno;
1064 DPRINT("Ref: %s\n", yytext+1);
1065 yylval.labelref = strdup(yytext+1);
1071 #line 169 "dtc-lexer.l"
1073 yylloc.file = srcpos_file;
1074 yylloc.first_line = yylineno;
1075 yylval.byte = strtol(yytext, NULL, 16);
1076 DPRINT("Byte: %02x\n", (int)yylval.byte);
1082 #line 177 "dtc-lexer.l"
1084 yylloc.file = srcpos_file;
1085 yylloc.first_line = yylineno;
1086 DPRINT("/BYTESTRING\n");
1093 #line 185 "dtc-lexer.l"
1095 yylloc.file = srcpos_file;
1096 yylloc.first_line = yylineno;
1097 DPRINT("PropNodeName: %s\n", yytext);
1098 yylval.propnodename = strdup(yytext);
1100 return DT_PROPNODENAME;
1105 #line 194 "dtc-lexer.l"
1107 yylloc.file = srcpos_file;
1108 yylloc.first_line = yylineno;
1109 DPRINT("Binary Include\n");
1114 /* rule 16 can match eol */
1116 #line 201 "dtc-lexer.l"
1117 /* eat whitespace */
1120 /* rule 17 can match eol */
1122 #line 202 "dtc-lexer.l"
1123 /* eat C-style comments */
1126 /* rule 18 can match eol */
1128 #line 203 "dtc-lexer.l"
1129 /* eat C++-style comments */
1133 #line 205 "dtc-lexer.l"
1135 yylloc.file = srcpos_file;
1136 yylloc.first_line = yylineno;
1137 DPRINT("Char: %c (\\x%02x)\n", yytext[0],
1138 (unsigned)yytext[0]);
1139 if (yytext[0] == '[') {
1140 DPRINT("<BYTESTRING>\n");
1143 if ((yytext[0] == '{')
1144 || (yytext[0] == ';')) {
1145 DPRINT("<PROPNODENAME>\n");
1146 BEGIN(PROPNODENAME);
1153 #line 222 "dtc-lexer.l"
1156 #line 1157 "dtc-lexer.lex.c"
1158 case YY_END_OF_BUFFER:
1160 /* Amount of text matched not including the EOB char. */
1161 int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
1163 /* Undo the effects of YY_DO_BEFORE_ACTION. */
1164 *yy_cp = (yy_hold_char);
1165 YY_RESTORE_YY_MORE_OFFSET
1167 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
1169 /* We're scanning a new file or input source. It's
1170 * possible that this happened because the user
1171 * just pointed yyin at a new source and called
1172 * yylex(). If so, then we have to assure
1173 * consistency between YY_CURRENT_BUFFER and our
1174 * globals. Here is the right place to do so, because
1175 * this is the first action (other than possibly a
1176 * back-up) that will match for the new input source.
1178 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1179 YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
1180 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
1183 /* Note that here we test for yy_c_buf_p "<=" to the position
1184 * of the first EOB in the buffer, since yy_c_buf_p will
1185 * already have been incremented past the NUL character
1186 * (since all states make transitions on EOB to the
1187 * end-of-buffer state). Contrast this with the test
1190 if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
1191 { /* This was really a NUL. */
1192 yy_state_type yy_next_state;
1194 (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
1196 yy_current_state = yy_get_previous_state( );
1198 /* Okay, we're now positioned to make the NUL
1199 * transition. We couldn't have
1200 * yy_get_previous_state() go ahead and do it
1201 * for us because it doesn't know how to deal
1202 * with the possibility of jamming (and we don't
1203 * want to build jamming into it because then it
1204 * will run more slowly).
1207 yy_next_state = yy_try_NUL_trans( yy_current_state );
1209 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1211 if ( yy_next_state )
1213 /* Consume the NUL. */
1214 yy_cp = ++(yy_c_buf_p);
1215 yy_current_state = yy_next_state;
1221 yy_cp = (yy_c_buf_p);
1222 goto yy_find_action;
1226 else switch ( yy_get_next_buffer( ) )
1228 case EOB_ACT_END_OF_FILE:
1230 (yy_did_buffer_switch_on_eof) = 0;
1234 /* Note: because we've taken care in
1235 * yy_get_next_buffer() to have set up
1236 * yytext, we can now set up
1237 * yy_c_buf_p so that if some total
1238 * hoser (like flex itself) wants to
1239 * call the scanner after we return the
1240 * YY_NULL, it'll still work - another
1241 * YY_NULL will get returned.
1243 (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
1245 yy_act = YY_STATE_EOF(YY_START);
1251 if ( ! (yy_did_buffer_switch_on_eof) )
1257 case EOB_ACT_CONTINUE_SCAN:
1259 (yytext_ptr) + yy_amount_of_matched_text;
1261 yy_current_state = yy_get_previous_state( );
1263 yy_cp = (yy_c_buf_p);
1264 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1267 case EOB_ACT_LAST_MATCH:
1269 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
1271 yy_current_state = yy_get_previous_state( );
1273 yy_cp = (yy_c_buf_p);
1274 yy_bp = (yytext_ptr) + YY_MORE_ADJ;
1275 goto yy_find_action;
1282 "fatal flex scanner internal error--no action found" );
1283 } /* end of action switch */
1284 } /* end of scanning one token */
1285 } /* end of yylex */
1287 /* yy_get_next_buffer - try to read in a new buffer
1289 * Returns a code representing an action:
1290 * EOB_ACT_LAST_MATCH -
1291 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1292 * EOB_ACT_END_OF_FILE - end of file
1294 static int yy_get_next_buffer (void)
1296 register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
1297 register char *source = (yytext_ptr);
1298 register int number_to_move, i;
1301 if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
1303 "fatal flex scanner internal error--end of buffer missed" );
1305 if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
1306 { /* Don't try to fill the buffer, so this is an EOF. */
1307 if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
1309 /* We matched a single character, the EOB, so
1310 * treat this as a final EOF.
1312 return EOB_ACT_END_OF_FILE;
1317 /* We matched some text prior to the EOB, first
1320 return EOB_ACT_LAST_MATCH;
1324 /* Try to read more data. */
1326 /* First move last chars to start of buffer. */
1327 number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr)) - 1;
1329 for ( i = 0; i < number_to_move; ++i )
1330 *(dest++) = *(source++);
1332 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
1333 /* don't do the read, it's not guaranteed to return an EOF,
1336 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
1341 YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
1343 while ( num_to_read <= 0 )
1344 { /* Not enough room in the buffer - grow it. */
1346 /* just a shorter name for the current buffer */
1347 YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
1349 int yy_c_buf_p_offset =
1350 (int) ((yy_c_buf_p) - b->yy_ch_buf);
1352 if ( b->yy_is_our_buffer )
1354 int new_size = b->yy_buf_size * 2;
1356 if ( new_size <= 0 )
1357 b->yy_buf_size += b->yy_buf_size / 8;
1359 b->yy_buf_size *= 2;
1361 b->yy_ch_buf = (char *)
1362 /* Include room in for 2 EOB chars. */
1363 yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 );
1366 /* Can't grow it, we don't own it. */
1369 if ( ! b->yy_ch_buf )
1371 "fatal error - scanner input buffer overflow" );
1373 (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
1375 num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
1380 if ( num_to_read > YY_READ_BUF_SIZE )
1381 num_to_read = YY_READ_BUF_SIZE;
1383 /* Read in more data. */
1384 YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
1385 (yy_n_chars), (size_t) num_to_read );
1387 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1390 if ( (yy_n_chars) == 0 )
1392 if ( number_to_move == YY_MORE_ADJ )
1394 ret_val = EOB_ACT_END_OF_FILE;
1400 ret_val = EOB_ACT_LAST_MATCH;
1401 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
1402 YY_BUFFER_EOF_PENDING;
1407 ret_val = EOB_ACT_CONTINUE_SCAN;
1409 if ((yy_size_t) ((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
1410 /* Extend the array by 50%, plus the number we really need. */
1411 yy_size_t new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
1412 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size );
1413 if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1414 YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
1417 (yy_n_chars) += number_to_move;
1418 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
1419 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
1421 (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
1426 /* yy_get_previous_state - get the state just before the EOB char was reached */
1428 static yy_state_type yy_get_previous_state (void)
1430 register yy_state_type yy_current_state;
1431 register char *yy_cp;
1433 yy_current_state = (yy_start);
1435 for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
1437 register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1438 if ( yy_accept[yy_current_state] )
1440 (yy_last_accepting_state) = yy_current_state;
1441 (yy_last_accepting_cpos) = yy_cp;
1443 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1445 yy_current_state = (int) yy_def[yy_current_state];
1446 if ( yy_current_state >= 104 )
1447 yy_c = yy_meta[(unsigned int) yy_c];
1449 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1452 return yy_current_state;
1455 /* yy_try_NUL_trans - try to make a transition on the NUL character
1458 * next_state = yy_try_NUL_trans( current_state );
1460 static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
1462 register int yy_is_jam;
1463 register char *yy_cp = (yy_c_buf_p);
1465 register YY_CHAR yy_c = 1;
1466 if ( yy_accept[yy_current_state] )
1468 (yy_last_accepting_state) = yy_current_state;
1469 (yy_last_accepting_cpos) = yy_cp;
1471 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1473 yy_current_state = (int) yy_def[yy_current_state];
1474 if ( yy_current_state >= 104 )
1475 yy_c = yy_meta[(unsigned int) yy_c];
1477 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1478 yy_is_jam = (yy_current_state == 103);
1480 return yy_is_jam ? 0 : yy_current_state;
1485 static int yyinput (void)
1487 static int input (void)
1493 *(yy_c_buf_p) = (yy_hold_char);
1495 if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
1497 /* yy_c_buf_p now points to the character we want to return.
1498 * If this occurs *before* the EOB characters, then it's a
1499 * valid NUL; if not, then we've hit the end of the buffer.
1501 if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
1502 /* This was really a NUL. */
1503 *(yy_c_buf_p) = '\0';
1506 { /* need more input */
1507 int offset = (yy_c_buf_p) - (yytext_ptr);
1510 switch ( yy_get_next_buffer( ) )
1512 case EOB_ACT_LAST_MATCH:
1513 /* This happens because yy_g_n_b()
1514 * sees that we've accumulated a
1515 * token and flags that we need to
1516 * try matching the token before
1517 * proceeding. But for input(),
1518 * there's no matching to consider.
1519 * So convert the EOB_ACT_LAST_MATCH
1520 * to EOB_ACT_END_OF_FILE.
1523 /* Reset buffer status. */
1528 case EOB_ACT_END_OF_FILE:
1533 if ( ! (yy_did_buffer_switch_on_eof) )
1542 case EOB_ACT_CONTINUE_SCAN:
1543 (yy_c_buf_p) = (yytext_ptr) + offset;
1549 c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
1550 *(yy_c_buf_p) = '\0'; /* preserve yytext */
1551 (yy_hold_char) = *++(yy_c_buf_p);
1560 #endif /* ifndef YY_NO_INPUT */
1562 /** Immediately switch to a different input stream.
1563 * @param input_file A readable stream.
1565 * @note This function does not reset the start condition to @c INITIAL .
1567 void yyrestart (FILE * input_file )
1570 if ( ! YY_CURRENT_BUFFER ){
1571 yyensure_buffer_stack ();
1572 YY_CURRENT_BUFFER_LVALUE =
1573 yy_create_buffer(yyin,YY_BUF_SIZE );
1576 yy_init_buffer(YY_CURRENT_BUFFER,input_file );
1577 yy_load_buffer_state( );
1580 /** Switch to a different input buffer.
1581 * @param new_buffer The new input buffer.
1584 void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer )
1587 /* TODO. We should be able to replace this entire function body
1589 * yypop_buffer_state();
1590 * yypush_buffer_state(new_buffer);
1592 yyensure_buffer_stack ();
1593 if ( YY_CURRENT_BUFFER == new_buffer )
1596 if ( YY_CURRENT_BUFFER )
1598 /* Flush out information for old buffer. */
1599 *(yy_c_buf_p) = (yy_hold_char);
1600 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1601 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1604 YY_CURRENT_BUFFER_LVALUE = new_buffer;
1605 yy_load_buffer_state( );
1607 /* We don't actually know whether we did this switch during
1608 * EOF (yywrap()) processing, but the only time this flag
1609 * is looked at is after yywrap() is called, so it's safe
1610 * to go ahead and always set it.
1612 (yy_did_buffer_switch_on_eof) = 1;
1615 static void yy_load_buffer_state (void)
1617 (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1618 (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
1619 yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
1620 (yy_hold_char) = *(yy_c_buf_p);
1623 /** Allocate and initialize an input buffer state.
1624 * @param file A readable stream.
1625 * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
1627 * @return the allocated buffer state.
1629 YY_BUFFER_STATE yy_create_buffer (FILE * file, int size )
1633 b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) );
1635 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1637 b->yy_buf_size = size;
1639 /* yy_ch_buf has to be 2 characters longer than the size given because
1640 * we need to put in 2 end-of-buffer characters.
1642 b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2 );
1643 if ( ! b->yy_ch_buf )
1644 YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1646 b->yy_is_our_buffer = 1;
1648 yy_init_buffer(b,file );
1653 /** Destroy the buffer.
1654 * @param b a buffer created with yy_create_buffer()
1657 void yy_delete_buffer (YY_BUFFER_STATE b )
1663 if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
1664 YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
1666 if ( b->yy_is_our_buffer )
1667 yyfree((void *) b->yy_ch_buf );
1669 yyfree((void *) b );
1673 extern int isatty (int );
1674 #endif /* __cplusplus */
1676 /* Initializes or reinitializes a buffer.
1677 * This function is sometimes called more than once on the same buffer,
1678 * such as during a yyrestart() or at EOF.
1680 static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file )
1685 yy_flush_buffer(b );
1687 b->yy_input_file = file;
1688 b->yy_fill_buffer = 1;
1690 /* If b is the current buffer, then yy_init_buffer was _probably_
1691 * called from yyrestart() or through yy_get_next_buffer.
1692 * In that case, we don't want to reset the lineno or column.
1694 if (b != YY_CURRENT_BUFFER){
1695 b->yy_bs_lineno = 1;
1696 b->yy_bs_column = 0;
1699 b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
1704 /** Discard all buffered characters. On the next scan, YY_INPUT will be called.
1705 * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
1708 void yy_flush_buffer (YY_BUFFER_STATE b )
1715 /* We always need two end-of-buffer characters. The first causes
1716 * a transition to the end-of-buffer state. The second causes
1717 * a jam in that state.
1719 b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1720 b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1722 b->yy_buf_pos = &b->yy_ch_buf[0];
1725 b->yy_buffer_status = YY_BUFFER_NEW;
1727 if ( b == YY_CURRENT_BUFFER )
1728 yy_load_buffer_state( );
1731 /** Pushes the new state onto the stack. The new state becomes
1732 * the current state. This function will allocate the stack
1734 * @param new_buffer The new state.
1737 void yypush_buffer_state (YY_BUFFER_STATE new_buffer )
1739 if (new_buffer == NULL)
1742 yyensure_buffer_stack();
1744 /* This block is copied from yy_switch_to_buffer. */
1745 if ( YY_CURRENT_BUFFER )
1747 /* Flush out information for old buffer. */
1748 *(yy_c_buf_p) = (yy_hold_char);
1749 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
1750 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
1753 /* Only push if top exists. Otherwise, replace top. */
1754 if (YY_CURRENT_BUFFER)
1755 (yy_buffer_stack_top)++;
1756 YY_CURRENT_BUFFER_LVALUE = new_buffer;
1758 /* copied from yy_switch_to_buffer. */
1759 yy_load_buffer_state( );
1760 (yy_did_buffer_switch_on_eof) = 1;
1763 /** Removes and deletes the top of the stack, if present.
1764 * The next element becomes the new top.
1767 void yypop_buffer_state (void)
1769 if (!YY_CURRENT_BUFFER)
1772 yy_delete_buffer(YY_CURRENT_BUFFER );
1773 YY_CURRENT_BUFFER_LVALUE = NULL;
1774 if ((yy_buffer_stack_top) > 0)
1775 --(yy_buffer_stack_top);
1777 if (YY_CURRENT_BUFFER) {
1778 yy_load_buffer_state( );
1779 (yy_did_buffer_switch_on_eof) = 1;
1783 /* Allocates the stack if it does not exist.
1784 * Guarantees space for at least one push.
1786 static void yyensure_buffer_stack (void)
1790 if (!(yy_buffer_stack)) {
1792 /* First allocation is just for 2 elements, since we don't know if this
1793 * scanner will even need a stack. We use 2 instead of 1 to avoid an
1794 * immediate realloc on the next call.
1797 (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc
1798 (num_to_alloc * sizeof(struct yy_buffer_state*)
1800 if ( ! (yy_buffer_stack) )
1801 YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
1803 memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
1805 (yy_buffer_stack_max) = num_to_alloc;
1806 (yy_buffer_stack_top) = 0;
1810 if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
1812 /* Increase the buffer to prepare for a possible push. */
1813 int grow_size = 8 /* arbitrary grow size */;
1815 num_to_alloc = (yy_buffer_stack_max) + grow_size;
1816 (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc
1818 num_to_alloc * sizeof(struct yy_buffer_state*)
1820 if ( ! (yy_buffer_stack) )
1821 YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
1823 /* zero only the new slots.*/
1824 memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
1825 (yy_buffer_stack_max) = num_to_alloc;
1829 /** Setup the input buffer state to scan directly from a user-specified character buffer.
1830 * @param base the character buffer
1831 * @param size the size in bytes of the character buffer
1833 * @return the newly allocated buffer state object.
1835 YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size )
1840 base[size-2] != YY_END_OF_BUFFER_CHAR ||
1841 base[size-1] != YY_END_OF_BUFFER_CHAR )
1842 /* They forgot to leave room for the EOB's. */
1845 b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) );
1847 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
1849 b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
1850 b->yy_buf_pos = b->yy_ch_buf = base;
1851 b->yy_is_our_buffer = 0;
1852 b->yy_input_file = 0;
1853 b->yy_n_chars = b->yy_buf_size;
1854 b->yy_is_interactive = 0;
1856 b->yy_fill_buffer = 0;
1857 b->yy_buffer_status = YY_BUFFER_NEW;
1859 yy_switch_to_buffer(b );
1864 /** Setup the input buffer state to scan a string. The next call to yylex() will
1865 * scan from a @e copy of @a str.
1866 * @param yystr a NUL-terminated string to scan
1868 * @return the newly allocated buffer state object.
1869 * @note If you want to scan bytes that may contain NUL values, then use
1870 * yy_scan_bytes() instead.
1872 YY_BUFFER_STATE yy_scan_string (yyconst char * yystr )
1875 return yy_scan_bytes(yystr,strlen(yystr) );
1878 /** Setup the input buffer state to scan the given bytes. The next call to yylex() will
1879 * scan from a @e copy of @a bytes.
1880 * @param yybytes the byte buffer to scan
1881 * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
1883 * @return the newly allocated buffer state object.
1885 YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, int _yybytes_len )
1892 /* Get memory for full buffer, including space for trailing EOB's. */
1893 n = _yybytes_len + 2;
1894 buf = (char *) yyalloc(n );
1896 YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
1898 for ( i = 0; i < _yybytes_len; ++i )
1899 buf[i] = yybytes[i];
1901 buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
1903 b = yy_scan_buffer(buf,n );
1905 YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
1907 /* It's okay to grow etc. this buffer, and we should throw it
1908 * away when we're done.
1910 b->yy_is_our_buffer = 1;
1915 #ifndef YY_EXIT_FAILURE
1916 #define YY_EXIT_FAILURE 2
1919 static void yy_fatal_error (yyconst char* msg )
1921 (void) fprintf( stderr, "%s\n", msg );
1922 exit( YY_EXIT_FAILURE );
1925 /* Redefine yyless() so it works in section 3 code. */
1931 /* Undo effects of setting up yytext. */ \
1932 int yyless_macro_arg = (n); \
1933 YY_LESS_LINENO(yyless_macro_arg);\
1934 yytext[yyleng] = (yy_hold_char); \
1935 (yy_c_buf_p) = yytext + yyless_macro_arg; \
1936 (yy_hold_char) = *(yy_c_buf_p); \
1937 *(yy_c_buf_p) = '\0'; \
1938 yyleng = yyless_macro_arg; \
1942 /* Accessor methods (get/set functions) to struct members. */
1944 /** Get the current line number.
1947 int yyget_lineno (void)
1953 /** Get the input stream.
1956 FILE *yyget_in (void)
1961 /** Get the output stream.
1964 FILE *yyget_out (void)
1969 /** Get the length of the current token.
1972 int yyget_leng (void)
1977 /** Get the current token.
1981 char *yyget_text (void)
1986 /** Set the current line number.
1987 * @param line_number
1990 void yyset_lineno (int line_number )
1993 yylineno = line_number;
1996 /** Set the input stream. This does not discard the current
1998 * @param in_str A readable stream.
2000 * @see yy_switch_to_buffer
2002 void yyset_in (FILE * in_str )
2007 void yyset_out (FILE * out_str )
2012 int yyget_debug (void)
2014 return yy_flex_debug;
2017 void yyset_debug (int bdebug )
2019 yy_flex_debug = bdebug ;
2022 static int yy_init_globals (void)
2024 /* Initialization is the same as for the non-reentrant scanner.
2025 * This function is called from yylex_destroy(), so don't allocate here.
2028 /* We do not touch yylineno unless the option is enabled. */
2031 (yy_buffer_stack) = 0;
2032 (yy_buffer_stack_top) = 0;
2033 (yy_buffer_stack_max) = 0;
2034 (yy_c_buf_p) = (char *) 0;
2038 /* Defined in main.c */
2047 /* For future reference: Set errno on error, since we are called by
2053 /* yylex_destroy is for both reentrant and non-reentrant scanners. */
2054 int yylex_destroy (void)
2057 /* Pop the buffer stack, destroying each element. */
2058 while(YY_CURRENT_BUFFER){
2059 yy_delete_buffer(YY_CURRENT_BUFFER );
2060 YY_CURRENT_BUFFER_LVALUE = NULL;
2061 yypop_buffer_state();
2064 /* Destroy the stack itself. */
2065 yyfree((yy_buffer_stack) );
2066 (yy_buffer_stack) = NULL;
2068 /* Reset the globals. This is important in a non-reentrant scanner so the next time
2069 * yylex() is called, initialization will occur. */
2076 * Internal utility routines.
2080 static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
2083 for ( i = 0; i < n; ++i )
2088 #ifdef YY_NEED_STRLEN
2089 static int yy_flex_strlen (yyconst char * s )
2092 for ( n = 0; s[n]; ++n )
2099 void *yyalloc (yy_size_t size )
2101 return (void *) malloc( size );
2104 void *yyrealloc (void * ptr, yy_size_t size )
2106 /* The cast to (char *) in the following accommodates both
2107 * implementations that use char* generic pointers, and those
2108 * that use void* generic pointers. It works with the latter
2109 * because both ANSI C and C++ allow castless assignment from
2110 * any pointer type to void*, and deal with argument conversions
2111 * as though doing an assignment.
2113 return (void *) realloc( (char *) ptr, size );
2116 void yyfree (void * ptr )
2118 free( (char *) ptr ); /* see yyrealloc() for (char *) cast */
2121 #define YYTABLES_NAME "yytables"
2123 #line 222 "dtc-lexer.l"
2129 * Stack of nested include file contexts.
2133 struct dtc_file *file;
2134 YY_BUFFER_STATE yy_prev_buf;
2136 struct incl_file *prev;
2139 static struct incl_file *incl_file_stack;
2143 * Detect infinite include recursion.
2145 #define MAX_INCLUDE_DEPTH (100)
2147 static int incl_depth = 0;
2150 static void push_input_file(const char *filename)
2152 struct incl_file *incl_file;
2153 struct dtc_file *newfile;
2154 struct search_path search, *searchptr = NULL;
2158 if (incl_depth++ >= MAX_INCLUDE_DEPTH)
2159 die("Includes nested too deeply");
2162 search.dir = srcpos_file->dir;
2165 searchptr = &search;
2168 newfile = dtc_open_file(filename, searchptr);
2170 incl_file = xmalloc(sizeof(struct incl_file));
2173 * Save current context.
2175 incl_file->yy_prev_buf = YY_CURRENT_BUFFER;
2176 incl_file->yy_prev_lineno = yylineno;
2177 incl_file->file = srcpos_file;
2178 incl_file->prev = incl_file_stack;
2180 incl_file_stack = incl_file;
2183 * Establish new context.
2185 srcpos_file = newfile;
2187 yyin = newfile->file;
2188 yy_switch_to_buffer(yy_create_buffer(yyin,YY_BUF_SIZE));
2192 static int pop_input_file(void)
2194 struct incl_file *incl_file;
2196 if (incl_file_stack == 0)
2199 dtc_close_file(srcpos_file);
2205 incl_file = incl_file_stack;
2206 incl_file_stack = incl_file->prev;
2209 * Recover old context.
2211 yy_delete_buffer(YY_CURRENT_BUFFER);
2212 yy_switch_to_buffer(incl_file->yy_prev_buf);
2213 yylineno = incl_file->yy_prev_lineno;
2214 srcpos_file = incl_file->file;
2215 yyin = incl_file->file ? incl_file->file->file : NULL;