Thu Apr 28 2011 17:15:16

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