Fri Jul 24 00:40:44 2009

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

Generated on Fri Jul 24 00:40:44 2009 for Asterisk - the Open Source PBX by  doxygen 1.4.7