Skip to content
Snippets Groups Projects
ast_expr2f.c 97.3 KiB
Newer Older
  • Learn to ignore specific revisions
  • 		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
    		}
    
    	if ( yyg->yy_n_chars == 0 )
    		{
    		if ( number_to_move == YY_MORE_ADJ )
    			{
    			ret_val = EOB_ACT_END_OF_FILE;
    			ast_yyrestart(yyin  ,yyscanner);
    			}
    
    		else
    			{
    			ret_val = EOB_ACT_LAST_MATCH;
    			YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
    				YY_BUFFER_EOF_PENDING;
    			}
    		}
    
    	else
    		ret_val = EOB_ACT_CONTINUE_SCAN;
    
    	yyg->yy_n_chars += number_to_move;
    	YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR;
    	YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
    
    	yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
    
    	return ret_val;
    }
    
    /* yy_get_previous_state - get the state just before the EOB char was reached */
    
        static yy_state_type yy_get_previous_state (yyscan_t yyscanner)
    {
    	register yy_state_type yy_current_state;
    	register char *yy_cp;
        struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
    
    	yy_current_state = yyg->yy_start;
    
    	for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp )
    		{
    
    		if ( *yy_cp )
    			{
    			yy_current_state = yy_nxt[yy_current_state][YY_SC_TO_UI(*yy_cp)];
    			}
    		else
    			yy_current_state = yy_NUL_trans[yy_current_state];
    
    		if ( yy_accept[yy_current_state] )
    			{
    			yyg->yy_last_accepting_state = yy_current_state;
    			yyg->yy_last_accepting_cpos = yy_cp;
    			}
    		}
    
    	return yy_current_state;
    }
    
    /* yy_try_NUL_trans - try to make a transition on the NUL character
     *
     * synopsis
     *	next_state = yy_try_NUL_trans( current_state );
     */
        static yy_state_type yy_try_NUL_trans  (yy_state_type yy_current_state , yyscan_t yyscanner)
    {
    	register int yy_is_jam;
        struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
    	register char *yy_cp = yyg->yy_c_buf_p;
    
    
    	yy_current_state = yy_NUL_trans[yy_current_state];
    	yy_is_jam = (yy_current_state == 0);
    
    	if ( ! yy_is_jam )
    
    		if ( yy_accept[yy_current_state] )
    			{
    			yyg->yy_last_accepting_state = yy_current_state;
    			yyg->yy_last_accepting_cpos = yy_cp;
    			}
    
    2081 2082 2083 2084 2085 2086 2087 2088 2089 2090 2091 2092 2093 2094 2095 2096 2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 2124 2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 2199 2200 2201 2202 2203 2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338 2339 2340 2341 2342 2343 2344 2345 2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 2365 2366 2367 2368 2369 2370 2371 2372 2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 2396 2397 2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 2434 2435 2436 2437 2438 2439 2440 2441 2442 2443 2444 2445 2446 2447 2448 2449 2450 2451 2452 2453 2454 2455 2456 2457 2458 2459 2460 2461 2462 2463 2464 2465 2466 2467 2468 2469 2470 2471 2472 2473 2474 2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 2487 2488 2489 2490 2491 2492 2493 2494 2495 2496 2497 2498 2499 2500 2501 2502 2503 2504 2505 2506 2507
    		}
    
    	return yy_is_jam ? 0 : yy_current_state;
    }
    
        static void yyunput (int c, register char * yy_bp , yyscan_t yyscanner)
    {
    	register char *yy_cp;
        struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
    
        yy_cp = yyg->yy_c_buf_p;
    
    	/* undo effects of setting up yytext */
    	*yy_cp = yyg->yy_hold_char;
    
    	if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
    		{ /* need to shift things up to make room */
    		/* +2 for EOB chars. */
    		register int number_to_move = yyg->yy_n_chars + 2;
    		register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
    					YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
    		register char *source =
    				&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
    
    		while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
    			*--dest = *--source;
    
    		yy_cp += (int) (dest - source);
    		yy_bp += (int) (dest - source);
    		YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
    			yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
    
    		if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
    			YY_FATAL_ERROR( "flex scanner push-back overflow" );
    		}
    
    	*--yy_cp = (char) c;
    
    	yyg->yytext_ptr = yy_bp;
    	yyg->yy_hold_char = *yy_cp;
    	yyg->yy_c_buf_p = yy_cp;
    }
    
    #ifndef YY_NO_INPUT
    #ifdef __cplusplus
        static int yyinput (yyscan_t yyscanner)
    #else
        static int input  (yyscan_t yyscanner)
    #endif
    
    {
    	int c;
        struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
    
    	*yyg->yy_c_buf_p = yyg->yy_hold_char;
    
    	if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
    		{
    		/* yy_c_buf_p now points to the character we want to return.
    		 * If this occurs *before* the EOB characters, then it's a
    		 * valid NUL; if not, then we've hit the end of the buffer.
    		 */
    		if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
    			/* This was really a NUL. */
    			*yyg->yy_c_buf_p = '\0';
    
    		else
    			{ /* need more input */
    			int offset = yyg->yy_c_buf_p - yyg->yytext_ptr;
    			++yyg->yy_c_buf_p;
    
    			switch ( yy_get_next_buffer( yyscanner ) )
    				{
    				case EOB_ACT_LAST_MATCH:
    					/* This happens because yy_g_n_b()
    					 * sees that we've accumulated a
    					 * token and flags that we need to
    					 * try matching the token before
    					 * proceeding.  But for input(),
    					 * there's no matching to consider.
    					 * So convert the EOB_ACT_LAST_MATCH
    					 * to EOB_ACT_END_OF_FILE.
    					 */
    
    					/* Reset buffer status. */
    					ast_yyrestart(yyin ,yyscanner);
    
    					/*FALLTHROUGH*/
    
    				case EOB_ACT_END_OF_FILE:
    					{
    					if ( ast_yywrap(yyscanner ) )
    						return EOF;
    
    					if ( ! yyg->yy_did_buffer_switch_on_eof )
    						YY_NEW_FILE;
    #ifdef __cplusplus
    					return yyinput(yyscanner);
    #else
    					return input(yyscanner);
    #endif
    					}
    
    				case EOB_ACT_CONTINUE_SCAN:
    					yyg->yy_c_buf_p = yyg->yytext_ptr + offset;
    					break;
    				}
    			}
    		}
    
    	c = *(unsigned char *) yyg->yy_c_buf_p;	/* cast for 8-bit char's */
    	*yyg->yy_c_buf_p = '\0';	/* preserve yytext */
    	yyg->yy_hold_char = *++yyg->yy_c_buf_p;
    
    	return c;
    }
    #endif	/* ifndef YY_NO_INPUT */
    
    /** Immediately switch to a different input stream.
     * @param input_file A readable stream.
     * @param yyscanner The scanner object.
     * @note This function does not reset the start condition to @c INITIAL .
     */
        void ast_yyrestart  (FILE * input_file , yyscan_t yyscanner)
    {
        struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
    
    	if ( ! YY_CURRENT_BUFFER ){
            ast_yyensure_buffer_stack (yyscanner);
    		YY_CURRENT_BUFFER_LVALUE =
                ast_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner);
    	}
    
    	ast_yy_init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner);
    	ast_yy_load_buffer_state(yyscanner );
    }
    
    /** Switch to a different input buffer.
     * @param new_buffer The new input buffer.
     * @param yyscanner The scanner object.
     */
        void ast_yy_switch_to_buffer  (YY_BUFFER_STATE  new_buffer , yyscan_t yyscanner)
    {
        struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
    
    	/* TODO. We should be able to replace this entire function body
    	 * with
    	 *		ast_yypop_buffer_state();
    	 *		ast_yypush_buffer_state(new_buffer);
         */
    	ast_yyensure_buffer_stack (yyscanner);
    	if ( YY_CURRENT_BUFFER == new_buffer )
    		return;
    
    	if ( YY_CURRENT_BUFFER )
    		{
    		/* Flush out information for old buffer. */
    		*yyg->yy_c_buf_p = yyg->yy_hold_char;
    		YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
    		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
    		}
    
    	YY_CURRENT_BUFFER_LVALUE = new_buffer;
    	ast_yy_load_buffer_state(yyscanner );
    
    	/* We don't actually know whether we did this switch during
    	 * EOF (ast_yywrap()) processing, but the only time this flag
    	 * is looked at is after ast_yywrap() is called, so it's safe
    	 * to go ahead and always set it.
    	 */
    	yyg->yy_did_buffer_switch_on_eof = 1;
    }
    
    static void ast_yy_load_buffer_state  (yyscan_t yyscanner)
    {
        struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
    	yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
    	yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
    	yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
    	yyg->yy_hold_char = *yyg->yy_c_buf_p;
    }
    
    /** Allocate and initialize an input buffer state.
     * @param file A readable stream.
     * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
     * @param yyscanner The scanner object.
     * @return the allocated buffer state.
     */
        YY_BUFFER_STATE ast_yy_create_buffer  (FILE * file, int  size , yyscan_t yyscanner)
    {
    	YY_BUFFER_STATE b;
        
    	b = (YY_BUFFER_STATE) ast_yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner );
    	if ( ! b )
    		YY_FATAL_ERROR( "out of dynamic memory in ast_yy_create_buffer()" );
    
    	b->yy_buf_size = size;
    
    	/* yy_ch_buf has to be 2 characters longer than the size given because
    	 * we need to put in 2 end-of-buffer characters.
    	 */
    	b->yy_ch_buf = (char *) ast_yyalloc(b->yy_buf_size + 2 ,yyscanner );
    	if ( ! b->yy_ch_buf )
    		YY_FATAL_ERROR( "out of dynamic memory in ast_yy_create_buffer()" );
    
    	b->yy_is_our_buffer = 1;
    
    	ast_yy_init_buffer(b,file ,yyscanner);
    
    	return b;
    }
    
    /** Destroy the buffer.
     * @param b a buffer created with ast_yy_create_buffer()
     * @param yyscanner The scanner object.
     */
        void ast_yy_delete_buffer (YY_BUFFER_STATE  b , yyscan_t yyscanner)
    {
        struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
    
    	if ( ! b )
    		return;
    
    	if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
    		YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
    
    	if ( b->yy_is_our_buffer )
    		ast_yyfree((void *) b->yy_ch_buf ,yyscanner );
    
    	ast_yyfree((void *) b ,yyscanner );
    }
    
    #ifndef __cplusplus
    extern int isatty (int );
    #endif /* __cplusplus */
        
    /* Initializes or reinitializes a buffer.
     * This function is sometimes called more than once on the same buffer,
     * such as during a ast_yyrestart() or at EOF.
     */
        static void ast_yy_init_buffer  (YY_BUFFER_STATE  b, FILE * file , yyscan_t yyscanner)
    
    {
    	int oerrno = errno;
        struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
    
    	ast_yy_flush_buffer(b ,yyscanner);
    
    	b->yy_input_file = file;
    	b->yy_fill_buffer = 1;
    
        /* If b is the current buffer, then ast_yy_init_buffer was _probably_
         * called from ast_yyrestart() or through yy_get_next_buffer.
         * In that case, we don't want to reset the lineno or column.
         */
        if (b != YY_CURRENT_BUFFER){
            b->yy_bs_lineno = 1;
            b->yy_bs_column = 0;
        }
    
            b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
        
    	errno = oerrno;
    }
    
    /** Discard all buffered characters. On the next scan, YY_INPUT will be called.
     * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
     * @param yyscanner The scanner object.
     */
        void ast_yy_flush_buffer (YY_BUFFER_STATE  b , yyscan_t yyscanner)
    {
        struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
    	if ( ! b )
    		return;
    
    	b->yy_n_chars = 0;
    
    	/* We always need two end-of-buffer characters.  The first causes
    	 * a transition to the end-of-buffer state.  The second causes
    	 * a jam in that state.
    	 */
    	b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
    	b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
    
    	b->yy_buf_pos = &b->yy_ch_buf[0];
    
    	b->yy_at_bol = 1;
    	b->yy_buffer_status = YY_BUFFER_NEW;
    
    	if ( b == YY_CURRENT_BUFFER )
    		ast_yy_load_buffer_state(yyscanner );
    }
    
    /** Pushes the new state onto the stack. The new state becomes
     *  the current state. This function will allocate the stack
     *  if necessary.
     *  @param new_buffer The new state.
     *  @param yyscanner The scanner object.
     */
    void ast_yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
    {
        struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
    	if (new_buffer == NULL)
    		return;
    
    	ast_yyensure_buffer_stack(yyscanner);
    
    	/* This block is copied from ast_yy_switch_to_buffer. */
    	if ( YY_CURRENT_BUFFER )
    		{
    		/* Flush out information for old buffer. */
    		*yyg->yy_c_buf_p = yyg->yy_hold_char;
    		YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
    		YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
    		}
    
    	/* Only push if top exists. Otherwise, replace top. */
    	if (YY_CURRENT_BUFFER)
    		yyg->yy_buffer_stack_top++;
    	YY_CURRENT_BUFFER_LVALUE = new_buffer;
    
    	/* copied from ast_yy_switch_to_buffer. */
    	ast_yy_load_buffer_state(yyscanner );
    	yyg->yy_did_buffer_switch_on_eof = 1;
    }
    
    /** Removes and deletes the top of the stack, if present.
     *  The next element becomes the new top.
     *  @param yyscanner The scanner object.
     */
    void ast_yypop_buffer_state (yyscan_t yyscanner)
    {
        struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
    	if (!YY_CURRENT_BUFFER)
    		return;
    
    	ast_yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner);
    	YY_CURRENT_BUFFER_LVALUE = NULL;
    	if (yyg->yy_buffer_stack_top > 0)
    		--yyg->yy_buffer_stack_top;
    
    	if (YY_CURRENT_BUFFER) {
    		ast_yy_load_buffer_state(yyscanner );
    		yyg->yy_did_buffer_switch_on_eof = 1;
    	}
    }
    
    /* Allocates the stack if it does not exist.
     *  Guarantees space for at least one push.
     */
    static void ast_yyensure_buffer_stack (yyscan_t yyscanner)
    {
    	int num_to_alloc;
        struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
    
    	if (!yyg->yy_buffer_stack) {
    
    		/* First allocation is just for 2 elements, since we don't know if this
    		 * scanner will even need a stack. We use 2 instead of 1 to avoid an
    		 * immediate realloc on the next call.
             */
    		num_to_alloc = 1;
    		yyg->yy_buffer_stack = (struct yy_buffer_state**)ast_yyalloc
    								(num_to_alloc * sizeof(struct yy_buffer_state*)
    								, yyscanner);
    		
    		memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*));
    				
    		yyg->yy_buffer_stack_max = num_to_alloc;
    		yyg->yy_buffer_stack_top = 0;
    		return;
    	}
    
    	if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){
    
    		/* Increase the buffer to prepare for a possible push. */
    		int grow_size = 8 /* arbitrary grow size */;
    
    		num_to_alloc = yyg->yy_buffer_stack_max + grow_size;
    		yyg->yy_buffer_stack = (struct yy_buffer_state**)ast_yyrealloc
    								(yyg->yy_buffer_stack,
    								num_to_alloc * sizeof(struct yy_buffer_state*)
    								, yyscanner);
    
    		/* zero only the new slots.*/
    		memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*));
    		yyg->yy_buffer_stack_max = num_to_alloc;
    	}
    }
    
    /** Setup the input buffer state to scan directly from a user-specified character buffer.
     * @param base the character buffer
     * @param size the size in bytes of the character buffer
     * @param yyscanner The scanner object.
     * @return the newly allocated buffer state object. 
     */
    YY_BUFFER_STATE ast_yy_scan_buffer  (char * base, yy_size_t  size , yyscan_t yyscanner)
    {
    	YY_BUFFER_STATE b;
        
    	if ( size < 2 ||
    	     base[size-2] != YY_END_OF_BUFFER_CHAR ||
    	     base[size-1] != YY_END_OF_BUFFER_CHAR )
    		/* They forgot to leave room for the EOB's. */
    		return 0;
    
    	b = (YY_BUFFER_STATE) ast_yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner );
    	if ( ! b )
    		YY_FATAL_ERROR( "out of dynamic memory in ast_yy_scan_buffer()" );
    
    	b->yy_buf_size = size - 2;	/* "- 2" to take care of EOB's */
    	b->yy_buf_pos = b->yy_ch_buf = base;
    	b->yy_is_our_buffer = 0;
    	b->yy_input_file = 0;
    	b->yy_n_chars = b->yy_buf_size;
    	b->yy_is_interactive = 0;
    	b->yy_at_bol = 1;
    	b->yy_fill_buffer = 0;
    	b->yy_buffer_status = YY_BUFFER_NEW;
    
    	ast_yy_switch_to_buffer(b ,yyscanner );
    
    	return b;
    }
    
    /** Setup the input buffer state to scan a string. The next call to ast_yylex() will
     * scan from a @e copy of @a str.
    
    Tilghman Lesher's avatar
     
    Tilghman Lesher committed
     * @param str a NUL-terminated string to scan
    
     * @param yyscanner The scanner object.
     * @return the newly allocated buffer state object.
     * @note If you want to scan bytes that may contain NUL values, then use
     *       ast_yy_scan_bytes() instead.
     */
    
    Tilghman Lesher's avatar
     
    Tilghman Lesher committed
    YY_BUFFER_STATE ast_yy_scan_string (yyconst char * str , yyscan_t yyscanner)
    
    Tilghman Lesher's avatar
     
    Tilghman Lesher committed
    	return ast_yy_scan_bytes(str,strlen(str) ,yyscanner);
    
    }
    
    /** Setup the input buffer state to scan the given bytes. The next call to ast_yylex() will
     * scan from a @e copy of @a bytes.
     * @param bytes the byte buffer to scan
     * @param len the number of bytes in the buffer pointed to by @a bytes.
     * @param yyscanner The scanner object.
     * @return the newly allocated buffer state object.
     */
    YY_BUFFER_STATE ast_yy_scan_bytes  (yyconst char * bytes, int  len , yyscan_t yyscanner)
    {
    	YY_BUFFER_STATE b;
    	char *buf;
    	yy_size_t n;
    	int i;
        
    	/* Get memory for full buffer, including space for trailing EOB's. */
    	n = len + 2;
    	buf = (char *) ast_yyalloc(n ,yyscanner );
    	if ( ! buf )
    		YY_FATAL_ERROR( "out of dynamic memory in ast_yy_scan_bytes()" );
    
    	for ( i = 0; i < len; ++i )
    		buf[i] = bytes[i];
    
    	buf[len] = buf[len+1] = YY_END_OF_BUFFER_CHAR;
    
    	b = ast_yy_scan_buffer(buf,n ,yyscanner);
    	if ( ! b )
    		YY_FATAL_ERROR( "bad buffer in ast_yy_scan_bytes()" );
    
    	/* It's okay to grow etc. this buffer, and we should throw it
    	 * away when we're done.
    	 */
    	b->yy_is_our_buffer = 1;
    
    	return b;
    }
    
    #ifndef YY_EXIT_FAILURE
    #define YY_EXIT_FAILURE 2
    #endif
    
    static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner)
    {
        	(void) fprintf( stderr, "%s\n", msg );
    	exit( YY_EXIT_FAILURE );
    }
    
    /* Redefine yyless() so it works in section 3 code. */
    
    #undef yyless
    #define yyless(n) \
    	do \
    		{ \
    		/* Undo effects of setting up yytext. */ \
            int yyless_macro_arg = (n); \
            YY_LESS_LINENO(yyless_macro_arg);\
    		yytext[yyleng] = yyg->yy_hold_char; \
    		yyg->yy_c_buf_p = yytext + yyless_macro_arg; \
    		yyg->yy_hold_char = *yyg->yy_c_buf_p; \
    		*yyg->yy_c_buf_p = '\0'; \
    		yyleng = yyless_macro_arg; \
    		} \
    	while ( 0 )
    
    /* Accessor  methods (get/set functions) to struct members. */
    
    /** Get the user-defined data for this scanner.
     * @param yyscanner The scanner object.
     */
    YY_EXTRA_TYPE ast_yyget_extra  (yyscan_t yyscanner)
    {
        struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
        return yyextra;
    }
    
    /** Get the current line number.
     * @param yyscanner The scanner object.
     */
    int ast_yyget_lineno  (yyscan_t yyscanner)
    {
        struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
        
            if (! YY_CURRENT_BUFFER)
                return 0;
        
        return yylineno;
    }
    
    /** Get the current column number.
     * @param yyscanner The scanner object.
     */
    int ast_yyget_column  (yyscan_t yyscanner)
    {
        struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
        
            if (! YY_CURRENT_BUFFER)
                return 0;
        
        return yycolumn;
    }
    
    /** Get the input stream.
     * @param yyscanner The scanner object.
     */
    FILE *ast_yyget_in  (yyscan_t yyscanner)
    {
        struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
        return yyin;
    }
    
    /** Get the output stream.
     * @param yyscanner The scanner object.
     */
    FILE *ast_yyget_out  (yyscan_t yyscanner)
    {
        struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
        return yyout;
    }
    
    /** Get the length of the current token.
     * @param yyscanner The scanner object.
     */
    int ast_yyget_leng  (yyscan_t yyscanner)
    {
        struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
        return yyleng;
    }
    
    /** Get the current token.
     * @param yyscanner The scanner object.
     */
    
    char *ast_yyget_text  (yyscan_t yyscanner)
    {
        struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
        return yytext;
    }
    
    /** Set the user-defined data. This data is never touched by the scanner.
     * @param user_defined The data to be associated with this scanner.
     * @param yyscanner The scanner object.
     */
    void ast_yyset_extra (YY_EXTRA_TYPE  user_defined , yyscan_t yyscanner)
    {
        struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
        yyextra = user_defined ;
    }
    
    /** Set the current line number.
     * @param line_number
     * @param yyscanner The scanner object.
     */
    void ast_yyset_lineno (int  line_number , yyscan_t yyscanner)
    {
        struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
    
            /* lineno is only valid if an input buffer exists. */
            if (! YY_CURRENT_BUFFER )
               yy_fatal_error( "ast_yyset_lineno called with no buffer" , yyscanner); 
        
        yylineno = line_number;
    }
    
    /** Set the current column.
    
    Tilghman Lesher's avatar
     
    Tilghman Lesher committed
     * @param line_number
    
     * @param yyscanner The scanner object.
     */
    void ast_yyset_column (int  column_no , yyscan_t yyscanner)
    {
        struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
    
            /* column is only valid if an input buffer exists. */
            if (! YY_CURRENT_BUFFER )
               yy_fatal_error( "ast_yyset_column called with no buffer" , yyscanner); 
        
        yycolumn = column_no;
    }
    
    /** Set the input stream. This does not discard the current
     * input buffer.
     * @param in_str A readable stream.
     * @param yyscanner The scanner object.
     * @see ast_yy_switch_to_buffer
     */
    void ast_yyset_in (FILE *  in_str , yyscan_t yyscanner)
    {
        struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
        yyin = in_str ;
    }
    
    void ast_yyset_out (FILE *  out_str , yyscan_t yyscanner)
    {
        struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
        yyout = out_str ;
    }
    
    int ast_yyget_debug  (yyscan_t yyscanner)
    {
        struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
        return yy_flex_debug;
    }
    
    void ast_yyset_debug (int  bdebug , yyscan_t yyscanner)
    {
        struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
        yy_flex_debug = bdebug ;
    }
    
    /* Accessor methods for yylval and yylloc */
    
    YYSTYPE * ast_yyget_lval  (yyscan_t yyscanner)
    {
        struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
        return yylval;
    }
    
    void ast_yyset_lval (YYSTYPE *  yylval_param , yyscan_t yyscanner)
    {
        struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
        yylval = yylval_param;
    }
    
    YYLTYPE *ast_yyget_lloc  (yyscan_t yyscanner)
    {
        struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
        return yylloc;
    }
        
    void ast_yyset_lloc (YYLTYPE *  yylloc_param , yyscan_t yyscanner)
    {
        struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
        yylloc = yylloc_param;
    }
        
    static int yy_init_globals (yyscan_t yyscanner)
    {
        struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
        /* Initialization is the same as for the non-reentrant scanner.
           This function is called once per scanner lifetime. */
    
        yyg->yy_buffer_stack = 0;
        yyg->yy_buffer_stack_top = 0;
        yyg->yy_buffer_stack_max = 0;
        yyg->yy_c_buf_p = (char *) 0;
        yyg->yy_init = 1;
        yyg->yy_start = 0;
        yyg->yy_start_stack_ptr = 0;
        yyg->yy_start_stack_depth = 0;
        yyg->yy_start_stack = (int *) 0;
    
    /* Defined in main.c */
    #ifdef YY_STDINIT
        yyin = stdin;
        yyout = stdout;
    #else
        yyin = (FILE *) 0;
        yyout = (FILE *) 0;
    #endif
    
        /* For future reference: Set errno on error, since we are called by
         * ast_yylex_init()
         */
        return 0;
    }
    
    /* User-visible API */
    
    /* ast_yylex_init is special because it creates the scanner itself, so it is
     * the ONLY reentrant function that doesn't take the scanner as the last argument.
     * That's why we explicitly handle the declaration, instead of using our macros.
     */
    
    int ast_yylex_init(yyscan_t* ptr_yy_globals)
    
    {
        if (ptr_yy_globals == NULL){
            errno = EINVAL;
            return 1;
        }
    
        *ptr_yy_globals = (yyscan_t) ast_yyalloc ( sizeof( struct yyguts_t ), NULL );
    
        if (*ptr_yy_globals == NULL){
            errno = ENOMEM;
            return 1;
        }
    
        memset(*ptr_yy_globals,0,sizeof(struct yyguts_t));
    
        return yy_init_globals ( *ptr_yy_globals );
    }
    
    /* ast_yylex_destroy is for both reentrant and non-reentrant scanners. */
    int ast_yylex_destroy  (yyscan_t yyscanner)
    {
        struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
    
        /* Pop the buffer stack, destroying each element. */
    	while(YY_CURRENT_BUFFER){
    		ast_yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner );
    		YY_CURRENT_BUFFER_LVALUE = NULL;
    		ast_yypop_buffer_state(yyscanner);
    	}
    
    	/* Destroy the stack itself. */
    	ast_yyfree(yyg->yy_buffer_stack ,yyscanner);
    	yyg->yy_buffer_stack = NULL;
    
        /* Destroy the start condition stack. */
            ast_yyfree(yyg->yy_start_stack ,yyscanner );
            yyg->yy_start_stack = NULL;
    
        /* Destroy the main struct (reentrant only). */
        ast_yyfree ( yyscanner , yyscanner );
        return 0;
    }
    
    /*
     * Internal utility routines.
     */
    
    #ifndef yytext_ptr
    static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner)
    {
    	register int i;
        struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
    	for ( i = 0; i < n; ++i )
    		s1[i] = s2[i];
    }
    #endif
    
    #ifdef YY_NEED_STRLEN
    static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner)
    {
    	register int n;
        struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
    	for ( n = 0; s[n]; ++n )
    		;
    
    	return n;
    }
    #endif
    
    void *ast_yyalloc (yy_size_t  size , yyscan_t yyscanner)
    {
    	return (void *) malloc( size );
    }
    
    void *ast_yyrealloc  (void * ptr, yy_size_t  size , yyscan_t yyscanner)
    {
    	/* The cast to (char *) in the following accommodates both
    	 * implementations that use char* generic pointers, and those
    	 * that use void* generic pointers.  It works with the latter
    	 * because both ANSI C and C++ allow castless assignment from
    	 * any pointer type to void*, and deal with argument conversions
    	 * as though doing an assignment.
    	 */
    	return (void *) realloc( (char *) ptr, size );
    }
    
    void ast_yyfree (void * ptr , yyscan_t yyscanner)
    {
    	free( (char *) ptr );	/* see ast_yyrealloc() for (char *) cast */
    }
    
    #define YYTABLES_NAME "yytables"
    
    #undef YY_NEW_FILE
    #undef YY_FLUSH_BUFFER
    #undef yy_set_bol
    #undef yy_new_buffer
    #undef yy_set_interactive
    #undef yytext_ptr
    #undef YY_DO_BEFORE_ACTION
    
    #ifdef YY_DECL_IS_OURS
    #undef YY_DECL_IS_OURS
    #undef YY_DECL
    #endif
    
    Tilghman Lesher's avatar
     
    Tilghman Lesher committed
    #line 103 "ast_expr2.fl"
    
    
    
    
    /* I'm putting the interface routine to the whole parse here in the flexer input file
       mainly because of all the flexer initialization that has to be done. Shouldn't matter
       where it is, as long as it's somewhere. I didn't want to define a prototype for the
       ast_yy_scan_string in the .y file, because then, I'd have to define YY_BUFFER_STATE there...
    	UGH! that would be inappropriate. */
    
    
    int ast_yyparse(void *); /* need to/should define this prototype for the call to yyparse */
    int ast_yyerror(const char *, YYLTYPE *, struct parse_io *); /* likewise */
    
    int ast_expr(char *expr, char *buf, int length)
    
    	struct parse_io io;
    	int return_value = 0;
    
    	memset(&io, 0, sizeof(io));
    	io.string = expr;  /* to pass to the error routine */
    
    	ast_yylex_init(&io.scanner);
    
    	ast_yy_scan_string(expr, io.scanner);
    
    	ast_yyparse ((void *) &io);
    
    	ast_yylex_destroy(io.scanner);
    
    			return_value = 1;
    
    		if (io.val->type == AST_EXPR_integer) {
    
    			res_length = snprintf(buf, length, "%ld", (long int) io.val->u.i);
    			return_value = (res_length <= length) ? res_length : length;
    
    			strncpy(buf, io.val->u.s, length - 1);
    
    			ast_copy_string(buf, io.val->u.s, length);
    
    			return_value = strlen(buf);
    
    Tilghman Lesher's avatar
     
    Tilghman Lesher committed
    			free(io.val->u.s);
    
    	return return_value;
    
    }
    
    int ast_yyerror (const char *s,  yyltype *loc, struct parse_io *parseio )
    {	
    	struct yyguts_t * yyg = (struct yyguts_t*)(parseio->scanner);
    	char spacebuf[8000]; /* best safe than sorry */
    	char spacebuf2[8000]; /* best safe than sorry */
    	int i=0;
    	spacebuf[0] = 0;
    	
    	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,
    													which is the same thing as... get this:
    													yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_bs_column
    													I was tempted to just use yy_buf_pos in the STATE, but..., well:
    														a. the yy_buf_pos is the current position in the buffer, which
    															may not relate to the entire string/buffer because of the
    															buffering.
    														b. but, analysis of the situation is that when you use the
    															ast_yy_scan_string func, it creates a single buffer the size of
    															string, so the two would be the same... 
    													so, in the end, the yycolumn macro is available, shorter, therefore easier. */
    	spacebuf2[i++]='^';
    	spacebuf2[i]= 0;
    
    #ifdef STANDALONE3
    	/* easier to read in the standalone version */
    	printf("ast_yyerror(): syntax error: %s; Input:\n%s\n%s\n",  
    			s, parseio->string,spacebuf2);
    #else
    	ast_log(LOG_WARNING,"ast_yyerror(): syntax error: %s; Input:\n%s\n%s\n",  
    			s, parseio->string,spacebuf2);
    #endif
    #ifndef STANDALONE
    
    	ast_log(LOG_WARNING,"If you have questions, please refer to doc/channelvariables.txt in the asterisk source.\n");