Wed Apr 6 11:29:40 2011

Asterisk developer's documentation


ast_expr2f.c

Go to the documentation of this file.
00001 #include "asterisk.h"
00002 
00003 #line 2 "ast_expr2f.c"
00004 
00005 #line 4 "ast_expr2f.c"
00006 
00007 #define  YY_INT_ALIGNED short int
00008 
00009 /* A lexical scanner generated by flex */
00010 
00011 #define FLEX_SCANNER
00012 #define YY_FLEX_MAJOR_VERSION 2
00013 #define YY_FLEX_MINOR_VERSION 5
00014 #define YY_FLEX_SUBMINOR_VERSION 35
00015 #if YY_FLEX_SUBMINOR_VERSION > 0
00016 #define FLEX_BETA
00017 #endif
00018 
00019 /* First, we deal with  platform-specific or compiler-specific issues. */
00020 
00021 /* begin standard C headers. */
00022 #include <stdio.h>
00023 #include <string.h>
00024 #include <errno.h>
00025 #include <stdlib.h>
00026 
00027 /* end standard C headers. */
00028 
00029 /* flex integer type definitions */
00030 
00031 #ifndef FLEXINT_H
00032 #define FLEXINT_H
00033 
00034 /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
00035 
00036 #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
00037 
00038 /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
00039  * if you want the limit (max/min) macros for int types. 
00040  */
00041 #ifndef __STDC_LIMIT_MACROS
00042 #define __STDC_LIMIT_MACROS 1
00043 #endif
00044 
00045 #include <inttypes.h>
00046 typedef int8_t flex_int8_t;
00047 typedef uint8_t flex_uint8_t;
00048 typedef int16_t flex_int16_t;
00049 typedef uint16_t flex_uint16_t;
00050 typedef int32_t flex_int32_t;
00051 typedef uint32_t flex_uint32_t;
00052 #else
00053 typedef signed char flex_int8_t;
00054 typedef short int flex_int16_t;
00055 typedef int flex_int32_t;
00056 typedef unsigned char flex_uint8_t; 
00057 typedef unsigned short int flex_uint16_t;
00058 typedef unsigned int flex_uint32_t;
00059 #endif /* ! C99 */
00060 
00061 /* Limits of integral types. */
00062 #ifndef INT8_MIN
00063 #define INT8_MIN               (-128)
00064 #endif
00065 #ifndef INT16_MIN
00066 #define INT16_MIN              (-32767-1)
00067 #endif
00068 #ifndef INT32_MIN
00069 #define INT32_MIN              (-2147483647-1)
00070 #endif
00071 #ifndef INT8_MAX
00072 #define INT8_MAX               (127)
00073 #endif
00074 #ifndef INT16_MAX
00075 #define INT16_MAX              (32767)
00076 #endif
00077 #ifndef INT32_MAX
00078 #define INT32_MAX              (2147483647)
00079 #endif
00080 #ifndef UINT8_MAX
00081 #define UINT8_MAX              (255U)
00082 #endif
00083 #ifndef UINT16_MAX
00084 #define UINT16_MAX             (65535U)
00085 #endif
00086 #ifndef UINT32_MAX
00087 #define UINT32_MAX             (4294967295U)
00088 #endif
00089 
00090 #endif /* ! FLEXINT_H */
00091 
00092 #ifdef __cplusplus
00093 
00094 /* The "const" storage-class-modifier is valid. */
00095 #define YY_USE_CONST
00096 
00097 #else /* ! __cplusplus */
00098 
00099 /* C99 requires __STDC__ to be defined as 1. */
00100 #if defined (__STDC__)
00101 
00102 #define YY_USE_CONST
00103 
00104 #endif   /* defined (__STDC__) */
00105 #endif   /* ! __cplusplus */
00106 
00107 #ifdef YY_USE_CONST
00108 #define yyconst const
00109 #else
00110 #define yyconst
00111 #endif
00112 
00113 /* Returned upon end-of-file. */
00114 #define YY_NULL 0
00115 
00116 /* Promotes a possibly negative, possibly signed char to an unsigned
00117  * integer for use as an array index.  If the signed char is negative,
00118  * we want to instead treat it as an 8-bit unsigned char, hence the
00119  * double cast.
00120  */
00121 #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
00122 
00123 /* An opaque pointer. */
00124 #ifndef YY_TYPEDEF_YY_SCANNER_T
00125 #define YY_TYPEDEF_YY_SCANNER_T
00126 typedef void* yyscan_t;
00127 #endif
00128 
00129 /* For convenience, these vars (plus the bison vars far below)
00130    are macros in the reentrant scanner. */
00131 #define yyin yyg->yyin_r
00132 #define yyout yyg->yyout_r
00133 #define yyextra yyg->yyextra_r
00134 #define yyleng yyg->yyleng_r
00135 #define yytext yyg->yytext_r
00136 #define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno)
00137 #define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column)
00138 #define yy_flex_debug yyg->yy_flex_debug_r
00139 
00140 /* Enter a start condition.  This macro really ought to take a parameter,
00141  * but we do it the disgusting crufty way forced on us by the ()-less
00142  * definition of BEGIN.
00143  */
00144 #define BEGIN yyg->yy_start = 1 + 2 *
00145 
00146 /* Translate the current start state into a value that can be later handed
00147  * to BEGIN to return to the state.  The YYSTATE alias is for lex
00148  * compatibility.
00149  */
00150 #define YY_START ((yyg->yy_start - 1) / 2)
00151 #define YYSTATE YY_START
00152 
00153 /* Action number for EOF rule of a given start state. */
00154 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
00155 
00156 /* Special action meaning "start processing a new file". */
00157 #define YY_NEW_FILE ast_yyrestart(yyin ,yyscanner )
00158 
00159 #define YY_END_OF_BUFFER_CHAR 0
00160 
00161 /* Size of default input buffer. */
00162 #ifndef YY_BUF_SIZE
00163 #define YY_BUF_SIZE 16384
00164 #endif
00165 
00166 /* The state buf must be large enough to hold one state per character in the main buffer.
00167  */
00168 #define YY_STATE_BUF_SIZE   ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
00169 
00170 #ifndef YY_TYPEDEF_YY_BUFFER_STATE
00171 #define YY_TYPEDEF_YY_BUFFER_STATE
00172 typedef struct yy_buffer_state *YY_BUFFER_STATE;
00173 #endif
00174 
00175 #define EOB_ACT_CONTINUE_SCAN 0
00176 #define EOB_ACT_END_OF_FILE 1
00177 #define EOB_ACT_LAST_MATCH 2
00178 
00179     #define YY_LESS_LINENO(n)
00180     
00181 /* Return all but the first "n" matched characters back to the input stream. */
00182 #define yyless(n) \
00183    do \
00184       { \
00185       /* Undo effects of setting up yytext. */ \
00186         int yyless_macro_arg = (n); \
00187         YY_LESS_LINENO(yyless_macro_arg);\
00188       *yy_cp = yyg->yy_hold_char; \
00189       YY_RESTORE_YY_MORE_OFFSET \
00190       yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
00191       YY_DO_BEFORE_ACTION; /* set up yytext again */ \
00192       } \
00193    while ( 0 )
00194 
00195 #define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner )
00196 
00197 #ifndef YY_TYPEDEF_YY_SIZE_T
00198 #define YY_TYPEDEF_YY_SIZE_T
00199 typedef size_t yy_size_t;
00200 #endif
00201 
00202 #ifndef YY_STRUCT_YY_BUFFER_STATE
00203 #define YY_STRUCT_YY_BUFFER_STATE
00204 struct yy_buffer_state
00205    {
00206    FILE *yy_input_file;
00207 
00208    char *yy_ch_buf;     /* input buffer */
00209    char *yy_buf_pos;    /* current position in input buffer */
00210 
00211    /* Size of input buffer in bytes, not including room for EOB
00212     * characters.
00213     */
00214    yy_size_t yy_buf_size;
00215 
00216    /* Number of characters read into yy_ch_buf, not including EOB
00217     * characters.
00218     */
00219    int yy_n_chars;
00220 
00221    /* Whether we "own" the buffer - i.e., we know we created it,
00222     * and can realloc() it to grow it, and should free() it to
00223     * delete it.
00224     */
00225    int yy_is_our_buffer;
00226 
00227    /* Whether this is an "interactive" input source; if so, and
00228     * if we're using stdio for input, then we want to use getc()
00229     * instead of fread(), to make sure we stop fetching input after
00230     * each newline.
00231     */
00232    int yy_is_interactive;
00233 
00234    /* Whether we're considered to be at the beginning of a line.
00235     * If so, '^' rules will be active on the next match, otherwise
00236     * not.
00237     */
00238    int yy_at_bol;
00239 
00240     int yy_bs_lineno; /**< The line count. */
00241     int yy_bs_column; /**< The column count. */
00242     
00243    /* Whether to try to fill the input buffer when we reach the
00244     * end of it.
00245     */
00246    int yy_fill_buffer;
00247 
00248    int yy_buffer_status;
00249 
00250 #define YY_BUFFER_NEW 0
00251 #define YY_BUFFER_NORMAL 1
00252    /* When an EOF's been seen but there's still some text to process
00253     * then we mark the buffer as YY_EOF_PENDING, to indicate that we
00254     * shouldn't try reading from the input source any more.  We might
00255     * still have a bunch of tokens to match, though, because of
00256     * possible backing-up.
00257     *
00258     * When we actually see the EOF, we change the status to "new"
00259     * (via ast_yyrestart()), so that the user can continue scanning by
00260     * just pointing yyin at a new input file.
00261     */
00262 #define YY_BUFFER_EOF_PENDING 2
00263 
00264    };
00265 #endif /* !YY_STRUCT_YY_BUFFER_STATE */
00266 
00267 /* We provide macros for accessing buffer states in case in the
00268  * future we want to put the buffer states in a more general
00269  * "scanner state".
00270  *
00271  * Returns the top of the stack, or NULL.
00272  */
00273 #define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \
00274                           ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \
00275                           : NULL)
00276 
00277 /* Same as previous macro, but useful when we know that the buffer stack is not
00278  * NULL or when we need an lvalue. For internal use only.
00279  */
00280 #define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]
00281 
00282 void ast_yyrestart (FILE *input_file ,yyscan_t yyscanner );
00283 void ast_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
00284 YY_BUFFER_STATE ast_yy_create_buffer (FILE *file,int size ,yyscan_t yyscanner );
00285 void ast_yy_delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
00286 void ast_yy_flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
00287 void ast_yypush_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
00288 void ast_yypop_buffer_state (yyscan_t yyscanner );
00289 
00290 static void ast_yyensure_buffer_stack (yyscan_t yyscanner );
00291 static void ast_yy_load_buffer_state (yyscan_t yyscanner );
00292 static void ast_yy_init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan_t yyscanner );
00293 
00294 #define YY_FLUSH_BUFFER ast_yy_flush_buffer(YY_CURRENT_BUFFER ,yyscanner)
00295 
00296 YY_BUFFER_STATE ast_yy_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner );
00297 YY_BUFFER_STATE ast_yy_scan_string (yyconst char *yy_str ,yyscan_t yyscanner );
00298 YY_BUFFER_STATE ast_yy_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner );
00299 
00300 void *ast_yyalloc (yy_size_t ,yyscan_t yyscanner );
00301 void *ast_yyrealloc (void *,yy_size_t ,yyscan_t yyscanner );
00302 void ast_yyfree (void * ,yyscan_t yyscanner );
00303 
00304 #define yy_new_buffer ast_yy_create_buffer
00305 
00306 #define yy_set_interactive(is_interactive) \
00307    { \
00308    if ( ! YY_CURRENT_BUFFER ){ \
00309         ast_yyensure_buffer_stack (yyscanner); \
00310       YY_CURRENT_BUFFER_LVALUE =    \
00311             ast_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \
00312    } \
00313    YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
00314    }
00315 
00316 #define yy_set_bol(at_bol) \
00317    { \
00318    if ( ! YY_CURRENT_BUFFER ){\
00319         ast_yyensure_buffer_stack (yyscanner); \
00320       YY_CURRENT_BUFFER_LVALUE =    \
00321             ast_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \
00322    } \
00323    YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
00324    }
00325 
00326 #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
00327 
00328 /* Begin user sect3 */
00329 
00330 #define ast_yywrap(n) 1
00331 #define YY_SKIP_YYWRAP
00332 
00333 typedef unsigned char YY_CHAR;
00334 
00335 typedef int yy_state_type;
00336 
00337 #define yytext_ptr yytext_r
00338 
00339 static yy_state_type yy_get_previous_state (yyscan_t yyscanner );
00340 static yy_state_type yy_try_NUL_trans (yy_state_type current_state  ,yyscan_t yyscanner);
00341 static int yy_get_next_buffer (yyscan_t yyscanner );
00342 static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner );
00343 
00344 /* Done after the current pattern has been matched and before the
00345  * corresponding action - sets up yytext.
00346  */
00347 #define YY_DO_BEFORE_ACTION \
00348    yyg->yytext_ptr = yy_bp; \
00349    yyg->yytext_ptr -= yyg->yy_more_len; \
00350    yyleng = (size_t) (yy_cp - yyg->yytext_ptr); \
00351    yyg->yy_hold_char = *yy_cp; \
00352    *yy_cp = '\0'; \
00353    yyg->yy_c_buf_p = yy_cp;
00354 
00355 #define YY_NUM_RULES 38
00356 #define YY_END_OF_BUFFER 39
00357 /* This struct is not used in this scanner,
00358    but its presence is necessary. */
00359 struct yy_trans_info
00360    {
00361    flex_int32_t yy_verify;
00362    flex_int32_t yy_nxt;
00363    };
00364 static yyconst flex_int16_t yy_accept[63] =
00365     {   0,
00366         0,    0,    0,    0,   35,   35,   39,   38,   27,   29,
00367        21,   38,   31,   38,   19,    2,   24,   25,   17,   14,
00368        15,   16,   18,   30,   22,   10,    3,    9,   20,    1,
00369        38,   38,   34,   33,   35,   37,   37,   13,    0,   28,
00370        31,    0,   26,    5,   31,   30,   23,   12,    6,    7,
00371        11,    4,    8,    0,   34,   33,   35,    0,   36,   32,
00372        30,    0
00373     } ;
00374 
00375 static yyconst flex_int32_t yy_ec[256] =
00376     {   0,
00377         1,    1,    1,    1,    1,    1,    1,    1,    2,    3,
00378         1,    1,    2,    1,    1,    1,    1,    1,    1,    1,
00379         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
00380         1,    2,    4,    5,    6,    7,    8,    9,    6,   10,
00381        11,   12,   13,   14,   15,   16,   17,   18,   18,   18,
00382        18,   18,   18,   18,   18,   18,   18,   19,    6,   20,
00383        21,   22,   23,    6,    6,    6,    6,    6,    6,    6,
00384         6,    6,    6,    6,    6,    6,    6,    6,    6,    6,
00385         6,    6,    6,    6,    6,    6,    6,    6,    6,    6,
00386         1,    6,    1,    6,    6,    1,    6,    6,    6,    6,
00387 
00388         6,    6,    6,    6,    6,    6,    6,    6,    6,    6,
00389         6,    6,    6,    6,    6,    6,    6,    6,    6,    6,
00390         6,    6,   24,   25,   26,   27,    1,   28,   28,   28,
00391        28,   28,   28,   28,   28,   28,   28,   28,   28,   28,
00392        28,   28,   28,   28,   28,   28,   28,   28,   28,   28,
00393        28,   28,   28,   28,   28,   28,   28,   28,   28,   28,
00394        28,   28,   28,   28,   28,   28,   28,   28,   28,   28,
00395        28,   28,   28,   28,   28,   28,   28,   28,   28,   28,
00396        28,   28,   28,   28,   28,   28,   28,   28,   28,   28,
00397        28,   28,   28,   28,   28,   28,   28,   28,   28,   28,
00398 
00399        28,   28,   28,   28,   28,   28,   28,   28,   28,   28,
00400        28,   28,   28,   28,   28,   28,   28,   28,   28,   28,
00401        28,   28,   28,   28,   28,   28,   28,   28,   28,   28,
00402        28,   28,   28,   28,   28,   28,   28,   28,   28,   28,
00403        28,   28,   28,   28,   28,   28,   28,   28,   28,   28,
00404        28,   28,   28,   28,   28
00405     } ;
00406 
00407 static yyconst flex_int32_t yy_meta[29] =
00408     {   0,
00409         1,    2,    2,    2,    1,    3,    3,    2,    2,    2,
00410         2,    2,    2,    1,    2,    3,    2,    3,    2,    2,
00411         2,    2,    2,    1,    2,    1,    1,    3
00412     } ;
00413 
00414 static yyconst flex_int16_t yy_base[70] =
00415     {   0,
00416         0,    0,    5,    6,   32,   60,   73,  130,  130,  130,
00417        51,   66,   63,   45,  130,   59,  130,  130,  130,  130,
00418       130,  130,  130,   83,   45,   42,   13,   41,  130,   32,
00419        28,   17,  130,  130,   47,  130,   29,  130,   47,  130,
00420        44,   25,  130,  130,   29,    0,  130,  130,  130,  130,
00421       130,  130,  130,   18,  130,  130,   38,   12,  130,  130,
00422         0,  130,  111,  114,  117,   32,  120,  123,  126
00423     } ;
00424 
00425 static yyconst flex_int16_t yy_def[70] =
00426     {   0,
00427        62,    1,   63,   63,   64,   64,   62,   62,   62,   62,
00428        62,   65,   66,   67,   62,   62,   62,   62,   62,   62,
00429        62,   62,   62,   62,   62,   62,   62,   62,   62,   62,
00430        62,   68,   62,   62,   69,   62,   62,   62,   65,   62,
00431        66,   67,   62,   62,   41,   24,   62,   62,   62,   62,
00432        62,   62,   62,   68,   62,   62,   69,   62,   62,   62,
00433        45,    0,   62,   62,   62,   62,   62,   62,   62
00434     } ;
00435 
00436 static yyconst flex_int16_t yy_nxt[159] =
00437     {   0,
00438         8,    9,   10,   11,   12,   13,   14,   15,   16,   17,
00439        18,   19,   20,   21,   22,   13,   23,   24,   25,   26,
00440        27,   28,   29,    8,   30,    8,   31,   13,   33,   33,
00441        34,   34,   35,   49,   41,   59,   35,   35,   37,   50,
00442        55,   55,   56,   56,   58,   35,   61,   35,   60,   35,
00443        42,   40,   59,   58,   53,   35,   52,   35,   35,   35,
00444        35,   51,   48,   47,   35,   35,   37,   44,   43,   42,
00445        40,   38,   62,   35,   62,   35,   62,   35,   62,   62,
00446        62,   62,   62,   35,   62,   35,   35,   35,   41,   42,
00447        62,   62,   62,   62,   62,   62,   62,   62,   45,   62,
00448 
00449        46,   62,   62,   62,   62,   62,   62,   62,   62,   62,
00450        41,   32,   32,   32,   36,   36,   36,   39,   39,   39,
00451        41,   41,   41,   54,   54,   54,   57,   62,   57,    7,
00452        62,   62,   62,   62,   62,   62,   62,   62,   62,   62,
00453        62,   62,   62,   62,   62,   62,   62,   62,   62,   62,
00454        62,   62,   62,   62,   62,   62,   62,   62
00455     } ;
00456 
00457 static yyconst flex_int16_t yy_chk[159] =
00458     {   0,
00459         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
00460         1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
00461         1,    1,    1,    1,    1,    1,    1,    1,    3,    4,
00462         3,    4,    5,   27,   66,   58,    5,    5,    5,   27,
00463        32,   54,   32,   54,   57,    5,   45,    5,   42,    5,
00464        41,   39,   37,   35,   31,    5,   30,    5,    5,    5,
00465         6,   28,   26,   25,    6,    6,    6,   16,   14,   13,
00466        12,   11,    7,    6,    0,    6,    0,    6,    0,    0,
00467         0,    0,    0,    6,    0,    6,    6,    6,   24,   24,
00468         0,    0,    0,    0,    0,    0,    0,    0,   24,    0,
00469 
00470        24,    0,    0,    0,    0,    0,    0,    0,    0,    0,
00471        24,   63,   63,   63,   64,   64,   64,   65,   65,   65,
00472        67,   67,   67,   68,   68,   68,   69,    0,   69,   62,
00473        62,   62,   62,   62,   62,   62,   62,   62,   62,   62,
00474        62,   62,   62,   62,   62,   62,   62,   62,   62,   62,
00475        62,   62,   62,   62,   62,   62,   62,   62
00476     } ;
00477 
00478 /* The intent behind this definition is that it'll catch
00479  * any uses of REJECT which flex missed.
00480  */
00481 #define REJECT reject_used_but_not_detected
00482 #define yymore() (yyg->yy_more_flag = 1)
00483 #define YY_MORE_ADJ yyg->yy_more_len
00484 #define YY_RESTORE_YY_MORE_OFFSET
00485 #line 1 "ast_expr2.fl"
00486 #line 2 "ast_expr2.fl"
00487 /*
00488  * Asterisk -- An open source telephony toolkit.
00489  *
00490  * Copyright (C) 1999 - 2006, Digium, Inc.
00491  *
00492  * Mark Spencer <markster@digium.com>
00493  *
00494  * See http://www.asterisk.org for more information about
00495  * the Asterisk project. Please do not directly contact
00496  * any of the maintainers of this project for assistance;
00497  * the project provides a web site, mailing lists and IRC
00498  * channels for your use.
00499  *
00500  * This program is free software, distributed under the terms of
00501  * the GNU General Public License Version 2. See the LICENSE file
00502  * at the top of the source tree.
00503  */
00504 
00505 /*! \file
00506  *
00507  * \brief Dialplan Expression Lexical Scanner
00508  */
00509 
00510 #include <sys/types.h>
00511 #include <stdio.h>
00512 
00513 #if !defined(STANDALONE)
00514 ASTERISK_FILE_VERSION(__FILE__, "$Revision: 268969 $")
00515 #else
00516 #ifndef __USE_ISOC99
00517 #define __USE_ISOC99 1
00518 #endif
00519 #endif
00520 
00521 #ifdef __USE_ISOC99
00522 #define FP___PRINTF "%.18Lg"
00523 #define FP___FMOD   fmodl
00524 #define FP___STRTOD  strtold
00525 #define FP___TYPE    long double
00526 #else
00527 #define FP___PRINTF "%.16g"
00528 #define FP___FMOD   fmod
00529 #define FP___STRTOD  strtod
00530 #define FP___TYPE    double
00531 #endif
00532 
00533 #include <stdlib.h>
00534 #include <string.h>
00535 #include <locale.h>
00536 #include <ctype.h>
00537 #if !defined(SOLARIS) && !defined(__CYGWIN__)
00538 /* #include <err.h> */
00539 #else
00540 #define quad_t int64_t
00541 #endif
00542 #include <errno.h>
00543 #include <regex.h>
00544 #include <limits.h>
00545 
00546 #include "asterisk/ast_expr.h"
00547 #include "asterisk/logger.h"
00548 #ifndef STANDALONE
00549 #include "asterisk/strings.h"
00550 #include "asterisk/channel.h"
00551 #endif
00552 
00553 /*!\note The latest Flex uses fwrite without checking its return value, which
00554  * is a warning on some compilers.  Therefore, we use this workaround, to trick
00555  * the compiler into suppressing this warning. */
00556 #define fwrite(a,b,c,d) do { int __res = fwrite(a,b,c,d); (__res); } while (0)
00557 
00558 enum valtype {
00559    AST_EXPR_number, AST_EXPR_numeric_string, AST_EXPR_string
00560 } ;
00561 
00562 struct val {
00563    enum valtype type;
00564    union {
00565       char *s;
00566       FP___TYPE i; /* long double or just double if it's a bad day */
00567    } u;
00568 } ;
00569 
00570 #include "ast_expr2.h" /* the o/p of the bison on ast_expr2.y */
00571 
00572 #define SET_COLUMNS  do {     \
00573    yylloc_param->first_column = (int)(yyg->yytext_r - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf); \
00574    yylloc_param->last_column += yyleng - 1; \
00575    yylloc_param->first_line = yylloc_param->last_line = 1; \
00576    } while (0)
00577 
00578 #define SET_STRING   do {     \
00579    yylval_param->val = calloc(1, sizeof(struct val)); \
00580    yylval_param->val->type = AST_EXPR_string;      \
00581    yylval_param->val->u.s = strdup(yytext);     \
00582    } while (0)
00583 
00584 #define SET_NUMERIC_STRING do {  \
00585    yylval_param->val = calloc(1, sizeof(struct val)); \
00586    yylval_param->val->type = AST_EXPR_numeric_string; \
00587    yylval_param->val->u.s = strdup(yytext);  \
00588    } while (0)
00589 
00590 struct parse_io
00591 {
00592    char *string;
00593    struct val *val;
00594    yyscan_t scanner;
00595    struct ast_channel *chan;
00596 };
00597  
00598 void ast_yyset_column(int column_no, yyscan_t yyscanner);
00599 int ast_yyget_column(yyscan_t yyscanner);
00600 static int curlycount = 0;
00601 static char *expr2_token_subst(const char *mess);
00602 
00603 #line 602 "ast_expr2f.c"
00604 
00605 #define INITIAL 0
00606 #define var 1
00607 #define trail 2
00608 
00609 #ifndef YY_NO_UNISTD_H
00610 /* Special case for "unistd.h", since it is non-ANSI. We include it way
00611  * down here because we want the user's section 1 to have been scanned first.
00612  * The user has a chance to override it with an option.
00613  */
00614 #include <unistd.h>
00615 #endif
00616 
00617 #ifndef YY_EXTRA_TYPE
00618 #define YY_EXTRA_TYPE void *
00619 #endif
00620 
00621 /* Holds the entire state of the reentrant scanner. */
00622 struct yyguts_t
00623     {
00624 
00625     /* User-defined. Not touched by flex. */
00626     YY_EXTRA_TYPE yyextra_r;
00627 
00628     /* The rest are the same as the globals declared in the non-reentrant scanner. */
00629     FILE *yyin_r, *yyout_r;
00630     size_t yy_buffer_stack_top; /**< index of top of stack. */
00631     size_t yy_buffer_stack_max; /**< capacity of stack. */
00632     YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */
00633     char yy_hold_char;
00634     int yy_n_chars;
00635     int yyleng_r;
00636     char *yy_c_buf_p;
00637     int yy_init;
00638     int yy_start;
00639     int yy_did_buffer_switch_on_eof;
00640     int yy_start_stack_ptr;
00641     int yy_start_stack_depth;
00642     int *yy_start_stack;
00643     yy_state_type yy_last_accepting_state;
00644     char* yy_last_accepting_cpos;
00645 
00646     int yylineno_r;
00647     int yy_flex_debug_r;
00648 
00649     char *yytext_r;
00650     int yy_more_flag;
00651     int yy_more_len;
00652 
00653     YYSTYPE * yylval_r;
00654 
00655     YYLTYPE * yylloc_r;
00656 
00657     }; /* end struct yyguts_t */
00658 
00659 static int yy_init_globals (yyscan_t yyscanner );
00660 
00661     /* This must go here because YYSTYPE and YYLTYPE are included
00662      * from bison output in section 1.*/
00663     #    define yylval yyg->yylval_r
00664     
00665     #    define yylloc yyg->yylloc_r
00666     
00667 int ast_yylex_init (yyscan_t* scanner);
00668 
00669 int ast_yylex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner);
00670 
00671 /* Accessor methods to globals.
00672    These are made visible to non-reentrant scanners for convenience. */
00673 
00674 int ast_yylex_destroy (yyscan_t yyscanner );
00675 
00676 int ast_yyget_debug (yyscan_t yyscanner );
00677 
00678 void ast_yyset_debug (int debug_flag ,yyscan_t yyscanner );
00679 
00680 YY_EXTRA_TYPE ast_yyget_extra (yyscan_t yyscanner );
00681 
00682 void ast_yyset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner );
00683 
00684 FILE *ast_yyget_in (yyscan_t yyscanner );
00685 
00686 void ast_yyset_in  (FILE * in_str ,yyscan_t yyscanner );
00687 
00688 FILE *ast_yyget_out (yyscan_t yyscanner );
00689 
00690 void ast_yyset_out  (FILE * out_str ,yyscan_t yyscanner );
00691 
00692 int ast_yyget_leng (yyscan_t yyscanner );
00693 
00694 char *ast_yyget_text (yyscan_t yyscanner );
00695 
00696 int ast_yyget_lineno (yyscan_t yyscanner );
00697 
00698 void ast_yyset_lineno (int line_number ,yyscan_t yyscanner );
00699 
00700 YYSTYPE * ast_yyget_lval (yyscan_t yyscanner );
00701 
00702 void ast_yyset_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner );
00703 
00704        YYLTYPE *ast_yyget_lloc (yyscan_t yyscanner );
00705     
00706         void ast_yyset_lloc (YYLTYPE * yylloc_param ,yyscan_t yyscanner );
00707     
00708 /* Macros after this point can all be overridden by user definitions in
00709  * section 1.
00710  */
00711 
00712 #ifndef YY_SKIP_YYWRAP
00713 #ifdef __cplusplus
00714 extern "C" int ast_yywrap (yyscan_t yyscanner );
00715 #else
00716 extern int ast_yywrap (yyscan_t yyscanner );
00717 #endif
00718 #endif
00719 
00720     static void yyunput (int c,char *buf_ptr  ,yyscan_t yyscanner);
00721     
00722 #ifndef yytext_ptr
00723 static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner);
00724 #endif
00725 
00726 #ifdef YY_NEED_STRLEN
00727 static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner);
00728 #endif
00729 
00730 #ifndef YY_NO_INPUT
00731 
00732 #ifdef __cplusplus
00733 static int yyinput (yyscan_t yyscanner );
00734 #else
00735 static int input (yyscan_t yyscanner );
00736 #endif
00737 
00738 #endif
00739 
00740 /* Amount of stuff to slurp up with each read. */
00741 #ifndef YY_READ_BUF_SIZE
00742 #define YY_READ_BUF_SIZE 8192
00743 #endif
00744 
00745 /* Copy whatever the last rule matched to the standard output. */
00746 #ifndef ECHO
00747 /* This used to be an fputs(), but since the string might contain NUL's,
00748  * we now use fwrite().
00749  */
00750 #define ECHO fwrite( yytext, yyleng, 1, yyout )
00751 #endif
00752 
00753 /* Gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
00754  * is returned in "result".
00755  */
00756 #ifndef YY_INPUT
00757 #define YY_INPUT(buf,result,max_size) \
00758    if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
00759       { \
00760       int c = '*'; \
00761       int n; \
00762       for ( n = 0; n < max_size && \
00763               (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
00764          buf[n] = (char) c; \
00765       if ( c == '\n' ) \
00766          buf[n++] = (char) c; \
00767       if ( c == EOF && ferror( yyin ) ) \
00768          YY_FATAL_ERROR( "input in flex scanner failed" ); \
00769       result = n; \
00770       } \
00771    else \
00772       { \
00773       errno=0; \
00774       while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
00775          { \
00776          if( errno != EINTR) \
00777             { \
00778             YY_FATAL_ERROR( "input in flex scanner failed" ); \
00779             break; \
00780             } \
00781          errno=0; \
00782          clearerr(yyin); \
00783          } \
00784       }\
00785 \
00786 
00787 #endif
00788 
00789 /* No semi-colon after return; correct usage is to write "yyterminate();" -
00790  * we don't want an extra ';' after the "return" because that will cause
00791  * some compilers to complain about unreachable statements.
00792  */
00793 #ifndef yyterminate
00794 #define yyterminate() return YY_NULL
00795 #endif
00796 
00797 /* Number of entries by which start-condition stack grows. */
00798 #ifndef YY_START_STACK_INCR
00799 #define YY_START_STACK_INCR 25
00800 #endif
00801 
00802 /* Report a fatal error. */
00803 #ifndef YY_FATAL_ERROR
00804 #define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner)
00805 #endif
00806 
00807 /* end tables serialization structures and prototypes */
00808 
00809 /* Default declaration of generated scanner - a define so the user can
00810  * easily add parameters.
00811  */
00812 #ifndef YY_DECL
00813 #define YY_DECL_IS_OURS 1
00814 
00815 extern int ast_yylex \
00816                (YYSTYPE * yylval_param,YYLTYPE * yylloc_param ,yyscan_t yyscanner);
00817 
00818 #define YY_DECL int ast_yylex \
00819                (YYSTYPE * yylval_param, YYLTYPE * yylloc_param , yyscan_t yyscanner)
00820 #endif /* !YY_DECL */
00821 
00822 /* Code executed at the beginning of each rule, after yytext and yyleng
00823  * have been set up.
00824  */
00825 #ifndef YY_USER_ACTION
00826 #define YY_USER_ACTION
00827 #endif
00828 
00829 /* Code executed at the end of each rule. */
00830 #ifndef YY_BREAK
00831 #define YY_BREAK break;
00832 #endif
00833 
00834 #define YY_RULE_SETUP \
00835    YY_USER_ACTION
00836 
00837 /** The main scanner function which does all the work.
00838  */
00839 YY_DECL
00840 {
00841    register yy_state_type yy_current_state;
00842    register char *yy_cp, *yy_bp;
00843    register int yy_act;
00844     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
00845 
00846 #line 130 "ast_expr2.fl"
00847 
00848 
00849 #line 848 "ast_expr2f.c"
00850 
00851     yylval = yylval_param;
00852 
00853     yylloc = yylloc_param;
00854 
00855    if ( !yyg->yy_init )
00856       {
00857       yyg->yy_init = 1;
00858 
00859 #ifdef YY_USER_INIT
00860       YY_USER_INIT;
00861 #endif
00862 
00863       if ( ! yyg->yy_start )
00864          yyg->yy_start = 1;   /* first start state */
00865 
00866       if ( ! yyin )
00867          yyin = stdin;
00868 
00869       if ( ! yyout )
00870          yyout = stdout;
00871 
00872       if ( ! YY_CURRENT_BUFFER ) {
00873          ast_yyensure_buffer_stack (yyscanner);
00874          YY_CURRENT_BUFFER_LVALUE =
00875             ast_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner);
00876       }
00877 
00878       ast_yy_load_buffer_state(yyscanner );
00879       }
00880 
00881    while ( 1 )    /* loops until end-of-file is reached */
00882       {
00883       yyg->yy_more_len = 0;
00884       if ( yyg->yy_more_flag )
00885          {
00886          yyg->yy_more_len = yyg->yy_c_buf_p - yyg->yytext_ptr;
00887          yyg->yy_more_flag = 0;
00888          }
00889       yy_cp = yyg->yy_c_buf_p;
00890 
00891       /* Support of yytext. */
00892       *yy_cp = yyg->yy_hold_char;
00893 
00894       /* yy_bp points to the position in yy_ch_buf of the start of
00895        * the current run.
00896        */
00897       yy_bp = yy_cp;
00898 
00899       yy_current_state = yyg->yy_start;
00900 yy_match:
00901       do
00902          {
00903          register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
00904          if ( yy_accept[yy_current_state] )
00905             {
00906             yyg->yy_last_accepting_state = yy_current_state;
00907             yyg->yy_last_accepting_cpos = yy_cp;
00908             }
00909          while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
00910             {
00911             yy_current_state = (int) yy_def[yy_current_state];
00912             if ( yy_current_state >= 63 )
00913                yy_c = yy_meta[(unsigned int) yy_c];
00914             }
00915          yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
00916          ++yy_cp;
00917          }
00918       while ( yy_current_state != 62 );
00919       yy_cp = yyg->yy_last_accepting_cpos;
00920       yy_current_state = yyg->yy_last_accepting_state;
00921 
00922 yy_find_action:
00923       yy_act = yy_accept[yy_current_state];
00924 
00925       YY_DO_BEFORE_ACTION;
00926 
00927 do_action:  /* This label is used only to access EOF actions. */
00928 
00929       switch ( yy_act )
00930    { /* beginning of action switch */
00931          case 0: /* must back up */
00932          /* undo the effects of YY_DO_BEFORE_ACTION */
00933          *yy_cp = yyg->yy_hold_char;
00934          yy_cp = yyg->yy_last_accepting_cpos;
00935          yy_current_state = yyg->yy_last_accepting_state;
00936          goto yy_find_action;
00937 
00938 case 1:
00939 YY_RULE_SETUP
00940 #line 132 "ast_expr2.fl"
00941 { SET_COLUMNS; SET_STRING; return TOK_OR;}
00942    YY_BREAK
00943 case 2:
00944 YY_RULE_SETUP
00945 #line 133 "ast_expr2.fl"
00946 { SET_COLUMNS; SET_STRING; return TOK_AND;}
00947    YY_BREAK
00948 case 3:
00949 YY_RULE_SETUP
00950 #line 134 "ast_expr2.fl"
00951 { SET_COLUMNS; SET_STRING; return TOK_EQ;}
00952    YY_BREAK
00953 case 4:
00954 YY_RULE_SETUP
00955 #line 135 "ast_expr2.fl"
00956 { SET_COLUMNS; SET_STRING; return TOK_OR;}
00957    YY_BREAK
00958 case 5:
00959 YY_RULE_SETUP
00960 #line 136 "ast_expr2.fl"
00961 { SET_COLUMNS; SET_STRING; return TOK_AND;}
00962    YY_BREAK
00963 case 6:
00964 YY_RULE_SETUP
00965 #line 137 "ast_expr2.fl"
00966 { SET_COLUMNS; SET_STRING; return TOK_EQ;}
00967    YY_BREAK
00968 case 7:
00969 YY_RULE_SETUP
00970 #line 138 "ast_expr2.fl"
00971 { SET_COLUMNS; SET_STRING; return TOK_EQTILDE;}
00972    YY_BREAK
00973 case 8:
00974 YY_RULE_SETUP
00975 #line 139 "ast_expr2.fl"
00976 { SET_COLUMNS; SET_STRING; return TOK_TILDETILDE;}
00977    YY_BREAK
00978 case 9:
00979 YY_RULE_SETUP
00980 #line 140 "ast_expr2.fl"
00981 { SET_COLUMNS; SET_STRING; return TOK_GT;}
00982    YY_BREAK
00983 case 10:
00984 YY_RULE_SETUP
00985 #line 141 "ast_expr2.fl"
00986 { SET_COLUMNS; SET_STRING; return TOK_LT;}
00987    YY_BREAK
00988 case 11:
00989 YY_RULE_SETUP
00990 #line 142 "ast_expr2.fl"
00991 { SET_COLUMNS; SET_STRING; return TOK_GE;}
00992    YY_BREAK
00993 case 12:
00994 YY_RULE_SETUP
00995 #line 143 "ast_expr2.fl"
00996 { SET_COLUMNS; SET_STRING; return TOK_LE;}
00997    YY_BREAK
00998 case 13:
00999 YY_RULE_SETUP
01000 #line 144 "ast_expr2.fl"
01001 { SET_COLUMNS; SET_STRING; return TOK_NE;}
01002    YY_BREAK
01003 case 14:
01004 YY_RULE_SETUP
01005 #line 145 "ast_expr2.fl"
01006 { SET_COLUMNS; SET_STRING; return TOK_PLUS;}
01007    YY_BREAK
01008 case 15:
01009 YY_RULE_SETUP
01010 #line 146 "ast_expr2.fl"
01011 { SET_COLUMNS; SET_STRING; return TOK_COMMA;}
01012    YY_BREAK
01013 case 16:
01014 YY_RULE_SETUP
01015 #line 147 "ast_expr2.fl"
01016 { SET_COLUMNS; SET_STRING; return TOK_MINUS;}
01017    YY_BREAK
01018 case 17:
01019 YY_RULE_SETUP
01020 #line 148 "ast_expr2.fl"
01021 { SET_COLUMNS; SET_STRING; return TOK_MULT;}
01022    YY_BREAK
01023 case 18:
01024 YY_RULE_SETUP
01025 #line 149 "ast_expr2.fl"
01026 { SET_COLUMNS; SET_STRING; return TOK_DIV;}
01027    YY_BREAK
01028 case 19:
01029 YY_RULE_SETUP
01030 #line 150 "ast_expr2.fl"
01031 { SET_COLUMNS; SET_STRING; return TOK_MOD;}
01032    YY_BREAK
01033 case 20:
01034 YY_RULE_SETUP
01035 #line 151 "ast_expr2.fl"
01036 { SET_COLUMNS; SET_STRING; return TOK_COND;}
01037    YY_BREAK
01038 case 21:
01039 YY_RULE_SETUP
01040 #line 152 "ast_expr2.fl"
01041 { SET_COLUMNS; SET_STRING; return TOK_COMPL;}
01042    YY_BREAK
01043 case 22:
01044 YY_RULE_SETUP
01045 #line 153 "ast_expr2.fl"
01046 { SET_COLUMNS; SET_STRING; return TOK_COLON;}
01047    YY_BREAK
01048 case 23:
01049 YY_RULE_SETUP
01050 #line 154 "ast_expr2.fl"
01051 { SET_COLUMNS; SET_STRING; return TOK_COLONCOLON;}
01052    YY_BREAK
01053 case 24:
01054 YY_RULE_SETUP
01055 #line 155 "ast_expr2.fl"
01056 { SET_COLUMNS; SET_STRING; return TOK_LP;}
01057    YY_BREAK
01058 case 25:
01059 YY_RULE_SETUP
01060 #line 156 "ast_expr2.fl"
01061 { SET_COLUMNS; SET_STRING; return TOK_RP;}
01062    YY_BREAK
01063 case 26:
01064 YY_RULE_SETUP
01065 #line 157 "ast_expr2.fl"
01066 {
01067       /* gather the contents of ${} expressions, with trailing stuff,
01068        * into a single TOKEN.
01069        * They are much more complex now than they used to be
01070        */
01071       curlycount = 0;
01072       BEGIN(var);
01073       yymore();
01074    }
01075    YY_BREAK
01076 case 27:
01077 YY_RULE_SETUP
01078 #line 167 "ast_expr2.fl"
01079 {}
01080    YY_BREAK
01081 case 28:
01082 /* rule 28 can match eol */
01083 YY_RULE_SETUP
01084 #line 168 "ast_expr2.fl"
01085 {SET_COLUMNS; SET_STRING; return TOKEN;}
01086    YY_BREAK
01087 case 29:
01088 /* rule 29 can match eol */
01089 YY_RULE_SETUP
01090 #line 170 "ast_expr2.fl"
01091 {/* what to do with eol */}
01092    YY_BREAK
01093 case 30:
01094 YY_RULE_SETUP
01095 #line 171 "ast_expr2.fl"
01096 {
01097       SET_COLUMNS;
01098       /* the original behavior of the expression parser was
01099        * to bring in numbers as a numeric string
01100        */
01101       SET_NUMERIC_STRING;
01102       return TOKEN;
01103    }
01104    YY_BREAK
01105 case 31:
01106 /* rule 31 can match eol */
01107 YY_RULE_SETUP
01108 #line 180 "ast_expr2.fl"
01109 {
01110       SET_COLUMNS;
01111       SET_STRING;
01112       return TOKEN;
01113    }
01114    YY_BREAK
01115 case 32:
01116 /* rule 32 can match eol */
01117 YY_RULE_SETUP
01118 #line 186 "ast_expr2.fl"
01119 {
01120       curlycount = 0;
01121       BEGIN(var);
01122       yymore();
01123    }
01124    YY_BREAK
01125 case 33:
01126 /* rule 33 can match eol */
01127 YY_RULE_SETUP
01128 #line 192 "ast_expr2.fl"
01129 {
01130       curlycount--;
01131       if (curlycount < 0) {
01132          BEGIN(trail);
01133          yymore();
01134       } else {
01135          yymore();
01136       }
01137    }
01138    YY_BREAK
01139 case 34:
01140 /* rule 34 can match eol */
01141 YY_RULE_SETUP
01142 #line 202 "ast_expr2.fl"
01143 {
01144       curlycount++;
01145       yymore();
01146    }
01147    YY_BREAK
01148 case 35:
01149 YY_RULE_SETUP
01150 #line 208 "ast_expr2.fl"
01151 {
01152       BEGIN(0);
01153       SET_COLUMNS;
01154       SET_STRING;
01155       return TOKEN;
01156    }
01157    YY_BREAK
01158 case 36:
01159 YY_RULE_SETUP
01160 #line 215 "ast_expr2.fl"
01161 {
01162       curlycount = 0;
01163       BEGIN(var);
01164       yymore();
01165    }
01166    YY_BREAK
01167 case 37:
01168 /* rule 37 can match eol */
01169 YY_RULE_SETUP
01170 #line 221 "ast_expr2.fl"
01171 {
01172       char c = yytext[yyleng-1];
01173       BEGIN(0);
01174       unput(c);
01175       SET_COLUMNS;
01176       SET_STRING;
01177       return TOKEN;
01178    }
01179    YY_BREAK
01180 case YY_STATE_EOF(trail):
01181 #line 230 "ast_expr2.fl"
01182 {
01183       BEGIN(0);
01184       SET_COLUMNS;
01185       SET_STRING;
01186       return TOKEN;
01187       /*actually, if an expr is only a variable ref, this could happen a LOT */
01188    }
01189    YY_BREAK
01190 case 38:
01191 YY_RULE_SETUP
01192 #line 238 "ast_expr2.fl"
01193 ECHO;
01194    YY_BREAK
01195 #line 1194 "ast_expr2f.c"
01196 case YY_STATE_EOF(INITIAL):
01197 case YY_STATE_EOF(var):
01198    yyterminate();
01199 
01200    case YY_END_OF_BUFFER:
01201       {
01202       /* Amount of text matched not including the EOB char. */
01203       int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1;
01204 
01205       /* Undo the effects of YY_DO_BEFORE_ACTION. */
01206       *yy_cp = yyg->yy_hold_char;
01207       YY_RESTORE_YY_MORE_OFFSET
01208 
01209       if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
01210          {
01211          /* We're scanning a new file or input source.  It's
01212           * possible that this happened because the user
01213           * just pointed yyin at a new source and called
01214           * ast_yylex().  If so, then we have to assure
01215           * consistency between YY_CURRENT_BUFFER and our
01216           * globals.  Here is the right place to do so, because
01217           * this is the first action (other than possibly a
01218           * back-up) that will match for the new input source.
01219           */
01220          yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
01221          YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
01222          YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
01223          }
01224 
01225       /* Note that here we test for yy_c_buf_p "<=" to the position
01226        * of the first EOB in the buffer, since yy_c_buf_p will
01227        * already have been incremented past the NUL character
01228        * (since all states make transitions on EOB to the
01229        * end-of-buffer state).  Contrast this with the test
01230        * in input().
01231        */
01232       if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
01233          { /* This was really a NUL. */
01234          yy_state_type yy_next_state;
01235 
01236          yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text;
01237 
01238          yy_current_state = yy_get_previous_state( yyscanner );
01239 
01240          /* Okay, we're now positioned to make the NUL
01241           * transition.  We couldn't have
01242           * yy_get_previous_state() go ahead and do it
01243           * for us because it doesn't know how to deal
01244           * with the possibility of jamming (and we don't
01245           * want to build jamming into it because then it
01246           * will run more slowly).
01247           */
01248 
01249          yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner);
01250 
01251          yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
01252 
01253          if ( yy_next_state )
01254             {
01255             /* Consume the NUL. */
01256             yy_cp = ++yyg->yy_c_buf_p;
01257             yy_current_state = yy_next_state;
01258             goto yy_match;
01259             }
01260 
01261          else
01262             {
01263             yy_cp = yyg->yy_last_accepting_cpos;
01264             yy_current_state = yyg->yy_last_accepting_state;
01265             goto yy_find_action;
01266             }
01267          }
01268 
01269       else switch ( yy_get_next_buffer( yyscanner ) )
01270          {
01271          case EOB_ACT_END_OF_FILE:
01272             {
01273             yyg->yy_did_buffer_switch_on_eof = 0;
01274 
01275             if ( ast_yywrap(yyscanner ) )
01276                {
01277                /* Note: because we've taken care in
01278                 * yy_get_next_buffer() to have set up
01279                 * yytext, we can now set up
01280                 * yy_c_buf_p so that if some total
01281                 * hoser (like flex itself) wants to
01282                 * call the scanner after we return the
01283                 * YY_NULL, it'll still work - another
01284                 * YY_NULL will get returned.
01285                 */
01286                yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ;
01287 
01288                yy_act = YY_STATE_EOF(YY_START);
01289                goto do_action;
01290                }
01291 
01292             else
01293                {
01294                if ( ! yyg->yy_did_buffer_switch_on_eof )
01295                   YY_NEW_FILE;
01296                }
01297             break;
01298             }
01299 
01300          case EOB_ACT_CONTINUE_SCAN:
01301             yyg->yy_c_buf_p =
01302                yyg->yytext_ptr + yy_amount_of_matched_text;
01303 
01304             yy_current_state = yy_get_previous_state( yyscanner );
01305 
01306             yy_cp = yyg->yy_c_buf_p;
01307             yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
01308             goto yy_match;
01309 
01310          case EOB_ACT_LAST_MATCH:
01311             yyg->yy_c_buf_p =
01312             &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars];
01313 
01314             yy_current_state = yy_get_previous_state( yyscanner );
01315 
01316             yy_cp = yyg->yy_c_buf_p;
01317             yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
01318             goto yy_find_action;
01319          }
01320       break;
01321       }
01322 
01323    default:
01324       YY_FATAL_ERROR(
01325          "fatal flex scanner internal error--no action found" );
01326    } /* end of action switch */
01327       } /* end of scanning one token */
01328 } /* end of ast_yylex */
01329 
01330 /* yy_get_next_buffer - try to read in a new buffer
01331  *
01332  * Returns a code representing an action:
01333  * EOB_ACT_LAST_MATCH -
01334  * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
01335  * EOB_ACT_END_OF_FILE - end of file
01336  */
01337 static int yy_get_next_buffer (yyscan_t yyscanner)
01338 {
01339     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
01340    register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
01341    register char *source = yyg->yytext_ptr;
01342    register int number_to_move, i;
01343    int ret_val;
01344 
01345    if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] )
01346       YY_FATAL_ERROR(
01347       "fatal flex scanner internal error--end of buffer missed" );
01348 
01349    if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
01350       { /* Don't try to fill the buffer, so this is an EOF. */
01351       if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 )
01352          {
01353          /* We matched a single character, the EOB, so
01354           * treat this as a final EOF.
01355           */
01356          return EOB_ACT_END_OF_FILE;
01357          }
01358 
01359       else
01360          {
01361          /* We matched some text prior to the EOB, first
01362           * process it.
01363           */
01364          return EOB_ACT_LAST_MATCH;
01365          }
01366       }
01367 
01368    /* Try to read more data. */
01369 
01370    /* First move last chars to start of buffer. */
01371    number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr) - 1;
01372 
01373    for ( i = 0; i < number_to_move; ++i )
01374       *(dest++) = *(source++);
01375 
01376    if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
01377       /* don't do the read, it's not guaranteed to return an EOF,
01378        * just force an EOF
01379        */
01380       YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0;
01381 
01382    else
01383       {
01384          int num_to_read =
01385          YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
01386 
01387       while ( num_to_read <= 0 )
01388          { /* Not enough room in the buffer - grow it. */
01389 
01390          /* just a shorter name for the current buffer */
01391          YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
01392 
01393          int yy_c_buf_p_offset =
01394             (int) (yyg->yy_c_buf_p - b->yy_ch_buf);
01395 
01396          if ( b->yy_is_our_buffer )
01397             {
01398             int new_size = b->yy_buf_size * 2;
01399 
01400             if ( new_size <= 0 )
01401                b->yy_buf_size += b->yy_buf_size / 8;
01402             else
01403                b->yy_buf_size *= 2;
01404 
01405             b->yy_ch_buf = (char *)
01406                /* Include room in for 2 EOB chars. */
01407                ast_yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ,yyscanner );
01408             }
01409          else
01410             /* Can't grow it, we don't own it. */
01411             b->yy_ch_buf = 0;
01412 
01413          if ( ! b->yy_ch_buf )
01414             YY_FATAL_ERROR(
01415             "fatal error - scanner input buffer overflow" );
01416 
01417          yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
01418 
01419          num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
01420                   number_to_move - 1;
01421 
01422          }
01423 
01424       if ( num_to_read > YY_READ_BUF_SIZE )
01425          num_to_read = YY_READ_BUF_SIZE;
01426 
01427       /* Read in more data. */
01428       YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
01429          yyg->yy_n_chars, (size_t) num_to_read );
01430 
01431       YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
01432       }
01433 
01434    if ( yyg->yy_n_chars == 0 )
01435       {
01436       if ( number_to_move == YY_MORE_ADJ )
01437          {
01438          ret_val = EOB_ACT_END_OF_FILE;
01439          ast_yyrestart(yyin  ,yyscanner);
01440          }
01441 
01442       else
01443          {
01444          ret_val = EOB_ACT_LAST_MATCH;
01445          YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
01446             YY_BUFFER_EOF_PENDING;
01447          }
01448       }
01449 
01450    else
01451       ret_val = EOB_ACT_CONTINUE_SCAN;
01452 
01453    if ((yy_size_t) (yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
01454       /* Extend the array by 50%, plus the number we really need. */
01455       yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1);
01456       YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) ast_yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner );
01457       if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
01458          YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
01459    }
01460 
01461    yyg->yy_n_chars += number_to_move;
01462    YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR;
01463    YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
01464 
01465    yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
01466 
01467    return ret_val;
01468 }
01469 
01470 /* yy_get_previous_state - get the state just before the EOB char was reached */
01471 
01472     static yy_state_type yy_get_previous_state (yyscan_t yyscanner)
01473 {
01474    register yy_state_type yy_current_state;
01475    register char *yy_cp;
01476     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
01477 
01478    yy_current_state = yyg->yy_start;
01479 
01480    for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp )
01481       {
01482       register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
01483       if ( yy_accept[yy_current_state] )
01484          {
01485          yyg->yy_last_accepting_state = yy_current_state;
01486          yyg->yy_last_accepting_cpos = yy_cp;
01487          }
01488       while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
01489          {
01490          yy_current_state = (int) yy_def[yy_current_state];
01491          if ( yy_current_state >= 63 )
01492             yy_c = yy_meta[(unsigned int) yy_c];
01493          }
01494       yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
01495       }
01496 
01497    return yy_current_state;
01498 }
01499 
01500 /* yy_try_NUL_trans - try to make a transition on the NUL character
01501  *
01502  * synopsis
01503  * next_state = yy_try_NUL_trans( current_state );
01504  */
01505     static yy_state_type yy_try_NUL_trans  (yy_state_type yy_current_state , yyscan_t yyscanner)
01506 {
01507    register int yy_is_jam;
01508     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */
01509    register char *yy_cp = yyg->yy_c_buf_p;
01510 
01511    register YY_CHAR yy_c = 1;
01512    if ( yy_accept[yy_current_state] )
01513       {
01514       yyg->yy_last_accepting_state = yy_current_state;
01515       yyg->yy_last_accepting_cpos = yy_cp;
01516       }
01517    while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
01518       {
01519       yy_current_state = (int) yy_def[yy_current_state];
01520       if ( yy_current_state >= 63 )
01521          yy_c = yy_meta[(unsigned int) yy_c];
01522       }
01523    yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
01524    yy_is_jam = (yy_current_state == 62);
01525 
01526    return yy_is_jam ? 0 : yy_current_state;
01527 }
01528 
01529     static void yyunput (int c, register char * yy_bp , yyscan_t yyscanner)
01530 {
01531    register char *yy_cp;
01532     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
01533 
01534     yy_cp = yyg->yy_c_buf_p;
01535 
01536    /* undo effects of setting up yytext */
01537    *yy_cp = yyg->yy_hold_char;
01538 
01539    if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
01540       { /* need to shift things up to make room */
01541       /* +2 for EOB chars. */
01542       register int number_to_move = yyg->yy_n_chars + 2;
01543       register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
01544                YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
01545       register char *source =
01546             &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
01547 
01548       while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
01549          *--dest = *--source;
01550 
01551       yy_cp += (int) (dest - source);
01552       yy_bp += (int) (dest - source);
01553       YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
01554          yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
01555 
01556       if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
01557          YY_FATAL_ERROR( "flex scanner push-back overflow" );
01558       }
01559 
01560    *--yy_cp = (char) c;
01561 
01562    yyg->yytext_ptr = yy_bp;
01563    yyg->yy_hold_char = *yy_cp;
01564    yyg->yy_c_buf_p = yy_cp;
01565 }
01566 
01567 #ifndef YY_NO_INPUT
01568 #ifdef __cplusplus
01569     static int yyinput (yyscan_t yyscanner)
01570 #else
01571     static int input  (yyscan_t yyscanner)
01572 #endif
01573 
01574 {
01575    int c;
01576     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
01577 
01578    *yyg->yy_c_buf_p = yyg->yy_hold_char;
01579 
01580    if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
01581       {
01582       /* yy_c_buf_p now points to the character we want to return.
01583        * If this occurs *before* the EOB characters, then it's a
01584        * valid NUL; if not, then we've hit the end of the buffer.
01585        */
01586       if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
01587          /* This was really a NUL. */
01588          *yyg->yy_c_buf_p = '\0';
01589 
01590       else
01591          { /* need more input */
01592          int offset = yyg->yy_c_buf_p - yyg->yytext_ptr;
01593          ++yyg->yy_c_buf_p;
01594 
01595          switch ( yy_get_next_buffer( yyscanner ) )
01596             {
01597             case EOB_ACT_LAST_MATCH:
01598                /* This happens because yy_g_n_b()
01599                 * sees that we've accumulated a
01600                 * token and flags that we need to
01601                 * try matching the token before
01602                 * proceeding.  But for input(),
01603                 * there's no matching to consider.
01604                 * So convert the EOB_ACT_LAST_MATCH
01605                 * to EOB_ACT_END_OF_FILE.
01606                 */
01607 
01608                /* Reset buffer status. */
01609                ast_yyrestart(yyin ,yyscanner);
01610 
01611                /*FALLTHROUGH*/
01612 
01613             case EOB_ACT_END_OF_FILE:
01614                {
01615                if ( ast_yywrap(yyscanner ) )
01616                   return EOF;
01617 
01618                if ( ! yyg->yy_did_buffer_switch_on_eof )
01619                   YY_NEW_FILE;
01620 #ifdef __cplusplus
01621                return yyinput(yyscanner);
01622 #else
01623                return input(yyscanner);
01624 #endif
01625                }
01626 
01627             case EOB_ACT_CONTINUE_SCAN:
01628                yyg->yy_c_buf_p = yyg->yytext_ptr + offset;
01629                break;
01630             }
01631          }
01632       }
01633 
01634    c = *(unsigned char *) yyg->yy_c_buf_p;   /* cast for 8-bit char's */
01635    *yyg->yy_c_buf_p = '\0';   /* preserve yytext */
01636    yyg->yy_hold_char = *++yyg->yy_c_buf_p;
01637 
01638    return c;
01639 }
01640 #endif   /* ifndef YY_NO_INPUT */
01641 
01642 /** Immediately switch to a different input stream.
01643  * @param input_file A readable stream.
01644  * @param yyscanner The scanner object.
01645  * @note This function does not reset the start condition to @c INITIAL .
01646  */
01647     void ast_yyrestart  (FILE * input_file , yyscan_t yyscanner)
01648 {
01649     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
01650 
01651    if ( ! YY_CURRENT_BUFFER ){
01652         ast_yyensure_buffer_stack (yyscanner);
01653       YY_CURRENT_BUFFER_LVALUE =
01654             ast_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner);
01655    }
01656 
01657    ast_yy_init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner);
01658    ast_yy_load_buffer_state(yyscanner );
01659 }
01660 
01661 /** Switch to a different input buffer.
01662  * @param new_buffer The new input buffer.
01663  * @param yyscanner The scanner object.
01664  */
01665     void ast_yy_switch_to_buffer  (YY_BUFFER_STATE  new_buffer , yyscan_t yyscanner)
01666 {
01667     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
01668 
01669    /* TODO. We should be able to replace this entire function body
01670     * with
01671     *    ast_yypop_buffer_state();
01672     *    ast_yypush_buffer_state(new_buffer);
01673      */
01674    ast_yyensure_buffer_stack (yyscanner);
01675    if ( YY_CURRENT_BUFFER == new_buffer )
01676       return;
01677 
01678    if ( YY_CURRENT_BUFFER )
01679       {
01680       /* Flush out information for old buffer. */
01681       *yyg->yy_c_buf_p = yyg->yy_hold_char;
01682       YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
01683       YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
01684       }
01685 
01686    YY_CURRENT_BUFFER_LVALUE = new_buffer;
01687    ast_yy_load_buffer_state(yyscanner );
01688 
01689    /* We don't actually know whether we did this switch during
01690     * EOF (ast_yywrap()) processing, but the only time this flag
01691     * is looked at is after ast_yywrap() is called, so it's safe
01692     * to go ahead and always set it.
01693     */
01694    yyg->yy_did_buffer_switch_on_eof = 1;
01695 }
01696 
01697 static void ast_yy_load_buffer_state  (yyscan_t yyscanner)
01698 {
01699     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
01700    yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
01701    yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
01702    yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
01703    yyg->yy_hold_char = *yyg->yy_c_buf_p;
01704 }
01705 
01706 /** Allocate and initialize an input buffer state.
01707  * @param file A readable stream.
01708  * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
01709  * @param yyscanner The scanner object.
01710  * @return the allocated buffer state.
01711  */
01712     YY_BUFFER_STATE ast_yy_create_buffer  (FILE * file, int  size , yyscan_t yyscanner)
01713 {
01714    YY_BUFFER_STATE b;
01715     
01716    b = (YY_BUFFER_STATE) ast_yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner );
01717    if ( ! b )
01718       YY_FATAL_ERROR( "out of dynamic memory in ast_yy_create_buffer()" );
01719 
01720    b->yy_buf_size = size;
01721 
01722    /* yy_ch_buf has to be 2 characters longer than the size given because
01723     * we need to put in 2 end-of-buffer characters.
01724     */
01725    b->yy_ch_buf = (char *) ast_yyalloc(b->yy_buf_size + 2 ,yyscanner );
01726    if ( ! b->yy_ch_buf )
01727       YY_FATAL_ERROR( "out of dynamic memory in ast_yy_create_buffer()" );
01728 
01729    b->yy_is_our_buffer = 1;
01730 
01731    ast_yy_init_buffer(b,file ,yyscanner);
01732 
01733    return b;
01734 }
01735 
01736 /** Destroy the buffer.
01737  * @param b a buffer created with ast_yy_create_buffer()
01738  * @param yyscanner The scanner object.
01739  */
01740     void ast_yy_delete_buffer (YY_BUFFER_STATE  b , yyscan_t yyscanner)
01741 {
01742     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
01743 
01744    if ( ! b )
01745       return;
01746 
01747    if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
01748       YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
01749 
01750    if ( b->yy_is_our_buffer )
01751       ast_yyfree((void *) b->yy_ch_buf ,yyscanner );
01752 
01753    ast_yyfree((void *) b ,yyscanner );
01754 }
01755 
01756 #ifndef __cplusplus
01757 extern int isatty (int );
01758 #endif /* __cplusplus */
01759     
01760 /* Initializes or reinitializes a buffer.
01761  * This function is sometimes called more than once on the same buffer,
01762  * such as during a ast_yyrestart() or at EOF.
01763  */
01764     static void ast_yy_init_buffer  (YY_BUFFER_STATE  b, FILE * file , yyscan_t yyscanner)
01765 
01766 {
01767    int oerrno = errno;
01768     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
01769 
01770    ast_yy_flush_buffer(b ,yyscanner);
01771 
01772    b->yy_input_file = file;
01773    b->yy_fill_buffer = 1;
01774 
01775     /* If b is the current buffer, then ast_yy_init_buffer was _probably_
01776      * called from ast_yyrestart() or through yy_get_next_buffer.
01777      * In that case, we don't want to reset the lineno or column.
01778      */
01779     if (b != YY_CURRENT_BUFFER){
01780         b->yy_bs_lineno = 1;
01781         b->yy_bs_column = 0;
01782     }
01783 
01784         b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
01785     
01786    errno = oerrno;
01787 }
01788 
01789 /** Discard all buffered characters. On the next scan, YY_INPUT will be called.
01790  * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
01791  * @param yyscanner The scanner object.
01792  */
01793     void ast_yy_flush_buffer (YY_BUFFER_STATE  b , yyscan_t yyscanner)
01794 {
01795     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
01796    if ( ! b )
01797       return;
01798 
01799    b->yy_n_chars = 0;
01800 
01801    /* We always need two end-of-buffer characters.  The first causes
01802     * a transition to the end-of-buffer state.  The second causes
01803     * a jam in that state.
01804     */
01805    b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
01806    b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
01807 
01808    b->yy_buf_pos = &b->yy_ch_buf[0];
01809 
01810    b->yy_at_bol = 1;
01811    b->yy_buffer_status = YY_BUFFER_NEW;
01812 
01813    if ( b == YY_CURRENT_BUFFER )
01814       ast_yy_load_buffer_state(yyscanner );
01815 }
01816 
01817 /** Pushes the new state onto the stack. The new state becomes
01818  *  the current state. This function will allocate the stack
01819  *  if necessary.
01820  *  @param new_buffer The new state.
01821  *  @param yyscanner The scanner object.
01822  */
01823 void ast_yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
01824 {
01825     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
01826    if (new_buffer == NULL)
01827       return;
01828 
01829    ast_yyensure_buffer_stack(yyscanner);
01830 
01831    /* This block is copied from ast_yy_switch_to_buffer. */
01832    if ( YY_CURRENT_BUFFER )
01833       {
01834       /* Flush out information for old buffer. */
01835       *yyg->yy_c_buf_p = yyg->yy_hold_char;
01836       YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
01837       YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
01838       }
01839 
01840    /* Only push if top exists. Otherwise, replace top. */
01841    if (YY_CURRENT_BUFFER)
01842       yyg->yy_buffer_stack_top++;
01843    YY_CURRENT_BUFFER_LVALUE = new_buffer;
01844 
01845    /* copied from ast_yy_switch_to_buffer. */
01846    ast_yy_load_buffer_state(yyscanner );
01847    yyg->yy_did_buffer_switch_on_eof = 1;
01848 }
01849 
01850 /** Removes and deletes the top of the stack, if present.
01851  *  The next element becomes the new top.
01852  *  @param yyscanner The scanner object.
01853  */
01854 void ast_yypop_buffer_state (yyscan_t yyscanner)
01855 {
01856     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
01857    if (!YY_CURRENT_BUFFER)
01858       return;
01859 
01860    ast_yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner);
01861    YY_CURRENT_BUFFER_LVALUE = NULL;
01862    if (yyg->yy_buffer_stack_top > 0)
01863       --yyg->yy_buffer_stack_top;
01864 
01865    if (YY_CURRENT_BUFFER) {
01866       ast_yy_load_buffer_state(yyscanner );
01867       yyg->yy_did_buffer_switch_on_eof = 1;
01868    }
01869 }
01870 
01871 /* Allocates the stack if it does not exist.
01872  *  Guarantees space for at least one push.
01873  */
01874 static void ast_yyensure_buffer_stack (yyscan_t yyscanner)
01875 {
01876    int num_to_alloc;
01877     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
01878 
01879    if (!yyg->yy_buffer_stack) {
01880 
01881       /* First allocation is just for 2 elements, since we don't know if this
01882        * scanner will even need a stack. We use 2 instead of 1 to avoid an
01883        * immediate realloc on the next call.
01884          */
01885       num_to_alloc = 1;
01886       yyg->yy_buffer_stack = (struct yy_buffer_state**)ast_yyalloc
01887                         (num_to_alloc * sizeof(struct yy_buffer_state*)
01888                         , yyscanner);
01889       if ( ! yyg->yy_buffer_stack )
01890          YY_FATAL_ERROR( "out of dynamic memory in ast_yyensure_buffer_stack()" );
01891                           
01892       memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*));
01893             
01894       yyg->yy_buffer_stack_max = num_to_alloc;
01895       yyg->yy_buffer_stack_top = 0;
01896       return;
01897    }
01898 
01899    if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){
01900 
01901       /* Increase the buffer to prepare for a possible push. */
01902       int grow_size = 8 /* arbitrary grow size */;
01903 
01904       num_to_alloc = yyg->yy_buffer_stack_max + grow_size;
01905       yyg->yy_buffer_stack = (struct yy_buffer_state**)ast_yyrealloc
01906                         (yyg->yy_buffer_stack,
01907                         num_to_alloc * sizeof(struct yy_buffer_state*)
01908                         , yyscanner);
01909       if ( ! yyg->yy_buffer_stack )
01910          YY_FATAL_ERROR( "out of dynamic memory in ast_yyensure_buffer_stack()" );
01911 
01912       /* zero only the new slots.*/
01913       memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*));
01914       yyg->yy_buffer_stack_max = num_to_alloc;
01915    }
01916 }
01917 
01918 /** Setup the input buffer state to scan directly from a user-specified character buffer.
01919  * @param base the character buffer
01920  * @param size the size in bytes of the character buffer
01921  * @param yyscanner The scanner object.
01922  * @return the newly allocated buffer state object. 
01923  */
01924 YY_BUFFER_STATE ast_yy_scan_buffer  (char * base, yy_size_t  size , yyscan_t yyscanner)
01925 {
01926    YY_BUFFER_STATE b;
01927     
01928    if ( size < 2 ||
01929         base[size-2] != YY_END_OF_BUFFER_CHAR ||
01930         base[size-1] != YY_END_OF_BUFFER_CHAR )
01931       /* They forgot to leave room for the EOB's. */
01932       return 0;
01933 
01934    b = (YY_BUFFER_STATE) ast_yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner );
01935    if ( ! b )
01936       YY_FATAL_ERROR( "out of dynamic memory in ast_yy_scan_buffer()" );
01937 
01938    b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
01939    b->yy_buf_pos = b->yy_ch_buf = base;
01940    b->yy_is_our_buffer = 0;
01941    b->yy_input_file = 0;
01942    b->yy_n_chars = b->yy_buf_size;
01943    b->yy_is_interactive = 0;
01944    b->yy_at_bol = 1;
01945    b->yy_fill_buffer = 0;
01946    b->yy_buffer_status = YY_BUFFER_NEW;
01947 
01948    ast_yy_switch_to_buffer(b ,yyscanner );
01949 
01950    return b;
01951 }
01952 
01953 /** Setup the input buffer state to scan a string. The next call to ast_yylex() will
01954  * scan from a @e copy of @a str.
01955  * @param yystr a NUL-terminated string to scan
01956  * @param yyscanner The scanner object.
01957  * @return the newly allocated buffer state object.
01958  * @note If you want to scan bytes that may contain NUL values, then use
01959  *       ast_yy_scan_bytes() instead.
01960  */
01961 YY_BUFFER_STATE ast_yy_scan_string (yyconst char * yystr , yyscan_t yyscanner)
01962 {
01963     
01964    return ast_yy_scan_bytes(yystr,strlen(yystr) ,yyscanner);
01965 }
01966 
01967 /** Setup the input buffer state to scan the given bytes. The next call to ast_yylex() will
01968  * scan from a @e copy of @a bytes.
01969  * @param yybytes the byte buffer to scan
01970  * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
01971  * @param yyscanner The scanner object.
01972  * @return the newly allocated buffer state object.
01973  */
01974 YY_BUFFER_STATE ast_yy_scan_bytes  (yyconst char * yybytes, int  _yybytes_len , yyscan_t yyscanner)
01975 {
01976    YY_BUFFER_STATE b;
01977    char *buf;
01978    yy_size_t n;
01979    int i;
01980     
01981    /* Get memory for full buffer, including space for trailing EOB's. */
01982    n = _yybytes_len + 2;
01983    buf = (char *) ast_yyalloc(n ,yyscanner );
01984    if ( ! buf )
01985       YY_FATAL_ERROR( "out of dynamic memory in ast_yy_scan_bytes()" );
01986 
01987    for ( i = 0; i < _yybytes_len; ++i )
01988       buf[i] = yybytes[i];
01989 
01990    buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
01991 
01992    b = ast_yy_scan_buffer(buf,n ,yyscanner);
01993    if ( ! b )
01994       YY_FATAL_ERROR( "bad buffer in ast_yy_scan_bytes()" );
01995 
01996    /* It's okay to grow etc. this buffer, and we should throw it
01997     * away when we're done.
01998     */
01999    b->yy_is_our_buffer = 1;
02000 
02001    return b;
02002 }
02003 
02004 #ifndef YY_EXIT_FAILURE
02005 #define YY_EXIT_FAILURE 2
02006 #endif
02007 
02008 static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner)
02009 {
02010       (void) fprintf( stderr, "%s\n", msg );
02011    exit( YY_EXIT_FAILURE );
02012 }
02013 
02014 /* Redefine yyless() so it works in section 3 code. */
02015 
02016 #undef yyless
02017 #define yyless(n) \
02018    do \
02019       { \
02020       /* Undo effects of setting up yytext. */ \
02021         int yyless_macro_arg = (n); \
02022         YY_LESS_LINENO(yyless_macro_arg);\
02023       yytext[yyleng] = yyg->yy_hold_char; \
02024       yyg->yy_c_buf_p = yytext + yyless_macro_arg; \
02025       yyg->yy_hold_char = *yyg->yy_c_buf_p; \
02026       *yyg->yy_c_buf_p = '\0'; \
02027       yyleng = yyless_macro_arg; \
02028       } \
02029    while ( 0 )
02030 
02031 /* Accessor  methods (get/set functions) to struct members. */
02032 
02033 /** Get the user-defined data for this scanner.
02034  * @param yyscanner The scanner object.
02035  */
02036 YY_EXTRA_TYPE ast_yyget_extra  (yyscan_t yyscanner)
02037 {
02038     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
02039     return yyextra;
02040 }
02041 
02042 /** Get the current line number.
02043  * @param yyscanner The scanner object.
02044  */
02045 int ast_yyget_lineno  (yyscan_t yyscanner)
02046 {
02047     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
02048     
02049         if (! YY_CURRENT_BUFFER)
02050             return 0;
02051     
02052     return yylineno;
02053 }
02054 
02055 /** Get the current column number.
02056  * @param yyscanner The scanner object.
02057  */
02058 int ast_yyget_column  (yyscan_t yyscanner)
02059 {
02060     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
02061     
02062         if (! YY_CURRENT_BUFFER)
02063             return 0;
02064     
02065     return yycolumn;
02066 }
02067 
02068 /** Get the input stream.
02069  * @param yyscanner The scanner object.
02070  */
02071 FILE *ast_yyget_in  (yyscan_t yyscanner)
02072 {
02073     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
02074     return yyin;
02075 }
02076 
02077 /** Get the output stream.
02078  * @param yyscanner The scanner object.
02079  */
02080 FILE *ast_yyget_out  (yyscan_t yyscanner)
02081 {
02082     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
02083     return yyout;
02084 }
02085 
02086 /** Get the length of the current token.
02087  * @param yyscanner The scanner object.
02088  */
02089 int ast_yyget_leng  (yyscan_t yyscanner)
02090 {
02091     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
02092     return yyleng;
02093 }
02094 
02095 /** Get the current token.
02096  * @param yyscanner The scanner object.
02097  */
02098 
02099 char *ast_yyget_text  (yyscan_t yyscanner)
02100 {
02101     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
02102     return yytext;
02103 }
02104 
02105 /** Set the user-defined data. This data is never touched by the scanner.
02106  * @param user_defined The data to be associated with this scanner.
02107  * @param yyscanner The scanner object.
02108  */
02109 void ast_yyset_extra (YY_EXTRA_TYPE  user_defined , yyscan_t yyscanner)
02110 {
02111     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
02112     yyextra = user_defined ;
02113 }
02114 
02115 /** Set the current line number.
02116  * @param line_number
02117  * @param yyscanner The scanner object.
02118  */
02119 void ast_yyset_lineno (int  line_number , yyscan_t yyscanner)
02120 {
02121     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
02122 
02123         /* lineno is only valid if an input buffer exists. */
02124         if (! YY_CURRENT_BUFFER )
02125            yy_fatal_error( "ast_yyset_lineno called with no buffer" , yyscanner); 
02126     
02127     yylineno = line_number;
02128 }
02129 
02130 /** Set the current column.
02131  * @param column_no 
02132  * @param yyscanner The scanner object.
02133  */
02134 void ast_yyset_column (int  column_no , yyscan_t yyscanner)
02135 {
02136     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
02137 
02138         /* column is only valid if an input buffer exists. */
02139         if (! YY_CURRENT_BUFFER )
02140            yy_fatal_error( "ast_yyset_column called with no buffer" , yyscanner); 
02141     
02142     yycolumn = column_no;
02143 }
02144 
02145 /** Set the input stream. This does not discard the current
02146  * input buffer.
02147  * @param in_str A readable stream.
02148  * @param yyscanner The scanner object.
02149  * @see ast_yy_switch_to_buffer
02150  */
02151 void ast_yyset_in (FILE *  in_str , yyscan_t yyscanner)
02152 {
02153     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
02154     yyin = in_str ;
02155 }
02156 
02157 void ast_yyset_out (FILE *  out_str , yyscan_t yyscanner)
02158 {
02159     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
02160     yyout = out_str ;
02161 }
02162 
02163 int ast_yyget_debug  (yyscan_t yyscanner)
02164 {
02165     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
02166     return yy_flex_debug;
02167 }
02168 
02169 void ast_yyset_debug (int  bdebug , yyscan_t yyscanner)
02170 {
02171     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
02172     yy_flex_debug = bdebug ;
02173 }
02174 
02175 /* Accessor methods for yylval and yylloc */
02176 
02177 YYSTYPE * ast_yyget_lval  (yyscan_t yyscanner)
02178 {
02179     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
02180     return yylval;
02181 }
02182 
02183 void ast_yyset_lval (YYSTYPE *  yylval_param , yyscan_t yyscanner)
02184 {
02185     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
02186     yylval = yylval_param;
02187 }
02188 
02189 YYLTYPE *ast_yyget_lloc  (yyscan_t yyscanner)
02190 {
02191     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
02192     return yylloc;
02193 }
02194     
02195 void ast_yyset_lloc (YYLTYPE *  yylloc_param , yyscan_t yyscanner)
02196 {
02197     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
02198     yylloc = yylloc_param;
02199 }
02200     
02201 /* User-visible API */
02202 
02203 /* ast_yylex_init is special because it creates the scanner itself, so it is
02204  * the ONLY reentrant function that doesn't take the scanner as the last argument.
02205  * That's why we explicitly handle the declaration, instead of using our macros.
02206  */
02207 
02208 int ast_yylex_init(yyscan_t* ptr_yy_globals)
02209 
02210 {
02211     if (ptr_yy_globals == NULL){
02212         errno = EINVAL;
02213         return 1;
02214     }
02215 
02216     *ptr_yy_globals = (yyscan_t) ast_yyalloc ( sizeof( struct yyguts_t ), NULL );
02217 
02218     if (*ptr_yy_globals == NULL){
02219         errno = ENOMEM;
02220         return 1;
02221     }
02222 
02223     /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */
02224     memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
02225 
02226     return yy_init_globals ( *ptr_yy_globals );
02227 }
02228 
02229 /* ast_yylex_init_extra has the same functionality as ast_yylex_init, but follows the
02230  * convention of taking the scanner as the last argument. Note however, that
02231  * this is a *pointer* to a scanner, as it will be allocated by this call (and
02232  * is the reason, too, why this function also must handle its own declaration).
02233  * The user defined value in the first argument will be available to ast_yyalloc in
02234  * the yyextra field.
02235  */
02236 
02237 int ast_yylex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals )
02238 
02239 {
02240     struct yyguts_t dummy_yyguts;
02241 
02242     ast_yyset_extra (yy_user_defined, &dummy_yyguts);
02243 
02244     if (ptr_yy_globals == NULL){
02245         errno = EINVAL;
02246         return 1;
02247     }
02248    
02249     *ptr_yy_globals = (yyscan_t) ast_yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts );
02250    
02251     if (*ptr_yy_globals == NULL){
02252         errno = ENOMEM;
02253         return 1;
02254     }
02255     
02256     /* By setting to 0xAA, we expose bugs in
02257     yy_init_globals. Leave at 0x00 for releases. */
02258     memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
02259     
02260     ast_yyset_extra (yy_user_defined, *ptr_yy_globals);
02261     
02262     return yy_init_globals ( *ptr_yy_globals );
02263 }
02264 
02265 static int yy_init_globals (yyscan_t yyscanner)
02266 {
02267     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
02268     /* Initialization is the same as for the non-reentrant scanner.
02269      * This function is called from ast_yylex_destroy(), so don't allocate here.
02270      */
02271 
02272     yyg->yy_buffer_stack = 0;
02273     yyg->yy_buffer_stack_top = 0;
02274     yyg->yy_buffer_stack_max = 0;
02275     yyg->yy_c_buf_p = (char *) 0;
02276     yyg->yy_init = 0;
02277     yyg->yy_start = 0;
02278 
02279     yyg->yy_start_stack_ptr = 0;
02280     yyg->yy_start_stack_depth = 0;
02281     yyg->yy_start_stack =  NULL;
02282 
02283 /* Defined in main.c */
02284 #ifdef YY_STDINIT
02285     yyin = stdin;
02286     yyout = stdout;
02287 #else
02288     yyin = (FILE *) 0;
02289     yyout = (FILE *) 0;
02290 #endif
02291 
02292     /* For future reference: Set errno on error, since we are called by
02293      * ast_yylex_init()
02294      */
02295     return 0;
02296 }
02297 
02298 /* ast_yylex_destroy is for both reentrant and non-reentrant scanners. */
02299 int ast_yylex_destroy  (yyscan_t yyscanner)
02300 {
02301     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
02302 
02303     /* Pop the buffer stack, destroying each element. */
02304    while(YY_CURRENT_BUFFER){
02305       ast_yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner );
02306       YY_CURRENT_BUFFER_LVALUE = NULL;
02307       ast_yypop_buffer_state(yyscanner);
02308    }
02309 
02310    /* Destroy the stack itself. */
02311    ast_yyfree(yyg->yy_buffer_stack ,yyscanner);
02312    yyg->yy_buffer_stack = NULL;
02313 
02314     /* Destroy the start condition stack. */
02315         ast_yyfree(yyg->yy_start_stack ,yyscanner );
02316         yyg->yy_start_stack = NULL;
02317 
02318     /* Reset the globals. This is important in a non-reentrant scanner so the next time
02319      * ast_yylex() is called, initialization will occur. */
02320     yy_init_globals( yyscanner);
02321 
02322     /* Destroy the main struct (reentrant only). */
02323     ast_yyfree ( yyscanner , yyscanner );
02324     yyscanner = NULL;
02325     return 0;
02326 }
02327 
02328 /*
02329  * Internal utility routines.
02330  */
02331 
02332 #ifndef yytext_ptr
02333 static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner)
02334 {
02335    register int i;
02336    for ( i = 0; i < n; ++i )
02337       s1[i] = s2[i];
02338 }
02339 #endif
02340 
02341 #ifdef YY_NEED_STRLEN
02342 static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner)
02343 {
02344    register int n;
02345    for ( n = 0; s[n]; ++n )
02346       ;
02347 
02348    return n;
02349 }
02350 #endif
02351 
02352 void *ast_yyalloc (yy_size_t  size , yyscan_t yyscanner)
02353 {
02354    return (void *) malloc( size );
02355 }
02356 
02357 void *ast_yyrealloc  (void * ptr, yy_size_t  size , yyscan_t yyscanner)
02358 {
02359    /* The cast to (char *) in the following accommodates both
02360     * implementations that use char* generic pointers, and those
02361     * that use void* generic pointers.  It works with the latter
02362     * because both ANSI C and C++ allow castless assignment from
02363     * any pointer type to void*, and deal with argument conversions
02364     * as though doing an assignment.
02365     */
02366    return (void *) realloc( (char *) ptr, size );
02367 }
02368 
02369 #define YYTABLES_NAME "yytables"
02370 
02371 #line 238 "ast_expr2.fl"
02372 
02373 
02374 
02375 /* I'm putting the interface routine to the whole parse here in the flexer input file
02376    mainly because of all the flexer initialization that has to be done. Shouldn't matter
02377    where it is, as long as it's somewhere. I didn't want to define a prototype for the
02378    ast_yy_scan_string in the .y file, because then, I'd have to define YY_BUFFER_STATE there...
02379    UGH! that would be inappropriate. */
02380 
02381 int ast_yyparse(void *); /* need to/should define this prototype for the call to yyparse */
02382 int ast_yyerror(const char *, YYLTYPE *, struct parse_io *); /* likewise */
02383 
02384 void ast_yyfree(void *ptr, yyscan_t yyscanner)
02385 {
02386     /* the normal generated ast_yyfree func just frees its first arg;
02387      this get complaints on some systems, as sometimes this
02388      arg is a nil ptr! It's usually not fatal, but is irritating! */
02389    free( (char *) ptr );
02390 }
02391 
02392 int ast_expr(char *expr, char *buf, int length, struct ast_channel *chan)
02393 {
02394    struct parse_io io = { .string = expr, .chan = chan };
02395    int return_value = 0;
02396 
02397    ast_yylex_init(&io.scanner);
02398 
02399    ast_yy_scan_string(expr, io.scanner);
02400 
02401    ast_yyparse ((void *) &io);
02402 
02403    ast_yylex_destroy(io.scanner);
02404 
02405    if (!io.val) {
02406       if (length > 1) {
02407          strcpy(buf, "0");
02408          return_value = 1;
02409       }
02410    } else {
02411       if (io.val->type == AST_EXPR_number) {
02412          int res_length;
02413 
02414          res_length = snprintf(buf, length, FP___PRINTF, io.val->u.i);
02415          return_value = (res_length <= length) ? res_length : length;
02416       } else {
02417          if (io.val->u.s)
02418 #if defined(STANDALONE) || defined(LOW_MEMORY) || defined(STANDALONE)
02419             strncpy(buf, io.val->u.s, length - 1);
02420 #else /* !STANDALONE && !LOW_MEMORY */
02421             ast_copy_string(buf, io.val->u.s, length);
02422 #endif /* STANDALONE || LOW_MEMORY */
02423          else
02424             buf[0] = 0;
02425          return_value = strlen(buf);
02426          free(io.val->u.s);
02427       }
02428       free(io.val);
02429    }
02430    return return_value;
02431 }
02432 
02433 #ifndef STANDALONE
02434 int ast_str_expr(struct ast_str **str, ssize_t maxlen, struct ast_channel *chan, char *expr)
02435 {
02436    struct parse_io io = { .string = expr, .chan = chan };
02437 
02438    ast_yylex_init(&io.scanner);
02439    ast_yy_scan_string(expr, io.scanner);
02440    ast_yyparse ((void *) &io);
02441    ast_yylex_destroy(io.scanner);
02442 
02443    if (!io.val) {
02444       ast_str_set(str, maxlen, "0");
02445    } else {
02446       if (io.val->type == AST_EXPR_number) {
02447          int res_length;
02448          ast_str_set(str, maxlen, FP___PRINTF, io.val->u.i);
02449       } else if (io.val->u.s) {
02450          ast_str_set(str, maxlen, "%s", io.val->u.s);
02451          free(io.val->u.s);
02452       }
02453       free(io.val);
02454    }
02455    return ast_str_strlen(*str);
02456 }
02457 #endif
02458 
02459 
02460 char extra_error_message[4095];
02461 int extra_error_message_supplied = 0;
02462 void  ast_expr_register_extra_error_info(char *message);
02463 void  ast_expr_clear_extra_error_info(void);
02464 
02465 void  ast_expr_register_extra_error_info(char *message)
02466 {
02467        extra_error_message_supplied=1;
02468        strcpy(extra_error_message, message);
02469 }
02470 
02471 void  ast_expr_clear_extra_error_info(void)
02472 {
02473        extra_error_message_supplied=0;
02474        extra_error_message[0] = 0;
02475 }
02476 
02477 static const char * const expr2_token_equivs1[] = 
02478 {
02479    "TOKEN",
02480    "TOK_COND",
02481    "TOK_COLONCOLON",
02482    "TOK_OR",
02483    "TOK_AND",
02484    "TOK_EQ",
02485    "TOK_GT",
02486    "TOK_LT",
02487    "TOK_GE",
02488    "TOK_LE",
02489    "TOK_NE",
02490    "TOK_PLUS",
02491    "TOK_MINUS",
02492    "TOK_MULT",
02493    "TOK_DIV",
02494    "TOK_MOD",
02495    "TOK_COMPL",
02496    "TOK_COLON",
02497    "TOK_EQTILDE",
02498    "TOK_COMMA",
02499    "TOK_RP",
02500    "TOK_LP"
02501 };
02502 
02503 static const char * const expr2_token_equivs2[] = 
02504 {
02505    "<token>",
02506    "?",
02507    "::",
02508    "|",
02509    "&",
02510    "=",
02511    ">",
02512    "<",
02513    ">=",
02514    "<=",
02515    "!=",
02516    "+",
02517    "-",
02518    "*",
02519    "/",
02520    "%",
02521    "!",
02522    ":",
02523    "=~",
02524    ",",
02525    ")",
02526    "("
02527 };
02528 
02529 
02530 static char *expr2_token_subst(const char *mess)
02531 {
02532    /* calc a length, malloc, fill, and return; yyerror had better free it! */
02533    int len=0,i;
02534    const char *p;
02535    char *res, *s;
02536    const char *t;
02537    int expr2_token_equivs_entries = sizeof(expr2_token_equivs1)/sizeof(char*);
02538 
02539    for (p=mess; *p; p++) {
02540       for (i=0; i<expr2_token_equivs_entries; i++) {
02541          if ( strncmp(p,expr2_token_equivs1[i],strlen(expr2_token_equivs1[i])) == 0 )
02542          {
02543             len+=strlen(expr2_token_equivs2[i])+2;
02544             p += strlen(expr2_token_equivs1[i])-1;
02545             break;
02546          }
02547       }
02548       len++;
02549    }
02550    res = (char*)malloc(len+1);
02551    res[0] = 0;
02552    s = res;
02553    for (p=mess; *p;) {
02554       int found = 0;
02555       for (i=0; i<expr2_token_equivs_entries; i++) {
02556          if ( strncmp(p,expr2_token_equivs1[i],strlen(expr2_token_equivs1[i])) == 0 ) {
02557             *s++ = '\'';
02558             for (t=expr2_token_equivs2[i]; *t;) {
02559                *s++ = *t++;
02560             }
02561             *s++ = '\'';
02562             p += strlen(expr2_token_equivs1[i]);
02563             found = 1;
02564             break;
02565          }
02566       }
02567       if( !found )
02568          *s++ = *p++;
02569    }
02570    *s++ = 0;
02571    return res;
02572 }
02573 
02574 int ast_yyerror (const char *s,  yyltype *loc, struct parse_io *parseio )
02575 {  
02576    struct yyguts_t * yyg = (struct yyguts_t*)(parseio->scanner);
02577    char spacebuf[8000]; /* best safe than sorry */
02578    char spacebuf2[8000]; /* best safe than sorry */
02579    int i=0;
02580    char *s2 = expr2_token_subst(s);
02581    spacebuf[0] = 0;
02582    
02583    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,
02584                                                                         which is the same thing as... get this:
02585                                        yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_bs_column
02586                                        I was tempted to just use yy_buf_pos in the STATE, but..., well:
02587                                           a. the yy_buf_pos is the current position in the buffer, which
02588                                              may not relate to the entire string/buffer because of the
02589                                              buffering.
02590                                           b. but, analysis of the situation is that when you use the
02591                                              ast_yy_scan_string func, it creates a single buffer the size of
02592                                              string, so the two would be the same... 
02593                                        so, in the end, the yycolumn macro is available, shorter, therefore easier. */
02594    spacebuf2[i++]='^';
02595    spacebuf2[i]= 0;
02596 
02597 #ifdef STANDALONE3
02598    /* easier to read in the standalone version */
02599    printf("ast_yyerror(): %s syntax error: %s; Input:\n%s\n%s\n",  
02600          (extra_error_message_supplied?extra_error_message:""), s2, parseio->string,spacebuf2);
02601 #else
02602    ast_log(LOG_WARNING,"ast_yyerror(): %s syntax error: %s; Input:\n%s\n%s\n",  
02603          (extra_error_message_supplied?extra_error_message:""), s2, parseio->string,spacebuf2);
02604 #endif
02605 #ifndef STANDALONE
02606    ast_log(LOG_WARNING,"If you have questions, please refer to doc/tex/channelvariables.tex.\n");
02607 #endif
02608    free(s2);
02609    return(0);
02610 }
02611 

Generated on Wed Apr 6 11:29:40 2011 for Asterisk - The Open Source Telephony Project by  doxygen 1.4.7