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 33
13 #if YY_FLEX_SUBMINOR_VERSION > 0
28 /* First, we deal with platform-specific or compiler-specific issues. */
30 /* begin standard C headers. */
38 /* %if-tables-serialization */
40 /* end standard C headers. */
43 /* flex integer type definitions */
48 /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
50 #if __STDC_VERSION__ >= 199901L
52 /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
53 * if you want the limit (max/min) macros for int types.
55 #ifndef __STDC_LIMIT_MACROS
56 #define __STDC_LIMIT_MACROS 1
60 typedef int8_t flex_int8_t
;
61 typedef uint8_t flex_uint8_t
;
62 typedef int16_t flex_int16_t
;
63 typedef uint16_t flex_uint16_t
;
64 typedef int32_t flex_int32_t
;
65 typedef uint32_t flex_uint32_t
;
67 typedef signed char flex_int8_t
;
68 typedef short int flex_int16_t
;
69 typedef int flex_int32_t
;
70 typedef unsigned char flex_uint8_t
;
71 typedef unsigned short int flex_uint16_t
;
72 typedef unsigned int flex_uint32_t
;
75 /* Limits of integral types. */
77 #define INT8_MIN (-128)
80 #define INT16_MIN (-32767-1)
83 #define INT32_MIN (-2147483647-1)
86 #define INT8_MAX (127)
89 #define INT16_MAX (32767)
92 #define INT32_MAX (2147483647)
95 #define UINT8_MAX (255U)
98 #define UINT16_MAX (65535U)
101 #define UINT32_MAX (4294967295U)
104 #endif /* ! FLEXINT_H */
113 /* The "const" storage-class-modifier is valid. */
116 #else /* ! __cplusplus */
122 #endif /* __STDC__ */
123 #endif /* ! __cplusplus */
126 #define yyconst const
131 /* %not-for-header */
133 /* Returned upon end-of-file. */
137 /* %not-for-header */
139 /* Promotes a possibly negative, possibly signed char to an unsigned
140 * integer for use as an array index. If the signed char is negative,
141 * we want to instead treat it as an 8-bit unsigned char, hence the
144 #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
149 /* An opaque pointer. */
150 #ifndef YY_TYPEDEF_YY_SCANNER_T
151 #define YY_TYPEDEF_YY_SCANNER_T
152 typedef void* yyscan_t
;
155 /* For convenience, these vars (plus the bison vars far below)
156 are macros in the reentrant scanner. */
157 #define yyin yyg->yyin_r
158 #define yyout yyg->yyout_r
159 #define yyextra yyg->yyextra_r
160 #define yyleng yyg->yyleng_r
161 #define yytext yyg->yytext_r
162 #define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno)
163 #define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column)
164 #define yy_flex_debug yyg->yy_flex_debug_r
166 int hd_prelex_init (yyscan_t
* scanner
);
169 /* %if-not-reentrant */
172 /* Enter a start condition. This macro really ought to take a parameter,
173 * but we do it the disgusting crufty way forced on us by the ()-less
174 * definition of BEGIN.
176 #define BEGIN yyg->yy_start = 1 + 2 *
178 /* Translate the current start state into a value that can be later handed
179 * to BEGIN to return to the state. The YYSTATE alias is for lex
182 #define YY_START ((yyg->yy_start - 1) / 2)
183 #define YYSTATE YY_START
185 /* Action number for EOF rule of a given start state. */
186 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
188 /* Special action meaning "start processing a new file". */
189 #define YY_NEW_FILE hd_prerestart(yyin ,yyscanner )
191 #define YY_END_OF_BUFFER_CHAR 0
193 /* Size of default input buffer. */
195 #define YY_BUF_SIZE 16384
198 /* The state buf must be large enough to hold one state per character in the main buffer.
200 #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
202 #ifndef YY_TYPEDEF_YY_BUFFER_STATE
203 #define YY_TYPEDEF_YY_BUFFER_STATE
204 typedef struct yy_buffer_state
*YY_BUFFER_STATE
;
207 /* %if-not-reentrant */
211 /* %if-not-reentrant */
215 #define EOB_ACT_CONTINUE_SCAN 0
216 #define EOB_ACT_END_OF_FILE 1
217 #define EOB_ACT_LAST_MATCH 2
219 /* Note: We specifically omit the test for yy_rule_can_match_eol because it requires
220 * access to the local variable yy_act. Since yyless() is a macro, it would break
221 * existing scanners that call yyless() from OUTSIDE hd_prelex.
222 * One obvious solution it to make yy_act a global. I tried that, and saw
223 * a 5% performance hit in a non-yylineno scanner, because yy_act is
224 * normally declared as a register variable-- so it is not worth it.
226 #define YY_LESS_LINENO(n) \
229 for ( yyl = n; yyl < yyleng; ++yyl )\
230 if ( yytext[yyl] == '\n' )\
234 /* Return all but the first "n" matched characters back to the input stream. */
238 /* Undo effects of setting up yytext. */ \
239 int yyless_macro_arg = (n); \
240 YY_LESS_LINENO(yyless_macro_arg);\
241 *yy_cp = yyg->yy_hold_char; \
242 YY_RESTORE_YY_MORE_OFFSET \
243 yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
244 YY_DO_BEFORE_ACTION; /* set up yytext again */ \
248 #define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner )
250 /* The following is because we cannot portably get our hands on size_t
251 * (without autoconf's help, which isn't available because we want
252 * flex-generated scanners to compile on their own).
255 #ifndef YY_TYPEDEF_YY_SIZE_T
256 #define YY_TYPEDEF_YY_SIZE_T
257 typedef unsigned int yy_size_t
;
260 #ifndef YY_STRUCT_YY_BUFFER_STATE
261 #define YY_STRUCT_YY_BUFFER_STATE
262 struct yy_buffer_state
271 char *yy_ch_buf
; /* input buffer */
272 char *yy_buf_pos
; /* current position in input buffer */
274 /* Size of input buffer in bytes, not including room for EOB
277 yy_size_t yy_buf_size
;
279 /* Number of characters read into yy_ch_buf, not including EOB
284 /* Whether we "own" the buffer - i.e., we know we created it,
285 * and can realloc() it to grow it, and should free() it to
288 int yy_is_our_buffer
;
290 /* Whether this is an "interactive" input source; if so, and
291 * if we're using stdio for input, then we want to use getc()
292 * instead of fread(), to make sure we stop fetching input after
295 int yy_is_interactive
;
297 /* Whether we're considered to be at the beginning of a line.
298 * If so, '^' rules will be active on the next match, otherwise
303 int yy_bs_lineno
; /**< The line count. */
304 int yy_bs_column
; /**< The column count. */
306 /* Whether to try to fill the input buffer when we reach the
311 int yy_buffer_status
;
313 #define YY_BUFFER_NEW 0
314 #define YY_BUFFER_NORMAL 1
315 /* When an EOF's been seen but there's still some text to process
316 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
317 * shouldn't try reading from the input source any more. We might
318 * still have a bunch of tokens to match, though, because of
319 * possible backing-up.
321 * When we actually see the EOF, we change the status to "new"
322 * (via hd_prerestart()), so that the user can continue scanning by
323 * just pointing yyin at a new input file.
325 #define YY_BUFFER_EOF_PENDING 2
328 #endif /* !YY_STRUCT_YY_BUFFER_STATE */
330 /* %if-c-only Standard (non-C++) definition */
331 /* %not-for-header */
333 /* %if-not-reentrant */
339 /* We provide macros for accessing buffer states in case in the
340 * future we want to put the buffer states in a more general
343 * Returns the top of the stack, or NULL.
345 #define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \
346 ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \
349 /* Same as previous macro, but useful when we know that the buffer stack is not
350 * NULL or when we need an lvalue. For internal use only.
352 #define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]
354 /* %if-c-only Standard (non-C++) definition */
356 /* %if-not-reentrant */
357 /* %not-for-header */
363 void hd_prerestart (FILE *input_file
,yyscan_t yyscanner
);
364 void hd_pre_switch_to_buffer (YY_BUFFER_STATE new_buffer
,yyscan_t yyscanner
);
365 YY_BUFFER_STATE
hd_pre_create_buffer (FILE *file
,int size
,yyscan_t yyscanner
);
366 void hd_pre_delete_buffer (YY_BUFFER_STATE b
,yyscan_t yyscanner
);
367 void hd_pre_flush_buffer (YY_BUFFER_STATE b
,yyscan_t yyscanner
);
368 void hd_prepush_buffer_state (YY_BUFFER_STATE new_buffer
,yyscan_t yyscanner
);
369 void hd_prepop_buffer_state (yyscan_t yyscanner
);
371 static void hd_preensure_buffer_stack (yyscan_t yyscanner
);
372 static void hd_pre_load_buffer_state (yyscan_t yyscanner
);
373 static void hd_pre_init_buffer (YY_BUFFER_STATE b
,FILE *file
,yyscan_t yyscanner
);
375 #define YY_FLUSH_BUFFER hd_pre_flush_buffer(YY_CURRENT_BUFFER ,yyscanner)
377 YY_BUFFER_STATE
hd_pre_scan_buffer (char *base
,yy_size_t size
,yyscan_t yyscanner
);
378 YY_BUFFER_STATE
hd_pre_scan_string (yyconst
char *yy_str
,yyscan_t yyscanner
);
379 YY_BUFFER_STATE
hd_pre_scan_bytes (yyconst
char *bytes
,int len
,yyscan_t yyscanner
);
383 void *hd_prealloc (yy_size_t
,yyscan_t yyscanner
);
384 void *hd_prerealloc (void *,yy_size_t
,yyscan_t yyscanner
);
385 void hd_prefree (void * ,yyscan_t yyscanner
);
387 #define yy_new_buffer hd_pre_create_buffer
389 #define yy_set_interactive(is_interactive) \
391 if ( ! YY_CURRENT_BUFFER ){ \
392 hd_preensure_buffer_stack (yyscanner); \
393 YY_CURRENT_BUFFER_LVALUE = \
394 hd_pre_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \
396 YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
399 #define yy_set_bol(at_bol) \
401 if ( ! YY_CURRENT_BUFFER ){\
402 hd_preensure_buffer_stack (yyscanner); \
403 YY_CURRENT_BUFFER_LVALUE = \
404 hd_pre_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \
406 YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
409 #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
411 /* %% [1.0] yytext/yyin/yyout/yy_state_type/yylineno etc. def's & init go here */
412 /* Begin user sect3 */
414 #define hd_prewrap(n) 1
415 #define YY_SKIP_YYWRAP
419 typedef unsigned char YY_CHAR
;
421 typedef int yy_state_type
;
423 #define yytext_ptr yytext_r
425 /* %if-c-only Standard (non-C++) definition */
427 static yy_state_type
yy_get_previous_state (yyscan_t yyscanner
);
428 static yy_state_type
yy_try_NUL_trans (yy_state_type current_state
,yyscan_t yyscanner
);
429 static int yy_get_next_buffer (yyscan_t yyscanner
);
430 static void yy_fatal_error (yyconst
char msg
[] ,yyscan_t yyscanner
);
434 /* Done after the current pattern has been matched and before the
435 * corresponding action - sets up yytext.
437 #define YY_DO_BEFORE_ACTION \
438 yyg->yytext_ptr = yy_bp; \
439 /* %% [2.0] code to fiddle yytext and yyleng for yymore() goes here \ */\
440 yyleng = (size_t) (yy_cp - yy_bp); \
441 yyg->yy_hold_char = *yy_cp; \
443 /* %% [3.0] code to copy yytext_ptr to yytext[] goes here, if %array \ */\
444 yyg->yy_c_buf_p = yy_cp;
446 /* %% [4.0] data tables for the DFA and the user's section 1 definitions go here */
447 #define YY_NUM_RULES 16
448 #define YY_END_OF_BUFFER 17
449 /* This struct is not used in this scanner,
450 but its presence is necessary. */
453 flex_int32_t yy_verify
;
456 static yyconst flex_int16_t yy_accept
[105] =
458 0, 0, 0, 0, 12, 12, 0, 0, 0, 0,
459 0, 0, 0, 0, 17, 15, 13, 15, 15, 15,
460 15, 16, 4, 16, 16, 16, 12, 11, 12, 12,
461 16, 14, 16, 16, 16, 9, 16, 16, 16, 10,
462 16, 16, 6, 5, 6, 6, 6, 13, 0, 13,
463 0, 1, 0, 0, 0, 2, 0, 0, 4, 0,
464 4, 0, 1, 0, 0, 12, 11, 12, 12, 14,
465 0, 9, 0, 9, 0, 1, 0, 0, 10, 0,
466 10, 0, 1, 0, 5, 0, 0, 0, 0, 0,
467 0, 0, 8, 0, 0, 0, 0, 7, 0, 0,
472 static yyconst flex_int32_t yy_ec
[256] =
474 1, 1, 1, 1, 1, 1, 1, 1, 1, 2,
475 1, 1, 3, 1, 1, 1, 1, 1, 1, 1,
476 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
477 1, 1, 1, 4, 5, 1, 1, 1, 6, 1,
478 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
479 1, 1, 1, 1, 1, 1, 1, 1, 1, 7,
480 8, 1, 1, 1, 1, 1, 1, 1, 1, 1,
481 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
482 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
483 1, 9, 1, 1, 1, 1, 1, 1, 10, 1,
485 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
486 1, 1, 1, 1, 1, 11, 12, 1, 1, 1,
487 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
488 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
489 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
490 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
491 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
492 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
493 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
494 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
496 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
497 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
498 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
499 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
500 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
504 static yyconst flex_int32_t yy_meta
[13] =
506 1, 2, 1, 1, 1, 1, 1, 1, 1, 1,
510 static yyconst flex_int16_t yy_base
[127] =
512 0, 6, 13, 17, 24, 28, 32, 36, 40, 44,
513 48, 52, 56, 62, 62, 216, 68, 58, 70, 49,
514 72, 74, 216, 76, 78, 80, 0, 216, 50, 89,
515 216, 216, 46, 91, 93, 216, 95, 97, 99, 216,
516 101, 103, 216, 216, 42, 105, 33, 0, 34, 0,
517 107, 216, 109, 109, 114, 216, 116, 22, 216, 18,
518 216, 118, 216, 120, 114, 0, 216, 125, 127, 216,
519 129, 216, 131, 216, 133, 216, 135, 137, 216, 139,
520 216, 141, 216, 143, 216, 143, 146, 18, 146, 154,
521 17, 160, 216, 0, 15, 168, 168, 216, 0, 11,
523 176, 216, 178, 216, 181, 183, 185, 187, 189, 191,
524 193, 195, 197, 199, 201, 11, 203, 205, 207, 209,
528 static yyconst flex_int16_t yy_def
[127] =
530 105, 105, 106, 106, 107, 107, 108, 108, 109, 109,
531 110, 110, 111, 111, 104, 104, 104, 104, 112, 104,
532 113, 114, 104, 114, 115, 114, 116, 104, 116, 117,
533 104, 104, 104, 112, 118, 104, 118, 119, 120, 104,
534 120, 121, 104, 104, 104, 112, 104, 17, 104, 17,
535 112, 104, 112, 104, 113, 104, 113, 26, 104, 26,
536 104, 115, 104, 115, 26, 116, 104, 117, 117, 104,
537 118, 104, 118, 104, 119, 104, 119, 120, 104, 120,
538 104, 121, 104, 121, 104, 104, 122, 123, 26, 124,
539 125, 122, 104, 122, 123, 126, 124, 104, 124, 125,
541 126, 104, 126, 0, 104, 104, 104, 104, 104, 104,
542 104, 104, 104, 104, 104, 104, 104, 104, 104, 104,
543 104, 104, 104, 104, 104, 104
546 static yyconst flex_int16_t yy_nxt
[229] =
548 100, 17, 18, 97, 19, 95, 20, 17, 18, 92,
549 19, 66, 20, 21, 23, 24, 98, 25, 23, 24,
550 93, 25, 98, 93, 26, 28, 29, 58, 30, 28,
551 29, 58, 30, 32, 33, 48, 34, 32, 33, 86,
552 34, 36, 37, 85, 38, 36, 37, 70, 38, 40,
553 41, 67, 42, 40, 41, 54, 42, 44, 45, 50,
554 46, 104, 47, 44, 45, 104, 46, 104, 47, 48,
555 49, 52, 53, 56, 57, 59, 60, 61, 60, 63,
556 64, 59, 60, 104, 104, 104, 104, 104, 104, 65,
557 52, 69, 52, 53, 72, 73, 74, 73, 76, 77,
559 79, 80, 81, 80, 83, 84, 52, 53, 52, 53,
560 52, 53, 87, 104, 88, 56, 57, 56, 57, 63,
561 64, 63, 64, 58, 104, 89, 52, 69, 52, 69,
562 72, 73, 72, 73, 76, 77, 76, 77, 79, 80,
563 79, 80, 83, 84, 83, 84, 90, 104, 91, 93,
564 104, 104, 104, 104, 94, 58, 96, 98, 104, 104,
565 104, 104, 99, 93, 104, 104, 104, 104, 94, 102,
566 103, 98, 104, 104, 104, 104, 99, 102, 103, 102,
567 103, 16, 16, 22, 22, 27, 27, 31, 31, 35,
568 35, 39, 39, 43, 43, 51, 51, 55, 55, 58,
570 58, 62, 62, 68, 68, 71, 71, 75, 75, 78,
571 78, 82, 82, 101, 101, 15, 104, 104, 104, 104,
572 104, 104, 104, 104, 104, 104, 104, 104
575 static yyconst flex_int16_t yy_chk
[229] =
577 125, 1, 1, 124, 1, 123, 1, 2, 2, 122,
578 2, 116, 2, 2, 3, 3, 100, 3, 4, 4,
579 95, 4, 91, 88, 4, 5, 5, 60, 5, 6,
580 6, 58, 6, 7, 7, 49, 7, 8, 8, 47,
581 8, 9, 9, 45, 9, 10, 10, 33, 10, 11,
582 11, 29, 11, 12, 12, 20, 12, 13, 13, 18,
583 13, 15, 13, 14, 14, 0, 14, 0, 14, 17,
584 17, 19, 19, 21, 21, 22, 22, 24, 24, 25,
585 25, 26, 26, 0, 0, 0, 0, 0, 0, 26,
586 30, 30, 34, 34, 35, 35, 37, 37, 38, 38,
588 39, 39, 41, 41, 42, 42, 46, 46, 51, 51,
589 53, 53, 54, 0, 54, 55, 55, 57, 57, 62,
590 62, 64, 64, 65, 0, 65, 68, 68, 69, 69,
591 71, 71, 73, 73, 75, 75, 77, 77, 78, 78,
592 80, 80, 82, 82, 84, 84, 86, 0, 86, 87,
593 0, 0, 0, 0, 87, 89, 89, 90, 0, 0,
594 0, 0, 90, 92, 0, 0, 0, 0, 92, 96,
595 96, 97, 0, 0, 0, 0, 97, 101, 101, 103,
596 103, 105, 105, 106, 106, 107, 107, 108, 108, 109,
597 109, 110, 110, 111, 111, 112, 112, 113, 113, 114,
599 114, 115, 115, 117, 117, 118, 118, 119, 119, 120,
600 120, 121, 121, 126, 126, 104, 104, 104, 104, 104,
601 104, 104, 104, 104, 104, 104, 104, 104
604 /* Table of booleans, true if rule could match eol. */
605 static yyconst flex_int32_t yy_rule_can_match_eol
[17] =
607 1, 1, 1, 1, 1, 0, 0, 0, 1, 1, 1, 0, 1, 1, 0, 0, };
609 static yyconst flex_int16_t yy_rule_linenum
[16] =
611 278, 280, 283, 287, 294, 296, 319, 329, 339, 359,
612 372, 394, 442, 446, 448
615 /* The intent behind this definition is that it'll catch
616 * any uses of REJECT which flex missed.
618 #define REJECT reject_used_but_not_detected
619 #define yymore() yymore_used_but_not_detected
620 #define YY_MORE_ADJ 0
621 #define YY_RESTORE_YY_MORE_OFFSET
627 * Copyright (C) 2007, The Perl Foundation.
631 * This pre-processor processes all heredoc strings into
632 * normal strings. Newline characters are escaped.
633 * POD comments and line comments are filtered out.
638 - there's a weirdness in the SAVELINE state; we need to duplicate
639 the yytext string twice, otherwise things go wrong badly.
641 - it might be interesting to improve memory handling to make things
642 a bit more efficient.
651 /* keep Microsoft Visual Studio compiler happy */
652 #define YY_NO_UNISTD_H
654 /* declare the prototype of hd_prelex */
655 #define YY_DECL int hd_prelex(yyscan_t yyscanner)
658 extern char *hd_preget_text(yyscan_t yyscanner
);
659 extern void hd_preset_in(FILE *fp
,yyscan_t yyscanner
);
660 extern int hd_prelex_destroy(yyscan_t yyscanner
);
661 extern int hd_prelex(yyscan_t yyscanner
);
664 /* all globals are collected in this structure which
665 * is set in yyscan_t's "extra" field, available through
666 * yy{get,set}_extra() function.
668 typedef struct global_state
{
669 char *heredoc
; /* heredoc string buffer */
670 char *linebuffer
; /* buffer to save the 'rest of the line' before scanning a heredoc */
671 char *delimiter
; /* buffer to save the delimiter of the heredoc string being scanned */
672 char *filename
; /* name of the file being scanned */
673 YY_BUFFER_STATE file_buffer
; /* needed to store the ref. to the file when scanning a string buffer */
677 /* accessor methods for setting and getting the lexer_state */
678 #define YY_EXTRA_TYPE struct global_state *
680 extern YY_EXTRA_TYPE
hd_preget_extra(yyscan_t scanner
);
681 extern void hd_preset_extra(YY_EXTRA_TYPE lexer
,yyscan_t scanner
);
683 #define output stdout
684 /* macro to chop off the last character, typically a newline character,
685 * but can also be something else
687 #define chop_yytext() (yytext[--yyleng] = '\0')
698 Emit an error message.
704 lex_error(char const * const message
, int lineno
, global_state
*state
) {
705 fprintf(stderr
, "\nHeredoc pre-processor error in '%s' (line %d): %s\n",
706 state
->filename
, lineno
, message
);
714 The C89 standard does not define a dupstr() in the C library,
715 so define our own dupstr. Function names beginning with "str"
716 are reserved (I think), so make it dupstr, as that is what it
717 does: duplicate a string.
723 dupstr(char * const source
) {
724 char *newstring
= (char *)calloc(strlen(source
) + 1, sizeof (char));
725 assert(newstring
!= NULL
);
726 strcpy(newstring
, source
);
735 for (i
= 0; i
< YY_NUM_RULES
; i
++)
736 fprintf(output
, "#rule %d was used %d times\n", i
, ctr
[i
]);
742 =item C<init_global_state>
744 create and initialize a global_state structure, containing all 'global'
745 variables that are needed during the scanning.
750 static global_state
*
751 init_global_state(char * const filename
) {
752 global_state
*state
= (global_state
*)malloc(sizeof (global_state
));
753 assert(state
!= NULL
);
754 state
->filename
= filename
;
755 state
->heredoc
= NULL
;
756 state
->linebuffer
= dupstr("");
757 state
->delimiter
= NULL
;
758 state
->file_buffer
= NULL
;
764 =item C<destroy_global_state>
766 free all memory of the global state structure.
772 destroy_global_state(global_state
*state
) {
773 if (state
->linebuffer
)
774 free(state
->linebuffer
);
776 free(state
->heredoc
);
787 Entry point of the heredoc pre-processor.
793 main(int argc
, char *argv
[]) {
796 global_state
*state
= NULL
;
798 /* check for proper usage */
800 fprintf(stderr
, "Usage: %s <file>\n", argv
[0]);
805 fp
= fopen(argv
[1], "r");
808 fprintf(stderr
, "error opening file '%s'\n", argv
[1]);
812 /* initialize a yyscan_t object */
813 hd_prelex_init(&yyscanner
);
814 /* set the scanner to a string buffer and go parse */
815 hd_preset_in(fp
,yyscanner
);
817 state
= init_global_state(argv
[1]);
819 hd_preset_extra(state
,yyscanner
);
821 /* the lexer never returns anything, only call it once.
822 * Don't give a YYSTYPE object.
824 hd_prelex(yyscanner
);
829 /* clean up after playing */
830 hd_prelex_destroy(yyscanner
);
831 destroy_global_state(state
);
848 using this we can check how often each rule is executed.
849 XXX this should be removed at some point (globals!)
853 int ctr
[YY_NUM_RULES
];
855 int num_rules
= YY_NUM_RULES
;
857 #define YY_USER_ACTION do { ++ctr[yy_act]; } while (0);
866 #line 867 "hdocprep.c"
876 #ifndef YY_NO_UNISTD_H
877 /* Special case for "unistd.h", since it is non-ANSI. We include it way
878 * down here because we want the user's section 1 to have been scanned first.
879 * The user has a chance to override it with an option.
888 #ifndef YY_EXTRA_TYPE
889 #define YY_EXTRA_TYPE void *
892 /* %if-c-only Reentrant structure and macros (non-C++). */
895 /* Holds the entire state of the reentrant scanner. */
899 /* User-defined. Not touched by flex. */
900 YY_EXTRA_TYPE yyextra_r
;
902 /* The rest are the same as the globals declared in the non-reentrant scanner. */
903 FILE *yyin_r
, *yyout_r
;
904 size_t yy_buffer_stack_top
; /**< index of top of stack. */
905 size_t yy_buffer_stack_max
; /**< capacity of stack. */
906 YY_BUFFER_STATE
* yy_buffer_stack
; /**< Stack as an array. */
913 int yy_did_buffer_switch_on_eof
;
914 int yy_start_stack_ptr
;
915 int yy_start_stack_depth
;
917 yy_state_type yy_last_accepting_state
;
918 char* yy_last_accepting_cpos
;
927 }; /* end struct yyguts_t */
931 static int yy_init_globals (yyscan_t yyscanner
);
939 /* Accessor methods to globals.
940 These are made visible to non-reentrant scanners for convenience. */
942 int hd_prelex_destroy (yyscan_t yyscanner
);
944 int hd_preget_debug (yyscan_t yyscanner
);
946 void hd_preset_debug (int debug_flag
,yyscan_t yyscanner
);
948 YY_EXTRA_TYPE
hd_preget_extra (yyscan_t yyscanner
);
950 void hd_preset_extra (YY_EXTRA_TYPE user_defined
,yyscan_t yyscanner
);
952 FILE *hd_preget_in (yyscan_t yyscanner
);
954 void hd_preset_in (FILE * in_str
,yyscan_t yyscanner
);
956 FILE *hd_preget_out (yyscan_t yyscanner
);
958 void hd_preset_out (FILE * out_str
,yyscan_t yyscanner
);
960 int hd_preget_leng (yyscan_t yyscanner
);
962 char *hd_preget_text (yyscan_t yyscanner
);
964 int hd_preget_lineno (yyscan_t yyscanner
);
966 void hd_preset_lineno (int line_number
,yyscan_t yyscanner
);
968 /* %if-bison-bridge */
970 /* %endif End reentrant structures and macros. */
972 /* Macros after this point can all be overridden by user definitions in
976 #ifndef YY_SKIP_YYWRAP
978 extern "C" int hd_prewrap (yyscan_t yyscanner
);
980 extern int hd_prewrap (yyscan_t yyscanner
);
984 /* %not-for-header */
991 static void yy_flex_strncpy (char *,yyconst
char *,int ,yyscan_t yyscanner
);
994 #ifdef YY_NEED_STRLEN
995 static int yy_flex_strlen (yyconst
char * ,yyscan_t yyscanner
);
999 /* %if-c-only Standard (non-C++) definition */
1000 /* %not-for-header */
1003 static int yyinput (yyscan_t yyscanner
);
1005 static int input (yyscan_t yyscanner
);
1007 /* %ok-for-header */
1014 static void yy_push_state (int new_state
,yyscan_t yyscanner
);
1016 static void yy_pop_state (yyscan_t yyscanner
);
1020 /* Amount of stuff to slurp up with each read. */
1021 #ifndef YY_READ_BUF_SIZE
1022 #define YY_READ_BUF_SIZE 8192
1025 /* Copy whatever the last rule matched to the standard output. */
1027 /* %if-c-only Standard (non-C++) definition */
1028 /* This used to be an fputs(), but since the string might contain NUL's,
1029 * we now use fwrite().
1031 #define ECHO (void) fwrite( yytext, yyleng, 1, yyout )
1033 /* %if-c++-only C++ definition */
1037 /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
1038 * is returned in "result".
1041 #define YY_INPUT(buf,result,max_size) \
1042 /* %% [5.0] fread()/read() definition of YY_INPUT goes here unless we're doing C++ \ */\
1043 if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
1047 for ( n = 0; n < max_size && \
1048 (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
1049 buf[n] = (char) c; \
1051 buf[n++] = (char) c; \
1052 if ( c == EOF && ferror( yyin ) ) \
1053 YY_FATAL_ERROR( "input in flex scanner failed" ); \
1059 while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
1061 if( errno != EINTR) \
1063 YY_FATAL_ERROR( "input in flex scanner failed" ); \
1071 /* %if-c++-only C++ definition \ */\
1076 /* No semi-colon after return; correct usage is to write "yyterminate();" -
1077 * we don't want an extra ';' after the "return" because that will cause
1078 * some compilers to complain about unreachable statements.
1081 #define yyterminate() return YY_NULL
1084 /* Number of entries by which start-condition stack grows. */
1085 #ifndef YY_START_STACK_INCR
1086 #define YY_START_STACK_INCR 25
1089 /* Report a fatal error. */
1090 #ifndef YY_FATAL_ERROR
1092 #define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner)
1098 /* %if-tables-serialization structures and prototypes */
1099 /* %not-for-header */
1101 /* %ok-for-header */
1103 /* %not-for-header */
1105 /* %tables-yydmap generated elements */
1107 /* end tables serialization structures and prototypes */
1109 /* %ok-for-header */
1111 /* Default declaration of generated scanner - a define so the user can
1112 * easily add parameters.
1115 #define YY_DECL_IS_OURS 1
1116 /* %if-c-only Standard (non-C++) definition */
1118 extern int hd_prelex (yyscan_t yyscanner
);
1120 #define YY_DECL int hd_prelex (yyscan_t yyscanner)
1122 /* %if-c++-only C++ definition */
1124 #endif /* !YY_DECL */
1126 /* Code executed at the beginning of each rule, after yytext and yyleng
1129 #ifndef YY_USER_ACTION
1130 #define YY_USER_ACTION
1133 /* Code executed at the end of each rule. */
1135 #define YY_BREAK break;
1138 /* %% [6.0] YY_RULE_SETUP definition goes here */
1139 #define YY_RULE_SETUP \
1141 YY_CURRENT_BUFFER_LVALUE->yy_at_bol = \
1142 (yytext[yyleng - 1] == '\n'); \
1145 /* %not-for-header */
1147 /** The main scanner function which does all the work.
1151 register yy_state_type yy_current_state
;
1152 register char *yy_cp
, *yy_bp
;
1153 register int yy_act
;
1154 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
;
1156 /* %% [7.0] user's declarations go here */
1157 #line 276 "hdocprep.l"
1160 #line 1161 "hdocprep.c"
1162 if ( !yyg
->yy_init
)
1170 if ( ! yyg
->yy_start
)
1171 yyg
->yy_start
= 1; /* first start state */
1187 if ( ! YY_CURRENT_BUFFER
) {
1188 hd_preensure_buffer_stack (yyscanner
);
1189 YY_CURRENT_BUFFER_LVALUE
=
1190 hd_pre_create_buffer(yyin
,YY_BUF_SIZE
,yyscanner
);
1193 hd_pre_load_buffer_state(yyscanner
);
1196 while ( 1 ) /* loops until end-of-file is reached */
1198 /* %% [8.0] yymore()-related code goes here */
1199 yy_cp
= yyg
->yy_c_buf_p
;
1201 /* Support of yytext. */
1202 *yy_cp
= yyg
->yy_hold_char
;
1204 /* yy_bp points to the position in yy_ch_buf of the start of
1209 /* %% [9.0] code to set up and find next match goes here */
1210 yy_current_state
= yyg
->yy_start
;
1211 yy_current_state
+= YY_AT_BOL();
1215 register YY_CHAR yy_c
= yy_ec
[YY_SC_TO_UI(*yy_cp
)];
1216 if ( yy_accept
[yy_current_state
] )
1218 yyg
->yy_last_accepting_state
= yy_current_state
;
1219 yyg
->yy_last_accepting_cpos
= yy_cp
;
1221 while ( yy_chk
[yy_base
[yy_current_state
] + yy_c
] != yy_current_state
)
1223 yy_current_state
= (int) yy_def
[yy_current_state
];
1224 if ( yy_current_state
>= 105 )
1225 yy_c
= yy_meta
[(unsigned int) yy_c
];
1227 yy_current_state
= yy_nxt
[yy_base
[yy_current_state
] + (unsigned int) yy_c
];
1230 while ( yy_current_state
!= 104 );
1231 yy_cp
= yyg
->yy_last_accepting_cpos
;
1232 yy_current_state
= yyg
->yy_last_accepting_state
;
1235 /* %% [10.0] code to find the action number goes here */
1236 yy_act
= yy_accept
[yy_current_state
];
1238 YY_DO_BEFORE_ACTION
;
1240 /* %% [11.0] code for yylineno update goes here */
1242 if ( yy_act
!= YY_END_OF_BUFFER
&& yy_rule_can_match_eol
[yy_act
] )
1245 for ( yyl
= 0; yyl
< yyleng
; ++yyl
)
1246 if ( yytext
[yyl
] == '\n' )
1254 do_action
: /* This label is used only to access EOF actions. */
1256 /* %% [12.0] debug code goes here */
1257 if ( yy_flex_debug
)
1260 fprintf( stderr
, "--scanner backing up\n" );
1261 else if ( yy_act
< 16 )
1262 fprintf( stderr
, "--accepting rule at line %ld (\"%s\")\n",
1263 (long)yy_rule_linenum
[yy_act
], yytext
);
1264 else if ( yy_act
== 16 )
1265 fprintf( stderr
, "--accepting default rule (\"%s\")\n",
1267 else if ( yy_act
== 17 )
1268 fprintf( stderr
, "--(end of buffer or a NUL)\n" );
1270 fprintf( stderr
, "--EOF (start condition %d)\n", YY_START
);
1274 { /* beginning of action switch */
1275 /* %% [13.0] actions go here */
1276 case 0: /* must back up */
1277 /* undo the effects of YY_DO_BEFORE_ACTION */
1278 *yy_cp
= yyg
->yy_hold_char
;
1279 yy_cp
= yyg
->yy_last_accepting_cpos
;
1280 yy_current_state
= yyg
->yy_last_accepting_state
;
1281 goto yy_find_action
;
1284 /* rule 1 can match eol */
1286 #line 278 "hdocprep.l"
1287 { /* ignore line comments */ }
1290 /* rule 2 can match eol */
1292 #line 280 "hdocprep.l"
1293 { yy_push_state(POD
, yyscanner
); }
1296 /* rule 3 can match eol */
1298 #line 283 "hdocprep.l"
1299 { /* end of POD comment */
1300 yy_pop_state(yyscanner
);
1304 /* rule 4 can match eol */
1306 #line 287 "hdocprep.l"
1307 { /* ignore pod comments */ }
1309 case YY_STATE_EOF(POD
):
1310 #line 289 "hdocprep.l"
1311 { /* we're scanning a POD comment, but encountered end-of-file. */
1312 lex_error("POD comment not closed!", yylineno
, hd_preget_extra(yyscanner
));
1317 /* rule 5 can match eol */
1319 #line 294 "hdocprep.l"
1320 { /* don't do anything */ }
1324 #line 296 "hdocprep.l"
1325 { /* echo everything when scanning the string. */
1326 fprintf(output
, "%s", yytext
);
1329 case YY_STATE_EOF(SCANSTRING
):
1330 #line 300 "hdocprep.l"
1331 { /* end of saved string */
1332 global_state
*state
= hd_preget_extra(yyscanner
);
1333 assert(state
->file_buffer
);
1334 hd_pre_switch_to_buffer(state
->file_buffer
,yyscanner
);
1336 /* clear the temp. variable; file_buffer is only used to temporarily
1337 * store a reference to the current buffer when we switch from file
1338 * to string scanning; after finishing scanning the string (which
1339 * is now, as we just scanned <<EOF>>), we switch back to the file
1342 state
->file_buffer
= NULL
;
1346 fprintf(output
, "\n setline %d\n", yylineno
);
1351 #line 319 "hdocprep.l"
1352 { /* 2nd and later heredoc argument */
1353 global_state
*state
= hd_preget_extra(yyscanner
);
1354 state
->delimiter
= (char *)calloc(yyleng
- 4 + 1, sizeof (char));
1355 assert(state
->delimiter
);
1356 strncpy(state
->delimiter
, yytext
+ 3, yyleng
- 4);
1358 state
->heredoc
= dupstr("");
1364 #line 329 "hdocprep.l"
1365 { /* only copy the string after "<<'" and skip the last quote too */
1366 global_state
*state
= hd_preget_extra(yyscanner
);
1367 /* allocate storage for the delimiter, skip the << and quote characters. */
1368 state
->delimiter
= (char *)calloc(yyleng
- 4 + 1, sizeof (char));
1369 assert(state
->delimiter
);
1370 strncpy(state
->delimiter
, yytext
+ 3, yyleng
- 4);
1371 state
->heredoc
= dupstr("");
1376 /* rule 9 can match eol */
1378 #line 339 "hdocprep.l"
1379 { /* this state is used when reading the first heredoc delimiter
1380 * argument. Save the rest of the line and go scan the heredoc.
1382 global_state
*state
= hd_preget_extra(yyscanner
);
1386 assert(state
->linebuffer
!= NULL
);
1387 free(state
->linebuffer
);
1389 /* somehow, if we don't duplicate the string twice,
1390 * things don't work. Unclear to me why this is.
1392 temp
= dupstr(yytext
);
1393 state
->linebuffer
= dupstr(temp
);
1394 assert(strcmp(temp
,state
->linebuffer
)==0 && strcmp(temp
,yytext
)==0);
1400 /* rule 10 can match eol */
1402 #line 359 "hdocprep.l"
1403 { /* this state is used when reading the 2nd and later heredoc
1404 delimiter arguments. Save the rest of the line and go scan
1405 the heredoc string. First, though, switch back to the file,
1406 because <SAVELINE2> state is activated when reading a string.
1408 global_state
*state
= hd_preget_extra(yyscanner
);
1410 state
->linebuffer
= dupstr(yytext
);
1412 hd_pre_switch_to_buffer(state
->file_buffer
,yyscanner
);
1417 /* rule 11 can match eol */
1419 #line 372 "hdocprep.l"
1420 { /* Scan a newline character, append this to the heredoc, but
1423 global_state
*state
= hd_preget_extra(yyscanner
);
1424 int len
= strlen(state
->heredoc
);
1425 char *temp
= (char *)calloc(len
+ 1 + 2, sizeof (char));
1426 assert(temp
!= NULL
);
1427 strcpy(temp
, state
->heredoc
);
1429 state
->heredoc
= temp
;
1431 assert(state
->heredoc
!= NULL
);
1433 /* translate "\n" to a "\" and "n" character */
1435 state->heredoc[len] = '\\';
1436 state->heredoc[len + 1] = 'n';
1437 state->heredoc[len + 2] = '\0';
1439 strcpy(state
->heredoc
+ len
, "\\n");
1444 #line 394 "hdocprep.l"
1445 { /* scan heredoc string contents */
1447 global_state
*state
= hd_preget_extra(yyscanner
);
1448 /* on windows remove the '\r' character */
1449 if (yytext
[yyleng
- 1] == '\r') {
1453 if (strcmp(yytext
, state
->delimiter
) == 0) {
1455 fprintf(output
, "\"%s\"", state
->heredoc
);
1456 /* free the delimiter memory */
1457 free(state
->delimiter
);
1458 state
->delimiter
= NULL
;
1460 assert(state
->heredoc
!= NULL
);
1461 free(state
->heredoc
);
1463 state
->heredoc
= dupstr("");
1465 /* save the current buffer, because we go scan the
1466 * rest of the string that was saved in <SAVELINE(2)>.
1468 state
->file_buffer
= YY_CURRENT_BUFFER
;
1470 assert(state
->linebuffer
!= NULL
);
1471 hd_pre_scan_string(state
->linebuffer
,yyscanner
);
1474 /* save this heredoc string line */
1475 char *thisline
= dupstr(yytext
);
1476 state
->heredoc
= strcat(state
->heredoc
, thisline
);
1480 case YY_STATE_EOF(HEREDOC
):
1481 #line 429 "hdocprep.l"
1482 { /* End of file while reading a heredoc string. This is bad. */
1483 global_state
*state
= hd_preget_extra(yyscanner
);
1485 "\nError: end of file while reading heredoc string '%s'\n",
1490 case YY_STATE_EOF(INITIAL
):
1491 case YY_STATE_EOF(HEREDOC2
):
1492 case YY_STATE_EOF(SAVELINE
):
1493 case YY_STATE_EOF(SAVELINE2
):
1494 #line 438 "hdocprep.l"
1500 /* rule 13 can match eol */
1502 #line 442 "hdocprep.l"
1503 { /* we only want to print a single newline instead of all newlines. */
1504 fprintf(output
, "\n");
1508 /* rule 14 can match eol */
1510 #line 446 "hdocprep.l"
1511 { /* do nothing. */ }
1515 #line 448 "hdocprep.l"
1516 { /* just echo everything else */
1517 fprintf(output
, "%s", yytext
);
1522 #line 452 "hdocprep.l"
1525 #line 1526 "hdocprep.c"
1527 case YY_END_OF_BUFFER
:
1529 /* Amount of text matched not including the EOB char. */
1530 int yy_amount_of_matched_text
= (int) (yy_cp
- yyg
->yytext_ptr
) - 1;
1532 /* Undo the effects of YY_DO_BEFORE_ACTION. */
1533 *yy_cp
= yyg
->yy_hold_char
;
1534 YY_RESTORE_YY_MORE_OFFSET
1536 if ( YY_CURRENT_BUFFER_LVALUE
->yy_buffer_status
== YY_BUFFER_NEW
)
1538 /* We're scanning a new file or input source. It's
1539 * possible that this happened because the user
1540 * just pointed yyin at a new source and called
1541 * hd_prelex(). If so, then we have to assure
1542 * consistency between YY_CURRENT_BUFFER and our
1543 * globals. Here is the right place to do so, because
1544 * this is the first action (other than possibly a
1545 * back-up) that will match for the new input source.
1547 yyg
->yy_n_chars
= YY_CURRENT_BUFFER_LVALUE
->yy_n_chars
;
1548 YY_CURRENT_BUFFER_LVALUE
->yy_input_file
= yyin
;
1549 YY_CURRENT_BUFFER_LVALUE
->yy_buffer_status
= YY_BUFFER_NORMAL
;
1552 /* Note that here we test for yy_c_buf_p "<=" to the position
1553 * of the first EOB in the buffer, since yy_c_buf_p will
1554 * already have been incremented past the NUL character
1555 * (since all states make transitions on EOB to the
1556 * end-of-buffer state). Contrast this with the test
1559 if ( yyg
->yy_c_buf_p
<= &YY_CURRENT_BUFFER_LVALUE
->yy_ch_buf
[yyg
->yy_n_chars
] )
1560 { /* This was really a NUL. */
1561 yy_state_type yy_next_state
;
1563 yyg
->yy_c_buf_p
= yyg
->yytext_ptr
+ yy_amount_of_matched_text
;
1565 yy_current_state
= yy_get_previous_state( yyscanner
);
1567 /* Okay, we're now positioned to make the NUL
1568 * transition. We couldn't have
1569 * yy_get_previous_state() go ahead and do it
1570 * for us because it doesn't know how to deal
1571 * with the possibility of jamming (and we don't
1572 * want to build jamming into it because then it
1573 * will run more slowly).
1576 yy_next_state
= yy_try_NUL_trans( yy_current_state
, yyscanner
);
1578 yy_bp
= yyg
->yytext_ptr
+ YY_MORE_ADJ
;
1580 if ( yy_next_state
)
1582 /* Consume the NUL. */
1583 yy_cp
= ++yyg
->yy_c_buf_p
;
1584 yy_current_state
= yy_next_state
;
1590 /* %% [14.0] code to do back-up for compressed tables and set up yy_cp goes here */
1591 yy_cp
= yyg
->yy_last_accepting_cpos
;
1592 yy_current_state
= yyg
->yy_last_accepting_state
;
1593 goto yy_find_action
;
1597 else switch ( yy_get_next_buffer( yyscanner
) )
1599 case EOB_ACT_END_OF_FILE
:
1601 yyg
->yy_did_buffer_switch_on_eof
= 0;
1603 if ( hd_prewrap(yyscanner
) )
1605 /* Note: because we've taken care in
1606 * yy_get_next_buffer() to have set up
1607 * yytext, we can now set up
1608 * yy_c_buf_p so that if some total
1609 * hoser (like flex itself) wants to
1610 * call the scanner after we return the
1611 * YY_NULL, it'll still work - another
1612 * YY_NULL will get returned.
1614 yyg
->yy_c_buf_p
= yyg
->yytext_ptr
+ YY_MORE_ADJ
;
1616 yy_act
= YY_STATE_EOF(YY_START
);
1622 if ( ! yyg
->yy_did_buffer_switch_on_eof
)
1628 case EOB_ACT_CONTINUE_SCAN
:
1630 yyg
->yytext_ptr
+ yy_amount_of_matched_text
;
1632 yy_current_state
= yy_get_previous_state( yyscanner
);
1634 yy_cp
= yyg
->yy_c_buf_p
;
1635 yy_bp
= yyg
->yytext_ptr
+ YY_MORE_ADJ
;
1638 case EOB_ACT_LAST_MATCH
:
1640 &YY_CURRENT_BUFFER_LVALUE
->yy_ch_buf
[yyg
->yy_n_chars
];
1642 yy_current_state
= yy_get_previous_state( yyscanner
);
1644 yy_cp
= yyg
->yy_c_buf_p
;
1645 yy_bp
= yyg
->yytext_ptr
+ YY_MORE_ADJ
;
1646 goto yy_find_action
;
1653 "fatal flex scanner internal error--no action found" );
1654 } /* end of action switch */
1655 } /* end of scanning one token */
1656 } /* end of hd_prelex */
1657 /* %ok-for-header */
1660 /* %not-for-header */
1662 /* %ok-for-header */
1666 /* yy_get_next_buffer - try to read in a new buffer
1668 * Returns a code representing an action:
1669 * EOB_ACT_LAST_MATCH -
1670 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1671 * EOB_ACT_END_OF_FILE - end of file
1674 static int yy_get_next_buffer (yyscan_t yyscanner
)
1679 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
;
1680 register char *dest
= YY_CURRENT_BUFFER_LVALUE
->yy_ch_buf
;
1681 register char *source
= yyg
->yytext_ptr
;
1682 register int number_to_move
, i
;
1685 if ( yyg
->yy_c_buf_p
> &YY_CURRENT_BUFFER_LVALUE
->yy_ch_buf
[yyg
->yy_n_chars
+ 1] )
1687 "fatal flex scanner internal error--end of buffer missed" );
1689 if ( YY_CURRENT_BUFFER_LVALUE
->yy_fill_buffer
== 0 )
1690 { /* Don't try to fill the buffer, so this is an EOF. */
1691 if ( yyg
->yy_c_buf_p
- yyg
->yytext_ptr
- YY_MORE_ADJ
== 1 )
1693 /* We matched a single character, the EOB, so
1694 * treat this as a final EOF.
1696 return EOB_ACT_END_OF_FILE
;
1701 /* We matched some text prior to the EOB, first
1704 return EOB_ACT_LAST_MATCH
;
1708 /* Try to read more data. */
1710 /* First move last chars to start of buffer. */
1711 number_to_move
= (int) (yyg
->yy_c_buf_p
- yyg
->yytext_ptr
) - 1;
1713 for ( i
= 0; i
< number_to_move
; ++i
)
1714 *(dest
++) = *(source
++);
1716 if ( YY_CURRENT_BUFFER_LVALUE
->yy_buffer_status
== YY_BUFFER_EOF_PENDING
)
1717 /* don't do the read, it's not guaranteed to return an EOF,
1720 YY_CURRENT_BUFFER_LVALUE
->yy_n_chars
= yyg
->yy_n_chars
= 0;
1725 YY_CURRENT_BUFFER_LVALUE
->yy_buf_size
- number_to_move
- 1;
1727 while ( num_to_read
<= 0 )
1728 { /* Not enough room in the buffer - grow it. */
1730 /* just a shorter name for the current buffer */
1731 YY_BUFFER_STATE b
= YY_CURRENT_BUFFER
;
1733 int yy_c_buf_p_offset
=
1734 (int) (yyg
->yy_c_buf_p
- b
->yy_ch_buf
);
1736 if ( b
->yy_is_our_buffer
)
1738 int new_size
= b
->yy_buf_size
* 2;
1740 if ( new_size
<= 0 )
1741 b
->yy_buf_size
+= b
->yy_buf_size
/ 8;
1743 b
->yy_buf_size
*= 2;
1745 b
->yy_ch_buf
= (char *)
1746 /* Include room in for 2 EOB chars. */
1747 hd_prerealloc((void *) b
->yy_ch_buf
,b
->yy_buf_size
+ 2 ,yyscanner
);
1750 /* Can't grow it, we don't own it. */
1753 if ( ! b
->yy_ch_buf
)
1755 "fatal error - scanner input buffer overflow" );
1757 yyg
->yy_c_buf_p
= &b
->yy_ch_buf
[yy_c_buf_p_offset
];
1759 num_to_read
= YY_CURRENT_BUFFER_LVALUE
->yy_buf_size
-
1764 if ( num_to_read
> YY_READ_BUF_SIZE
)
1765 num_to_read
= YY_READ_BUF_SIZE
;
1767 /* Read in more data. */
1768 YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE
->yy_ch_buf
[number_to_move
]),
1769 yyg
->yy_n_chars
, num_to_read
);
1771 YY_CURRENT_BUFFER_LVALUE
->yy_n_chars
= yyg
->yy_n_chars
;
1774 if ( yyg
->yy_n_chars
== 0 )
1776 if ( number_to_move
== YY_MORE_ADJ
)
1778 ret_val
= EOB_ACT_END_OF_FILE
;
1779 hd_prerestart(yyin
,yyscanner
);
1784 ret_val
= EOB_ACT_LAST_MATCH
;
1785 YY_CURRENT_BUFFER_LVALUE
->yy_buffer_status
=
1786 YY_BUFFER_EOF_PENDING
;
1791 ret_val
= EOB_ACT_CONTINUE_SCAN
;
1793 yyg
->yy_n_chars
+= number_to_move
;
1794 YY_CURRENT_BUFFER_LVALUE
->yy_ch_buf
[yyg
->yy_n_chars
] = YY_END_OF_BUFFER_CHAR
;
1795 YY_CURRENT_BUFFER_LVALUE
->yy_ch_buf
[yyg
->yy_n_chars
+ 1] = YY_END_OF_BUFFER_CHAR
;
1797 yyg
->yytext_ptr
= &YY_CURRENT_BUFFER_LVALUE
->yy_ch_buf
[0];
1802 /* yy_get_previous_state - get the state just before the EOB char was reached */
1805 /* %not-for-header */
1807 static yy_state_type
yy_get_previous_state (yyscan_t yyscanner
)
1812 register yy_state_type yy_current_state
;
1813 register char *yy_cp
;
1814 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
;
1816 /* %% [15.0] code to get the start state into yy_current_state goes here */
1817 yy_current_state
= yyg
->yy_start
;
1818 yy_current_state
+= YY_AT_BOL();
1820 for ( yy_cp
= yyg
->yytext_ptr
+ YY_MORE_ADJ
; yy_cp
< yyg
->yy_c_buf_p
; ++yy_cp
)
1822 /* %% [16.0] code to find the next state goes here */
1823 register YY_CHAR yy_c
= (*yy_cp
? yy_ec
[YY_SC_TO_UI(*yy_cp
)] : 1);
1824 if ( yy_accept
[yy_current_state
] )
1826 yyg
->yy_last_accepting_state
= yy_current_state
;
1827 yyg
->yy_last_accepting_cpos
= yy_cp
;
1829 while ( yy_chk
[yy_base
[yy_current_state
] + yy_c
] != yy_current_state
)
1831 yy_current_state
= (int) yy_def
[yy_current_state
];
1832 if ( yy_current_state
>= 105 )
1833 yy_c
= yy_meta
[(unsigned int) yy_c
];
1835 yy_current_state
= yy_nxt
[yy_base
[yy_current_state
] + (unsigned int) yy_c
];
1838 return yy_current_state
;
1841 /* yy_try_NUL_trans - try to make a transition on the NUL character
1844 * next_state = yy_try_NUL_trans( current_state );
1847 static yy_state_type
yy_try_NUL_trans (yy_state_type yy_current_state
, yyscan_t yyscanner
)
1852 register int yy_is_jam
;
1853 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
; /* This var may be unused depending upon options. */
1854 /* %% [17.0] code to find the next state, and perhaps do backing up, goes here */
1855 register char *yy_cp
= yyg
->yy_c_buf_p
;
1857 register YY_CHAR yy_c
= 1;
1858 if ( yy_accept
[yy_current_state
] )
1860 yyg
->yy_last_accepting_state
= yy_current_state
;
1861 yyg
->yy_last_accepting_cpos
= yy_cp
;
1863 while ( yy_chk
[yy_base
[yy_current_state
] + yy_c
] != yy_current_state
)
1865 yy_current_state
= (int) yy_def
[yy_current_state
];
1866 if ( yy_current_state
>= 105 )
1867 yy_c
= yy_meta
[(unsigned int) yy_c
];
1869 yy_current_state
= yy_nxt
[yy_base
[yy_current_state
] + (unsigned int) yy_c
];
1870 yy_is_jam
= (yy_current_state
== 104);
1872 return yy_is_jam
? 0 : yy_current_state
;
1882 static int yyinput (yyscan_t yyscanner
)
1884 static int input (yyscan_t yyscanner
)
1892 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
;
1894 *yyg
->yy_c_buf_p
= yyg
->yy_hold_char
;
1896 if ( *yyg
->yy_c_buf_p
== YY_END_OF_BUFFER_CHAR
)
1898 /* yy_c_buf_p now points to the character we want to return.
1899 * If this occurs *before* the EOB characters, then it's a
1900 * valid NUL; if not, then we've hit the end of the buffer.
1902 if ( yyg
->yy_c_buf_p
< &YY_CURRENT_BUFFER_LVALUE
->yy_ch_buf
[yyg
->yy_n_chars
] )
1903 /* This was really a NUL. */
1904 *yyg
->yy_c_buf_p
= '\0';
1907 { /* need more input */
1908 int offset
= yyg
->yy_c_buf_p
- yyg
->yytext_ptr
;
1911 switch ( yy_get_next_buffer( yyscanner
) )
1913 case EOB_ACT_LAST_MATCH
:
1914 /* This happens because yy_g_n_b()
1915 * sees that we've accumulated a
1916 * token and flags that we need to
1917 * try matching the token before
1918 * proceeding. But for input(),
1919 * there's no matching to consider.
1920 * So convert the EOB_ACT_LAST_MATCH
1921 * to EOB_ACT_END_OF_FILE.
1924 /* Reset buffer status. */
1925 hd_prerestart(yyin
,yyscanner
);
1929 case EOB_ACT_END_OF_FILE
:
1931 if ( hd_prewrap(yyscanner
) )
1934 if ( ! yyg
->yy_did_buffer_switch_on_eof
)
1937 return yyinput(yyscanner
);
1939 return input(yyscanner
);
1943 case EOB_ACT_CONTINUE_SCAN
:
1944 yyg
->yy_c_buf_p
= yyg
->yytext_ptr
+ offset
;
1950 c
= *(unsigned char *) yyg
->yy_c_buf_p
; /* cast for 8-bit char's */
1951 *yyg
->yy_c_buf_p
= '\0'; /* preserve yytext */
1952 yyg
->yy_hold_char
= *++yyg
->yy_c_buf_p
;
1954 /* %% [19.0] update BOL and yylineno */
1955 YY_CURRENT_BUFFER_LVALUE
->yy_at_bol
= (c
== '\n');
1956 if ( YY_CURRENT_BUFFER_LVALUE
->yy_at_bol
)
1966 #endif /* ifndef YY_NO_INPUT */
1969 /** Immediately switch to a different input stream.
1970 * @param input_file A readable stream.
1971 * @param yyscanner The scanner object.
1972 * @note This function does not reset the start condition to @c INITIAL .
1975 void hd_prerestart (FILE * input_file
, yyscan_t yyscanner
)
1980 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
;
1982 if ( ! YY_CURRENT_BUFFER
){
1983 hd_preensure_buffer_stack (yyscanner
);
1984 YY_CURRENT_BUFFER_LVALUE
=
1985 hd_pre_create_buffer(yyin
,YY_BUF_SIZE
,yyscanner
);
1988 hd_pre_init_buffer(YY_CURRENT_BUFFER
,input_file
,yyscanner
);
1989 hd_pre_load_buffer_state(yyscanner
);
1992 /** Switch to a different input buffer.
1993 * @param new_buffer The new input buffer.
1994 * @param yyscanner The scanner object.
1997 void hd_pre_switch_to_buffer (YY_BUFFER_STATE new_buffer
, yyscan_t yyscanner
)
2002 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
;
2004 /* TODO. We should be able to replace this entire function body
2006 * hd_prepop_buffer_state();
2007 * hd_prepush_buffer_state(new_buffer);
2009 hd_preensure_buffer_stack (yyscanner
);
2010 if ( YY_CURRENT_BUFFER
== new_buffer
)
2013 if ( YY_CURRENT_BUFFER
)
2015 /* Flush out information for old buffer. */
2016 *yyg
->yy_c_buf_p
= yyg
->yy_hold_char
;
2017 YY_CURRENT_BUFFER_LVALUE
->yy_buf_pos
= yyg
->yy_c_buf_p
;
2018 YY_CURRENT_BUFFER_LVALUE
->yy_n_chars
= yyg
->yy_n_chars
;
2021 YY_CURRENT_BUFFER_LVALUE
= new_buffer
;
2022 hd_pre_load_buffer_state(yyscanner
);
2024 /* We don't actually know whether we did this switch during
2025 * EOF (hd_prewrap()) processing, but the only time this flag
2026 * is looked at is after hd_prewrap() is called, so it's safe
2027 * to go ahead and always set it.
2029 yyg
->yy_did_buffer_switch_on_eof
= 1;
2033 static void hd_pre_load_buffer_state (yyscan_t yyscanner
)
2038 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
;
2039 yyg
->yy_n_chars
= YY_CURRENT_BUFFER_LVALUE
->yy_n_chars
;
2040 yyg
->yytext_ptr
= yyg
->yy_c_buf_p
= YY_CURRENT_BUFFER_LVALUE
->yy_buf_pos
;
2041 yyin
= YY_CURRENT_BUFFER_LVALUE
->yy_input_file
;
2042 yyg
->yy_hold_char
= *yyg
->yy_c_buf_p
;
2045 /** Allocate and initialize an input buffer state.
2046 * @param file A readable stream.
2047 * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
2048 * @param yyscanner The scanner object.
2049 * @return the allocated buffer state.
2052 YY_BUFFER_STATE
hd_pre_create_buffer (FILE * file
, int size
, yyscan_t yyscanner
)
2059 b
= (YY_BUFFER_STATE
) hd_prealloc(sizeof( struct yy_buffer_state
) ,yyscanner
);
2061 YY_FATAL_ERROR( "out of dynamic memory in hd_pre_create_buffer()" );
2063 b
->yy_buf_size
= size
;
2065 /* yy_ch_buf has to be 2 characters longer than the size given because
2066 * we need to put in 2 end-of-buffer characters.
2068 b
->yy_ch_buf
= (char *) hd_prealloc(b
->yy_buf_size
+ 2 ,yyscanner
);
2069 if ( ! b
->yy_ch_buf
)
2070 YY_FATAL_ERROR( "out of dynamic memory in hd_pre_create_buffer()" );
2072 b
->yy_is_our_buffer
= 1;
2074 hd_pre_init_buffer(b
,file
,yyscanner
);
2079 /** Destroy the buffer.
2080 * @param b a buffer created with hd_pre_create_buffer()
2081 * @param yyscanner The scanner object.
2084 void hd_pre_delete_buffer (YY_BUFFER_STATE b
, yyscan_t yyscanner
)
2089 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
;
2094 if ( b
== YY_CURRENT_BUFFER
) /* Not sure if we should pop here. */
2095 YY_CURRENT_BUFFER_LVALUE
= (YY_BUFFER_STATE
) 0;
2097 if ( b
->yy_is_our_buffer
)
2098 hd_prefree((void *) b
->yy_ch_buf
,yyscanner
);
2100 hd_prefree((void *) b
,yyscanner
);
2110 /* Initializes or reinitializes a buffer.
2111 * This function is sometimes called more than once on the same buffer,
2112 * such as during a hd_prerestart() or at EOF.
2115 static void hd_pre_init_buffer (YY_BUFFER_STATE b
, FILE * file
, yyscan_t yyscanner
)
2122 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
;
2124 hd_pre_flush_buffer(b
,yyscanner
);
2126 b
->yy_input_file
= file
;
2127 b
->yy_fill_buffer
= 1;
2129 /* If b is the current buffer, then hd_pre_init_buffer was _probably_
2130 * called from hd_prerestart() or through yy_get_next_buffer.
2131 * In that case, we don't want to reset the lineno or column.
2133 if (b
!= YY_CURRENT_BUFFER
){
2134 b
->yy_bs_lineno
= 1;
2135 b
->yy_bs_column
= 0;
2140 b
->yy_is_interactive
= 0;
2148 /** Discard all buffered characters. On the next scan, YY_INPUT will be called.
2149 * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
2150 * @param yyscanner The scanner object.
2153 void hd_pre_flush_buffer (YY_BUFFER_STATE b
, yyscan_t yyscanner
)
2158 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
;
2164 /* We always need two end-of-buffer characters. The first causes
2165 * a transition to the end-of-buffer state. The second causes
2166 * a jam in that state.
2168 b
->yy_ch_buf
[0] = YY_END_OF_BUFFER_CHAR
;
2169 b
->yy_ch_buf
[1] = YY_END_OF_BUFFER_CHAR
;
2171 b
->yy_buf_pos
= &b
->yy_ch_buf
[0];
2174 b
->yy_buffer_status
= YY_BUFFER_NEW
;
2176 if ( b
== YY_CURRENT_BUFFER
)
2177 hd_pre_load_buffer_state(yyscanner
);
2181 /** Pushes the new state onto the stack. The new state becomes
2182 * the current state. This function will allocate the stack
2184 * @param new_buffer The new state.
2185 * @param yyscanner The scanner object.
2188 void hd_prepush_buffer_state (YY_BUFFER_STATE new_buffer
, yyscan_t yyscanner
)
2193 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
;
2194 if (new_buffer
== NULL
)
2197 hd_preensure_buffer_stack(yyscanner
);
2199 /* This block is copied from hd_pre_switch_to_buffer. */
2200 if ( YY_CURRENT_BUFFER
)
2202 /* Flush out information for old buffer. */
2203 *yyg
->yy_c_buf_p
= yyg
->yy_hold_char
;
2204 YY_CURRENT_BUFFER_LVALUE
->yy_buf_pos
= yyg
->yy_c_buf_p
;
2205 YY_CURRENT_BUFFER_LVALUE
->yy_n_chars
= yyg
->yy_n_chars
;
2208 /* Only push if top exists. Otherwise, replace top. */
2209 if (YY_CURRENT_BUFFER
)
2210 yyg
->yy_buffer_stack_top
++;
2211 YY_CURRENT_BUFFER_LVALUE
= new_buffer
;
2213 /* copied from hd_pre_switch_to_buffer. */
2214 hd_pre_load_buffer_state(yyscanner
);
2215 yyg
->yy_did_buffer_switch_on_eof
= 1;
2220 /** Removes and deletes the top of the stack, if present.
2221 * The next element becomes the new top.
2222 * @param yyscanner The scanner object.
2225 void hd_prepop_buffer_state (yyscan_t yyscanner
)
2230 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
;
2231 if (!YY_CURRENT_BUFFER
)
2234 hd_pre_delete_buffer(YY_CURRENT_BUFFER
,yyscanner
);
2235 YY_CURRENT_BUFFER_LVALUE
= NULL
;
2236 if (yyg
->yy_buffer_stack_top
> 0)
2237 --yyg
->yy_buffer_stack_top
;
2239 if (YY_CURRENT_BUFFER
) {
2240 hd_pre_load_buffer_state(yyscanner
);
2241 yyg
->yy_did_buffer_switch_on_eof
= 1;
2247 /* Allocates the stack if it does not exist.
2248 * Guarantees space for at least one push.
2251 static void hd_preensure_buffer_stack (yyscan_t yyscanner
)
2257 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
;
2259 if (!yyg
->yy_buffer_stack
) {
2261 /* First allocation is just for 2 elements, since we don't know if this
2262 * scanner will even need a stack. We use 2 instead of 1 to avoid an
2263 * immediate realloc on the next call.
2266 yyg
->yy_buffer_stack
= (struct yy_buffer_state
**)hd_prealloc
2267 (num_to_alloc
* sizeof(struct yy_buffer_state
*)
2270 memset(yyg
->yy_buffer_stack
, 0, num_to_alloc
* sizeof(struct yy_buffer_state
*));
2272 yyg
->yy_buffer_stack_max
= num_to_alloc
;
2273 yyg
->yy_buffer_stack_top
= 0;
2277 if (yyg
->yy_buffer_stack_top
>= (yyg
->yy_buffer_stack_max
) - 1){
2279 /* Increase the buffer to prepare for a possible push. */
2280 int grow_size
= 8 /* arbitrary grow size */;
2282 num_to_alloc
= yyg
->yy_buffer_stack_max
+ grow_size
;
2283 yyg
->yy_buffer_stack
= (struct yy_buffer_state
**)hd_prerealloc
2284 (yyg
->yy_buffer_stack
,
2285 num_to_alloc
* sizeof(struct yy_buffer_state
*)
2288 /* zero only the new slots.*/
2289 memset(yyg
->yy_buffer_stack
+ yyg
->yy_buffer_stack_max
, 0, grow_size
* sizeof(struct yy_buffer_state
*));
2290 yyg
->yy_buffer_stack_max
= num_to_alloc
;
2296 /** Setup the input buffer state to scan directly from a user-specified character buffer.
2297 * @param base the character buffer
2298 * @param size the size in bytes of the character buffer
2299 * @param yyscanner The scanner object.
2300 * @return the newly allocated buffer state object.
2302 YY_BUFFER_STATE
hd_pre_scan_buffer (char * base
, yy_size_t size
, yyscan_t yyscanner
)
2307 base
[size
-2] != YY_END_OF_BUFFER_CHAR
||
2308 base
[size
-1] != YY_END_OF_BUFFER_CHAR
)
2309 /* They forgot to leave room for the EOB's. */
2312 b
= (YY_BUFFER_STATE
) hd_prealloc(sizeof( struct yy_buffer_state
) ,yyscanner
);
2314 YY_FATAL_ERROR( "out of dynamic memory in hd_pre_scan_buffer()" );
2316 b
->yy_buf_size
= size
- 2; /* "- 2" to take care of EOB's */
2317 b
->yy_buf_pos
= b
->yy_ch_buf
= base
;
2318 b
->yy_is_our_buffer
= 0;
2319 b
->yy_input_file
= 0;
2320 b
->yy_n_chars
= b
->yy_buf_size
;
2321 b
->yy_is_interactive
= 0;
2323 b
->yy_fill_buffer
= 0;
2324 b
->yy_buffer_status
= YY_BUFFER_NEW
;
2326 hd_pre_switch_to_buffer(b
,yyscanner
);
2333 /** Setup the input buffer state to scan a string. The next call to hd_prelex() will
2334 * scan from a @e copy of @a str.
2335 * @param str a NUL-terminated string to scan
2336 * @param yyscanner The scanner object.
2337 * @return the newly allocated buffer state object.
2338 * @note If you want to scan bytes that may contain NUL values, then use
2339 * hd_pre_scan_bytes() instead.
2341 YY_BUFFER_STATE
hd_pre_scan_string (yyconst
char * yystr
, yyscan_t yyscanner
)
2344 return hd_pre_scan_bytes(yystr
,strlen(yystr
) ,yyscanner
);
2349 /** Setup the input buffer state to scan the given bytes. The next call to hd_prelex() will
2350 * scan from a @e copy of @a bytes.
2351 * @param bytes the byte buffer to scan
2352 * @param len the number of bytes in the buffer pointed to by @a bytes.
2353 * @param yyscanner The scanner object.
2354 * @return the newly allocated buffer state object.
2356 YY_BUFFER_STATE
hd_pre_scan_bytes (yyconst
char * yybytes
, int _yybytes_len
, yyscan_t yyscanner
)
2363 /* Get memory for full buffer, including space for trailing EOB's. */
2364 n
= _yybytes_len
+ 2;
2365 buf
= (char *) hd_prealloc(n
,yyscanner
);
2367 YY_FATAL_ERROR( "out of dynamic memory in hd_pre_scan_bytes()" );
2369 for ( i
= 0; i
< _yybytes_len
; ++i
)
2370 buf
[i
] = yybytes
[i
];
2372 buf
[_yybytes_len
] = buf
[_yybytes_len
+1] = YY_END_OF_BUFFER_CHAR
;
2374 b
= hd_pre_scan_buffer(buf
,n
,yyscanner
);
2376 YY_FATAL_ERROR( "bad buffer in hd_pre_scan_bytes()" );
2378 /* It's okay to grow etc. this buffer, and we should throw it
2379 * away when we're done.
2381 b
->yy_is_our_buffer
= 1;
2388 static void yy_push_state (int new_state
, yyscan_t yyscanner
)
2393 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
;
2394 if ( yyg
->yy_start_stack_ptr
>= yyg
->yy_start_stack_depth
)
2398 yyg
->yy_start_stack_depth
+= YY_START_STACK_INCR
;
2399 new_size
= yyg
->yy_start_stack_depth
* sizeof( int );
2401 if ( ! yyg
->yy_start_stack
)
2402 yyg
->yy_start_stack
= (int *) hd_prealloc(new_size
,yyscanner
);
2405 yyg
->yy_start_stack
= (int *) hd_prerealloc((void *) yyg
->yy_start_stack
,new_size
,yyscanner
);
2407 if ( ! yyg
->yy_start_stack
)
2409 "out of memory expanding start-condition stack" );
2412 yyg
->yy_start_stack
[yyg
->yy_start_stack_ptr
++] = YY_START
;
2418 static void yy_pop_state (yyscan_t yyscanner
)
2423 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
;
2424 if ( --yyg
->yy_start_stack_ptr
< 0 )
2425 YY_FATAL_ERROR( "start-condition stack underflow" );
2427 BEGIN(yyg
->yy_start_stack
[yyg
->yy_start_stack_ptr
]);
2430 #ifndef YY_EXIT_FAILURE
2431 #define YY_EXIT_FAILURE 2
2435 static void yy_fatal_error (yyconst
char* msg
, yyscan_t yyscanner
)
2437 (void) fprintf( stderr
, "%s\n", msg
);
2438 exit( YY_EXIT_FAILURE
);
2444 /* Redefine yyless() so it works in section 3 code. */
2450 /* Undo effects of setting up yytext. */ \
2451 int yyless_macro_arg = (n); \
2452 YY_LESS_LINENO(yyless_macro_arg);\
2453 yytext[yyleng] = yyg->yy_hold_char; \
2454 yyg->yy_c_buf_p = yytext + yyless_macro_arg; \
2455 yyg->yy_hold_char = *yyg->yy_c_buf_p; \
2456 *yyg->yy_c_buf_p = '\0'; \
2457 yyleng = yyless_macro_arg; \
2461 /* Accessor methods (get/set functions) to struct members. */
2466 /** Get the user-defined data for this scanner.
2467 * @param yyscanner The scanner object.
2469 YY_EXTRA_TYPE
hd_preget_extra (yyscan_t yyscanner
)
2471 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
;
2477 /** Get the current line number.
2478 * @param yyscanner The scanner object.
2480 int hd_preget_lineno (yyscan_t yyscanner
)
2482 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
;
2484 if (! YY_CURRENT_BUFFER
)
2490 /** Get the current column number.
2491 * @param yyscanner The scanner object.
2493 int hd_preget_column (yyscan_t yyscanner
)
2495 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
;
2497 if (! YY_CURRENT_BUFFER
)
2503 /** Get the input stream.
2504 * @param yyscanner The scanner object.
2506 FILE *hd_preget_in (yyscan_t yyscanner
)
2508 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
;
2512 /** Get the output stream.
2513 * @param yyscanner The scanner object.
2515 FILE *hd_preget_out (yyscan_t yyscanner
)
2517 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
;
2521 /** Get the length of the current token.
2522 * @param yyscanner The scanner object.
2524 int hd_preget_leng (yyscan_t yyscanner
)
2526 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
;
2530 /** Get the current token.
2531 * @param yyscanner The scanner object.
2534 char *hd_preget_text (yyscan_t yyscanner
)
2536 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
;
2542 /** Set the user-defined data. This data is never touched by the scanner.
2543 * @param user_defined The data to be associated with this scanner.
2544 * @param yyscanner The scanner object.
2546 void hd_preset_extra (YY_EXTRA_TYPE user_defined
, yyscan_t yyscanner
)
2548 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
;
2549 yyextra
= user_defined
;
2554 /** Set the current line number.
2555 * @param line_number
2556 * @param yyscanner The scanner object.
2558 void hd_preset_lineno (int line_number
, yyscan_t yyscanner
)
2560 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
;
2562 /* lineno is only valid if an input buffer exists. */
2563 if (! YY_CURRENT_BUFFER
)
2564 yy_fatal_error( "hd_preset_lineno called with no buffer" , yyscanner
);
2566 yylineno
= line_number
;
2569 /** Set the current column.
2570 * @param line_number
2571 * @param yyscanner The scanner object.
2573 void hd_preset_column (int column_no
, yyscan_t yyscanner
)
2575 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
;
2577 /* column is only valid if an input buffer exists. */
2578 if (! YY_CURRENT_BUFFER
)
2579 yy_fatal_error( "hd_preset_column called with no buffer" , yyscanner
);
2581 yycolumn
= column_no
;
2584 /** Set the input stream. This does not discard the current
2586 * @param in_str A readable stream.
2587 * @param yyscanner The scanner object.
2588 * @see hd_pre_switch_to_buffer
2590 void hd_preset_in (FILE * in_str
, yyscan_t yyscanner
)
2592 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
;
2596 void hd_preset_out (FILE * out_str
, yyscan_t yyscanner
)
2598 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
;
2602 int hd_preget_debug (yyscan_t yyscanner
)
2604 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
;
2605 return yy_flex_debug
;
2608 void hd_preset_debug (int bdebug
, yyscan_t yyscanner
)
2610 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
;
2611 yy_flex_debug
= bdebug
;
2617 /* Accessor methods for yylval and yylloc */
2619 /* %if-bison-bridge */
2622 /* User-visible API */
2624 /* hd_prelex_init is special because it creates the scanner itself, so it is
2625 * the ONLY reentrant function that doesn't take the scanner as the last argument.
2626 * That's why we explicitly handle the declaration, instead of using our macros.
2629 int hd_prelex_init(yyscan_t
* ptr_yy_globals
)
2632 if (ptr_yy_globals
== NULL
){
2637 *ptr_yy_globals
= (yyscan_t
) hd_prealloc ( sizeof( struct yyguts_t
), NULL
);
2639 if (*ptr_yy_globals
== NULL
){
2644 /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */
2645 memset(*ptr_yy_globals
,0x00,sizeof(struct yyguts_t
));
2647 return yy_init_globals ( *ptr_yy_globals
);
2653 static int yy_init_globals (yyscan_t yyscanner
)
2655 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
;
2656 /* Initialization is the same as for the non-reentrant scanner.
2657 * This function is called from hd_prelex_destroy(), so don't allocate here.
2660 yyg
->yy_buffer_stack
= 0;
2661 yyg
->yy_buffer_stack_top
= 0;
2662 yyg
->yy_buffer_stack_max
= 0;
2663 yyg
->yy_c_buf_p
= (char *) 0;
2667 yyg
->yy_start_stack_ptr
= 0;
2668 yyg
->yy_start_stack_depth
= 0;
2669 yyg
->yy_start_stack
= NULL
;
2671 /* Defined in main.c */
2680 /* For future reference: Set errno on error, since we are called by
2687 /* %if-c-only SNIP! this currently causes conflicts with the c++ scanner */
2688 /* hd_prelex_destroy is for both reentrant and non-reentrant scanners. */
2689 int hd_prelex_destroy (yyscan_t yyscanner
)
2691 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
;
2693 /* Pop the buffer stack, destroying each element. */
2694 while(YY_CURRENT_BUFFER
){
2695 hd_pre_delete_buffer(YY_CURRENT_BUFFER
,yyscanner
);
2696 YY_CURRENT_BUFFER_LVALUE
= NULL
;
2697 hd_prepop_buffer_state(yyscanner
);
2700 /* Destroy the stack itself. */
2701 hd_prefree(yyg
->yy_buffer_stack
,yyscanner
);
2702 yyg
->yy_buffer_stack
= NULL
;
2704 /* Destroy the start condition stack. */
2705 hd_prefree(yyg
->yy_start_stack
,yyscanner
);
2706 yyg
->yy_start_stack
= NULL
;
2708 /* Reset the globals. This is important in a non-reentrant scanner so the next time
2709 * hd_prelex() is called, initialization will occur. */
2710 yy_init_globals( yyscanner
);
2713 /* Destroy the main struct (reentrant only). */
2714 hd_prefree ( yyscanner
, yyscanner
);
2722 * Internal utility routines.
2726 static void yy_flex_strncpy (char* s1
, yyconst
char * s2
, int n
, yyscan_t yyscanner
)
2729 for ( i
= 0; i
< n
; ++i
)
2734 #ifdef YY_NEED_STRLEN
2735 static int yy_flex_strlen (yyconst
char * s
, yyscan_t yyscanner
)
2738 for ( n
= 0; s
[n
]; ++n
)
2745 void *hd_prealloc (yy_size_t size
, yyscan_t yyscanner
)
2747 return (void *) malloc( size
);
2750 void *hd_prerealloc (void * ptr
, yy_size_t size
, yyscan_t yyscanner
)
2752 /* The cast to (char *) in the following accommodates both
2753 * implementations that use char* generic pointers, and those
2754 * that use void* generic pointers. It works with the latter
2755 * because both ANSI C and C++ allow castless assignment from
2756 * any pointer type to void*, and deal with argument conversions
2757 * as though doing an assignment.
2759 return (void *) realloc( (char *) ptr
, size
);
2762 void hd_prefree (void * ptr
, yyscan_t yyscanner
)
2764 free( (char *) ptr
); /* see hd_prerealloc() for (char *) cast */
2767 /* %if-tables-serialization definitions */
2768 /* %define-yytables The name for this specific scanner's tables. */
2769 #define YYTABLES_NAME "yytables"
2772 /* %ok-for-header */
2774 #line 452 "hdocprep.l"
2781 * c-file-style: "parrot"
2783 * vim: expandtab shiftwidth=4: