Mon Oct 8 12:38:58 2012

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: 360357 $")
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 /* Conditionally redefine the macro from flex 2.5.35, in case someone uses flex <2.5.35 to regenerate this file. */
00554 #ifndef ECHO
00555 #define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0)
00556 #endif
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 int ast_yyget_column  (yyscan_t yyscanner );
00701 
00702 void ast_yyset_column (int column_no ,yyscan_t yyscanner );
00703 
00704 YYSTYPE * ast_yyget_lval (yyscan_t yyscanner );
00705 
00706 void ast_yyset_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner );
00707 
00708        YYLTYPE *ast_yyget_lloc (yyscan_t yyscanner );
00709     
00710         void ast_yyset_lloc (YYLTYPE * yylloc_param ,yyscan_t yyscanner );
00711     
00712 /* Macros after this point can all be overridden by user definitions in
00713  * section 1.
00714  */
00715 
00716 #ifndef YY_SKIP_YYWRAP
00717 #ifdef __cplusplus
00718 extern "C" int ast_yywrap (yyscan_t yyscanner );
00719 #else
00720 extern int ast_yywrap (yyscan_t yyscanner );
00721 #endif
00722 #endif
00723 
00724     static void yyunput (int c,char *buf_ptr  ,yyscan_t yyscanner);
00725     
00726 #ifndef yytext_ptr
00727 static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner);
00728 #endif
00729 
00730 #ifdef YY_NEED_STRLEN
00731 static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner);
00732 #endif
00733 
00734 #ifndef YY_NO_INPUT
00735 
00736 #ifdef __cplusplus
00737 static int yyinput (yyscan_t yyscanner );
00738 #else
00739 static int input (yyscan_t yyscanner );
00740 #endif
00741 
00742 #endif
00743 
00744 /* Amount of stuff to slurp up with each read. */
00745 #ifndef YY_READ_BUF_SIZE
00746 #define YY_READ_BUF_SIZE 8192
00747 #endif
00748 
00749 /* Copy whatever the last rule matched to the standard output. */
00750 #ifndef ECHO
00751 /* This used to be an fputs(), but since the string might contain NUL's,
00752  * we now use fwrite().
00753  */
00754 #define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0)
00755 #endif
00756 
00757 /* Gets input and stuffs it into "buf".  number of characters read, or YY_NULL,
00758  * is returned in "result".
00759  */
00760 #ifndef YY_INPUT
00761 #define YY_INPUT(buf,result,max_size) \
00762    if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
00763       { \
00764       int c = '*'; \
00765       unsigned n; \
00766       for ( n = 0; n < max_size && \
00767               (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
00768          buf[n] = (char) c; \
00769       if ( c == '\n' ) \
00770          buf[n++] = (char) c; \
00771       if ( c == EOF && ferror( yyin ) ) \
00772          YY_FATAL_ERROR( "input in flex scanner failed" ); \
00773       result = n; \
00774       } \
00775    else \
00776       { \
00777       errno=0; \
00778       while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
00779          { \
00780          if( errno != EINTR) \
00781             { \
00782             YY_FATAL_ERROR( "input in flex scanner failed" ); \
00783             break; \
00784             } \
00785          errno=0; \
00786          clearerr(yyin); \
00787          } \
00788       }\
00789 \
00790 
00791 #endif
00792 
00793 /* No semi-colon after return; correct usage is to write "yyterminate();" -
00794  * we don't want an extra ';' after the "return" because that will cause
00795  * some compilers to complain about unreachable statements.
00796  */
00797 #ifndef yyterminate
00798 #define yyterminate() return YY_NULL
00799 #endif
00800 
00801 /* Number of entries by which start-condition stack grows. */
00802 #ifndef YY_START_STACK_INCR
00803 #define YY_START_STACK_INCR 25
00804 #endif
00805 
00806 /* Report a fatal error. */
00807 #ifndef YY_FATAL_ERROR
00808 #define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner)
00809 #endif
00810 
00811 /* end tables serialization structures and prototypes */
00812 
00813 /* Default declaration of generated scanner - a define so the user can
00814  * easily add parameters.
00815  */
00816 #ifndef YY_DECL
00817 #define YY_DECL_IS_OURS 1
00818 
00819 extern int ast_yylex \
00820                (YYSTYPE * yylval_param,YYLTYPE * yylloc_param ,yyscan_t yyscanner);
00821 
00822 #define YY_DECL int ast_yylex \
00823                (YYSTYPE * yylval_param, YYLTYPE * yylloc_param , yyscan_t yyscanner)
00824 #endif /* !YY_DECL */
00825 
00826 /* Code executed at the beginning of each rule, after yytext and yyleng
00827  * have been set up.
00828  */
00829 #ifndef YY_USER_ACTION
00830 #define YY_USER_ACTION
00831 #endif
00832 
00833 /* Code executed at the end of each rule. */
00834 #ifndef YY_BREAK
00835 #define YY_BREAK break;
00836 #endif
00837 
00838 #define YY_RULE_SETUP \
00839    YY_USER_ACTION
00840 
00841 /** The main scanner function which does all the work.
00842  */
00843 YY_DECL
00844 {
00845    register yy_state_type yy_current_state;
00846    register char *yy_cp, *yy_bp;
00847    register int yy_act;
00848     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
00849 
00850 #line 130 "ast_expr2.fl"
00851 
00852 
00853 #line 852 "ast_expr2f.c"
00854 
00855     yylval = yylval_param;
00856 
00857     yylloc = yylloc_param;
00858 
00859    if ( !yyg->yy_init )
00860       {
00861       yyg->yy_init = 1;
00862 
00863 #ifdef YY_USER_INIT
00864       YY_USER_INIT;
00865 #endif
00866 
00867       if ( ! yyg->yy_start )
00868          yyg->yy_start = 1;   /* first start state */
00869 
00870       if ( ! yyin )
00871          yyin = stdin;
00872 
00873       if ( ! yyout )
00874          yyout = stdout;
00875 
00876       if ( ! YY_CURRENT_BUFFER ) {
00877          ast_yyensure_buffer_stack (yyscanner);
00878          YY_CURRENT_BUFFER_LVALUE =
00879             ast_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner);
00880       }
00881 
00882       ast_yy_load_buffer_state(yyscanner );
00883       }
00884 
00885    while ( 1 )    /* loops until end-of-file is reached */
00886       {
00887       yyg->yy_more_len = 0;
00888       if ( yyg->yy_more_flag )
00889          {
00890          yyg->yy_more_len = yyg->yy_c_buf_p - yyg->yytext_ptr;
00891          yyg->yy_more_flag = 0;
00892          }
00893       yy_cp = yyg->yy_c_buf_p;
00894 
00895       /* Support of yytext. */
00896       *yy_cp = yyg->yy_hold_char;
00897 
00898       /* yy_bp points to the position in yy_ch_buf of the start of
00899        * the current run.
00900        */
00901       yy_bp = yy_cp;
00902 
00903       yy_current_state = yyg->yy_start;
00904 yy_match:
00905       do
00906          {
00907          register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
00908          if ( yy_accept[yy_current_state] )
00909             {
00910             yyg->yy_last_accepting_state = yy_current_state;
00911             yyg->yy_last_accepting_cpos = yy_cp;
00912             }
00913          while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
00914             {
00915             yy_current_state = (int) yy_def[yy_current_state];
00916             if ( yy_current_state >= 63 )
00917                yy_c = yy_meta[(unsigned int) yy_c];
00918             }
00919          yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
00920          ++yy_cp;
00921          }
00922       while ( yy_current_state != 62 );
00923       yy_cp = yyg->yy_last_accepting_cpos;
00924       yy_current_state = yyg->yy_last_accepting_state;
00925 
00926 yy_find_action:
00927       yy_act = yy_accept[yy_current_state];
00928 
00929       YY_DO_BEFORE_ACTION;
00930 
00931 do_action:  /* This label is used only to access EOF actions. */
00932 
00933       switch ( yy_act )
00934    { /* beginning of action switch */
00935          case 0: /* must back up */
00936          /* undo the effects of YY_DO_BEFORE_ACTION */
00937          *yy_cp = yyg->yy_hold_char;
00938          yy_cp = yyg->yy_last_accepting_cpos;
00939          yy_current_state = yyg->yy_last_accepting_state;
00940          goto yy_find_action;
00941 
00942 case 1:
00943 YY_RULE_SETUP
00944 #line 132 "ast_expr2.fl"
00945 { SET_COLUMNS; SET_STRING; return TOK_OR;}
00946    YY_BREAK
00947 case 2:
00948 YY_RULE_SETUP
00949 #line 133 "ast_expr2.fl"
00950 { SET_COLUMNS; SET_STRING; return TOK_AND;}
00951    YY_BREAK
00952 case 3:
00953 YY_RULE_SETUP
00954 #line 134 "ast_expr2.fl"
00955 { SET_COLUMNS; SET_STRING; return TOK_EQ;}
00956    YY_BREAK
00957 case 4:
00958 YY_RULE_SETUP
00959 #line 135 "ast_expr2.fl"
00960 { SET_COLUMNS; SET_STRING; return TOK_OR;}
00961    YY_BREAK
00962 case 5:
00963 YY_RULE_SETUP
00964 #line 136 "ast_expr2.fl"
00965 { SET_COLUMNS; SET_STRING; return TOK_AND;}
00966    YY_BREAK
00967 case 6:
00968 YY_RULE_SETUP
00969 #line 137 "ast_expr2.fl"
00970 { SET_COLUMNS; SET_STRING; return TOK_EQ;}
00971    YY_BREAK
00972 case 7:
00973 YY_RULE_SETUP
00974 #line 138 "ast_expr2.fl"
00975 { SET_COLUMNS; SET_STRING; return TOK_EQTILDE;}
00976    YY_BREAK
00977 case 8:
00978 YY_RULE_SETUP
00979 #line 139 "ast_expr2.fl"
00980 { SET_COLUMNS; SET_STRING; return TOK_TILDETILDE;}
00981    YY_BREAK
00982 case 9:
00983 YY_RULE_SETUP
00984 #line 140 "ast_expr2.fl"
00985 { SET_COLUMNS; SET_STRING; return TOK_GT;}
00986    YY_BREAK
00987 case 10:
00988 YY_RULE_SETUP
00989 #line 141 "ast_expr2.fl"
00990 { SET_COLUMNS; SET_STRING; return TOK_LT;}
00991    YY_BREAK
00992 case 11:
00993 YY_RULE_SETUP
00994 #line 142 "ast_expr2.fl"
00995 { SET_COLUMNS; SET_STRING; return TOK_GE;}
00996    YY_BREAK
00997 case 12:
00998 YY_RULE_SETUP
00999 #line 143 "ast_expr2.fl"
01000 { SET_COLUMNS; SET_STRING; return TOK_LE;}
01001    YY_BREAK
01002 case 13:
01003 YY_RULE_SETUP
01004 #line 144 "ast_expr2.fl"
01005 { SET_COLUMNS; SET_STRING; return TOK_NE;}
01006    YY_BREAK
01007 case 14:
01008 YY_RULE_SETUP
01009 #line 145 "ast_expr2.fl"
01010 { SET_COLUMNS; SET_STRING; return TOK_PLUS;}
01011    YY_BREAK
01012 case 15:
01013 YY_RULE_SETUP
01014 #line 146 "ast_expr2.fl"
01015 { SET_COLUMNS; SET_STRING; return TOK_COMMA;}
01016    YY_BREAK
01017 case 16:
01018 YY_RULE_SETUP
01019 #line 147 "ast_expr2.fl"
01020 { SET_COLUMNS; SET_STRING; return TOK_MINUS;}
01021    YY_BREAK
01022 case 17:
01023 YY_RULE_SETUP
01024 #line 148 "ast_expr2.fl"
01025 { SET_COLUMNS; SET_STRING; return TOK_MULT;}
01026    YY_BREAK
01027 case 18:
01028 YY_RULE_SETUP
01029 #line 149 "ast_expr2.fl"
01030 { SET_COLUMNS; SET_STRING; return TOK_DIV;}
01031    YY_BREAK
01032 case 19:
01033 YY_RULE_SETUP
01034 #line 150 "ast_expr2.fl"
01035 { SET_COLUMNS; SET_STRING; return TOK_MOD;}
01036    YY_BREAK
01037 case 20:
01038 YY_RULE_SETUP
01039 #line 151 "ast_expr2.fl"
01040 { SET_COLUMNS; SET_STRING; return TOK_COND;}
01041    YY_BREAK
01042 case 21:
01043 YY_RULE_SETUP
01044 #line 152 "ast_expr2.fl"
01045 { SET_COLUMNS; SET_STRING; return TOK_COMPL;}
01046    YY_BREAK
01047 case 22:
01048 YY_RULE_SETUP
01049 #line 153 "ast_expr2.fl"
01050 { SET_COLUMNS; SET_STRING; return TOK_COLON;}
01051    YY_BREAK
01052 case 23:
01053 YY_RULE_SETUP
01054 #line 154 "ast_expr2.fl"
01055 { SET_COLUMNS; SET_STRING; return TOK_COLONCOLON;}
01056    YY_BREAK
01057 case 24:
01058 YY_RULE_SETUP
01059 #line 155 "ast_expr2.fl"
01060 { SET_COLUMNS; SET_STRING; return TOK_LP;}
01061    YY_BREAK
01062 case 25:
01063 YY_RULE_SETUP
01064 #line 156 "ast_expr2.fl"
01065 { SET_COLUMNS; SET_STRING; return TOK_RP;}
01066    YY_BREAK
01067 case 26:
01068 YY_RULE_SETUP
01069 #line 157 "ast_expr2.fl"
01070 {
01071       /* gather the contents of ${} expressions, with trailing stuff,
01072        * into a single TOKEN.
01073        * They are much more complex now than they used to be
01074        */
01075       curlycount = 0;
01076       BEGIN(var);
01077       yymore();
01078    }
01079    YY_BREAK
01080 case 27:
01081 YY_RULE_SETUP
01082 #line 167 "ast_expr2.fl"
01083 {}
01084    YY_BREAK
01085 case 28:
01086 /* rule 28 can match eol */
01087 YY_RULE_SETUP
01088 #line 168 "ast_expr2.fl"
01089 {SET_COLUMNS; SET_STRING; return TOKEN;}
01090    YY_BREAK
01091 case 29:
01092 /* rule 29 can match eol */
01093 YY_RULE_SETUP
01094 #line 170 "ast_expr2.fl"
01095 {/* what to do with eol */}
01096    YY_BREAK
01097 case 30:
01098 YY_RULE_SETUP
01099 #line 171 "ast_expr2.fl"
01100 {
01101       SET_COLUMNS;
01102       /* the original behavior of the expression parser was
01103        * to bring in numbers as a numeric string
01104        */
01105       SET_NUMERIC_STRING;
01106       return TOKEN;
01107    }
01108    YY_BREAK
01109 case 31:
01110 /* rule 31 can match eol */
01111 YY_RULE_SETUP
01112 #line 180 "ast_expr2.fl"
01113 {
01114       SET_COLUMNS;
01115       SET_STRING;
01116       return TOKEN;
01117    }
01118    YY_BREAK
01119 case 32:
01120 /* rule 32 can match eol */
01121 YY_RULE_SETUP
01122 #line 186 "ast_expr2.fl"
01123 {
01124       curlycount = 0;
01125       BEGIN(var);
01126       yymore();
01127    }
01128    YY_BREAK
01129 case 33:
01130 /* rule 33 can match eol */
01131 YY_RULE_SETUP
01132 #line 192 "ast_expr2.fl"
01133 {
01134       curlycount--;
01135       if (curlycount < 0) {
01136          BEGIN(trail);
01137          yymore();
01138       } else {
01139          yymore();
01140       }
01141    }
01142    YY_BREAK
01143 case 34:
01144 /* rule 34 can match eol */
01145 YY_RULE_SETUP
01146 #line 202 "ast_expr2.fl"
01147 {
01148       curlycount++;
01149       yymore();
01150    }
01151    YY_BREAK
01152 case 35:
01153 YY_RULE_SETUP
01154 #line 208 "ast_expr2.fl"
01155 {
01156       BEGIN(0);
01157       SET_COLUMNS;
01158       SET_STRING;
01159       return TOKEN;
01160    }
01161    YY_BREAK
01162 case 36:
01163 YY_RULE_SETUP
01164 #line 215 "ast_expr2.fl"
01165 {
01166       curlycount = 0;
01167       BEGIN(var);
01168       yymore();
01169    }
01170    YY_BREAK
01171 case 37:
01172 /* rule 37 can match eol */
01173 YY_RULE_SETUP
01174 #line 221 "ast_expr2.fl"
01175 {
01176       char c = yytext[yyleng-1];
01177       BEGIN(0);
01178       unput(c);
01179       SET_COLUMNS;
01180       SET_STRING;
01181       return TOKEN;
01182    }
01183    YY_BREAK
01184 case YY_STATE_EOF(trail):
01185 #line 230 "ast_expr2.fl"
01186 {
01187       BEGIN(0);
01188       SET_COLUMNS;
01189       SET_STRING;
01190       return TOKEN;
01191       /*actually, if an expr is only a variable ref, this could happen a LOT */
01192    }
01193    YY_BREAK
01194 case 38:
01195 YY_RULE_SETUP
01196 #line 238 "ast_expr2.fl"
01197 ECHO;
01198    YY_BREAK
01199 #line 1198 "ast_expr2f.c"
01200 case YY_STATE_EOF(INITIAL):
01201 case YY_STATE_EOF(var):
01202    yyterminate();
01203 
01204    case YY_END_OF_BUFFER:
01205       {
01206       /* Amount of text matched not including the EOB char. */
01207       int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1;
01208 
01209       /* Undo the effects of YY_DO_BEFORE_ACTION. */
01210       *yy_cp = yyg->yy_hold_char;
01211       YY_RESTORE_YY_MORE_OFFSET
01212 
01213       if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
01214          {
01215          /* We're scanning a new file or input source.  It's
01216           * possible that this happened because the user
01217           * just pointed yyin at a new source and called
01218           * ast_yylex().  If so, then we have to assure
01219           * consistency between YY_CURRENT_BUFFER and our
01220           * globals.  Here is the right place to do so, because
01221           * this is the first action (other than possibly a
01222           * back-up) that will match for the new input source.
01223           */
01224          yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
01225          YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
01226          YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
01227          }
01228 
01229       /* Note that here we test for yy_c_buf_p "<=" to the position
01230        * of the first EOB in the buffer, since yy_c_buf_p will
01231        * already have been incremented past the NUL character
01232        * (since all states make transitions on EOB to the
01233        * end-of-buffer state).  Contrast this with the test
01234        * in input().
01235        */
01236       if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
01237          { /* This was really a NUL. */
01238          yy_state_type yy_next_state;
01239 
01240          yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text;
01241 
01242          yy_current_state = yy_get_previous_state( yyscanner );
01243 
01244          /* Okay, we're now positioned to make the NUL
01245           * transition.  We couldn't have
01246           * yy_get_previous_state() go ahead and do it
01247           * for us because it doesn't know how to deal
01248           * with the possibility of jamming (and we don't
01249           * want to build jamming into it because then it
01250           * will run more slowly).
01251           */
01252 
01253          yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner);
01254 
01255          yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
01256 
01257          if ( yy_next_state )
01258             {
01259             /* Consume the NUL. */
01260             yy_cp = ++yyg->yy_c_buf_p;
01261             yy_current_state = yy_next_state;
01262             goto yy_match;
01263             }
01264 
01265          else
01266             {
01267             yy_cp = yyg->yy_last_accepting_cpos;
01268             yy_current_state = yyg->yy_last_accepting_state;
01269             goto yy_find_action;
01270             }
01271          }
01272 
01273       else switch ( yy_get_next_buffer( yyscanner ) )
01274          {
01275          case EOB_ACT_END_OF_FILE:
01276             {
01277             yyg->yy_did_buffer_switch_on_eof = 0;
01278 
01279             if ( ast_yywrap(yyscanner ) )
01280                {
01281                /* Note: because we've taken care in
01282                 * yy_get_next_buffer() to have set up
01283                 * yytext, we can now set up
01284                 * yy_c_buf_p so that if some total
01285                 * hoser (like flex itself) wants to
01286                 * call the scanner after we return the
01287                 * YY_NULL, it'll still work - another
01288                 * YY_NULL will get returned.
01289                 */
01290                yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ;
01291 
01292                yy_act = YY_STATE_EOF(YY_START);
01293                goto do_action;
01294                }
01295 
01296             else
01297                {
01298                if ( ! yyg->yy_did_buffer_switch_on_eof )
01299                   YY_NEW_FILE;
01300                }
01301             break;
01302             }
01303 
01304          case EOB_ACT_CONTINUE_SCAN:
01305             yyg->yy_c_buf_p =
01306                yyg->yytext_ptr + yy_amount_of_matched_text;
01307 
01308             yy_current_state = yy_get_previous_state( yyscanner );
01309 
01310             yy_cp = yyg->yy_c_buf_p;
01311             yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
01312             goto yy_match;
01313 
01314          case EOB_ACT_LAST_MATCH:
01315             yyg->yy_c_buf_p =
01316             &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars];
01317 
01318             yy_current_state = yy_get_previous_state( yyscanner );
01319 
01320             yy_cp = yyg->yy_c_buf_p;
01321             yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
01322             goto yy_find_action;
01323          }
01324       break;
01325       }
01326 
01327    default:
01328       YY_FATAL_ERROR(
01329          "fatal flex scanner internal error--no action found" );
01330    } /* end of action switch */
01331       } /* end of scanning one token */
01332 } /* end of ast_yylex */
01333 
01334 /* yy_get_next_buffer - try to read in a new buffer
01335  *
01336  * Returns a code representing an action:
01337  * EOB_ACT_LAST_MATCH -
01338  * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
01339  * EOB_ACT_END_OF_FILE - end of file
01340  */
01341 static int yy_get_next_buffer (yyscan_t yyscanner)
01342 {
01343     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
01344    register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
01345    register char *source = yyg->yytext_ptr;
01346    register int number_to_move, i;
01347    int ret_val;
01348 
01349    if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] )
01350       YY_FATAL_ERROR(
01351       "fatal flex scanner internal error--end of buffer missed" );
01352 
01353    if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
01354       { /* Don't try to fill the buffer, so this is an EOF. */
01355       if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 )
01356          {
01357          /* We matched a single character, the EOB, so
01358           * treat this as a final EOF.
01359           */
01360          return EOB_ACT_END_OF_FILE;
01361          }
01362 
01363       else
01364          {
01365          /* We matched some text prior to the EOB, first
01366           * process it.
01367           */
01368          return EOB_ACT_LAST_MATCH;
01369          }
01370       }
01371 
01372    /* Try to read more data. */
01373 
01374    /* First move last chars to start of buffer. */
01375    number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr) - 1;
01376 
01377    for ( i = 0; i < number_to_move; ++i )
01378       *(dest++) = *(source++);
01379 
01380    if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
01381       /* don't do the read, it's not guaranteed to return an EOF,
01382        * just force an EOF
01383        */
01384       YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0;
01385 
01386    else
01387       {
01388          int num_to_read =
01389          YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
01390 
01391       while ( num_to_read <= 0 )
01392          { /* Not enough room in the buffer - grow it. */
01393 
01394          /* just a shorter name for the current buffer */
01395          YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
01396 
01397          int yy_c_buf_p_offset =
01398             (int) (yyg->yy_c_buf_p - b->yy_ch_buf);
01399 
01400          if ( b->yy_is_our_buffer )
01401             {
01402             int new_size = b->yy_buf_size * 2;
01403 
01404             if ( new_size <= 0 )
01405                b->yy_buf_size += b->yy_buf_size / 8;
01406             else
01407                b->yy_buf_size *= 2;
01408 
01409             b->yy_ch_buf = (char *)
01410                /* Include room in for 2 EOB chars. */
01411                ast_yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ,yyscanner );
01412             }
01413          else
01414             /* Can't grow it, we don't own it. */
01415             b->yy_ch_buf = 0;
01416 
01417          if ( ! b->yy_ch_buf )
01418             YY_FATAL_ERROR(
01419             "fatal error - scanner input buffer overflow" );
01420 
01421          yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
01422 
01423          num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
01424                   number_to_move - 1;
01425 
01426          }
01427 
01428       if ( num_to_read > YY_READ_BUF_SIZE )
01429          num_to_read = YY_READ_BUF_SIZE;
01430 
01431       /* Read in more data. */
01432       YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
01433          yyg->yy_n_chars, (size_t) num_to_read );
01434 
01435       YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
01436       }
01437 
01438    if ( yyg->yy_n_chars == 0 )
01439       {
01440       if ( number_to_move == YY_MORE_ADJ )
01441          {
01442          ret_val = EOB_ACT_END_OF_FILE;
01443          ast_yyrestart(yyin  ,yyscanner);
01444          }
01445 
01446       else
01447          {
01448          ret_val = EOB_ACT_LAST_MATCH;
01449          YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
01450             YY_BUFFER_EOF_PENDING;
01451          }
01452       }
01453 
01454    else
01455       ret_val = EOB_ACT_CONTINUE_SCAN;
01456 
01457    if ((yy_size_t) (yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
01458       /* Extend the array by 50%, plus the number we really need. */
01459       yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1);
01460       YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) ast_yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner );
01461       if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
01462          YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
01463    }
01464 
01465    yyg->yy_n_chars += number_to_move;
01466    YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR;
01467    YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
01468 
01469    yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
01470 
01471    return ret_val;
01472 }
01473 
01474 /* yy_get_previous_state - get the state just before the EOB char was reached */
01475 
01476     static yy_state_type yy_get_previous_state (yyscan_t yyscanner)
01477 {
01478    register yy_state_type yy_current_state;
01479    register char *yy_cp;
01480     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
01481 
01482    yy_current_state = yyg->yy_start;
01483 
01484    for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp )
01485       {
01486       register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
01487       if ( yy_accept[yy_current_state] )
01488          {
01489          yyg->yy_last_accepting_state = yy_current_state;
01490          yyg->yy_last_accepting_cpos = yy_cp;
01491          }
01492       while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
01493          {
01494          yy_current_state = (int) yy_def[yy_current_state];
01495          if ( yy_current_state >= 63 )
01496             yy_c = yy_meta[(unsigned int) yy_c];
01497          }
01498       yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
01499       }
01500 
01501    return yy_current_state;
01502 }
01503 
01504 /* yy_try_NUL_trans - try to make a transition on the NUL character
01505  *
01506  * synopsis
01507  * next_state = yy_try_NUL_trans( current_state );
01508  */
01509     static yy_state_type yy_try_NUL_trans  (yy_state_type yy_current_state , yyscan_t yyscanner)
01510 {
01511    register int yy_is_jam;
01512     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */
01513    register char *yy_cp = yyg->yy_c_buf_p;
01514 
01515    register YY_CHAR yy_c = 1;
01516    if ( yy_accept[yy_current_state] )
01517       {
01518       yyg->yy_last_accepting_state = yy_current_state;
01519       yyg->yy_last_accepting_cpos = yy_cp;
01520       }
01521    while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
01522       {
01523       yy_current_state = (int) yy_def[yy_current_state];
01524       if ( yy_current_state >= 63 )
01525          yy_c = yy_meta[(unsigned int) yy_c];
01526       }
01527    yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
01528    yy_is_jam = (yy_current_state == 62);
01529 
01530    return yy_is_jam ? 0 : yy_current_state;
01531 }
01532 
01533     static void yyunput (int c, register char * yy_bp , yyscan_t yyscanner)
01534 {
01535    register char *yy_cp;
01536     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
01537 
01538     yy_cp = yyg->yy_c_buf_p;
01539 
01540    /* undo effects of setting up yytext */
01541    *yy_cp = yyg->yy_hold_char;
01542 
01543    if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
01544       { /* need to shift things up to make room */
01545       /* +2 for EOB chars. */
01546       register int number_to_move = yyg->yy_n_chars + 2;
01547       register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
01548                YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
01549       register char *source =
01550             &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
01551 
01552       while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
01553          *--dest = *--source;
01554 
01555       yy_cp += (int) (dest - source);
01556       yy_bp += (int) (dest - source);
01557       YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
01558          yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
01559 
01560       if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
01561          YY_FATAL_ERROR( "flex scanner push-back overflow" );
01562       }
01563 
01564    *--yy_cp = (char) c;
01565 
01566    yyg->yytext_ptr = yy_bp;
01567    yyg->yy_hold_char = *yy_cp;
01568    yyg->yy_c_buf_p = yy_cp;
01569 }
01570 
01571 #ifndef YY_NO_INPUT
01572 #ifdef __cplusplus
01573     static int yyinput (yyscan_t yyscanner)
01574 #else
01575     static int input  (yyscan_t yyscanner)
01576 #endif
01577 
01578 {
01579    int c;
01580     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
01581 
01582    *yyg->yy_c_buf_p = yyg->yy_hold_char;
01583 
01584    if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
01585       {
01586       /* yy_c_buf_p now points to the character we want to return.
01587        * If this occurs *before* the EOB characters, then it's a
01588        * valid NUL; if not, then we've hit the end of the buffer.
01589        */
01590       if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
01591          /* This was really a NUL. */
01592          *yyg->yy_c_buf_p = '\0';
01593 
01594       else
01595          { /* need more input */
01596          int offset = yyg->yy_c_buf_p - yyg->yytext_ptr;
01597          ++yyg->yy_c_buf_p;
01598 
01599          switch ( yy_get_next_buffer( yyscanner ) )
01600             {
01601             case EOB_ACT_LAST_MATCH:
01602                /* This happens because yy_g_n_b()
01603                 * sees that we've accumulated a
01604                 * token and flags that we need to
01605                 * try matching the token before
01606                 * proceeding.  But for input(),
01607                 * there's no matching to consider.
01608                 * So convert the EOB_ACT_LAST_MATCH
01609                 * to EOB_ACT_END_OF_FILE.
01610                 */
01611 
01612                /* Reset buffer status. */
01613                ast_yyrestart(yyin ,yyscanner);
01614 
01615                /*FALLTHROUGH*/
01616 
01617             case EOB_ACT_END_OF_FILE:
01618                {
01619                if ( ast_yywrap(yyscanner ) )
01620                   return EOF;
01621 
01622                if ( ! yyg->yy_did_buffer_switch_on_eof )
01623                   YY_NEW_FILE;
01624 #ifdef __cplusplus
01625                return yyinput(yyscanner);
01626 #else
01627                return input(yyscanner);
01628 #endif
01629                }
01630 
01631             case EOB_ACT_CONTINUE_SCAN:
01632                yyg->yy_c_buf_p = yyg->yytext_ptr + offset;
01633                break;
01634             }
01635          }
01636       }
01637 
01638    c = *(unsigned char *) yyg->yy_c_buf_p;   /* cast for 8-bit char's */
01639    *yyg->yy_c_buf_p = '\0';   /* preserve yytext */
01640    yyg->yy_hold_char = *++yyg->yy_c_buf_p;
01641 
01642    return c;
01643 }
01644 #endif   /* ifndef YY_NO_INPUT */
01645 
01646 /** Immediately switch to a different input stream.
01647  * @param input_file A readable stream.
01648  * @param yyscanner The scanner object.
01649  * @note This function does not reset the start condition to @c INITIAL .
01650  */
01651     void ast_yyrestart  (FILE * input_file , yyscan_t yyscanner)
01652 {
01653     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
01654 
01655    if ( ! YY_CURRENT_BUFFER ){
01656         ast_yyensure_buffer_stack (yyscanner);
01657       YY_CURRENT_BUFFER_LVALUE =
01658             ast_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner);
01659    }
01660 
01661    ast_yy_init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner);
01662    ast_yy_load_buffer_state(yyscanner );
01663 }
01664 
01665 /** Switch to a different input buffer.
01666  * @param new_buffer The new input buffer.
01667  * @param yyscanner The scanner object.
01668  */
01669     void ast_yy_switch_to_buffer  (YY_BUFFER_STATE  new_buffer , yyscan_t yyscanner)
01670 {
01671     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
01672 
01673    /* TODO. We should be able to replace this entire function body
01674     * with
01675     *    ast_yypop_buffer_state();
01676     *    ast_yypush_buffer_state(new_buffer);
01677      */
01678    ast_yyensure_buffer_stack (yyscanner);
01679    if ( YY_CURRENT_BUFFER == new_buffer )
01680       return;
01681 
01682    if ( YY_CURRENT_BUFFER )
01683       {
01684       /* Flush out information for old buffer. */
01685       *yyg->yy_c_buf_p = yyg->yy_hold_char;
01686       YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
01687       YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
01688       }
01689 
01690    YY_CURRENT_BUFFER_LVALUE = new_buffer;
01691    ast_yy_load_buffer_state(yyscanner );
01692 
01693    /* We don't actually know whether we did this switch during
01694     * EOF (ast_yywrap()) processing, but the only time this flag
01695     * is looked at is after ast_yywrap() is called, so it's safe
01696     * to go ahead and always set it.
01697     */
01698    yyg->yy_did_buffer_switch_on_eof = 1;
01699 }
01700 
01701 static void ast_yy_load_buffer_state  (yyscan_t yyscanner)
01702 {
01703     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
01704    yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
01705    yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
01706    yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
01707    yyg->yy_hold_char = *yyg->yy_c_buf_p;
01708 }
01709 
01710 /** Allocate and initialize an input buffer state.
01711  * @param file A readable stream.
01712  * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
01713  * @param yyscanner The scanner object.
01714  * @return the allocated buffer state.
01715  */
01716     YY_BUFFER_STATE ast_yy_create_buffer  (FILE * file, int  size , yyscan_t yyscanner)
01717 {
01718    YY_BUFFER_STATE b;
01719     
01720    b = (YY_BUFFER_STATE) ast_yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner );
01721    if ( ! b )
01722       YY_FATAL_ERROR( "out of dynamic memory in ast_yy_create_buffer()" );
01723 
01724    b->yy_buf_size = size;
01725 
01726    /* yy_ch_buf has to be 2 characters longer than the size given because
01727     * we need to put in 2 end-of-buffer characters.
01728     */
01729    b->yy_ch_buf = (char *) ast_yyalloc(b->yy_buf_size + 2 ,yyscanner );
01730    if ( ! b->yy_ch_buf )
01731       YY_FATAL_ERROR( "out of dynamic memory in ast_yy_create_buffer()" );
01732 
01733    b->yy_is_our_buffer = 1;
01734 
01735    ast_yy_init_buffer(b,file ,yyscanner);
01736 
01737    return b;
01738 }
01739 
01740 /** Destroy the buffer.
01741  * @param b a buffer created with ast_yy_create_buffer()
01742  * @param yyscanner The scanner object.
01743  */
01744     void ast_yy_delete_buffer (YY_BUFFER_STATE  b , yyscan_t yyscanner)
01745 {
01746     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
01747 
01748    if ( ! b )
01749       return;
01750 
01751    if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
01752       YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
01753 
01754    if ( b->yy_is_our_buffer )
01755       ast_yyfree((void *) b->yy_ch_buf ,yyscanner );
01756 
01757    ast_yyfree((void *) b ,yyscanner );
01758 }
01759 
01760 #ifndef __cplusplus
01761 extern int isatty (int );
01762 #endif /* __cplusplus */
01763     
01764 /* Initializes or reinitializes a buffer.
01765  * This function is sometimes called more than once on the same buffer,
01766  * such as during a ast_yyrestart() or at EOF.
01767  */
01768     static void ast_yy_init_buffer  (YY_BUFFER_STATE  b, FILE * file , yyscan_t yyscanner)
01769 
01770 {
01771    int oerrno = errno;
01772     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
01773 
01774    ast_yy_flush_buffer(b ,yyscanner);
01775 
01776    b->yy_input_file = file;
01777    b->yy_fill_buffer = 1;
01778 
01779     /* If b is the current buffer, then ast_yy_init_buffer was _probably_
01780      * called from ast_yyrestart() or through yy_get_next_buffer.
01781      * In that case, we don't want to reset the lineno or column.
01782      */
01783     if (b != YY_CURRENT_BUFFER){
01784         b->yy_bs_lineno = 1;
01785         b->yy_bs_column = 0;
01786     }
01787 
01788         b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
01789     
01790    errno = oerrno;
01791 }
01792 
01793 /** Discard all buffered characters. On the next scan, YY_INPUT will be called.
01794  * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
01795  * @param yyscanner The scanner object.
01796  */
01797     void ast_yy_flush_buffer (YY_BUFFER_STATE  b , yyscan_t yyscanner)
01798 {
01799     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
01800    if ( ! b )
01801       return;
01802 
01803    b->yy_n_chars = 0;
01804 
01805    /* We always need two end-of-buffer characters.  The first causes
01806     * a transition to the end-of-buffer state.  The second causes
01807     * a jam in that state.
01808     */
01809    b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
01810    b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
01811 
01812    b->yy_buf_pos = &b->yy_ch_buf[0];
01813 
01814    b->yy_at_bol = 1;
01815    b->yy_buffer_status = YY_BUFFER_NEW;
01816 
01817    if ( b == YY_CURRENT_BUFFER )
01818       ast_yy_load_buffer_state(yyscanner );
01819 }
01820 
01821 /** Pushes the new state onto the stack. The new state becomes
01822  *  the current state. This function will allocate the stack
01823  *  if necessary.
01824  *  @param new_buffer The new state.
01825  *  @param yyscanner The scanner object.
01826  */
01827 void ast_yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
01828 {
01829     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
01830    if (new_buffer == NULL)
01831       return;
01832 
01833    ast_yyensure_buffer_stack(yyscanner);
01834 
01835    /* This block is copied from ast_yy_switch_to_buffer. */
01836    if ( YY_CURRENT_BUFFER )
01837       {
01838       /* Flush out information for old buffer. */
01839       *yyg->yy_c_buf_p = yyg->yy_hold_char;
01840       YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
01841       YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
01842       }
01843 
01844    /* Only push if top exists. Otherwise, replace top. */
01845    if (YY_CURRENT_BUFFER)
01846       yyg->yy_buffer_stack_top++;
01847    YY_CURRENT_BUFFER_LVALUE = new_buffer;
01848 
01849    /* copied from ast_yy_switch_to_buffer. */
01850    ast_yy_load_buffer_state(yyscanner );
01851    yyg->yy_did_buffer_switch_on_eof = 1;
01852 }
01853 
01854 /** Removes and deletes the top of the stack, if present.
01855  *  The next element becomes the new top.
01856  *  @param yyscanner The scanner object.
01857  */
01858 void ast_yypop_buffer_state (yyscan_t yyscanner)
01859 {
01860     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
01861    if (!YY_CURRENT_BUFFER)
01862       return;
01863 
01864    ast_yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner);
01865    YY_CURRENT_BUFFER_LVALUE = NULL;
01866    if (yyg->yy_buffer_stack_top > 0)
01867       --yyg->yy_buffer_stack_top;
01868 
01869    if (YY_CURRENT_BUFFER) {
01870       ast_yy_load_buffer_state(yyscanner );
01871       yyg->yy_did_buffer_switch_on_eof = 1;
01872    }
01873 }
01874 
01875 /* Allocates the stack if it does not exist.
01876  *  Guarantees space for at least one push.
01877  */
01878 static void ast_yyensure_buffer_stack (yyscan_t yyscanner)
01879 {
01880    int num_to_alloc;
01881     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
01882 
01883    if (!yyg->yy_buffer_stack) {
01884 
01885       /* First allocation is just for 2 elements, since we don't know if this
01886        * scanner will even need a stack. We use 2 instead of 1 to avoid an
01887        * immediate realloc on the next call.
01888          */
01889       num_to_alloc = 1;
01890       yyg->yy_buffer_stack = (struct yy_buffer_state**)ast_yyalloc
01891                         (num_to_alloc * sizeof(struct yy_buffer_state*)
01892                         , yyscanner);
01893       if ( ! yyg->yy_buffer_stack )
01894          YY_FATAL_ERROR( "out of dynamic memory in ast_yyensure_buffer_stack()" );
01895                           
01896       memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*));
01897             
01898       yyg->yy_buffer_stack_max = num_to_alloc;
01899       yyg->yy_buffer_stack_top = 0;
01900       return;
01901    }
01902 
01903    if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){
01904 
01905       /* Increase the buffer to prepare for a possible push. */
01906       int grow_size = 8 /* arbitrary grow size */;
01907 
01908       num_to_alloc = yyg->yy_buffer_stack_max + grow_size;
01909       yyg->yy_buffer_stack = (struct yy_buffer_state**)ast_yyrealloc
01910                         (yyg->yy_buffer_stack,
01911                         num_to_alloc * sizeof(struct yy_buffer_state*)
01912                         , yyscanner);
01913       if ( ! yyg->yy_buffer_stack )
01914          YY_FATAL_ERROR( "out of dynamic memory in ast_yyensure_buffer_stack()" );
01915 
01916       /* zero only the new slots.*/
01917       memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*));
01918       yyg->yy_buffer_stack_max = num_to_alloc;
01919    }
01920 }
01921 
01922 /** Setup the input buffer state to scan directly from a user-specified character buffer.
01923  * @param base the character buffer
01924  * @param size the size in bytes of the character buffer
01925  * @param yyscanner The scanner object.
01926  * @return the newly allocated buffer state object. 
01927  */
01928 YY_BUFFER_STATE ast_yy_scan_buffer  (char * base, yy_size_t  size , yyscan_t yyscanner)
01929 {
01930    YY_BUFFER_STATE b;
01931     
01932    if ( size < 2 ||
01933         base[size-2] != YY_END_OF_BUFFER_CHAR ||
01934         base[size-1] != YY_END_OF_BUFFER_CHAR )
01935       /* They forgot to leave room for the EOB's. */
01936       return 0;
01937 
01938    b = (YY_BUFFER_STATE) ast_yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner );
01939    if ( ! b )
01940       YY_FATAL_ERROR( "out of dynamic memory in ast_yy_scan_buffer()" );
01941 
01942    b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
01943    b->yy_buf_pos = b->yy_ch_buf = base;
01944    b->yy_is_our_buffer = 0;
01945    b->yy_input_file = 0;
01946    b->yy_n_chars = b->yy_buf_size;
01947    b->yy_is_interactive = 0;
01948    b->yy_at_bol = 1;
01949    b->yy_fill_buffer = 0;
01950    b->yy_buffer_status = YY_BUFFER_NEW;
01951 
01952    ast_yy_switch_to_buffer(b ,yyscanner );
01953 
01954    return b;
01955 }
01956 
01957 /** Setup the input buffer state to scan a string. The next call to ast_yylex() will
01958  * scan from a @e copy of @a str.
01959  * @param yystr a NUL-terminated string to scan
01960  * @param yyscanner The scanner object.
01961  * @return the newly allocated buffer state object.
01962  * @note If you want to scan bytes that may contain NUL values, then use
01963  *       ast_yy_scan_bytes() instead.
01964  */
01965 YY_BUFFER_STATE ast_yy_scan_string (yyconst char * yystr , yyscan_t yyscanner)
01966 {
01967     
01968    return ast_yy_scan_bytes(yystr,strlen(yystr) ,yyscanner);
01969 }
01970 
01971 /** Setup the input buffer state to scan the given bytes. The next call to ast_yylex() will
01972  * scan from a @e copy of @a bytes.
01973  * @param bytes the byte buffer to scan
01974  * @param len the number of bytes in the buffer pointed to by @a bytes.
01975  * @param yyscanner The scanner object.
01976  * @return the newly allocated buffer state object.
01977  */
01978 YY_BUFFER_STATE ast_yy_scan_bytes  (yyconst char * yybytes, int  _yybytes_len , yyscan_t yyscanner)
01979 {
01980    YY_BUFFER_STATE b;
01981    char *buf;
01982    yy_size_t n;
01983    int i;
01984     
01985    /* Get memory for full buffer, including space for trailing EOB's. */
01986    n = _yybytes_len + 2;
01987    buf = (char *) ast_yyalloc(n ,yyscanner );
01988    if ( ! buf )
01989       YY_FATAL_ERROR( "out of dynamic memory in ast_yy_scan_bytes()" );
01990 
01991    for ( i = 0; i < _yybytes_len; ++i )
01992       buf[i] = yybytes[i];
01993 
01994    buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
01995 
01996    b = ast_yy_scan_buffer(buf,n ,yyscanner);
01997    if ( ! b )
01998       YY_FATAL_ERROR( "bad buffer in ast_yy_scan_bytes()" );
01999 
02000    /* It's okay to grow etc. this buffer, and we should throw it
02001     * away when we're done.
02002     */
02003    b->yy_is_our_buffer = 1;
02004 
02005    return b;
02006 }
02007 
02008 #ifndef YY_EXIT_FAILURE
02009 #define YY_EXIT_FAILURE 2
02010 #endif
02011 
02012 static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner)
02013 {
02014       (void) fprintf( stderr, "%s\n", msg );
02015    exit( YY_EXIT_FAILURE );
02016 }
02017 
02018 /* Redefine yyless() so it works in section 3 code. */
02019 
02020 #undef yyless
02021 #define yyless(n) \
02022    do \
02023       { \
02024       /* Undo effects of setting up yytext. */ \
02025         int yyless_macro_arg = (n); \
02026         YY_LESS_LINENO(yyless_macro_arg);\
02027       yytext[yyleng] = yyg->yy_hold_char; \
02028       yyg->yy_c_buf_p = yytext + yyless_macro_arg; \
02029       yyg->yy_hold_char = *yyg->yy_c_buf_p; \
02030       *yyg->yy_c_buf_p = '\0'; \
02031       yyleng = yyless_macro_arg; \
02032       } \
02033    while ( 0 )
02034 
02035 /* Accessor  methods (get/set functions) to struct members. */
02036 
02037 /** Get the user-defined data for this scanner.
02038  * @param yyscanner The scanner object.
02039  */
02040 YY_EXTRA_TYPE ast_yyget_extra  (yyscan_t yyscanner)
02041 {
02042     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
02043     return yyextra;
02044 }
02045 
02046 /** Get the current line number.
02047  * @param yyscanner The scanner object.
02048  */
02049 int ast_yyget_lineno  (yyscan_t yyscanner)
02050 {
02051     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
02052     
02053         if (! YY_CURRENT_BUFFER)
02054             return 0;
02055     
02056     return yylineno;
02057 }
02058 
02059 /** Get the current column number.
02060  * @param yyscanner The scanner object.
02061  */
02062 int ast_yyget_column  (yyscan_t yyscanner)
02063 {
02064     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
02065     
02066         if (! YY_CURRENT_BUFFER)
02067             return 0;
02068     
02069     return yycolumn;
02070 }
02071 
02072 /** Get the input stream.
02073  * @param yyscanner The scanner object.
02074  */
02075 FILE *ast_yyget_in  (yyscan_t yyscanner)
02076 {
02077     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
02078     return yyin;
02079 }
02080 
02081 /** Get the output stream.
02082  * @param yyscanner The scanner object.
02083  */
02084 FILE *ast_yyget_out  (yyscan_t yyscanner)
02085 {
02086     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
02087     return yyout;
02088 }
02089 
02090 /** Get the length of the current token.
02091  * @param yyscanner The scanner object.
02092  */
02093 int ast_yyget_leng  (yyscan_t yyscanner)
02094 {
02095     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
02096     return yyleng;
02097 }
02098 
02099 /** Get the current token.
02100  * @param yyscanner The scanner object.
02101  */
02102 
02103 char *ast_yyget_text  (yyscan_t yyscanner)
02104 {
02105     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
02106     return yytext;
02107 }
02108 
02109 /** Set the user-defined data. This data is never touched by the scanner.
02110  * @param user_defined The data to be associated with this scanner.
02111  * @param yyscanner The scanner object.
02112  */
02113 void ast_yyset_extra (YY_EXTRA_TYPE  user_defined , yyscan_t yyscanner)
02114 {
02115     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
02116     yyextra = user_defined ;
02117 }
02118 
02119 /** Set the current line number.
02120  * @param line_number
02121  * @param yyscanner The scanner object.
02122  */
02123 void ast_yyset_lineno (int  line_number , yyscan_t yyscanner)
02124 {
02125     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
02126 
02127         /* lineno is only valid if an input buffer exists. */
02128         if (! YY_CURRENT_BUFFER )
02129            yy_fatal_error( "ast_yyset_lineno called with no buffer" , yyscanner); 
02130     
02131     yylineno = line_number;
02132 }
02133 
02134 /** Set the current column.
02135  * @param line_number
02136  * @param yyscanner The scanner object.
02137  */
02138 void ast_yyset_column (int  column_no , yyscan_t yyscanner)
02139 {
02140     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
02141 
02142         /* column is only valid if an input buffer exists. */
02143         if (! YY_CURRENT_BUFFER )
02144            yy_fatal_error( "ast_yyset_column called with no buffer" , yyscanner); 
02145     
02146     yycolumn = column_no;
02147 }
02148 
02149 /** Set the input stream. This does not discard the current
02150  * input buffer.
02151  * @param in_str A readable stream.
02152  * @param yyscanner The scanner object.
02153  * @see ast_yy_switch_to_buffer
02154  */
02155 void ast_yyset_in (FILE *  in_str , yyscan_t yyscanner)
02156 {
02157     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
02158     yyin = in_str ;
02159 }
02160 
02161 void ast_yyset_out (FILE *  out_str , yyscan_t yyscanner)
02162 {
02163     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
02164     yyout = out_str ;
02165 }
02166 
02167 int ast_yyget_debug  (yyscan_t yyscanner)
02168 {
02169     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
02170     return yy_flex_debug;
02171 }
02172 
02173 void ast_yyset_debug (int  bdebug , yyscan_t yyscanner)
02174 {
02175     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
02176     yy_flex_debug = bdebug ;
02177 }
02178 
02179 /* Accessor methods for yylval and yylloc */
02180 
02181 YYSTYPE * ast_yyget_lval  (yyscan_t yyscanner)
02182 {
02183     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
02184     return yylval;
02185 }
02186 
02187 void ast_yyset_lval (YYSTYPE *  yylval_param , yyscan_t yyscanner)
02188 {
02189     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
02190     yylval = yylval_param;
02191 }
02192 
02193 YYLTYPE *ast_yyget_lloc  (yyscan_t yyscanner)
02194 {
02195     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
02196     return yylloc;
02197 }
02198     
02199 void ast_yyset_lloc (YYLTYPE *  yylloc_param , yyscan_t yyscanner)
02200 {
02201     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
02202     yylloc = yylloc_param;
02203 }
02204     
02205 /* User-visible API */
02206 
02207 /* ast_yylex_init is special because it creates the scanner itself, so it is
02208  * the ONLY reentrant function that doesn't take the scanner as the last argument.
02209  * That's why we explicitly handle the declaration, instead of using our macros.
02210  */
02211 
02212 int ast_yylex_init(yyscan_t* ptr_yy_globals)
02213 
02214 {
02215     if (ptr_yy_globals == NULL){
02216         errno = EINVAL;
02217         return 1;
02218     }
02219 
02220     *ptr_yy_globals = (yyscan_t) ast_yyalloc ( sizeof( struct yyguts_t ), NULL );
02221 
02222     if (*ptr_yy_globals == NULL){
02223         errno = ENOMEM;
02224         return 1;
02225     }
02226 
02227     /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */
02228     memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
02229 
02230     return yy_init_globals ( *ptr_yy_globals );
02231 }
02232 
02233 /* ast_yylex_init_extra has the same functionality as ast_yylex_init, but follows the
02234  * convention of taking the scanner as the last argument. Note however, that
02235  * this is a *pointer* to a scanner, as it will be allocated by this call (and
02236  * is the reason, too, why this function also must handle its own declaration).
02237  * The user defined value in the first argument will be available to ast_yyalloc in
02238  * the yyextra field.
02239  */
02240 
02241 int ast_yylex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals )
02242 
02243 {
02244     struct yyguts_t dummy_yyguts;
02245 
02246     ast_yyset_extra (yy_user_defined, &dummy_yyguts);
02247 
02248     if (ptr_yy_globals == NULL){
02249         errno = EINVAL;
02250         return 1;
02251     }
02252    
02253     *ptr_yy_globals = (yyscan_t) ast_yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts );
02254    
02255     if (*ptr_yy_globals == NULL){
02256         errno = ENOMEM;
02257         return 1;
02258     }
02259     
02260     /* By setting to 0xAA, we expose bugs in
02261     yy_init_globals. Leave at 0x00 for releases. */
02262     memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
02263     
02264     ast_yyset_extra (yy_user_defined, *ptr_yy_globals);
02265     
02266     return yy_init_globals ( *ptr_yy_globals );
02267 }
02268 
02269 static int yy_init_globals (yyscan_t yyscanner)
02270 {
02271     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
02272     /* Initialization is the same as for the non-reentrant scanner.
02273      * This function is called from ast_yylex_destroy(), so don't allocate here.
02274      */
02275 
02276     yyg->yy_buffer_stack = 0;
02277     yyg->yy_buffer_stack_top = 0;
02278     yyg->yy_buffer_stack_max = 0;
02279     yyg->yy_c_buf_p = (char *) 0;
02280     yyg->yy_init = 0;
02281     yyg->yy_start = 0;
02282 
02283     yyg->yy_start_stack_ptr = 0;
02284     yyg->yy_start_stack_depth = 0;
02285     yyg->yy_start_stack =  NULL;
02286 
02287 /* Defined in main.c */
02288 #ifdef YY_STDINIT
02289     yyin = stdin;
02290     yyout = stdout;
02291 #else
02292     yyin = (FILE *) 0;
02293     yyout = (FILE *) 0;
02294 #endif
02295 
02296     /* For future reference: Set errno on error, since we are called by
02297      * ast_yylex_init()
02298      */
02299     return 0;
02300 }
02301 
02302 /* ast_yylex_destroy is for both reentrant and non-reentrant scanners. */
02303 int ast_yylex_destroy  (yyscan_t yyscanner)
02304 {
02305     struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
02306 
02307     /* Pop the buffer stack, destroying each element. */
02308    while(YY_CURRENT_BUFFER){
02309       ast_yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner );
02310       YY_CURRENT_BUFFER_LVALUE = NULL;
02311       ast_yypop_buffer_state(yyscanner);
02312    }
02313 
02314    /* Destroy the stack itself. */
02315    ast_yyfree(yyg->yy_buffer_stack ,yyscanner);
02316    yyg->yy_buffer_stack = NULL;
02317 
02318     /* Destroy the start condition stack. */
02319         ast_yyfree(yyg->yy_start_stack ,yyscanner );
02320         yyg->yy_start_stack = NULL;
02321 
02322     /* Reset the globals. This is important in a non-reentrant scanner so the next time
02323      * ast_yylex() is called, initialization will occur. */
02324     yy_init_globals( yyscanner);
02325 
02326     /* Destroy the main struct (reentrant only). */
02327     ast_yyfree ( yyscanner , yyscanner );
02328     yyscanner = NULL;
02329     return 0;
02330 }
02331 
02332 /*
02333  * Internal utility routines.
02334  */
02335 
02336 #ifndef yytext_ptr
02337 static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner)
02338 {
02339    register int i;
02340    for ( i = 0; i < n; ++i )
02341       s1[i] = s2[i];
02342 }
02343 #endif
02344 
02345 #ifdef YY_NEED_STRLEN
02346 static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner)
02347 {
02348    register int n;
02349    for ( n = 0; s[n]; ++n )
02350       ;
02351 
02352    return n;
02353 }
02354 #endif
02355 
02356 void *ast_yyalloc (yy_size_t  size , yyscan_t yyscanner)
02357 {
02358    return (void *) malloc( size );
02359 }
02360 
02361 void *ast_yyrealloc  (void * ptr, yy_size_t  size , yyscan_t yyscanner)
02362 {
02363    /* The cast to (char *) in the following accommodates both
02364     * implementations that use char* generic pointers, and those
02365     * that use void* generic pointers.  It works with the latter
02366     * because both ANSI C and C++ allow castless assignment from
02367     * any pointer type to void*, and deal with argument conversions
02368     * as though doing an assignment.
02369     */
02370    return (void *) realloc( (char *) ptr, size );
02371 }
02372 
02373 #define YYTABLES_NAME "yytables"
02374 
02375 #line 238 "ast_expr2.fl"
02376 
02377 
02378 
02379 /* I'm putting the interface routine to the whole parse here in the flexer input file
02380    mainly because of all the flexer initialization that has to be done. Shouldn't matter
02381    where it is, as long as it's somewhere. I didn't want to define a prototype for the
02382    ast_yy_scan_string in the .y file, because then, I'd have to define YY_BUFFER_STATE there...
02383    UGH! that would be inappropriate. */
02384 
02385 int ast_yyparse(void *); /* need to/should define this prototype for the call to yyparse */
02386 int ast_yyerror(const char *, YYLTYPE *, struct parse_io *); /* likewise */
02387 
02388 void ast_yyfree(void *ptr, yyscan_t yyscanner)
02389 {
02390     /* the normal generated ast_yyfree func just frees its first arg;
02391      this get complaints on some systems, as sometimes this
02392      arg is a nil ptr! It's usually not fatal, but is irritating! */
02393    free( (char *) ptr );
02394 }
02395 
02396 int ast_expr(char *expr, char *buf, int length, struct ast_channel *chan)
02397 {
02398    struct parse_io io = { .string = expr, .chan = chan };
02399    int return_value = 0;
02400 
02401    ast_yylex_init(&io.scanner);
02402 
02403    ast_yy_scan_string(expr, io.scanner);
02404 
02405    ast_yyparse ((void *) &io);
02406 
02407    ast_yylex_destroy(io.scanner);
02408 
02409    if (!io.val) {
02410       if (length > 1) {
02411          strcpy(buf, "0");
02412          return_value = 1;
02413       }
02414    } else {
02415       if (io.val->type == AST_EXPR_number) {
02416          int res_length;
02417 
02418          res_length = snprintf(buf, length, FP___PRINTF, io.val->u.i);
02419          return_value = (res_length <= length) ? res_length : length;
02420       } else {
02421          if (io.val->u.s)
02422 #if defined(STANDALONE) || defined(LOW_MEMORY) || defined(STANDALONE)
02423             strncpy(buf, io.val->u.s, length - 1);
02424 #else /* !STANDALONE && !LOW_MEMORY */
02425             ast_copy_string(buf, io.val->u.s, length);
02426 #endif /* STANDALONE || LOW_MEMORY */
02427          else
02428             buf[0] = 0;
02429          return_value = strlen(buf);
02430          free(io.val->u.s);
02431       }
02432       free(io.val);
02433    }
02434    return return_value;
02435 }
02436 
02437 #ifndef STANDALONE
02438 int ast_str_expr(struct ast_str **str, ssize_t maxlen, struct ast_channel *chan, char *expr)
02439 {
02440    struct parse_io io = { .string = expr, .chan = chan };
02441 
02442    ast_yylex_init(&io.scanner);
02443    ast_yy_scan_string(expr, io.scanner);
02444    ast_yyparse ((void *) &io);
02445    ast_yylex_destroy(io.scanner);
02446 
02447    if (!io.val) {
02448       ast_str_set(str, maxlen, "0");
02449    } else {
02450       if (io.val->type == AST_EXPR_number) {
02451          int res_length;
02452          ast_str_set(str, maxlen, FP___PRINTF, io.val->u.i);
02453       } else if (io.val->u.s) {
02454          ast_str_set(str, maxlen, "%s", io.val->u.s);
02455          free(io.val->u.s);
02456       }
02457       free(io.val);
02458    }
02459    return ast_str_strlen(*str);
02460 }
02461 #endif
02462 
02463 
02464 char extra_error_message[4095];
02465 int extra_error_message_supplied = 0;
02466 void  ast_expr_register_extra_error_info(char *message);
02467 void  ast_expr_clear_extra_error_info(void);
02468 
02469 void  ast_expr_register_extra_error_info(char *message)
02470 {
02471        extra_error_message_supplied=1;
02472        strcpy(extra_error_message, message);
02473 }
02474 
02475 void  ast_expr_clear_extra_error_info(void)
02476 {
02477        extra_error_message_supplied=0;
02478        extra_error_message[0] = 0;
02479 }
02480 
02481 static const char * const expr2_token_equivs1[] = 
02482 {
02483    "TOKEN",
02484    "TOK_COND",
02485    "TOK_COLONCOLON",
02486    "TOK_OR",
02487    "TOK_AND",
02488    "TOK_EQ",
02489    "TOK_GT",
02490    "TOK_LT",
02491    "TOK_GE",
02492    "TOK_LE",
02493    "TOK_NE",
02494    "TOK_PLUS",
02495    "TOK_MINUS",
02496    "TOK_MULT",
02497    "TOK_DIV",
02498    "TOK_MOD",
02499    "TOK_COMPL",
02500    "TOK_COLON",
02501    "TOK_EQTILDE",
02502    "TOK_COMMA",
02503    "TOK_RP",
02504    "TOK_LP"
02505 };
02506 
02507 static const char * const expr2_token_equivs2[] = 
02508 {
02509    "<token>",
02510    "?",
02511    "::",
02512    "|",
02513    "&",
02514    "=",
02515    ">",
02516    "<",
02517    ">=",
02518    "<=",
02519    "!=",
02520    "+",
02521    "-",
02522    "*",
02523    "/",
02524    "%",
02525    "!",
02526    ":",
02527    "=~",
02528    ",",
02529    ")",
02530    "("
02531 };
02532 
02533 
02534 static char *expr2_token_subst(const char *mess)
02535 {
02536    /* calc a length, malloc, fill, and return; yyerror had better free it! */
02537    int len=0,i;
02538    const char *p;
02539    char *res, *s;
02540    const char *t;
02541    int expr2_token_equivs_entries = sizeof(expr2_token_equivs1)/sizeof(char*);
02542 
02543    for (p=mess; *p; p++) {
02544       for (i=0; i<expr2_token_equivs_entries; i++) {
02545          if ( strncmp(p,expr2_token_equivs1[i],strlen(expr2_token_equivs1[i])) == 0 )
02546          {
02547             len+=strlen(expr2_token_equivs2[i])+2;
02548             p += strlen(expr2_token_equivs1[i])-1;
02549             break;
02550          }
02551       }
02552       len++;
02553    }
02554    res = (char*)malloc(len+1);
02555    res[0] = 0;
02556    s = res;
02557    for (p=mess; *p;) {
02558       int found = 0;
02559       for (i=0; i<expr2_token_equivs_entries; i++) {
02560          if ( strncmp(p,expr2_token_equivs1[i],strlen(expr2_token_equivs1[i])) == 0 ) {
02561             *s++ = '\'';
02562             for (t=expr2_token_equivs2[i]; *t;) {
02563                *s++ = *t++;
02564             }
02565             *s++ = '\'';
02566             p += strlen(expr2_token_equivs1[i]);
02567             found = 1;
02568             break;
02569          }
02570       }
02571       if( !found )
02572          *s++ = *p++;
02573    }
02574    *s++ = 0;
02575    return res;
02576 }
02577 
02578 int ast_yyerror (const char *s,  yyltype *loc, struct parse_io *parseio )
02579 {  
02580    struct yyguts_t * yyg = (struct yyguts_t*)(parseio->scanner);
02581    char spacebuf[8000]; /* best safe than sorry */
02582    char spacebuf2[8000]; /* best safe than sorry */
02583    int i=0;
02584    char *s2 = expr2_token_subst(s);
02585    spacebuf[0] = 0;
02586    
02587    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,
02588                                                                         which is the same thing as... get this:
02589                                        yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_bs_column
02590                                        I was tempted to just use yy_buf_pos in the STATE, but..., well:
02591                                           a. the yy_buf_pos is the current position in the buffer, which
02592                                              may not relate to the entire string/buffer because of the
02593                                              buffering.
02594                                           b. but, analysis of the situation is that when you use the
02595                                              ast_yy_scan_string func, it creates a single buffer the size of
02596                                              string, so the two would be the same... 
02597                                        so, in the end, the yycolumn macro is available, shorter, therefore easier. */
02598    spacebuf2[i++]='^';
02599    spacebuf2[i]= 0;
02600 
02601 #ifdef STANDALONE3
02602    /* easier to read in the standalone version */
02603    printf("ast_yyerror(): %s syntax error: %s; Input:\n%s\n%s\n",  
02604          (extra_error_message_supplied?extra_error_message:""), s2, parseio->string,spacebuf2);
02605 #else
02606    ast_log(LOG_WARNING,"ast_yyerror(): %s syntax error: %s; Input:\n%s\n%s\n",  
02607          (extra_error_message_supplied?extra_error_message:""), s2, parseio->string,spacebuf2);
02608 #endif
02609 #ifndef STANDALONE
02610    ast_log(LOG_WARNING,"If you have questions, please refer to https://wiki.asterisk.org/wiki/display/AST/Channel+Variables\n");
02611 #endif
02612    free(s2);
02613    return(0);
02614 }
02615 

Generated on Mon Oct 8 12:38:58 2012 for Asterisk - The Open Source Telephony Project by  doxygen 1.4.7