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
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
;
59 /* Limits of integral types. */
61 #define INT8_MIN (-128)
64 #define INT16_MIN (-32767-1)
67 #define INT32_MIN (-2147483647-1)
70 #define INT8_MAX (127)
73 #define INT16_MAX (32767)
76 #define INT32_MAX (2147483647)
79 #define UINT8_MAX (255U)
82 #define UINT16_MAX (65535U)
85 #define UINT32_MAX (4294967295U)
88 #endif /* ! FLEXINT_H */
92 /* The "const" storage-class-modifier is valid. */
95 #else /* ! __cplusplus */
101 #endif /* __STDC__ */
102 #endif /* ! __cplusplus */
105 #define yyconst const
110 /* Returned upon end-of-file. */
113 /* Promotes a possibly negative, possibly signed char to an unsigned
114 * integer for use as an array index. If the signed char is negative,
115 * we want to instead treat it as an 8-bit unsigned char, hence the
118 #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
120 /* An opaque pointer. */
121 #ifndef YY_TYPEDEF_YY_SCANNER_T
122 #define YY_TYPEDEF_YY_SCANNER_T
123 typedef void* yyscan_t
;
126 /* For convenience, these vars (plus the bison vars far below)
127 are macros in the reentrant scanner. */
128 #define yyin yyg->yyin_r
129 #define yyout yyg->yyout_r
130 #define yyextra yyg->yyextra_r
131 #define yyleng yyg->yyleng_r
132 #define yytext yyg->yytext_r
133 #define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno)
134 #define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column)
135 #define yy_flex_debug yyg->yy_flex_debug_r
137 int ast_yylex_init (yyscan_t
* scanner
);
139 /* Enter a start condition. This macro really ought to take a parameter,
140 * but we do it the disgusting crufty way forced on us by the ()-less
141 * definition of BEGIN.
143 #define BEGIN yyg->yy_start = 1 + 2 *
145 /* Translate the current start state into a value that can be later handed
146 * to BEGIN to return to the state. The YYSTATE alias is for lex
149 #define YY_START ((yyg->yy_start - 1) / 2)
150 #define YYSTATE YY_START
152 /* Action number for EOF rule of a given start state. */
153 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
155 /* Special action meaning "start processing a new file". */
156 #define YY_NEW_FILE ast_yyrestart(yyin ,yyscanner )
158 #define YY_END_OF_BUFFER_CHAR 0
160 /* Size of default input buffer. */
162 #define YY_BUF_SIZE 16384
165 /* The state buf must be large enough to hold one state per character in the main buffer.
167 #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
169 #ifndef YY_TYPEDEF_YY_BUFFER_STATE
170 #define YY_TYPEDEF_YY_BUFFER_STATE
171 typedef struct yy_buffer_state
*YY_BUFFER_STATE
;
174 #define EOB_ACT_CONTINUE_SCAN 0
175 #define EOB_ACT_END_OF_FILE 1
176 #define EOB_ACT_LAST_MATCH 2
178 #define YY_LESS_LINENO(n)
180 /* Return all but the first "n" matched characters back to the input stream. */
184 /* Undo effects of setting up yytext. */ \
185 int yyless_macro_arg = (n); \
186 YY_LESS_LINENO(yyless_macro_arg);\
187 *yy_cp = yyg->yy_hold_char; \
188 YY_RESTORE_YY_MORE_OFFSET \
189 yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
190 YY_DO_BEFORE_ACTION; /* set up yytext again */ \
194 #define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner )
196 /* The following is because we cannot portably get our hands on size_t
197 * (without autoconf's help, which isn't available because we want
198 * flex-generated scanners to compile on their own).
201 #ifndef YY_TYPEDEF_YY_SIZE_T
202 #define YY_TYPEDEF_YY_SIZE_T
203 typedef unsigned int yy_size_t
;
206 #ifndef YY_STRUCT_YY_BUFFER_STATE
207 #define YY_STRUCT_YY_BUFFER_STATE
208 struct yy_buffer_state
212 char *yy_ch_buf
; /* input buffer */
213 char *yy_buf_pos
; /* current position in input buffer */
215 /* Size of input buffer in bytes, not including room for EOB
218 yy_size_t yy_buf_size
;
220 /* Number of characters read into yy_ch_buf, not including EOB
225 /* Whether we "own" the buffer - i.e., we know we created it,
226 * and can realloc() it to grow it, and should free() it to
229 int yy_is_our_buffer
;
231 /* Whether this is an "interactive" input source; if so, and
232 * if we're using stdio for input, then we want to use getc()
233 * instead of fread(), to make sure we stop fetching input after
236 int yy_is_interactive
;
238 /* Whether we're considered to be at the beginning of a line.
239 * If so, '^' rules will be active on the next match, otherwise
244 int yy_bs_lineno
; /**< The line count. */
245 int yy_bs_column
; /**< The column count. */
247 /* Whether to try to fill the input buffer when we reach the
252 int yy_buffer_status
;
254 #define YY_BUFFER_NEW 0
255 #define YY_BUFFER_NORMAL 1
256 /* When an EOF's been seen but there's still some text to process
257 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
258 * shouldn't try reading from the input source any more. We might
259 * still have a bunch of tokens to match, though, because of
260 * possible backing-up.
262 * When we actually see the EOF, we change the status to "new"
263 * (via ast_yyrestart()), so that the user can continue scanning by
264 * just pointing yyin at a new input file.
266 #define YY_BUFFER_EOF_PENDING 2
269 #endif /* !YY_STRUCT_YY_BUFFER_STATE */
271 /* We provide macros for accessing buffer states in case in the
272 * future we want to put the buffer states in a more general
275 * Returns the top of the stack, or NULL.
277 #define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \
278 ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \
281 /* Same as previous macro, but useful when we know that the buffer stack is not
282 * NULL or when we need an lvalue. For internal use only.
284 #define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]
286 void ast_yyrestart (FILE *input_file
,yyscan_t yyscanner
);
287 void ast_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer
,yyscan_t yyscanner
);
288 YY_BUFFER_STATE
ast_yy_create_buffer (FILE *file
,int size
,yyscan_t yyscanner
);
289 void ast_yy_delete_buffer (YY_BUFFER_STATE b
,yyscan_t yyscanner
);
290 void ast_yy_flush_buffer (YY_BUFFER_STATE b
,yyscan_t yyscanner
);
291 void ast_yypush_buffer_state (YY_BUFFER_STATE new_buffer
,yyscan_t yyscanner
);
292 void ast_yypop_buffer_state (yyscan_t yyscanner
);
294 static void ast_yyensure_buffer_stack (yyscan_t yyscanner
);
295 static void ast_yy_load_buffer_state (yyscan_t yyscanner
);
296 static void ast_yy_init_buffer (YY_BUFFER_STATE b
,FILE *file
,yyscan_t yyscanner
);
298 #define YY_FLUSH_BUFFER ast_yy_flush_buffer(YY_CURRENT_BUFFER ,yyscanner)
300 YY_BUFFER_STATE
ast_yy_scan_buffer (char *base
,yy_size_t size
,yyscan_t yyscanner
);
301 YY_BUFFER_STATE
ast_yy_scan_string (yyconst
char *yy_str
,yyscan_t yyscanner
);
302 YY_BUFFER_STATE
ast_yy_scan_bytes (yyconst
char *bytes
,int len
,yyscan_t yyscanner
);
304 void *ast_yyalloc (yy_size_t
,yyscan_t yyscanner
);
305 void *ast_yyrealloc (void *,yy_size_t
,yyscan_t yyscanner
);
306 void ast_yyfree (void * ,yyscan_t yyscanner
);
308 #define yy_new_buffer ast_yy_create_buffer
310 #define yy_set_interactive(is_interactive) \
312 if ( ! YY_CURRENT_BUFFER ){ \
313 ast_yyensure_buffer_stack (yyscanner); \
314 YY_CURRENT_BUFFER_LVALUE = \
315 ast_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \
317 YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
320 #define yy_set_bol(at_bol) \
322 if ( ! YY_CURRENT_BUFFER ){\
323 ast_yyensure_buffer_stack (yyscanner); \
324 YY_CURRENT_BUFFER_LVALUE = \
325 ast_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \
327 YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
330 #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
332 /* Begin user sect3 */
334 #define ast_yywrap(n) 1
335 #define YY_SKIP_YYWRAP
337 typedef unsigned char YY_CHAR
;
339 typedef int yy_state_type
;
341 #define yytext_ptr yytext_r
343 static yy_state_type
yy_get_previous_state (yyscan_t yyscanner
);
344 static yy_state_type
yy_try_NUL_trans (yy_state_type current_state
,yyscan_t yyscanner
);
345 static int yy_get_next_buffer (yyscan_t yyscanner
);
346 static void yy_fatal_error (yyconst
char msg
[] ,yyscan_t yyscanner
);
348 /* Done after the current pattern has been matched and before the
349 * corresponding action - sets up yytext.
351 #define YY_DO_BEFORE_ACTION \
352 yyg->yytext_ptr = yy_bp; \
353 yyg->yytext_ptr -= yyg->yy_more_len; \
354 yyleng = (size_t) (yy_cp - yyg->yytext_ptr); \
355 yyg->yy_hold_char = *yy_cp; \
357 yyg->yy_c_buf_p = yy_cp;
359 #define YY_NUM_RULES 35
360 #define YY_END_OF_BUFFER 36
361 /* This struct is not used in this scanner,
362 but its presence is necessary. */
365 flex_int32_t yy_verify
;
368 static yyconst flex_int16_t yy_accept
[55] =
370 0, 0, 0, 0, 32, 32, 36, 35, 25, 27,
371 19, 35, 29, 29, 17, 2, 22, 23, 15, 13,
372 14, 16, 28, 20, 9, 3, 8, 18, 1, 35,
373 31, 30, 32, 33, 33, 12, 0, 26, 29, 24,
374 5, 28, 21, 11, 6, 7, 10, 4, 0, 31,
378 static yyconst flex_int32_t yy_ec
[256] =
380 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
381 1, 1, 2, 1, 1, 1, 1, 1, 1, 1,
382 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
383 1, 2, 4, 5, 6, 7, 8, 9, 6, 10,
384 11, 12, 13, 6, 14, 6, 15, 16, 16, 16,
385 16, 16, 16, 16, 16, 16, 16, 17, 6, 18,
386 19, 20, 21, 6, 6, 6, 6, 6, 6, 6,
387 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
388 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
389 1, 6, 1, 6, 6, 1, 6, 6, 6, 6,
391 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
392 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
393 6, 6, 22, 23, 24, 25, 1, 1, 1, 1,
394 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
395 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
396 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
397 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
398 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
399 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
400 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
402 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
403 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
404 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
405 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
406 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
410 static yyconst flex_int32_t yy_meta
[26] =
412 1, 2, 2, 2, 1, 3, 4, 2, 2, 2,
413 2, 2, 2, 2, 2, 3, 2, 2, 2, 2,
417 static yyconst flex_int16_t yy_base
[61] =
419 0, 0, 4, 5, 29, 54, 71, 101, 101, 101,
420 50, 63, 25, 45, 101, 56, 101, 101, 101, 101,
421 101, 101, 31, 47, 44, 14, 43, 101, 29, 18,
422 101, 101, 0, 101, 28, 101, 38, 101, 42, 101,
423 101, 50, 101, 101, 101, 101, 101, 101, 22, 101,
424 101, 0, 101, 101, 79, 83, 87, 89, 93, 97
427 static yyconst flex_int16_t yy_def
[61] =
429 54, 1, 55, 55, 56, 56, 54, 54, 54, 54,
430 54, 57, 54, 58, 54, 54, 54, 54, 54, 54,
431 54, 54, 54, 54, 54, 54, 54, 54, 54, 59,
432 54, 54, 60, 54, 54, 54, 57, 54, 54, 54,
433 54, 54, 54, 54, 54, 54, 54, 54, 59, 54,
434 54, 60, 54, 0, 54, 54, 54, 54, 54, 54
437 static yyconst flex_int16_t yy_nxt
[127] =
439 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
440 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
441 28, 8, 29, 8, 8, 31, 31, 32, 32, 33,
442 39, 39, 45, 33, 33, 35, 39, 39, 46, 50,
443 39, 51, 38, 50, 33, 51, 42, 39, 39, 53,
444 33, 48, 33, 33, 33, 39, 39, 39, 33, 33,
445 35, 47, 44, 43, 41, 42, 40, 38, 36, 33,
446 54, 54, 54, 54, 54, 33, 54, 33, 33, 30,
447 30, 30, 30, 34, 34, 34, 34, 37, 37, 37,
448 37, 39, 39, 49, 49, 49, 49, 52, 54, 52,
450 7, 54, 54, 54, 54, 54, 54, 54, 54, 54,
451 54, 54, 54, 54, 54, 54, 54, 54, 54, 54,
452 54, 54, 54, 54, 54, 54
455 static yyconst flex_int16_t yy_chk
[127] =
457 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
458 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
459 1, 1, 1, 1, 1, 3, 4, 3, 4, 5,
460 13, 13, 26, 5, 5, 5, 23, 23, 26, 30,
461 13, 30, 37, 49, 5, 49, 23, 39, 39, 35,
462 5, 29, 5, 5, 6, 42, 42, 39, 6, 6,
463 6, 27, 25, 24, 16, 42, 14, 12, 11, 6,
464 7, 0, 0, 0, 0, 6, 0, 6, 6, 55,
465 55, 55, 55, 56, 56, 56, 56, 57, 57, 57,
466 57, 58, 58, 59, 59, 59, 59, 60, 0, 60,
468 54, 54, 54, 54, 54, 54, 54, 54, 54, 54,
469 54, 54, 54, 54, 54, 54, 54, 54, 54, 54,
470 54, 54, 54, 54, 54, 54
473 /* The intent behind this definition is that it'll catch
474 * any uses of REJECT which flex missed.
476 #define REJECT reject_used_but_not_detected
477 #define yymore() (yyg->yy_more_flag = 1)
478 #define YY_MORE_ADJ yyg->yy_more_len
479 #define YY_RESTORE_YY_MORE_OFFSET
480 #line 1 "ast_expr2.fl"
481 #line 2 "ast_expr2.fl"
483 * Asterisk -- An open source telephony toolkit.
485 * Copyright (C) 1999 - 2006, Digium, Inc.
487 * Mark Spencer <markster@digium.com>
489 * See http://www.asterisk.org for more information about
490 * the Asterisk project. Please do not directly contact
491 * any of the maintainers of this project for assistance;
492 * the project provides a web site, mailing lists and IRC
493 * channels for your use.
495 * This program is free software, distributed under the terms of
496 * the GNU General Public License Version 2. See the LICENSE file
497 * at the top of the source tree.
502 * \brief Dialplan Expression Lexical Scanner
505 #include "asterisk.h"
508 ASTERISK_FILE_VERSION(__FILE__
, "$Revision$")
511 #include <sys/types.h>
517 #if !defined(SOLARIS) && !defined(__CYGWIN__)
518 /* #include <err.h> */
520 #define quad_t int64_t
526 #include "asterisk/ast_expr.h"
527 #include "asterisk/logger.h"
528 #include "asterisk/strings.h"
531 AST_EXPR_integer
, AST_EXPR_numeric_string
, AST_EXPR_string
542 #include "ast_expr2.h" /* the o/p of the bison on ast_expr2.y */
544 #define SET_COLUMNS do { \
545 yylloc_param->first_column = (int)(yyg->yytext_r - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf); \
546 yylloc_param->last_column += yyleng - 1; \
547 yylloc_param->first_line = yylloc_param->last_line = 1; \
550 #define SET_STRING do { \
551 yylval_param->val = calloc(1, sizeof(struct val)); \
552 yylval_param->val->type = AST_EXPR_string; \
553 yylval_param->val->u.s = strdup(yytext); \
556 #define SET_NUMERIC_STRING do { \
557 yylval_param->val = calloc(1, sizeof(struct val)); \
558 yylval_param->val->type = AST_EXPR_numeric_string; \
559 yylval_param->val->u.s = strdup(yytext); \
569 void ast_yyset_column(int column_no
, yyscan_t yyscanner
);
570 int ast_yyget_column(yyscan_t yyscanner
);
571 static int curlycount
= 0;
572 static char *expr2_token_subst(const char *mess
);
574 #line 575 "ast_expr2f.c"
580 #ifndef YY_NO_UNISTD_H
581 /* Special case for "unistd.h", since it is non-ANSI. We include it way
582 * down here because we want the user's section 1 to have been scanned first.
583 * The user has a chance to override it with an option.
588 #ifndef YY_EXTRA_TYPE
589 #define YY_EXTRA_TYPE void *
592 /* Holds the entire state of the reentrant scanner. */
596 /* User-defined. Not touched by flex. */
597 YY_EXTRA_TYPE yyextra_r
;
599 /* The rest are the same as the globals declared in the non-reentrant scanner. */
600 FILE *yyin_r
, *yyout_r
;
601 size_t yy_buffer_stack_top
; /**< index of top of stack. */
602 size_t yy_buffer_stack_max
; /**< capacity of stack. */
603 YY_BUFFER_STATE
* yy_buffer_stack
; /**< Stack as an array. */
610 int yy_did_buffer_switch_on_eof
;
611 int yy_start_stack_ptr
;
612 int yy_start_stack_depth
;
614 yy_state_type yy_last_accepting_state
;
615 char* yy_last_accepting_cpos
;
628 }; /* end struct yyguts_t */
630 static int yy_init_globals (yyscan_t yyscanner
);
632 /* This must go here because YYSTYPE and YYLTYPE are included
633 * from bison output in section 1.*/
634 # define yylval yyg->yylval_r
636 # define yylloc yyg->yylloc_r
638 /* Accessor methods to globals.
639 These are made visible to non-reentrant scanners for convenience. */
641 int ast_yylex_destroy (yyscan_t yyscanner
);
643 int ast_yyget_debug (yyscan_t yyscanner
);
645 void ast_yyset_debug (int debug_flag
,yyscan_t yyscanner
);
647 YY_EXTRA_TYPE
ast_yyget_extra (yyscan_t yyscanner
);
649 void ast_yyset_extra (YY_EXTRA_TYPE user_defined
,yyscan_t yyscanner
);
651 FILE *ast_yyget_in (yyscan_t yyscanner
);
653 void ast_yyset_in (FILE * in_str
,yyscan_t yyscanner
);
655 FILE *ast_yyget_out (yyscan_t yyscanner
);
657 void ast_yyset_out (FILE * out_str
,yyscan_t yyscanner
);
659 int ast_yyget_leng (yyscan_t yyscanner
);
661 char *ast_yyget_text (yyscan_t yyscanner
);
663 int ast_yyget_lineno (yyscan_t yyscanner
);
665 void ast_yyset_lineno (int line_number
,yyscan_t yyscanner
);
667 YYSTYPE
* ast_yyget_lval (yyscan_t yyscanner
);
669 void ast_yyset_lval (YYSTYPE
* yylval_param
,yyscan_t yyscanner
);
671 YYLTYPE
*ast_yyget_lloc (yyscan_t yyscanner
);
673 void ast_yyset_lloc (YYLTYPE
* yylloc_param
,yyscan_t yyscanner
);
675 /* Macros after this point can all be overridden by user definitions in
679 #ifndef YY_SKIP_YYWRAP
681 extern "C" int ast_yywrap (yyscan_t yyscanner
);
683 extern int ast_yywrap (yyscan_t yyscanner
);
687 static void yyunput (int c
,char *buf_ptr
,yyscan_t yyscanner
);
690 static void yy_flex_strncpy (char *,yyconst
char *,int ,yyscan_t yyscanner
);
693 #ifdef YY_NEED_STRLEN
694 static int yy_flex_strlen (yyconst
char * ,yyscan_t yyscanner
);
700 static int yyinput (yyscan_t yyscanner
);
702 static int input (yyscan_t yyscanner
);
707 /* Amount of stuff to slurp up with each read. */
708 #ifndef YY_READ_BUF_SIZE
709 #define YY_READ_BUF_SIZE 8192
712 /* Copy whatever the last rule matched to the standard output. */
714 /* This used to be an fputs(), but since the string might contain NUL's,
715 * we now use fwrite().
717 #define ECHO (void) fwrite( yytext, yyleng, 1, yyout )
720 /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
721 * is returned in "result".
724 #define YY_INPUT(buf,result,max_size) \
725 if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
729 for ( n = 0; n < max_size && \
730 (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
733 buf[n++] = (char) c; \
734 if ( c == EOF && ferror( yyin ) ) \
735 YY_FATAL_ERROR( "input in flex scanner failed" ); \
741 while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
743 if( errno != EINTR) \
745 YY_FATAL_ERROR( "input in flex scanner failed" ); \
756 /* No semi-colon after return; correct usage is to write "yyterminate();" -
757 * we don't want an extra ';' after the "return" because that will cause
758 * some compilers to complain about unreachable statements.
761 #define yyterminate() return YY_NULL
764 /* Number of entries by which start-condition stack grows. */
765 #ifndef YY_START_STACK_INCR
766 #define YY_START_STACK_INCR 25
769 /* Report a fatal error. */
770 #ifndef YY_FATAL_ERROR
771 #define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner)
774 /* end tables serialization structures and prototypes */
776 /* Default declaration of generated scanner - a define so the user can
777 * easily add parameters.
780 #define YY_DECL_IS_OURS 1
782 extern int ast_yylex (YYSTYPE
* yylval_param
,YYLTYPE
* yylloc_param
,yyscan_t yyscanner
);
784 #define YY_DECL int ast_yylex (YYSTYPE * yylval_param, YYLTYPE * yylloc_param , yyscan_t yyscanner)
785 #endif /* !YY_DECL */
787 /* Code executed at the beginning of each rule, after yytext and yyleng
790 #ifndef YY_USER_ACTION
791 #define YY_USER_ACTION
794 /* Code executed at the end of each rule. */
796 #define YY_BREAK break;
799 #define YY_RULE_SETUP \
802 /** The main scanner function which does all the work.
806 register yy_state_type yy_current_state
;
807 register char *yy_cp
, *yy_bp
;
809 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
;
811 #line 105 "ast_expr2.fl"
814 #line 815 "ast_expr2f.c"
816 yylval
= yylval_param
;
818 yylloc
= yylloc_param
;
828 if ( ! yyg
->yy_start
)
829 yyg
->yy_start
= 1; /* first start state */
837 if ( ! YY_CURRENT_BUFFER
) {
838 ast_yyensure_buffer_stack (yyscanner
);
839 YY_CURRENT_BUFFER_LVALUE
=
840 ast_yy_create_buffer(yyin
,YY_BUF_SIZE
,yyscanner
);
843 ast_yy_load_buffer_state(yyscanner
);
846 while ( 1 ) /* loops until end-of-file is reached */
848 yyg
->yy_more_len
= 0;
849 if ( yyg
->yy_more_flag
)
851 yyg
->yy_more_len
= yyg
->yy_c_buf_p
- yyg
->yytext_ptr
;
852 yyg
->yy_more_flag
= 0;
854 yy_cp
= yyg
->yy_c_buf_p
;
856 /* Support of yytext. */
857 *yy_cp
= yyg
->yy_hold_char
;
859 /* yy_bp points to the position in yy_ch_buf of the start of
864 yy_current_state
= yyg
->yy_start
;
868 register YY_CHAR yy_c
= yy_ec
[YY_SC_TO_UI(*yy_cp
)];
869 if ( yy_accept
[yy_current_state
] )
871 yyg
->yy_last_accepting_state
= yy_current_state
;
872 yyg
->yy_last_accepting_cpos
= yy_cp
;
874 while ( yy_chk
[yy_base
[yy_current_state
] + yy_c
] != yy_current_state
)
876 yy_current_state
= (int) yy_def
[yy_current_state
];
877 if ( yy_current_state
>= 55 )
878 yy_c
= yy_meta
[(unsigned int) yy_c
];
880 yy_current_state
= yy_nxt
[yy_base
[yy_current_state
] + (unsigned int) yy_c
];
883 while ( yy_current_state
!= 54 );
884 yy_cp
= yyg
->yy_last_accepting_cpos
;
885 yy_current_state
= yyg
->yy_last_accepting_state
;
888 yy_act
= yy_accept
[yy_current_state
];
892 do_action
: /* This label is used only to access EOF actions. */
895 { /* beginning of action switch */
896 case 0: /* must back up */
897 /* undo the effects of YY_DO_BEFORE_ACTION */
898 *yy_cp
= yyg
->yy_hold_char
;
899 yy_cp
= yyg
->yy_last_accepting_cpos
;
900 yy_current_state
= yyg
->yy_last_accepting_state
;
905 #line 107 "ast_expr2.fl"
906 { SET_COLUMNS
; SET_STRING
; return TOK_OR
;}
910 #line 108 "ast_expr2.fl"
911 { SET_COLUMNS
; SET_STRING
; return TOK_AND
;}
915 #line 109 "ast_expr2.fl"
916 { SET_COLUMNS
; SET_STRING
; return TOK_EQ
;}
920 #line 110 "ast_expr2.fl"
921 { SET_COLUMNS
; SET_STRING
; return TOK_OR
;}
925 #line 111 "ast_expr2.fl"
926 { SET_COLUMNS
; SET_STRING
; return TOK_AND
;}
930 #line 112 "ast_expr2.fl"
931 { SET_COLUMNS
; SET_STRING
; return TOK_EQ
;}
935 #line 113 "ast_expr2.fl"
936 { SET_COLUMNS
; SET_STRING
; return TOK_EQTILDE
;}
940 #line 114 "ast_expr2.fl"
941 { SET_COLUMNS
; SET_STRING
; return TOK_GT
;}
945 #line 115 "ast_expr2.fl"
946 { SET_COLUMNS
; SET_STRING
; return TOK_LT
;}
950 #line 116 "ast_expr2.fl"
951 { SET_COLUMNS
; SET_STRING
; return TOK_GE
;}
955 #line 117 "ast_expr2.fl"
956 { SET_COLUMNS
; SET_STRING
; return TOK_LE
;}
960 #line 118 "ast_expr2.fl"
961 { SET_COLUMNS
; SET_STRING
; return TOK_NE
;}
965 #line 119 "ast_expr2.fl"
966 { SET_COLUMNS
; SET_STRING
; return TOK_PLUS
;}
970 #line 120 "ast_expr2.fl"
971 { SET_COLUMNS
; SET_STRING
; return TOK_MINUS
;}
975 #line 121 "ast_expr2.fl"
976 { SET_COLUMNS
; SET_STRING
; return TOK_MULT
;}
980 #line 122 "ast_expr2.fl"
981 { SET_COLUMNS
; SET_STRING
; return TOK_DIV
;}
985 #line 123 "ast_expr2.fl"
986 { SET_COLUMNS
; SET_STRING
; return TOK_MOD
;}
990 #line 124 "ast_expr2.fl"
991 { SET_COLUMNS
; SET_STRING
; return TOK_COND
;}
995 #line 125 "ast_expr2.fl"
996 { SET_COLUMNS
; SET_STRING
; return TOK_COMPL
;}
1000 #line 126 "ast_expr2.fl"
1001 { SET_COLUMNS
; SET_STRING
; return TOK_COLON
;}
1005 #line 127 "ast_expr2.fl"
1006 { SET_COLUMNS
; SET_STRING
; return TOK_COLONCOLON
;}
1010 #line 128 "ast_expr2.fl"
1011 { SET_COLUMNS
; SET_STRING
; return TOK_LP
;}
1015 #line 129 "ast_expr2.fl"
1016 { SET_COLUMNS
; SET_STRING
; return TOK_RP
;}
1020 #line 130 "ast_expr2.fl"
1022 /* gather the contents of ${} expressions, with trailing stuff,
1023 * into a single TOKEN.
1024 * They are much more complex now than they used to be
1033 #line 140 "ast_expr2.fl"
1037 /* rule 26 can match eol */
1039 #line 141 "ast_expr2.fl"
1040 {SET_COLUMNS
; SET_STRING
; return TOKEN
;}
1043 /* rule 27 can match eol */
1045 #line 143 "ast_expr2.fl"
1046 {/* what to do with eol */}
1050 #line 144 "ast_expr2.fl"
1053 /* the original behavior of the expression parser was
1054 * to bring in numbers as a numeric string
1062 #line 153 "ast_expr2.fl"
1070 /* rule 30 can match eol */
1072 #line 160 "ast_expr2.fl"
1075 if (curlycount
< 0) {
1084 /* rule 31 can match eol */
1086 #line 170 "ast_expr2.fl"
1094 #line 176 "ast_expr2.fl"
1103 /* rule 33 can match eol */
1105 #line 183 "ast_expr2.fl"
1107 char c
= yytext
[yyleng
-1];
1117 #line 192 "ast_expr2.fl"
1124 case YY_STATE_EOF(trail
):
1125 #line 198 "ast_expr2.fl"
1131 /*actually, if an expr is only a variable ref, this could happen a LOT */
1136 #line 206 "ast_expr2.fl"
1139 #line 1140 "ast_expr2f.c"
1140 case YY_STATE_EOF(INITIAL
):
1141 case YY_STATE_EOF(var
):
1144 case YY_END_OF_BUFFER
:
1146 /* Amount of text matched not including the EOB char. */
1147 int yy_amount_of_matched_text
= (int) (yy_cp
- yyg
->yytext_ptr
) - 1;
1149 /* Undo the effects of YY_DO_BEFORE_ACTION. */
1150 *yy_cp
= yyg
->yy_hold_char
;
1151 YY_RESTORE_YY_MORE_OFFSET
1153 if ( YY_CURRENT_BUFFER_LVALUE
->yy_buffer_status
== YY_BUFFER_NEW
)
1155 /* We're scanning a new file or input source. It's
1156 * possible that this happened because the user
1157 * just pointed yyin at a new source and called
1158 * ast_yylex(). If so, then we have to assure
1159 * consistency between YY_CURRENT_BUFFER and our
1160 * globals. Here is the right place to do so, because
1161 * this is the first action (other than possibly a
1162 * back-up) that will match for the new input source.
1164 yyg
->yy_n_chars
= YY_CURRENT_BUFFER_LVALUE
->yy_n_chars
;
1165 YY_CURRENT_BUFFER_LVALUE
->yy_input_file
= yyin
;
1166 YY_CURRENT_BUFFER_LVALUE
->yy_buffer_status
= YY_BUFFER_NORMAL
;
1169 /* Note that here we test for yy_c_buf_p "<=" to the position
1170 * of the first EOB in the buffer, since yy_c_buf_p will
1171 * already have been incremented past the NUL character
1172 * (since all states make transitions on EOB to the
1173 * end-of-buffer state). Contrast this with the test
1176 if ( yyg
->yy_c_buf_p
<= &YY_CURRENT_BUFFER_LVALUE
->yy_ch_buf
[yyg
->yy_n_chars
] )
1177 { /* This was really a NUL. */
1178 yy_state_type yy_next_state
;
1180 yyg
->yy_c_buf_p
= yyg
->yytext_ptr
+ yy_amount_of_matched_text
;
1182 yy_current_state
= yy_get_previous_state( yyscanner
);
1184 /* Okay, we're now positioned to make the NUL
1185 * transition. We couldn't have
1186 * yy_get_previous_state() go ahead and do it
1187 * for us because it doesn't know how to deal
1188 * with the possibility of jamming (and we don't
1189 * want to build jamming into it because then it
1190 * will run more slowly).
1193 yy_next_state
= yy_try_NUL_trans( yy_current_state
, yyscanner
);
1195 yy_bp
= yyg
->yytext_ptr
+ YY_MORE_ADJ
;
1197 if ( yy_next_state
)
1199 /* Consume the NUL. */
1200 yy_cp
= ++yyg
->yy_c_buf_p
;
1201 yy_current_state
= yy_next_state
;
1207 yy_cp
= yyg
->yy_last_accepting_cpos
;
1208 yy_current_state
= yyg
->yy_last_accepting_state
;
1209 goto yy_find_action
;
1213 else switch ( yy_get_next_buffer( yyscanner
) )
1215 case EOB_ACT_END_OF_FILE
:
1217 yyg
->yy_did_buffer_switch_on_eof
= 0;
1219 if ( ast_yywrap(yyscanner
) )
1221 /* Note: because we've taken care in
1222 * yy_get_next_buffer() to have set up
1223 * yytext, we can now set up
1224 * yy_c_buf_p so that if some total
1225 * hoser (like flex itself) wants to
1226 * call the scanner after we return the
1227 * YY_NULL, it'll still work - another
1228 * YY_NULL will get returned.
1230 yyg
->yy_c_buf_p
= yyg
->yytext_ptr
+ YY_MORE_ADJ
;
1232 yy_act
= YY_STATE_EOF(YY_START
);
1238 if ( ! yyg
->yy_did_buffer_switch_on_eof
)
1244 case EOB_ACT_CONTINUE_SCAN
:
1246 yyg
->yytext_ptr
+ yy_amount_of_matched_text
;
1248 yy_current_state
= yy_get_previous_state( yyscanner
);
1250 yy_cp
= yyg
->yy_c_buf_p
;
1251 yy_bp
= yyg
->yytext_ptr
+ YY_MORE_ADJ
;
1254 case EOB_ACT_LAST_MATCH
:
1256 &YY_CURRENT_BUFFER_LVALUE
->yy_ch_buf
[yyg
->yy_n_chars
];
1258 yy_current_state
= yy_get_previous_state( yyscanner
);
1260 yy_cp
= yyg
->yy_c_buf_p
;
1261 yy_bp
= yyg
->yytext_ptr
+ YY_MORE_ADJ
;
1262 goto yy_find_action
;
1269 "fatal flex scanner internal error--no action found" );
1270 } /* end of action switch */
1271 } /* end of scanning one token */
1272 } /* end of ast_yylex */
1274 /* yy_get_next_buffer - try to read in a new buffer
1276 * Returns a code representing an action:
1277 * EOB_ACT_LAST_MATCH -
1278 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1279 * EOB_ACT_END_OF_FILE - end of file
1281 static int yy_get_next_buffer (yyscan_t yyscanner
)
1283 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
;
1284 register char *dest
= YY_CURRENT_BUFFER_LVALUE
->yy_ch_buf
;
1285 register char *source
= yyg
->yytext_ptr
;
1286 register int number_to_move
, i
;
1289 if ( yyg
->yy_c_buf_p
> &YY_CURRENT_BUFFER_LVALUE
->yy_ch_buf
[yyg
->yy_n_chars
+ 1] )
1291 "fatal flex scanner internal error--end of buffer missed" );
1293 if ( YY_CURRENT_BUFFER_LVALUE
->yy_fill_buffer
== 0 )
1294 { /* Don't try to fill the buffer, so this is an EOF. */
1295 if ( yyg
->yy_c_buf_p
- yyg
->yytext_ptr
- YY_MORE_ADJ
== 1 )
1297 /* We matched a single character, the EOB, so
1298 * treat this as a final EOF.
1300 return EOB_ACT_END_OF_FILE
;
1305 /* We matched some text prior to the EOB, first
1308 return EOB_ACT_LAST_MATCH
;
1312 /* Try to read more data. */
1314 /* First move last chars to start of buffer. */
1315 number_to_move
= (int) (yyg
->yy_c_buf_p
- yyg
->yytext_ptr
) - 1;
1317 for ( i
= 0; i
< number_to_move
; ++i
)
1318 *(dest
++) = *(source
++);
1320 if ( YY_CURRENT_BUFFER_LVALUE
->yy_buffer_status
== YY_BUFFER_EOF_PENDING
)
1321 /* don't do the read, it's not guaranteed to return an EOF,
1324 YY_CURRENT_BUFFER_LVALUE
->yy_n_chars
= yyg
->yy_n_chars
= 0;
1329 YY_CURRENT_BUFFER_LVALUE
->yy_buf_size
- number_to_move
- 1;
1331 while ( num_to_read
<= 0 )
1332 { /* Not enough room in the buffer - grow it. */
1334 /* just a shorter name for the current buffer */
1335 YY_BUFFER_STATE b
= YY_CURRENT_BUFFER
;
1337 int yy_c_buf_p_offset
=
1338 (int) (yyg
->yy_c_buf_p
- b
->yy_ch_buf
);
1340 if ( b
->yy_is_our_buffer
)
1342 int new_size
= b
->yy_buf_size
* 2;
1344 if ( new_size
<= 0 )
1345 b
->yy_buf_size
+= b
->yy_buf_size
/ 8;
1347 b
->yy_buf_size
*= 2;
1349 b
->yy_ch_buf
= (char *)
1350 /* Include room in for 2 EOB chars. */
1351 ast_yyrealloc((void *) b
->yy_ch_buf
,b
->yy_buf_size
+ 2 ,yyscanner
);
1354 /* Can't grow it, we don't own it. */
1357 if ( ! b
->yy_ch_buf
)
1359 "fatal error - scanner input buffer overflow" );
1361 yyg
->yy_c_buf_p
= &b
->yy_ch_buf
[yy_c_buf_p_offset
];
1363 num_to_read
= YY_CURRENT_BUFFER_LVALUE
->yy_buf_size
-
1368 if ( num_to_read
> YY_READ_BUF_SIZE
)
1369 num_to_read
= YY_READ_BUF_SIZE
;
1371 /* Read in more data. */
1372 YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE
->yy_ch_buf
[number_to_move
]),
1373 yyg
->yy_n_chars
, num_to_read
);
1375 YY_CURRENT_BUFFER_LVALUE
->yy_n_chars
= yyg
->yy_n_chars
;
1378 if ( yyg
->yy_n_chars
== 0 )
1380 if ( number_to_move
== YY_MORE_ADJ
)
1382 ret_val
= EOB_ACT_END_OF_FILE
;
1383 ast_yyrestart(yyin
,yyscanner
);
1388 ret_val
= EOB_ACT_LAST_MATCH
;
1389 YY_CURRENT_BUFFER_LVALUE
->yy_buffer_status
=
1390 YY_BUFFER_EOF_PENDING
;
1395 ret_val
= EOB_ACT_CONTINUE_SCAN
;
1397 yyg
->yy_n_chars
+= number_to_move
;
1398 YY_CURRENT_BUFFER_LVALUE
->yy_ch_buf
[yyg
->yy_n_chars
] = YY_END_OF_BUFFER_CHAR
;
1399 YY_CURRENT_BUFFER_LVALUE
->yy_ch_buf
[yyg
->yy_n_chars
+ 1] = YY_END_OF_BUFFER_CHAR
;
1401 yyg
->yytext_ptr
= &YY_CURRENT_BUFFER_LVALUE
->yy_ch_buf
[0];
1406 /* yy_get_previous_state - get the state just before the EOB char was reached */
1408 static yy_state_type
yy_get_previous_state (yyscan_t yyscanner
)
1410 register yy_state_type yy_current_state
;
1411 register char *yy_cp
;
1412 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
;
1414 yy_current_state
= yyg
->yy_start
;
1416 for ( yy_cp
= yyg
->yytext_ptr
+ YY_MORE_ADJ
; yy_cp
< yyg
->yy_c_buf_p
; ++yy_cp
)
1418 register YY_CHAR yy_c
= (*yy_cp
? yy_ec
[YY_SC_TO_UI(*yy_cp
)] : 1);
1419 if ( yy_accept
[yy_current_state
] )
1421 yyg
->yy_last_accepting_state
= yy_current_state
;
1422 yyg
->yy_last_accepting_cpos
= yy_cp
;
1424 while ( yy_chk
[yy_base
[yy_current_state
] + yy_c
] != yy_current_state
)
1426 yy_current_state
= (int) yy_def
[yy_current_state
];
1427 if ( yy_current_state
>= 55 )
1428 yy_c
= yy_meta
[(unsigned int) yy_c
];
1430 yy_current_state
= yy_nxt
[yy_base
[yy_current_state
] + (unsigned int) yy_c
];
1433 return yy_current_state
;
1436 /* yy_try_NUL_trans - try to make a transition on the NUL character
1439 * next_state = yy_try_NUL_trans( current_state );
1441 static yy_state_type
yy_try_NUL_trans (yy_state_type yy_current_state
, yyscan_t yyscanner
)
1443 register int yy_is_jam
;
1444 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
; /* This var may be unused depending upon options. */
1445 register char *yy_cp
= yyg
->yy_c_buf_p
;
1447 register YY_CHAR yy_c
= 1;
1448 if ( yy_accept
[yy_current_state
] )
1450 yyg
->yy_last_accepting_state
= yy_current_state
;
1451 yyg
->yy_last_accepting_cpos
= yy_cp
;
1453 while ( yy_chk
[yy_base
[yy_current_state
] + yy_c
] != yy_current_state
)
1455 yy_current_state
= (int) yy_def
[yy_current_state
];
1456 if ( yy_current_state
>= 55 )
1457 yy_c
= yy_meta
[(unsigned int) yy_c
];
1459 yy_current_state
= yy_nxt
[yy_base
[yy_current_state
] + (unsigned int) yy_c
];
1460 yy_is_jam
= (yy_current_state
== 54);
1462 return yy_is_jam
? 0 : yy_current_state
;
1465 static void yyunput (int c
, register char * yy_bp
, yyscan_t yyscanner
)
1467 register char *yy_cp
;
1468 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
;
1470 yy_cp
= yyg
->yy_c_buf_p
;
1472 /* undo effects of setting up yytext */
1473 *yy_cp
= yyg
->yy_hold_char
;
1475 if ( yy_cp
< YY_CURRENT_BUFFER_LVALUE
->yy_ch_buf
+ 2 )
1476 { /* need to shift things up to make room */
1477 /* +2 for EOB chars. */
1478 register int number_to_move
= yyg
->yy_n_chars
+ 2;
1479 register char *dest
= &YY_CURRENT_BUFFER_LVALUE
->yy_ch_buf
[
1480 YY_CURRENT_BUFFER_LVALUE
->yy_buf_size
+ 2];
1481 register char *source
=
1482 &YY_CURRENT_BUFFER_LVALUE
->yy_ch_buf
[number_to_move
];
1484 while ( source
> YY_CURRENT_BUFFER_LVALUE
->yy_ch_buf
)
1485 *--dest
= *--source
;
1487 yy_cp
+= (int) (dest
- source
);
1488 yy_bp
+= (int) (dest
- source
);
1489 YY_CURRENT_BUFFER_LVALUE
->yy_n_chars
=
1490 yyg
->yy_n_chars
= YY_CURRENT_BUFFER_LVALUE
->yy_buf_size
;
1492 if ( yy_cp
< YY_CURRENT_BUFFER_LVALUE
->yy_ch_buf
+ 2 )
1493 YY_FATAL_ERROR( "flex scanner push-back overflow" );
1496 *--yy_cp
= (char) c
;
1498 yyg
->yytext_ptr
= yy_bp
;
1499 yyg
->yy_hold_char
= *yy_cp
;
1500 yyg
->yy_c_buf_p
= yy_cp
;
1505 static int yyinput (yyscan_t yyscanner
)
1507 static int input (yyscan_t yyscanner
)
1512 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
;
1514 *yyg
->yy_c_buf_p
= yyg
->yy_hold_char
;
1516 if ( *yyg
->yy_c_buf_p
== YY_END_OF_BUFFER_CHAR
)
1518 /* yy_c_buf_p now points to the character we want to return.
1519 * If this occurs *before* the EOB characters, then it's a
1520 * valid NUL; if not, then we've hit the end of the buffer.
1522 if ( yyg
->yy_c_buf_p
< &YY_CURRENT_BUFFER_LVALUE
->yy_ch_buf
[yyg
->yy_n_chars
] )
1523 /* This was really a NUL. */
1524 *yyg
->yy_c_buf_p
= '\0';
1527 { /* need more input */
1528 int offset
= yyg
->yy_c_buf_p
- yyg
->yytext_ptr
;
1531 switch ( yy_get_next_buffer( yyscanner
) )
1533 case EOB_ACT_LAST_MATCH
:
1534 /* This happens because yy_g_n_b()
1535 * sees that we've accumulated a
1536 * token and flags that we need to
1537 * try matching the token before
1538 * proceeding. But for input(),
1539 * there's no matching to consider.
1540 * So convert the EOB_ACT_LAST_MATCH
1541 * to EOB_ACT_END_OF_FILE.
1544 /* Reset buffer status. */
1545 ast_yyrestart(yyin
,yyscanner
);
1549 case EOB_ACT_END_OF_FILE
:
1551 if ( ast_yywrap(yyscanner
) )
1554 if ( ! yyg
->yy_did_buffer_switch_on_eof
)
1557 return yyinput(yyscanner
);
1559 return input(yyscanner
);
1563 case EOB_ACT_CONTINUE_SCAN
:
1564 yyg
->yy_c_buf_p
= yyg
->yytext_ptr
+ offset
;
1570 c
= *(unsigned char *) yyg
->yy_c_buf_p
; /* cast for 8-bit char's */
1571 *yyg
->yy_c_buf_p
= '\0'; /* preserve yytext */
1572 yyg
->yy_hold_char
= *++yyg
->yy_c_buf_p
;
1576 #endif /* ifndef YY_NO_INPUT */
1578 /** Immediately switch to a different input stream.
1579 * @param input_file A readable stream.
1580 * @param yyscanner The scanner object.
1581 * @note This function does not reset the start condition to @c INITIAL .
1583 void ast_yyrestart (FILE * input_file
, yyscan_t yyscanner
)
1585 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
;
1587 if ( ! YY_CURRENT_BUFFER
){
1588 ast_yyensure_buffer_stack (yyscanner
);
1589 YY_CURRENT_BUFFER_LVALUE
=
1590 ast_yy_create_buffer(yyin
,YY_BUF_SIZE
,yyscanner
);
1593 ast_yy_init_buffer(YY_CURRENT_BUFFER
,input_file
,yyscanner
);
1594 ast_yy_load_buffer_state(yyscanner
);
1597 /** Switch to a different input buffer.
1598 * @param new_buffer The new input buffer.
1599 * @param yyscanner The scanner object.
1601 void ast_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer
, yyscan_t yyscanner
)
1603 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
;
1605 /* TODO. We should be able to replace this entire function body
1607 * ast_yypop_buffer_state();
1608 * ast_yypush_buffer_state(new_buffer);
1610 ast_yyensure_buffer_stack (yyscanner
);
1611 if ( YY_CURRENT_BUFFER
== new_buffer
)
1614 if ( YY_CURRENT_BUFFER
)
1616 /* Flush out information for old buffer. */
1617 *yyg
->yy_c_buf_p
= yyg
->yy_hold_char
;
1618 YY_CURRENT_BUFFER_LVALUE
->yy_buf_pos
= yyg
->yy_c_buf_p
;
1619 YY_CURRENT_BUFFER_LVALUE
->yy_n_chars
= yyg
->yy_n_chars
;
1622 YY_CURRENT_BUFFER_LVALUE
= new_buffer
;
1623 ast_yy_load_buffer_state(yyscanner
);
1625 /* We don't actually know whether we did this switch during
1626 * EOF (ast_yywrap()) processing, but the only time this flag
1627 * is looked at is after ast_yywrap() is called, so it's safe
1628 * to go ahead and always set it.
1630 yyg
->yy_did_buffer_switch_on_eof
= 1;
1633 static void ast_yy_load_buffer_state (yyscan_t yyscanner
)
1635 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
;
1636 yyg
->yy_n_chars
= YY_CURRENT_BUFFER_LVALUE
->yy_n_chars
;
1637 yyg
->yytext_ptr
= yyg
->yy_c_buf_p
= YY_CURRENT_BUFFER_LVALUE
->yy_buf_pos
;
1638 yyin
= YY_CURRENT_BUFFER_LVALUE
->yy_input_file
;
1639 yyg
->yy_hold_char
= *yyg
->yy_c_buf_p
;
1642 /** Allocate and initialize an input buffer state.
1643 * @param file A readable stream.
1644 * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
1645 * @param yyscanner The scanner object.
1646 * @return the allocated buffer state.
1648 YY_BUFFER_STATE
ast_yy_create_buffer (FILE * file
, int size
, yyscan_t yyscanner
)
1652 b
= (YY_BUFFER_STATE
) ast_yyalloc(sizeof( struct yy_buffer_state
) ,yyscanner
);
1654 YY_FATAL_ERROR( "out of dynamic memory in ast_yy_create_buffer()" );
1656 b
->yy_buf_size
= size
;
1658 /* yy_ch_buf has to be 2 characters longer than the size given because
1659 * we need to put in 2 end-of-buffer characters.
1661 b
->yy_ch_buf
= (char *) ast_yyalloc(b
->yy_buf_size
+ 2 ,yyscanner
);
1662 if ( ! b
->yy_ch_buf
)
1663 YY_FATAL_ERROR( "out of dynamic memory in ast_yy_create_buffer()" );
1665 b
->yy_is_our_buffer
= 1;
1667 ast_yy_init_buffer(b
,file
,yyscanner
);
1672 /** Destroy the buffer.
1673 * @param b a buffer created with ast_yy_create_buffer()
1674 * @param yyscanner The scanner object.
1676 void ast_yy_delete_buffer (YY_BUFFER_STATE b
, yyscan_t yyscanner
)
1678 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
;
1683 if ( b
== YY_CURRENT_BUFFER
) /* Not sure if we should pop here. */
1684 YY_CURRENT_BUFFER_LVALUE
= (YY_BUFFER_STATE
) 0;
1686 if ( b
->yy_is_our_buffer
)
1687 ast_yyfree((void *) b
->yy_ch_buf
,yyscanner
);
1689 ast_yyfree((void *) b
,yyscanner
);
1693 extern int isatty (int );
1694 #endif /* __cplusplus */
1696 /* Initializes or reinitializes a buffer.
1697 * This function is sometimes called more than once on the same buffer,
1698 * such as during a ast_yyrestart() or at EOF.
1700 static void ast_yy_init_buffer (YY_BUFFER_STATE b
, FILE * file
, yyscan_t yyscanner
)
1704 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
;
1706 ast_yy_flush_buffer(b
,yyscanner
);
1708 b
->yy_input_file
= file
;
1709 b
->yy_fill_buffer
= 1;
1711 /* If b is the current buffer, then ast_yy_init_buffer was _probably_
1712 * called from ast_yyrestart() or through yy_get_next_buffer.
1713 * In that case, we don't want to reset the lineno or column.
1715 if (b
!= YY_CURRENT_BUFFER
){
1716 b
->yy_bs_lineno
= 1;
1717 b
->yy_bs_column
= 0;
1720 b
->yy_is_interactive
= file
? (isatty( fileno(file
) ) > 0) : 0;
1725 /** Discard all buffered characters. On the next scan, YY_INPUT will be called.
1726 * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
1727 * @param yyscanner The scanner object.
1729 void ast_yy_flush_buffer (YY_BUFFER_STATE b
, yyscan_t yyscanner
)
1731 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
;
1737 /* We always need two end-of-buffer characters. The first causes
1738 * a transition to the end-of-buffer state. The second causes
1739 * a jam in that state.
1741 b
->yy_ch_buf
[0] = YY_END_OF_BUFFER_CHAR
;
1742 b
->yy_ch_buf
[1] = YY_END_OF_BUFFER_CHAR
;
1744 b
->yy_buf_pos
= &b
->yy_ch_buf
[0];
1747 b
->yy_buffer_status
= YY_BUFFER_NEW
;
1749 if ( b
== YY_CURRENT_BUFFER
)
1750 ast_yy_load_buffer_state(yyscanner
);
1753 /** Pushes the new state onto the stack. The new state becomes
1754 * the current state. This function will allocate the stack
1756 * @param new_buffer The new state.
1757 * @param yyscanner The scanner object.
1759 void ast_yypush_buffer_state (YY_BUFFER_STATE new_buffer
, yyscan_t yyscanner
)
1761 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
;
1762 if (new_buffer
== NULL
)
1765 ast_yyensure_buffer_stack(yyscanner
);
1767 /* This block is copied from ast_yy_switch_to_buffer. */
1768 if ( YY_CURRENT_BUFFER
)
1770 /* Flush out information for old buffer. */
1771 *yyg
->yy_c_buf_p
= yyg
->yy_hold_char
;
1772 YY_CURRENT_BUFFER_LVALUE
->yy_buf_pos
= yyg
->yy_c_buf_p
;
1773 YY_CURRENT_BUFFER_LVALUE
->yy_n_chars
= yyg
->yy_n_chars
;
1776 /* Only push if top exists. Otherwise, replace top. */
1777 if (YY_CURRENT_BUFFER
)
1778 yyg
->yy_buffer_stack_top
++;
1779 YY_CURRENT_BUFFER_LVALUE
= new_buffer
;
1781 /* copied from ast_yy_switch_to_buffer. */
1782 ast_yy_load_buffer_state(yyscanner
);
1783 yyg
->yy_did_buffer_switch_on_eof
= 1;
1786 /** Removes and deletes the top of the stack, if present.
1787 * The next element becomes the new top.
1788 * @param yyscanner The scanner object.
1790 void ast_yypop_buffer_state (yyscan_t yyscanner
)
1792 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
;
1793 if (!YY_CURRENT_BUFFER
)
1796 ast_yy_delete_buffer(YY_CURRENT_BUFFER
,yyscanner
);
1797 YY_CURRENT_BUFFER_LVALUE
= NULL
;
1798 if (yyg
->yy_buffer_stack_top
> 0)
1799 --yyg
->yy_buffer_stack_top
;
1801 if (YY_CURRENT_BUFFER
) {
1802 ast_yy_load_buffer_state(yyscanner
);
1803 yyg
->yy_did_buffer_switch_on_eof
= 1;
1807 /* Allocates the stack if it does not exist.
1808 * Guarantees space for at least one push.
1810 static void ast_yyensure_buffer_stack (yyscan_t yyscanner
)
1813 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
;
1815 if (!yyg
->yy_buffer_stack
) {
1817 /* First allocation is just for 2 elements, since we don't know if this
1818 * scanner will even need a stack. We use 2 instead of 1 to avoid an
1819 * immediate realloc on the next call.
1822 yyg
->yy_buffer_stack
= (struct yy_buffer_state
**)ast_yyalloc
1823 (num_to_alloc
* sizeof(struct yy_buffer_state
*)
1826 memset(yyg
->yy_buffer_stack
, 0, num_to_alloc
* sizeof(struct yy_buffer_state
*));
1828 yyg
->yy_buffer_stack_max
= num_to_alloc
;
1829 yyg
->yy_buffer_stack_top
= 0;
1833 if (yyg
->yy_buffer_stack_top
>= (yyg
->yy_buffer_stack_max
) - 1){
1835 /* Increase the buffer to prepare for a possible push. */
1836 int grow_size
= 8 /* arbitrary grow size */;
1838 num_to_alloc
= yyg
->yy_buffer_stack_max
+ grow_size
;
1839 yyg
->yy_buffer_stack
= (struct yy_buffer_state
**)ast_yyrealloc
1840 (yyg
->yy_buffer_stack
,
1841 num_to_alloc
* sizeof(struct yy_buffer_state
*)
1844 /* zero only the new slots.*/
1845 memset(yyg
->yy_buffer_stack
+ yyg
->yy_buffer_stack_max
, 0, grow_size
* sizeof(struct yy_buffer_state
*));
1846 yyg
->yy_buffer_stack_max
= num_to_alloc
;
1850 /** Setup the input buffer state to scan directly from a user-specified character buffer.
1851 * @param base the character buffer
1852 * @param size the size in bytes of the character buffer
1853 * @param yyscanner The scanner object.
1854 * @return the newly allocated buffer state object.
1856 YY_BUFFER_STATE
ast_yy_scan_buffer (char * base
, yy_size_t size
, yyscan_t yyscanner
)
1861 base
[size
-2] != YY_END_OF_BUFFER_CHAR
||
1862 base
[size
-1] != YY_END_OF_BUFFER_CHAR
)
1863 /* They forgot to leave room for the EOB's. */
1866 b
= (YY_BUFFER_STATE
) ast_yyalloc(sizeof( struct yy_buffer_state
) ,yyscanner
);
1868 YY_FATAL_ERROR( "out of dynamic memory in ast_yy_scan_buffer()" );
1870 b
->yy_buf_size
= size
- 2; /* "- 2" to take care of EOB's */
1871 b
->yy_buf_pos
= b
->yy_ch_buf
= base
;
1872 b
->yy_is_our_buffer
= 0;
1873 b
->yy_input_file
= 0;
1874 b
->yy_n_chars
= b
->yy_buf_size
;
1875 b
->yy_is_interactive
= 0;
1877 b
->yy_fill_buffer
= 0;
1878 b
->yy_buffer_status
= YY_BUFFER_NEW
;
1880 ast_yy_switch_to_buffer(b
,yyscanner
);
1885 /** Setup the input buffer state to scan a string. The next call to ast_yylex() will
1886 * scan from a @e copy of @a str.
1887 * @param str a NUL-terminated string to scan
1888 * @param yyscanner The scanner object.
1889 * @return the newly allocated buffer state object.
1890 * @note If you want to scan bytes that may contain NUL values, then use
1891 * ast_yy_scan_bytes() instead.
1893 YY_BUFFER_STATE
ast_yy_scan_string (yyconst
char * yystr
, yyscan_t yyscanner
)
1896 return ast_yy_scan_bytes(yystr
,strlen(yystr
) ,yyscanner
);
1899 /** Setup the input buffer state to scan the given bytes. The next call to ast_yylex() will
1900 * scan from a @e copy of @a bytes.
1901 * @param bytes the byte buffer to scan
1902 * @param len the number of bytes in the buffer pointed to by @a bytes.
1903 * @param yyscanner The scanner object.
1904 * @return the newly allocated buffer state object.
1906 YY_BUFFER_STATE
ast_yy_scan_bytes (yyconst
char * yybytes
, int _yybytes_len
, yyscan_t yyscanner
)
1913 /* Get memory for full buffer, including space for trailing EOB's. */
1914 n
= _yybytes_len
+ 2;
1915 buf
= (char *) ast_yyalloc(n
,yyscanner
);
1917 YY_FATAL_ERROR( "out of dynamic memory in ast_yy_scan_bytes()" );
1919 for ( i
= 0; i
< _yybytes_len
; ++i
)
1920 buf
[i
] = yybytes
[i
];
1922 buf
[_yybytes_len
] = buf
[_yybytes_len
+1] = YY_END_OF_BUFFER_CHAR
;
1924 b
= ast_yy_scan_buffer(buf
,n
,yyscanner
);
1926 YY_FATAL_ERROR( "bad buffer in ast_yy_scan_bytes()" );
1928 /* It's okay to grow etc. this buffer, and we should throw it
1929 * away when we're done.
1931 b
->yy_is_our_buffer
= 1;
1936 #ifndef YY_EXIT_FAILURE
1937 #define YY_EXIT_FAILURE 2
1940 static void yy_fatal_error (yyconst
char* msg
, yyscan_t yyscanner
)
1942 (void) fprintf( stderr
, "%s\n", msg
);
1943 exit( YY_EXIT_FAILURE
);
1946 /* Redefine yyless() so it works in section 3 code. */
1952 /* Undo effects of setting up yytext. */ \
1953 int yyless_macro_arg = (n); \
1954 YY_LESS_LINENO(yyless_macro_arg);\
1955 yytext[yyleng] = yyg->yy_hold_char; \
1956 yyg->yy_c_buf_p = yytext + yyless_macro_arg; \
1957 yyg->yy_hold_char = *yyg->yy_c_buf_p; \
1958 *yyg->yy_c_buf_p = '\0'; \
1959 yyleng = yyless_macro_arg; \
1963 /* Accessor methods (get/set functions) to struct members. */
1965 /** Get the user-defined data for this scanner.
1966 * @param yyscanner The scanner object.
1968 YY_EXTRA_TYPE
ast_yyget_extra (yyscan_t yyscanner
)
1970 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
;
1974 /** Get the current line number.
1975 * @param yyscanner The scanner object.
1977 int ast_yyget_lineno (yyscan_t yyscanner
)
1979 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
;
1981 if (! YY_CURRENT_BUFFER
)
1987 /** Get the current column number.
1988 * @param yyscanner The scanner object.
1990 int ast_yyget_column (yyscan_t yyscanner
)
1992 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
;
1994 if (! YY_CURRENT_BUFFER
)
2000 /** Get the input stream.
2001 * @param yyscanner The scanner object.
2003 FILE *ast_yyget_in (yyscan_t yyscanner
)
2005 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
;
2009 /** Get the output stream.
2010 * @param yyscanner The scanner object.
2012 FILE *ast_yyget_out (yyscan_t yyscanner
)
2014 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
;
2018 /** Get the length of the current token.
2019 * @param yyscanner The scanner object.
2021 int ast_yyget_leng (yyscan_t yyscanner
)
2023 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
;
2027 /** Get the current token.
2028 * @param yyscanner The scanner object.
2031 char *ast_yyget_text (yyscan_t yyscanner
)
2033 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
;
2037 /** Set the user-defined data. This data is never touched by the scanner.
2038 * @param user_defined The data to be associated with this scanner.
2039 * @param yyscanner The scanner object.
2041 void ast_yyset_extra (YY_EXTRA_TYPE user_defined
, yyscan_t yyscanner
)
2043 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
;
2044 yyextra
= user_defined
;
2047 /** Set the current line number.
2048 * @param line_number
2049 * @param yyscanner The scanner object.
2051 void ast_yyset_lineno (int line_number
, yyscan_t yyscanner
)
2053 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
;
2055 /* lineno is only valid if an input buffer exists. */
2056 if (! YY_CURRENT_BUFFER
)
2057 yy_fatal_error( "ast_yyset_lineno called with no buffer" , yyscanner
);
2059 yylineno
= line_number
;
2062 /** Set the current column.
2063 * @param line_number
2064 * @param yyscanner The scanner object.
2066 void ast_yyset_column (int column_no
, yyscan_t yyscanner
)
2068 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
;
2070 /* column is only valid if an input buffer exists. */
2071 if (! YY_CURRENT_BUFFER
)
2072 yy_fatal_error( "ast_yyset_column called with no buffer" , yyscanner
);
2074 yycolumn
= column_no
;
2077 /** Set the input stream. This does not discard the current
2079 * @param in_str A readable stream.
2080 * @param yyscanner The scanner object.
2081 * @see ast_yy_switch_to_buffer
2083 void ast_yyset_in (FILE * in_str
, yyscan_t yyscanner
)
2085 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
;
2089 void ast_yyset_out (FILE * out_str
, yyscan_t yyscanner
)
2091 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
;
2095 int ast_yyget_debug (yyscan_t yyscanner
)
2097 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
;
2098 return yy_flex_debug
;
2101 void ast_yyset_debug (int bdebug
, yyscan_t yyscanner
)
2103 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
;
2104 yy_flex_debug
= bdebug
;
2107 /* Accessor methods for yylval and yylloc */
2109 YYSTYPE
* ast_yyget_lval (yyscan_t yyscanner
)
2111 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
;
2115 void ast_yyset_lval (YYSTYPE
* yylval_param
, yyscan_t yyscanner
)
2117 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
;
2118 yylval
= yylval_param
;
2121 YYLTYPE
*ast_yyget_lloc (yyscan_t yyscanner
)
2123 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
;
2127 void ast_yyset_lloc (YYLTYPE
* yylloc_param
, yyscan_t yyscanner
)
2129 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
;
2130 yylloc
= yylloc_param
;
2133 /* User-visible API */
2135 /* ast_yylex_init is special because it creates the scanner itself, so it is
2136 * the ONLY reentrant function that doesn't take the scanner as the last argument.
2137 * That's why we explicitly handle the declaration, instead of using our macros.
2140 int ast_yylex_init(yyscan_t
* ptr_yy_globals
)
2143 if (ptr_yy_globals
== NULL
){
2148 *ptr_yy_globals
= (yyscan_t
) ast_yyalloc ( sizeof( struct yyguts_t
), NULL
);
2150 if (*ptr_yy_globals
== NULL
){
2155 /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */
2156 memset(*ptr_yy_globals
,0x00,sizeof(struct yyguts_t
));
2158 return yy_init_globals ( *ptr_yy_globals
);
2161 static int yy_init_globals (yyscan_t yyscanner
)
2163 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
;
2164 /* Initialization is the same as for the non-reentrant scanner.
2165 * This function is called from ast_yylex_destroy(), so don't allocate here.
2168 yyg
->yy_buffer_stack
= 0;
2169 yyg
->yy_buffer_stack_top
= 0;
2170 yyg
->yy_buffer_stack_max
= 0;
2171 yyg
->yy_c_buf_p
= (char *) 0;
2175 yyg
->yy_start_stack_ptr
= 0;
2176 yyg
->yy_start_stack_depth
= 0;
2177 yyg
->yy_start_stack
= NULL
;
2179 /* Defined in main.c */
2188 /* For future reference: Set errno on error, since we are called by
2194 /* ast_yylex_destroy is for both reentrant and non-reentrant scanners. */
2195 int ast_yylex_destroy (yyscan_t yyscanner
)
2197 struct yyguts_t
* yyg
= (struct yyguts_t
*)yyscanner
;
2199 /* Pop the buffer stack, destroying each element. */
2200 while(YY_CURRENT_BUFFER
){
2201 ast_yy_delete_buffer(YY_CURRENT_BUFFER
,yyscanner
);
2202 YY_CURRENT_BUFFER_LVALUE
= NULL
;
2203 ast_yypop_buffer_state(yyscanner
);
2206 /* Destroy the stack itself. */
2207 ast_yyfree(yyg
->yy_buffer_stack
,yyscanner
);
2208 yyg
->yy_buffer_stack
= NULL
;
2210 /* Destroy the start condition stack. */
2211 ast_yyfree(yyg
->yy_start_stack
,yyscanner
);
2212 yyg
->yy_start_stack
= NULL
;
2214 /* Reset the globals. This is important in a non-reentrant scanner so the next time
2215 * ast_yylex() is called, initialization will occur. */
2216 yy_init_globals( yyscanner
);
2218 /* Destroy the main struct (reentrant only). */
2219 ast_yyfree ( yyscanner
, yyscanner
);
2225 * Internal utility routines.
2229 static void yy_flex_strncpy (char* s1
, yyconst
char * s2
, int n
, yyscan_t yyscanner
)
2232 for ( i
= 0; i
< n
; ++i
)
2237 #ifdef YY_NEED_STRLEN
2238 static int yy_flex_strlen (yyconst
char * s
, yyscan_t yyscanner
)
2241 for ( n
= 0; s
[n
]; ++n
)
2248 void *ast_yyalloc (yy_size_t size
, yyscan_t yyscanner
)
2250 return (void *) malloc( size
);
2253 void *ast_yyrealloc (void * ptr
, yy_size_t size
, yyscan_t yyscanner
)
2255 /* The cast to (char *) in the following accommodates both
2256 * implementations that use char* generic pointers, and those
2257 * that use void* generic pointers. It works with the latter
2258 * because both ANSI C and C++ allow castless assignment from
2259 * any pointer type to void*, and deal with argument conversions
2260 * as though doing an assignment.
2262 return (void *) realloc( (char *) ptr
, size
);
2265 #define YYTABLES_NAME "yytables"
2267 #line 206 "ast_expr2.fl"
2271 /* I'm putting the interface routine to the whole parse here in the flexer input file
2272 mainly because of all the flexer initialization that has to be done. Shouldn't matter
2273 where it is, as long as it's somewhere. I didn't want to define a prototype for the
2274 ast_yy_scan_string in the .y file, because then, I'd have to define YY_BUFFER_STATE there...
2275 UGH! that would be inappropriate. */
2277 int ast_yyparse(void *); /* need to/should define this prototype for the call to yyparse */
2278 int ast_yyerror(const char *, YYLTYPE
*, struct parse_io
*); /* likewise */
2280 void ast_yyfree(void *ptr
, yyscan_t yyscanner
)
2282 if (ptr
) /* the normal generated ast_yyfree func just frees its first arg;
2283 this get complaints on some systems, as sometimes this
2284 arg is a nil ptr! It's usually not fatal, but is irritating! */
2285 free( (char *) ptr
);
2288 int ast_expr(char *expr
, char *buf
, int length
)
2291 int return_value
= 0;
2293 memset(&io
, 0, sizeof(io
));
2294 io
.string
= expr
; /* to pass to the error routine */
2296 ast_yylex_init(&io
.scanner
);
2298 ast_yy_scan_string(expr
, io
.scanner
);
2300 ast_yyparse ((void *) &io
);
2302 ast_yylex_destroy(io
.scanner
);
2310 if (io
.val
->type
== AST_EXPR_integer
) {
2313 res_length
= snprintf(buf
, length
, "%ld", (long int) io
.val
->u
.i
);
2314 return_value
= (res_length
<= length
) ? res_length
: length
;
2316 #if defined(STANDALONE) || defined(LOW_MEMORY) || defined(STANDALONE_AEL)
2317 strncpy(buf
, io
.val
->u
.s
, length
- 1);
2318 #else /* !STANDALONE && !LOW_MEMORY */
2319 ast_copy_string(buf
, io
.val
->u
.s
, length
);
2320 #endif /* STANDALONE || LOW_MEMORY */
2321 return_value
= strlen(buf
);
2326 return return_value
;
2330 char extra_error_message
[4095];
2331 int extra_error_message_supplied
= 0;
2332 void ast_expr_register_extra_error_info(char *message
);
2333 void ast_expr_clear_extra_error_info(void);
2335 void ast_expr_register_extra_error_info(char *message
)
2337 extra_error_message_supplied
=1;
2338 strcpy(extra_error_message
, message
);
2341 void ast_expr_clear_extra_error_info(void)
2343 extra_error_message_supplied
=0;
2344 extra_error_message
[0] = 0;
2347 static char *expr2_token_equivs1
[] =
2372 static char *expr2_token_equivs2
[] =
2398 static char *expr2_token_subst(const char *mess
)
2400 /* calc a length, malloc, fill, and return; yyerror had better free it! */
2404 int expr2_token_equivs_entries
= sizeof(expr2_token_equivs1
)/sizeof(char*);
2406 for (p
=mess
; *p
; p
++) {
2407 for (i
=0; i
<expr2_token_equivs_entries
; i
++) {
2408 if ( strncmp(p
,expr2_token_equivs1
[i
],strlen(expr2_token_equivs1
[i
])) == 0 )
2410 len
+=strlen(expr2_token_equivs2
[i
])+2;
2411 p
+= strlen(expr2_token_equivs1
[i
])-1;
2417 res
= (char*)malloc(len
+1);
2422 for (i
=0; i
<expr2_token_equivs_entries
; i
++) {
2423 if ( strncmp(p
,expr2_token_equivs1
[i
],strlen(expr2_token_equivs1
[i
])) == 0 ) {
2425 for (t
=expr2_token_equivs2
[i
]; *t
;) {
2429 p
+= strlen(expr2_token_equivs1
[i
]);
2441 int ast_yyerror (const char *s
, yyltype
*loc
, struct parse_io
*parseio
)
2443 struct yyguts_t
* yyg
= (struct yyguts_t
*)(parseio
->scanner
);
2444 char spacebuf
[8000]; /* best safe than sorry */
2445 char spacebuf2
[8000]; /* best safe than sorry */
2447 char *s2
= expr2_token_subst(s
);
2450 for(i
=0;i
< (int)(yytext
- YY_CURRENT_BUFFER_LVALUE
->yy_ch_buf
);i
++) spacebuf2
[i
] = ' '; /* uh... assuming yyg is defined, then I can use the yycolumn macro,
2451 which is the same thing as... get this:
2452 yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_bs_column
2453 I was tempted to just use yy_buf_pos in the STATE, but..., well:
2454 a. the yy_buf_pos is the current position in the buffer, which
2455 may not relate to the entire string/buffer because of the
2457 b. but, analysis of the situation is that when you use the
2458 ast_yy_scan_string func, it creates a single buffer the size of
2459 string, so the two would be the same...
2460 so, in the end, the yycolumn macro is available, shorter, therefore easier. */
2465 /* easier to read in the standalone version */
2466 printf("ast_yyerror(): %s syntax error: %s; Input:\n%s\n%s\n",
2467 (extra_error_message_supplied
?extra_error_message
:""), s2
, parseio
->string
,spacebuf2
);
2469 ast_log(LOG_WARNING
,"ast_yyerror(): %s syntax error: %s; Input:\n%s\n%s\n",
2470 (extra_error_message_supplied
?extra_error_message
:""), s2
, parseio
->string
,spacebuf2
);
2473 ast_log(LOG_WARNING
,"If you have questions, please refer to doc/channelvariables.txt in the asterisk source.\n");