Debian Codegraph @

main/ast_expr2f.c

raw symbols SCIP
1 #define ASTMM_LIBC ASTMM_REDIRECT
2 #include "asterisk.h"
3
4 #line 2 "ast_expr2f.c"
5
6 #line 4 "ast_expr2f.c"
7
8 #define YY_INT_ALIGNED short int
9
10 /* A lexical scanner generated by flex */
11
12 #define FLEX_SCANNER
13 #define YY_FLEX_MAJOR_VERSION 2
14 #define YY_FLEX_MINOR_VERSION 5
15 #define YY_FLEX_SUBMINOR_VERSION 35
16 #if YY_FLEX_SUBMINOR_VERSION > 0
17 #define FLEX_BETA
18 #endif
19
20 /* First, we deal with platform-specific or compiler-specific issues. */
21
22 /* begin standard C headers. */
23 #include <stdio.h>
24 #include <string.h>
25 #include <errno.h>
26 #include <stdlib.h>
27
28 /* end standard C headers. */
29
30 /* flex integer type definitions */
31
32 #ifndef FLEXINT_H
33 #define FLEXINT_H
34
35 /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
36
37 #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
38
39 /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
40 * if you want the limit (max/min) macros for int types.
41 */
42 #ifndef __STDC_LIMIT_MACROS
43 #define __STDC_LIMIT_MACROS 1
44 #endif
45
46 #include <inttypes.h>
47 typedef int8_t flex_int8_t;
48 typedef uint8_t flex_uint8_t;
49 typedef int16_t flex_int16_t;
50 typedef uint16_t flex_uint16_t;
51 typedef int32_t flex_int32_t;
52 typedef uint32_t flex_uint32_t;
53 #else
54 typedef signed char flex_int8_t;
55 typedef short int flex_int16_t;
56 typedef int flex_int32_t;
57 typedef unsigned char flex_uint8_t;
58 typedef unsigned short int flex_uint16_t;
59 typedef unsigned int flex_uint32_t;
60 #endif /* ! C99 */
61
62 /* Limits of integral types. */
63 #ifndef INT8_MIN
64 #define INT8_MIN (-128)
65 #endif
66 #ifndef INT16_MIN
67 #define INT16_MIN (-32767-1)
68 #endif
69 #ifndef INT32_MIN
70 #define INT32_MIN (-2147483647-1)
71 #endif
72 #ifndef INT8_MAX
73 #define INT8_MAX (127)
74 #endif
75 #ifndef INT16_MAX
76 #define INT16_MAX (32767)
77 #endif
78 #ifndef INT32_MAX
79 #define INT32_MAX (2147483647)
80 #endif
81 #ifndef UINT8_MAX
82 #define UINT8_MAX (255U)
83 #endif
84 #ifndef UINT16_MAX
85 #define UINT16_MAX (65535U)
86 #endif
87 #ifndef UINT32_MAX
88 #define UINT32_MAX (4294967295U)
89 #endif
90
91 #endif /* ! FLEXINT_H */
92
93 #ifdef __cplusplus
94
95 /* The "const" storage-class-modifier is valid. */
96 #define YY_USE_CONST
97
98 #else /* ! __cplusplus */
99
100 /* C99 requires __STDC__ to be defined as 1. */
101 #if defined (__STDC__)
102
103 #define YY_USE_CONST
104
105 #endif /* defined (__STDC__) */
106 #endif /* ! __cplusplus */
107
108 #ifdef YY_USE_CONST
109 #define yyconst const
110 #else
111 #define yyconst
112 #endif
113
114 /* Returned upon end-of-file. */
115 #define YY_NULL 0
116
117 /* Promotes a possibly negative, possibly signed char to an unsigned
118 * integer for use as an array index. If the signed char is negative,
119 * we want to instead treat it as an 8-bit unsigned char, hence the
120 * double cast.
121 */
122 #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
123
124 /* An opaque pointer. */
125 #ifndef YY_TYPEDEF_YY_SCANNER_T
126 #define YY_TYPEDEF_YY_SCANNER_T
127 typedef void* yyscan_t;
128 #endif
129
130 /* For convenience, these vars (plus the bison vars far below)
131 are macros in the reentrant scanner. */
132 #define yyin yyg->yyin_r
133 #define yyout yyg->yyout_r
134 #define yyextra yyg->yyextra_r
135 #define yyleng yyg->yyleng_r
136 #define yytext yyg->yytext_r
137 #define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno)
138 #define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column)
139 #define yy_flex_debug yyg->yy_flex_debug_r
140
141 /* Enter a start condition. This macro really ought to take a parameter,
142 * but we do it the disgusting crufty way forced on us by the ()-less
143 * definition of BEGIN.
144 */
145 #define BEGIN yyg->yy_start = 1 + 2 *
146
147 /* Translate the current start state into a value that can be later handed
148 * to BEGIN to return to the state. The YYSTATE alias is for lex
149 * compatibility.
150 */
151 #define YY_START ((yyg->yy_start - 1) / 2)
152 #define YYSTATE YY_START
153
154 /* Action number for EOF rule of a given start state. */
155 #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
156
157 /* Special action meaning "start processing a new file". */
158 #define YY_NEW_FILE ast_yyrestart(yyin ,yyscanner )
159
160 #define YY_END_OF_BUFFER_CHAR 0
161
162 /* Size of default input buffer. */
163 #ifndef YY_BUF_SIZE
164 #define YY_BUF_SIZE 16384
165 #endif
166
167 /* The state buf must be large enough to hold one state per character in the main buffer.
168 */
169 #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
170
171 #ifndef YY_TYPEDEF_YY_BUFFER_STATE
172 #define YY_TYPEDEF_YY_BUFFER_STATE
173 typedef struct yy_buffer_state *YY_BUFFER_STATE;
174 #endif
175
176 #define EOB_ACT_CONTINUE_SCAN 0
177 #define EOB_ACT_END_OF_FILE 1
178 #define EOB_ACT_LAST_MATCH 2
179
180 #define YY_LESS_LINENO(n)
181
182 /* Return all but the first "n" matched characters back to the input stream. */
183 #define yyless(n) \
184 do \
185 { \
186 /* Undo effects of setting up yytext. */ \
187 int yyless_macro_arg = (n); \
188 YY_LESS_LINENO(yyless_macro_arg);\
189 *yy_cp = yyg->yy_hold_char; \
190 YY_RESTORE_YY_MORE_OFFSET \
191 yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
192 YY_DO_BEFORE_ACTION; /* set up yytext again */ \
193 } \
194 while ( 0 )
195
196 #define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner )
197
198 #ifndef YY_TYPEDEF_YY_SIZE_T
199 #define YY_TYPEDEF_YY_SIZE_T
200 typedef size_t yy_size_t;
201 #endif
202
203 #ifndef YY_STRUCT_YY_BUFFER_STATE
204 #define YY_STRUCT_YY_BUFFER_STATE
205 struct yy_buffer_state
206 {
207 FILE *yy_input_file;
208
209 char *yy_ch_buf; /* input buffer */
210 char *yy_buf_pos; /* current position in input buffer */
211
212 /* Size of input buffer in bytes, not including room for EOB
213 * characters.
214 */
215 yy_size_t yy_buf_size;
216
217 /* Number of characters read into yy_ch_buf, not including EOB
218 * characters.
219 */
220 int yy_n_chars;
221
222 /* Whether we "own" the buffer - i.e., we know we created it,
223 * and can realloc() it to grow it, and should free() it to
224 * delete it.
225 */
226 int yy_is_our_buffer;
227
228 /* Whether this is an "interactive" input source; if so, and
229 * if we're using stdio for input, then we want to use getc()
230 * instead of fread(), to make sure we stop fetching input after
231 * each newline.
232 */
233 int yy_is_interactive;
234
235 /* Whether we're considered to be at the beginning of a line.
236 * If so, '^' rules will be active on the next match, otherwise
237 * not.
238 */
239 int yy_at_bol;
240
241 int yy_bs_lineno; /**< The line count. */
242 int yy_bs_column; /**< The column count. */
243
244 /* Whether to try to fill the input buffer when we reach the
245 * end of it.
246 */
247 int yy_fill_buffer;
248
249 int yy_buffer_status;
250
251 #define YY_BUFFER_NEW 0
252 #define YY_BUFFER_NORMAL 1
253 /* When an EOF's been seen but there's still some text to process
254 * then we mark the buffer as YY_EOF_PENDING, to indicate that we
255 * shouldn't try reading from the input source any more. We might
256 * still have a bunch of tokens to match, though, because of
257 * possible backing-up.
258 *
259 * When we actually see the EOF, we change the status to "new"
260 * (via ast_yyrestart()), so that the user can continue scanning by
261 * just pointing yyin at a new input file.
262 */
263 #define YY_BUFFER_EOF_PENDING 2
264
265 };
266 #endif /* !YY_STRUCT_YY_BUFFER_STATE */
267
268 /* We provide macros for accessing buffer states in case in the
269 * future we want to put the buffer states in a more general
270 * "scanner state".
271 *
272 * Returns the top of the stack, or NULL.
273 */
274 #define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \
275 ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \
276 : NULL)
277
278 /* Same as previous macro, but useful when we know that the buffer stack is not
279 * NULL or when we need an lvalue. For internal use only.
280 */
281 #define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]
282
283 void ast_yyrestart (FILE *input_file ,yyscan_t yyscanner );
284 void ast_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
285 YY_BUFFER_STATE ast_yy_create_buffer (FILE *file,int size ,yyscan_t yyscanner );
286 void ast_yy_delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
287 void ast_yy_flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
288 void ast_yypush_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
289 void ast_yypop_buffer_state (yyscan_t yyscanner );
290
291 static void ast_yyensure_buffer_stack (yyscan_t yyscanner );
292 static void ast_yy_load_buffer_state (yyscan_t yyscanner );
293 static void ast_yy_init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan_t yyscanner );
294
295 #define YY_FLUSH_BUFFER ast_yy_flush_buffer(YY_CURRENT_BUFFER ,yyscanner)
296
297 YY_BUFFER_STATE ast_yy_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner );
298 YY_BUFFER_STATE ast_yy_scan_string (yyconst char *yy_str ,yyscan_t yyscanner );
299 YY_BUFFER_STATE ast_yy_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner );
300
301 void *ast_yyalloc (yy_size_t ,yyscan_t yyscanner );
302 void *ast_yyrealloc (void *,yy_size_t ,yyscan_t yyscanner );
303 void ast_yyfree (void * ,yyscan_t yyscanner );
304
305 #define yy_new_buffer ast_yy_create_buffer
306
307 #define yy_set_interactive(is_interactive) \
308 { \
309 if ( ! YY_CURRENT_BUFFER ){ \
310 ast_yyensure_buffer_stack (yyscanner); \
311 YY_CURRENT_BUFFER_LVALUE = \
312 ast_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \
313 } \
314 YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
315 }
316
317 #define yy_set_bol(at_bol) \
318 { \
319 if ( ! YY_CURRENT_BUFFER ){\
320 ast_yyensure_buffer_stack (yyscanner); \
321 YY_CURRENT_BUFFER_LVALUE = \
322 ast_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \
323 } \
324 YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
325 }
326
327 #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
328
329 /* Begin user sect3 */
330
331 #define ast_yywrap(n) 1
332 #define YY_SKIP_YYWRAP
333
334 typedef unsigned char YY_CHAR;
335
336 typedef int yy_state_type;
337
338 #define yytext_ptr yytext_r
339
340 static yy_state_type yy_get_previous_state (yyscan_t yyscanner );
341 static yy_state_type yy_try_NUL_trans (yy_state_type current_state ,yyscan_t yyscanner);
342 static int yy_get_next_buffer (yyscan_t yyscanner );
343 static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner );
344
345 /* Done after the current pattern has been matched and before the
346 * corresponding action - sets up yytext.
347 */
348 #define YY_DO_BEFORE_ACTION \
349 yyg->yytext_ptr = yy_bp; \
350 yyg->yytext_ptr -= yyg->yy_more_len; \
351 yyleng = (size_t) (yy_cp - yyg->yytext_ptr); \
352 yyg->yy_hold_char = *yy_cp; \
353 *yy_cp = '\0'; \
354 yyg->yy_c_buf_p = yy_cp;
355
356 #define YY_NUM_RULES 38
357 #define YY_END_OF_BUFFER 39
358 /* This struct is not used in this scanner,
359 but its presence is necessary. */
360 struct yy_trans_info
361 {
362 flex_int32_t yy_verify;
363 flex_int32_t yy_nxt;
364 };
365 static yyconst flex_int16_t yy_accept[63] =
366 { 0,
367 0, 0, 0, 0, 35, 35, 39, 38, 27, 29,
368 21, 38, 31, 38, 19, 2, 24, 25, 17, 14,
369 15, 16, 18, 30, 22, 10, 3, 9, 20, 1,
370 38, 38, 34, 33, 35, 37, 37, 13, 0, 28,
371 31, 0, 26, 5, 31, 30, 23, 12, 6, 7,
372 11, 4, 8, 0, 34, 33, 35, 0, 36, 32,
373 30, 0
374 } ;
375
376 static yyconst flex_int32_t yy_ec[256] =
377 { 0,
378 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
379 1, 1, 2, 1, 1, 1, 1, 1, 1, 1,
380 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
381 1, 2, 4, 5, 6, 7, 8, 9, 6, 10,
382 11, 12, 13, 14, 15, 16, 17, 18, 18, 18,
383 18, 18, 18, 18, 18, 18, 18, 19, 6, 20,
384 21, 22, 23, 6, 6, 6, 6, 6, 6, 6,
385 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
386 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
387 1, 6, 1, 6, 6, 1, 6, 6, 6, 6,
388
389 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
390 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
391 6, 6, 24, 25, 26, 27, 1, 28, 28, 28,
392 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
393 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
394 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
395 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
396 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
397 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
398 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
399
400 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
401 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
402 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
403 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
404 28, 28, 28, 28, 28, 28, 28, 28, 28, 28,
405 28, 28, 28, 28, 28
406 } ;
407
408 static yyconst flex_int32_t yy_meta[29] =
409 { 0,
410 1, 2, 2, 2, 1, 3, 3, 2, 2, 2,
411 2, 2, 2, 1, 2, 3, 2, 3, 2, 2,
412 2, 2, 2, 1, 2, 1, 1, 3
413 } ;
414
415 static yyconst flex_int16_t yy_base[70] =
416 { 0,
417 0, 0, 5, 6, 32, 60, 73, 130, 130, 130,
418 51, 66, 63, 45, 130, 59, 130, 130, 130, 130,
419 130, 130, 130, 83, 45, 42, 13, 41, 130, 32,
420 28, 17, 130, 130, 47, 130, 29, 130, 47, 130,
421 44, 25, 130, 130, 29, 0, 130, 130, 130, 130,
422 130, 130, 130, 18, 130, 130, 38, 12, 130, 130,
423 0, 130, 111, 114, 117, 32, 120, 123, 126
424 } ;
425
426 static yyconst flex_int16_t yy_def[70] =
427 { 0,
428 62, 1, 63, 63, 64, 64, 62, 62, 62, 62,
429 62, 65, 66, 67, 62, 62, 62, 62, 62, 62,
430 62, 62, 62, 62, 62, 62, 62, 62, 62, 62,
431 62, 68, 62, 62, 69, 62, 62, 62, 65, 62,
432 66, 67, 62, 62, 41, 24, 62, 62, 62, 62,
433 62, 62, 62, 68, 62, 62, 69, 62, 62, 62,
434 45, 0, 62, 62, 62, 62, 62, 62, 62
435 } ;
436
437 static yyconst flex_int16_t yy_nxt[159] =
438 { 0,
439 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
440 18, 19, 20, 21, 22, 13, 23, 24, 25, 26,
441 27, 28, 29, 8, 30, 8, 31, 13, 33, 33,
442 34, 34, 35, 49, 41, 59, 35, 35, 37, 50,
443 55, 55, 56, 56, 58, 35, 61, 35, 60, 35,
444 42, 40, 59, 58, 53, 35, 52, 35, 35, 35,
445 35, 51, 48, 47, 35, 35, 37, 44, 43, 42,
446 40, 38, 62, 35, 62, 35, 62, 35, 62, 62,
447 62, 62, 62, 35, 62, 35, 35, 35, 41, 42,
448 62, 62, 62, 62, 62, 62, 62, 62, 45, 62,
449
450 46, 62, 62, 62, 62, 62, 62, 62, 62, 62,
451 41, 32, 32, 32, 36, 36, 36, 39, 39, 39,
452 41, 41, 41, 54, 54, 54, 57, 62, 57, 7,
453 62, 62, 62, 62, 62, 62, 62, 62, 62, 62,
454 62, 62, 62, 62, 62, 62, 62, 62, 62, 62,
455 62, 62, 62, 62, 62, 62, 62, 62
456 } ;
457
458 static yyconst flex_int16_t yy_chk[159] =
459 { 0,
460 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
461 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
462 1, 1, 1, 1, 1, 1, 1, 1, 3, 4,
463 3, 4, 5, 27, 66, 58, 5, 5, 5, 27,
464 32, 54, 32, 54, 57, 5, 45, 5, 42, 5,
465 41, 39, 37, 35, 31, 5, 30, 5, 5, 5,
466 6, 28, 26, 25, 6, 6, 6, 16, 14, 13,
467 12, 11, 7, 6, 0, 6, 0, 6, 0, 0,
468 0, 0, 0, 6, 0, 6, 6, 6, 24, 24,
469 0, 0, 0, 0, 0, 0, 0, 0, 24, 0,
470
471 24, 0, 0, 0, 0, 0, 0, 0, 0, 0,
472 24, 63, 63, 63, 64, 64, 64, 65, 65, 65,
473 67, 67, 67, 68, 68, 68, 69, 0, 69, 62,
474 62, 62, 62, 62, 62, 62, 62, 62, 62, 62,
475 62, 62, 62, 62, 62, 62, 62, 62, 62, 62,
476 62, 62, 62, 62, 62, 62, 62, 62
477 } ;
478
479 /* The intent behind this definition is that it'll catch
480 * any uses of REJECT which flex missed.
481 */
482 #define REJECT reject_used_but_not_detected
483 #define yymore() (yyg->yy_more_flag = 1)
484 #define YY_MORE_ADJ yyg->yy_more_len
485 #define YY_RESTORE_YY_MORE_OFFSET
486 #line 1 "ast_expr2.fl"
487 #line 2 "ast_expr2.fl"
488 /*
489 * Asterisk -- An open source telephony toolkit.
490 *
491 * Copyright (C) 1999 - 2006, Digium, Inc.
492 *
493 * Mark Spencer <[email protected]>
494 *
495 * See http://www.asterisk.org for more information about
496 * the Asterisk project. Please do not directly contact
497 * any of the maintainers of this project for assistance;
498 * the project provides a web site, mailing lists and IRC
499 * channels for your use.
500 *
501 * This program is free software, distributed under the terms of
502 * the GNU General Public License Version 2. See the LICENSE file
503 * at the top of the source tree.
504 */
505
506 /*! \file
507 *
508 * \brief Dialplan Expression Lexical Scanner
509 */
510
511 #include <sys/types.h>
512 #include <stdio.h>
513
514 #if defined(STANDALONE)
515 #ifndef __USE_ISOC99
516 #define __USE_ISOC99 1
517 #endif
518 #endif
519
520 #ifdef __USE_ISOC99
521 #define FP___PRINTF "%.18Lg"
522 #define FP___FMOD fmodl
523 #define FP___STRTOD strtold
524 #define FP___TYPE long double
525 #else
526 #define FP___PRINTF "%.16g"
527 #define FP___FMOD fmod
528 #define FP___STRTOD strtod
529 #define FP___TYPE double
530 #endif
531
532 #include <stdlib.h>
533 #include <string.h>
534 #include <locale.h>
535 #include <ctype.h>
536 #if !defined(SOLARIS) && !defined(__CYGWIN__)
537 /* #include <err.h> */
538 #else
539 #define quad_t int64_t
540 #endif
541 #include <errno.h>
542 #include <regex.h>
543 #include <limits.h>
544
545 #include "asterisk/ast_expr.h"
546 #include "asterisk/logger.h"
547 #ifndef STANDALONE
548 #include "asterisk/strings.h"
549 #include "asterisk/channel.h"
550 #endif
551
552 /* Conditionally redefine the macro from flex 2.5.35, in case someone uses flex <2.5.35 to regenerate this file. */
553 #ifndef ECHO
554 #define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0)
555 #endif
556
557 enum valtype {
558 AST_EXPR_number, AST_EXPR_numeric_string, AST_EXPR_string
559 } ;
560
561 struct val {
562 enum valtype type;
563 union {
564 char *s;
565 FP___TYPE i; /* long double or just double if it's a bad day */
566 } u;
567 } ;
568
569 #include "ast_expr2.h" /* the o/p of the bison on ast_expr2.y */
570
571 #define SET_COLUMNS do { \
572 yylloc_param->first_column = (int)(yyg->yytext_r - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf); \
573 yylloc_param->last_column += yyleng - 1; \
574 yylloc_param->first_line = yylloc_param->last_line = 1; \
575 } while (0)
576
577 #define SET_STRING do { \
578 yylval_param->val = calloc(1, sizeof(struct val)); \
579 yylval_param->val->type = AST_EXPR_string; \
580 yylval_param->val->u.s = strdup(yytext); \
581 } while (0)
582
583 #define SET_NUMERIC_STRING do { \
584 yylval_param->val = calloc(1, sizeof(struct val)); \
585 yylval_param->val->type = AST_EXPR_numeric_string; \
586 yylval_param->val->u.s = strdup(yytext); \
587 } while (0)
588
589 struct parse_io
590 {
591 char *string;
592 struct val *val;
593 yyscan_t scanner;
594 struct ast_channel *chan;
595 };
596
597 void ast_yyset_column(int column_no, yyscan_t yyscanner);
598 int ast_yyget_column(yyscan_t yyscanner);
599 static int curlycount = 0;
600 static char *expr2_token_subst(const char *mess);
601
602 #line 600 "ast_expr2f.c"
603
604 #define INITIAL 0
605 #define var 1
606 #define trail 2
607
608 #ifndef YY_NO_UNISTD_H
609 /* Special case for "unistd.h", since it is non-ANSI. We include it way
610 * down here because we want the user's section 1 to have been scanned first.
611 * The user has a chance to override it with an option.
612 */
613 #include <unistd.h>
614 #endif
615
616 #ifndef YY_EXTRA_TYPE
617 #define YY_EXTRA_TYPE void *
618 #endif
619
620 /* Holds the entire state of the reentrant scanner. */
621 struct yyguts_t
622 {
623
624 /* User-defined. Not touched by flex. */
625 YY_EXTRA_TYPE yyextra_r;
626
627 /* The rest are the same as the globals declared in the non-reentrant scanner. */
628 FILE *yyin_r, *yyout_r;
629 size_t yy_buffer_stack_top; /**< index of top of stack. */
630 size_t yy_buffer_stack_max; /**< capacity of stack. */
631 YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */
632 char yy_hold_char;
633 int yy_n_chars;
634 int yyleng_r;
635 char *yy_c_buf_p;
636 int yy_init;
637 int yy_start;
638 int yy_did_buffer_switch_on_eof;
639 int yy_start_stack_ptr;
640 int yy_start_stack_depth;
641 int *yy_start_stack;
642 yy_state_type yy_last_accepting_state;
643 char* yy_last_accepting_cpos;
644
645 int yylineno_r;
646 int yy_flex_debug_r;
647
648 char *yytext_r;
649 int yy_more_flag;
650 int yy_more_len;
651
652 YYSTYPE * yylval_r;
653
654 YYLTYPE * yylloc_r;
655
656 }; /* end struct yyguts_t */
657
658 static int yy_init_globals (yyscan_t yyscanner );
659
660 /* This must go here because YYSTYPE and YYLTYPE are included
661 * from bison output in section 1.*/
662 # define yylval yyg->yylval_r
663
664 # define yylloc yyg->yylloc_r
665
666 int ast_yylex_init (yyscan_t* scanner);
667
668 int ast_yylex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner);
669
670 /* Accessor methods to globals.
671 These are made visible to non-reentrant scanners for convenience. */
672
673 int ast_yylex_destroy (yyscan_t yyscanner );
674
675 int ast_yyget_debug (yyscan_t yyscanner );
676
677 void ast_yyset_debug (int debug_flag ,yyscan_t yyscanner );
678
679 YY_EXTRA_TYPE ast_yyget_extra (yyscan_t yyscanner );
680
681 void ast_yyset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner );
682
683 FILE *ast_yyget_in (yyscan_t yyscanner );
684
685 void ast_yyset_in (FILE * in_str ,yyscan_t yyscanner );
686
687 FILE *ast_yyget_out (yyscan_t yyscanner );
688
689 void ast_yyset_out (FILE * out_str ,yyscan_t yyscanner );
690
691 int ast_yyget_leng (yyscan_t yyscanner );
692
693 char *ast_yyget_text (yyscan_t yyscanner );
694
695 int ast_yyget_lineno (yyscan_t yyscanner );
696
697 void ast_yyset_lineno (int line_number ,yyscan_t yyscanner );
698
699 YYSTYPE * ast_yyget_lval (yyscan_t yyscanner );
700
701 void ast_yyset_lval (YYSTYPE * yylval_param ,yyscan_t yyscanner );
702
703 YYLTYPE *ast_yyget_lloc (yyscan_t yyscanner );
704
705 void ast_yyset_lloc (YYLTYPE * yylloc_param ,yyscan_t yyscanner );
706
707 /* Macros after this point can all be overridden by user definitions in
708 * section 1.
709 */
710
711 #ifndef YY_SKIP_YYWRAP
712 #ifdef __cplusplus
713 extern "C" int ast_yywrap (yyscan_t yyscanner );
714 #else
715 extern int ast_yywrap (yyscan_t yyscanner );
716 #endif
717 #endif
718
719 static void yyunput (int c,char *buf_ptr ,yyscan_t yyscanner);
720
721 #ifndef yytext_ptr
722 static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner);
723 #endif
724
725 #ifdef YY_NEED_STRLEN
726 static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner);
727 #endif
728
729 #ifndef YY_NO_INPUT
730
731 #ifdef __cplusplus
732 static int yyinput (yyscan_t yyscanner );
733 #else
734 static int input (yyscan_t yyscanner );
735 #endif
736
737 #endif
738
739 /* Amount of stuff to slurp up with each read. */
740 #ifndef YY_READ_BUF_SIZE
741 #define YY_READ_BUF_SIZE 8192
742 #endif
743
744 /* Copy whatever the last rule matched to the standard output. */
745 #ifndef ECHO
746 /* This used to be an fputs(), but since the string might contain NUL's,
747 * we now use fwrite().
748 */
749 #define ECHO fwrite( yytext, yyleng, 1, yyout )
750 #endif
751
752 /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
753 * is returned in "result".
754 */
755 #ifndef YY_INPUT
756 #define YY_INPUT(buf,result,max_size) \
757 if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
758 { \
759 int c = '*'; \
760 int n; \
761 for ( n = 0; n < max_size && \
762 (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
763 buf[n] = (char) c; \
764 if ( c == '\n' ) \
765 buf[n++] = (char) c; \
766 if ( c == EOF && ferror( yyin ) ) \
767 YY_FATAL_ERROR( "input in flex scanner failed" ); \
768 result = n; \
769 } \
770 else \
771 { \
772 errno=0; \
773 while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
774 { \
775 if( errno != EINTR) \
776 { \
777 YY_FATAL_ERROR( "input in flex scanner failed" ); \
778 break; \
779 } \
780 errno=0; \
781 clearerr(yyin); \
782 } \
783 }\
784 \
785
786 #endif
787
788 /* No semi-colon after return; correct usage is to write "yyterminate();" -
789 * we don't want an extra ';' after the "return" because that will cause
790 * some compilers to complain about unreachable statements.
791 */
792 #ifndef yyterminate
793 #define yyterminate() return YY_NULL
794 #endif
795
796 /* Number of entries by which start-condition stack grows. */
797 #ifndef YY_START_STACK_INCR
798 #define YY_START_STACK_INCR 25
799 #endif
800
801 /* Report a fatal error. */
802 #ifndef YY_FATAL_ERROR
803 #define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner)
804 #endif
805
806 /* end tables serialization structures and prototypes */
807
808 /* Default declaration of generated scanner - a define so the user can
809 * easily add parameters.
810 */
811 #ifndef YY_DECL
812 #define YY_DECL_IS_OURS 1
813
814 extern int ast_yylex \
815 (YYSTYPE * yylval_param,YYLTYPE * yylloc_param ,yyscan_t yyscanner);
816
817 #define YY_DECL int ast_yylex \
818 (YYSTYPE * yylval_param, YYLTYPE * yylloc_param , yyscan_t yyscanner)
819 #endif /* !YY_DECL */
820
821 /* Code executed at the beginning of each rule, after yytext and yyleng
822 * have been set up.
823 */
824 #ifndef YY_USER_ACTION
825 #define YY_USER_ACTION
826 #endif
827
828 /* Code executed at the end of each rule. */
829 #ifndef YY_BREAK
830 #define YY_BREAK break;
831 #endif
832
833 #define YY_RULE_SETUP \
834 YY_USER_ACTION
835
836 /** The main scanner function which does all the work.
837 */
838 YY_DECL
839 {
840 register yy_state_type yy_current_state;
841 register char *yy_cp, *yy_bp;
842 register int yy_act;
843 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
844
845 #line 128 "ast_expr2.fl"
846
847
848 #line 846 "ast_expr2f.c"
849
850 yylval = yylval_param;
851
852 yylloc = yylloc_param;
853
854 if ( !yyg->yy_init )
855 {
856 yyg->yy_init = 1;
857
858 #ifdef YY_USER_INIT
859 YY_USER_INIT;
860 #endif
861
862 if ( ! yyg->yy_start )
863 yyg->yy_start = 1; /* first start state */
864
865 if ( ! yyin )
866 yyin = stdin;
867
868 if ( ! yyout )
869 yyout = stdout;
870
871 if ( ! YY_CURRENT_BUFFER ) {
872 ast_yyensure_buffer_stack (yyscanner);
873 YY_CURRENT_BUFFER_LVALUE =
874 ast_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner);
875 }
876
877 ast_yy_load_buffer_state(yyscanner );
878 }
879
880 while ( 1 ) /* loops until end-of-file is reached */
881 {
882 yyg->yy_more_len = 0;
883 if ( yyg->yy_more_flag )
884 {
885 yyg->yy_more_len = yyg->yy_c_buf_p - yyg->yytext_ptr;
886 yyg->yy_more_flag = 0;
887 }
888 yy_cp = yyg->yy_c_buf_p;
889
890 /* Support of yytext. */
891 *yy_cp = yyg->yy_hold_char;
892
893 /* yy_bp points to the position in yy_ch_buf of the start of
894 * the current run.
895 */
896 yy_bp = yy_cp;
897
898 yy_current_state = yyg->yy_start;
899 yy_match:
900 do
901 {
902 register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
903 if ( yy_accept[yy_current_state] )
904 {
905 yyg->yy_last_accepting_state = yy_current_state;
906 yyg->yy_last_accepting_cpos = yy_cp;
907 }
908 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
909 {
910 yy_current_state = (int) yy_def[yy_current_state];
911 if ( yy_current_state >= 63 )
912 yy_c = yy_meta[(unsigned int) yy_c];
913 }
914 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
915 ++yy_cp;
916 }
917 while ( yy_current_state != 62 );
918 yy_cp = yyg->yy_last_accepting_cpos;
919 yy_current_state = yyg->yy_last_accepting_state;
920
921 yy_find_action:
922 yy_act = yy_accept[yy_current_state];
923
924 YY_DO_BEFORE_ACTION;
925
926 do_action: /* This label is used only to access EOF actions. */
927
928 switch ( yy_act )
929 { /* beginning of action switch */
930 case 0: /* must back up */
931 /* undo the effects of YY_DO_BEFORE_ACTION */
932 *yy_cp = yyg->yy_hold_char;
933 yy_cp = yyg->yy_last_accepting_cpos;
934 yy_current_state = yyg->yy_last_accepting_state;
935 goto yy_find_action;
936
937 case 1:
938 YY_RULE_SETUP
939 #line 130 "ast_expr2.fl"
940 { SET_COLUMNS; SET_STRING; return TOK_OR;}
941 YY_BREAK
942 case 2:
943 YY_RULE_SETUP
944 #line 131 "ast_expr2.fl"
945 { SET_COLUMNS; SET_STRING; return TOK_AND;}
946 YY_BREAK
947 case 3:
948 YY_RULE_SETUP
949 #line 132 "ast_expr2.fl"
950 { SET_COLUMNS; SET_STRING; return TOK_EQ;}
951 YY_BREAK
952 case 4:
953 YY_RULE_SETUP
954 #line 133 "ast_expr2.fl"
955 { SET_COLUMNS; SET_STRING; return TOK_OR;}
956 YY_BREAK
957 case 5:
958 YY_RULE_SETUP
959 #line 134 "ast_expr2.fl"
960 { SET_COLUMNS; SET_STRING; return TOK_AND;}
961 YY_BREAK
962 case 6:
963 YY_RULE_SETUP
964 #line 135 "ast_expr2.fl"
965 { SET_COLUMNS; SET_STRING; return TOK_EQ;}
966 YY_BREAK
967 case 7:
968 YY_RULE_SETUP
969 #line 136 "ast_expr2.fl"
970 { SET_COLUMNS; SET_STRING; return TOK_EQTILDE;}
971 YY_BREAK
972 case 8:
973 YY_RULE_SETUP
974 #line 137 "ast_expr2.fl"
975 { SET_COLUMNS; SET_STRING; return TOK_TILDETILDE;}
976 YY_BREAK
977 case 9:
978 YY_RULE_SETUP
979 #line 138 "ast_expr2.fl"
980 { SET_COLUMNS; SET_STRING; return TOK_GT;}
981 YY_BREAK
982 case 10:
983 YY_RULE_SETUP
984 #line 139 "ast_expr2.fl"
985 { SET_COLUMNS; SET_STRING; return TOK_LT;}
986 YY_BREAK
987 case 11:
988 YY_RULE_SETUP
989 #line 140 "ast_expr2.fl"
990 { SET_COLUMNS; SET_STRING; return TOK_GE;}
991 YY_BREAK
992 case 12:
993 YY_RULE_SETUP
994 #line 141 "ast_expr2.fl"
995 { SET_COLUMNS; SET_STRING; return TOK_LE;}
996 YY_BREAK
997 case 13:
998 YY_RULE_SETUP
999 #line 142 "ast_expr2.fl"
1000 { SET_COLUMNS; SET_STRING; return TOK_NE;}
1001 YY_BREAK
1002 case 14:
1003 YY_RULE_SETUP
1004 #line 143 "ast_expr2.fl"
1005 { SET_COLUMNS; SET_STRING; return TOK_PLUS;}
1006 YY_BREAK
1007 case 15:
1008 YY_RULE_SETUP
1009 #line 144 "ast_expr2.fl"
1010 { SET_COLUMNS; SET_STRING; return TOK_COMMA;}
1011 YY_BREAK
1012 case 16:
1013 YY_RULE_SETUP
1014 #line 145 "ast_expr2.fl"
1015 { SET_COLUMNS; SET_STRING; return TOK_MINUS;}
1016 YY_BREAK
1017 case 17:
1018 YY_RULE_SETUP
1019 #line 146 "ast_expr2.fl"
1020 { SET_COLUMNS; SET_STRING; return TOK_MULT;}
1021 YY_BREAK
1022 case 18:
1023 YY_RULE_SETUP
1024 #line 147 "ast_expr2.fl"
1025 { SET_COLUMNS; SET_STRING; return TOK_DIV;}
1026 YY_BREAK
1027 case 19:
1028 YY_RULE_SETUP
1029 #line 148 "ast_expr2.fl"
1030 { SET_COLUMNS; SET_STRING; return TOK_MOD;}
1031 YY_BREAK
1032 case 20:
1033 YY_RULE_SETUP
1034 #line 149 "ast_expr2.fl"
1035 { SET_COLUMNS; SET_STRING; return TOK_COND;}
1036 YY_BREAK
1037 case 21:
1038 YY_RULE_SETUP
1039 #line 150 "ast_expr2.fl"
1040 { SET_COLUMNS; SET_STRING; return TOK_COMPL;}
1041 YY_BREAK
1042 case 22:
1043 YY_RULE_SETUP
1044 #line 151 "ast_expr2.fl"
1045 { SET_COLUMNS; SET_STRING; return TOK_COLON;}
1046 YY_BREAK
1047 case 23:
1048 YY_RULE_SETUP
1049 #line 152 "ast_expr2.fl"
1050 { SET_COLUMNS; SET_STRING; return TOK_COLONCOLON;}
1051 YY_BREAK
1052 case 24:
1053 YY_RULE_SETUP
1054 #line 153 "ast_expr2.fl"
1055 { SET_COLUMNS; SET_STRING; return TOK_LP;}
1056 YY_BREAK
1057 case 25:
1058 YY_RULE_SETUP
1059 #line 154 "ast_expr2.fl"
1060 { SET_COLUMNS; SET_STRING; return TOK_RP;}
1061 YY_BREAK
1062 case 26:
1063 YY_RULE_SETUP
1064 #line 155 "ast_expr2.fl"
1065 {
1066 /* gather the contents of ${} expressions, with trailing stuff,
1067 * into a single TOKEN.
1068 * They are much more complex now than they used to be
1069 */
1070 curlycount = 0;
1071 BEGIN(var);
1072 yymore();
1073 }
1074 YY_BREAK
1075 case 27:
1076 YY_RULE_SETUP
1077 #line 165 "ast_expr2.fl"
1078 {}
1079 YY_BREAK
1080 case 28:
1081 /* rule 28 can match eol */
1082 YY_RULE_SETUP
1083 #line 166 "ast_expr2.fl"
1084 {SET_COLUMNS; SET_STRING; return TOKEN;}
1085 YY_BREAK
1086 case 29:
1087 /* rule 29 can match eol */
1088 YY_RULE_SETUP
1089 #line 168 "ast_expr2.fl"
1090 {/* what to do with eol */}
1091 YY_BREAK
1092 case 30:
1093 YY_RULE_SETUP
1094 #line 169 "ast_expr2.fl"
1095 {
1096 SET_COLUMNS;
1097 /* the original behavior of the expression parser was
1098 * to bring in numbers as a numeric string
1099 */
1100 SET_NUMERIC_STRING;
1101 return TOKEN;
1102 }
1103 YY_BREAK
1104 case 31:
1105 /* rule 31 can match eol */
1106 YY_RULE_SETUP
1107 #line 178 "ast_expr2.fl"
1108 {
1109 SET_COLUMNS;
1110 SET_STRING;
1111 return TOKEN;
1112 }
1113 YY_BREAK
1114 case 32:
1115 /* rule 32 can match eol */
1116 YY_RULE_SETUP
1117 #line 184 "ast_expr2.fl"
1118 {
1119 curlycount = 0;
1120 BEGIN(var);
1121 yymore();
1122 }
1123 YY_BREAK
1124 case 33:
1125 /* rule 33 can match eol */
1126 YY_RULE_SETUP
1127 #line 190 "ast_expr2.fl"
1128 {
1129 curlycount--;
1130 if (curlycount < 0) {
1131 BEGIN(trail);
1132 yymore();
1133 } else {
1134 yymore();
1135 }
1136 }
1137 YY_BREAK
1138 case 34:
1139 /* rule 34 can match eol */
1140 YY_RULE_SETUP
1141 #line 200 "ast_expr2.fl"
1142 {
1143 curlycount++;
1144 yymore();
1145 }
1146 YY_BREAK
1147 case 35:
1148 YY_RULE_SETUP
1149 #line 206 "ast_expr2.fl"
1150 {
1151 BEGIN(0);
1152 SET_COLUMNS;
1153 SET_STRING;
1154 return TOKEN;
1155 }
1156 YY_BREAK
1157 case 36:
1158 YY_RULE_SETUP
1159 #line 213 "ast_expr2.fl"
1160 {
1161 curlycount = 0;
1162 BEGIN(var);
1163 yymore();
1164 }
1165 YY_BREAK
1166 case 37:
1167 /* rule 37 can match eol */
1168 YY_RULE_SETUP
1169 #line 219 "ast_expr2.fl"
1170 {
1171 char c = yytext[yyleng-1];
1172 BEGIN(0);
1173 unput(c);
1174 SET_COLUMNS;
1175 SET_STRING;
1176 return TOKEN;
1177 }
1178 YY_BREAK
1179 case YY_STATE_EOF(trail):
1180 #line 228 "ast_expr2.fl"
1181 {
1182 BEGIN(0);
1183 SET_COLUMNS;
1184 SET_STRING;
1185 return TOKEN;
1186 /*actually, if an expr is only a variable ref, this could happen a LOT */
1187 }
1188 YY_BREAK
1189 case 38:
1190 YY_RULE_SETUP
1191 #line 236 "ast_expr2.fl"
1192 ECHO;
1193 YY_BREAK
1194 #line 1192 "ast_expr2f.c"
1195 case YY_STATE_EOF(INITIAL):
1196 case YY_STATE_EOF(var):
1197 yyterminate();
1198
1199 case YY_END_OF_BUFFER:
1200 {
1201 /* Amount of text matched not including the EOB char. */
1202 int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1;
1203
1204 /* Undo the effects of YY_DO_BEFORE_ACTION. */
1205 *yy_cp = yyg->yy_hold_char;
1206 YY_RESTORE_YY_MORE_OFFSET
1207
1208 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
1209 {
1210 /* We're scanning a new file or input source. It's
1211 * possible that this happened because the user
1212 * just pointed yyin at a new source and called
1213 * ast_yylex(). If so, then we have to assure
1214 * consistency between YY_CURRENT_BUFFER and our
1215 * globals. Here is the right place to do so, because
1216 * this is the first action (other than possibly a
1217 * back-up) that will match for the new input source.
1218 */
1219 yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1220 YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
1221 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
1222 }
1223
1224 /* Note that here we test for yy_c_buf_p "<=" to the position
1225 * of the first EOB in the buffer, since yy_c_buf_p will
1226 * already have been incremented past the NUL character
1227 * (since all states make transitions on EOB to the
1228 * end-of-buffer state). Contrast this with the test
1229 * in input().
1230 */
1231 if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
1232 { /* This was really a NUL. */
1233 yy_state_type yy_next_state;
1234
1235 yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text;
1236
1237 yy_current_state = yy_get_previous_state( yyscanner );
1238
1239 /* Okay, we're now positioned to make the NUL
1240 * transition. We couldn't have
1241 * yy_get_previous_state() go ahead and do it
1242 * for us because it doesn't know how to deal
1243 * with the possibility of jamming (and we don't
1244 * want to build jamming into it because then it
1245 * will run more slowly).
1246 */
1247
1248 yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner);
1249
1250 yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
1251
1252 if ( yy_next_state )
1253 {
1254 /* Consume the NUL. */
1255 yy_cp = ++yyg->yy_c_buf_p;
1256 yy_current_state = yy_next_state;
1257 goto yy_match;
1258 }
1259
1260 else
1261 {
1262 yy_cp = yyg->yy_last_accepting_cpos;
1263 yy_current_state = yyg->yy_last_accepting_state;
1264 goto yy_find_action;
1265 }
1266 }
1267
1268 else switch ( yy_get_next_buffer( yyscanner ) )
1269 {
1270 case EOB_ACT_END_OF_FILE:
1271 {
1272 yyg->yy_did_buffer_switch_on_eof = 0;
1273
1274 if ( ast_yywrap(yyscanner ) )
1275 {
1276 /* Note: because we've taken care in
1277 * yy_get_next_buffer() to have set up
1278 * yytext, we can now set up
1279 * yy_c_buf_p so that if some total
1280 * hoser (like flex itself) wants to
1281 * call the scanner after we return the
1282 * YY_NULL, it'll still work - another
1283 * YY_NULL will get returned.
1284 */
1285 yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ;
1286
1287 yy_act = YY_STATE_EOF(YY_START);
1288 goto do_action;
1289 }
1290
1291 else
1292 {
1293 if ( ! yyg->yy_did_buffer_switch_on_eof )
1294 YY_NEW_FILE;
1295 }
1296 break;
1297 }
1298
1299 case EOB_ACT_CONTINUE_SCAN:
1300 yyg->yy_c_buf_p =
1301 yyg->yytext_ptr + yy_amount_of_matched_text;
1302
1303 yy_current_state = yy_get_previous_state( yyscanner );
1304
1305 yy_cp = yyg->yy_c_buf_p;
1306 yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
1307 goto yy_match;
1308
1309 case EOB_ACT_LAST_MATCH:
1310 yyg->yy_c_buf_p =
1311 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars];
1312
1313 yy_current_state = yy_get_previous_state( yyscanner );
1314
1315 yy_cp = yyg->yy_c_buf_p;
1316 yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
1317 goto yy_find_action;
1318 }
1319 break;
1320 }
1321
1322 default:
1323 YY_FATAL_ERROR(
1324 "fatal flex scanner internal error--no action found" );
1325 } /* end of action switch */
1326 } /* end of scanning one token */
1327 } /* end of ast_yylex */
1328
1329 /* yy_get_next_buffer - try to read in a new buffer
1330 *
1331 * Returns a code representing an action:
1332 * EOB_ACT_LAST_MATCH -
1333 * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1334 * EOB_ACT_END_OF_FILE - end of file
1335 */
1336 static int yy_get_next_buffer (yyscan_t yyscanner)
1337 {
1338 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1339 register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
1340 register char *source = yyg->yytext_ptr;
1341 register int number_to_move, i;
1342 int ret_val;
1343
1344 if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] )
1345 YY_FATAL_ERROR(
1346 "fatal flex scanner internal error--end of buffer missed" );
1347
1348 if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
1349 { /* Don't try to fill the buffer, so this is an EOF. */
1350 if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 )
1351 {
1352 /* We matched a single character, the EOB, so
1353 * treat this as a final EOF.
1354 */
1355 return EOB_ACT_END_OF_FILE;
1356 }
1357
1358 else
1359 {
1360 /* We matched some text prior to the EOB, first
1361 * process it.
1362 */
1363 return EOB_ACT_LAST_MATCH;
1364 }
1365 }
1366
1367 /* Try to read more data. */
1368
1369 /* First move last chars to start of buffer. */
1370 number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr) - 1;
1371
1372 for ( i = 0; i < number_to_move; ++i )
1373 *(dest++) = *(source++);
1374
1375 if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
1376 /* don't do the read, it's not guaranteed to return an EOF,
1377 * just force an EOF
1378 */
1379 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0;
1380
1381 else
1382 {
1383 int num_to_read =
1384 YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
1385
1386 while ( num_to_read <= 0 )
1387 { /* Not enough room in the buffer - grow it. */
1388
1389 /* just a shorter name for the current buffer */
1390 YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
1391
1392 int yy_c_buf_p_offset =
1393 (int) (yyg->yy_c_buf_p - b->yy_ch_buf);
1394
1395 if ( b->yy_is_our_buffer )
1396 {
1397 int new_size = b->yy_buf_size * 2;
1398
1399 if ( new_size <= 0 )
1400 b->yy_buf_size += b->yy_buf_size / 8;
1401 else
1402 b->yy_buf_size *= 2;
1403
1404 b->yy_ch_buf = (char *)
1405 /* Include room in for 2 EOB chars. */
1406 ast_yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ,yyscanner );
1407 }
1408 else
1409 /* Can't grow it, we don't own it. */
1410 b->yy_ch_buf = 0;
1411
1412 if ( ! b->yy_ch_buf )
1413 YY_FATAL_ERROR(
1414 "fatal error - scanner input buffer overflow" );
1415
1416 yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
1417
1418 num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
1419 number_to_move - 1;
1420
1421 }
1422
1423 if ( num_to_read > YY_READ_BUF_SIZE )
1424 num_to_read = YY_READ_BUF_SIZE;
1425
1426 /* Read in more data. */
1427 YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
1428 yyg->yy_n_chars, (size_t) num_to_read );
1429
1430 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
1431 }
1432
1433 if ( yyg->yy_n_chars == 0 )
1434 {
1435 if ( number_to_move == YY_MORE_ADJ )
1436 {
1437 ret_val = EOB_ACT_END_OF_FILE;
1438 ast_yyrestart(yyin ,yyscanner);
1439 }
1440
1441 else
1442 {
1443 ret_val = EOB_ACT_LAST_MATCH;
1444 YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
1445 YY_BUFFER_EOF_PENDING;
1446 }
1447 }
1448
1449 else
1450 ret_val = EOB_ACT_CONTINUE_SCAN;
1451
1452 if ((yy_size_t) (yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
1453 /* Extend the array by 50%, plus the number we really need. */
1454 yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1);
1455 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) ast_yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner );
1456 if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1457 YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
1458 }
1459
1460 yyg->yy_n_chars += number_to_move;
1461 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR;
1462 YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
1463
1464 yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
1465
1466 return ret_val;
1467 }
1468
1469 /* yy_get_previous_state - get the state just before the EOB char was reached */
1470
1471 static yy_state_type yy_get_previous_state (yyscan_t yyscanner)
1472 {
1473 register yy_state_type yy_current_state;
1474 register char *yy_cp;
1475 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1476
1477 yy_current_state = yyg->yy_start;
1478
1479 for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp )
1480 {
1481 register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1482 if ( yy_accept[yy_current_state] )
1483 {
1484 yyg->yy_last_accepting_state = yy_current_state;
1485 yyg->yy_last_accepting_cpos = yy_cp;
1486 }
1487 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1488 {
1489 yy_current_state = (int) yy_def[yy_current_state];
1490 if ( yy_current_state >= 63 )
1491 yy_c = yy_meta[(unsigned int) yy_c];
1492 }
1493 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1494 }
1495
1496 return yy_current_state;
1497 }
1498
1499 /* yy_try_NUL_trans - try to make a transition on the NUL character
1500 *
1501 * synopsis
1502 * next_state = yy_try_NUL_trans( current_state );
1503 */
1504 static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner)
1505 {
1506 register int yy_is_jam;
1507 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */
1508 register char *yy_cp = yyg->yy_c_buf_p;
1509
1510 register YY_CHAR yy_c = 1;
1511 if ( yy_accept[yy_current_state] )
1512 {
1513 yyg->yy_last_accepting_state = yy_current_state;
1514 yyg->yy_last_accepting_cpos = yy_cp;
1515 }
1516 while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1517 {
1518 yy_current_state = (int) yy_def[yy_current_state];
1519 if ( yy_current_state >= 63 )
1520 yy_c = yy_meta[(unsigned int) yy_c];
1521 }
1522 yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1523 yy_is_jam = (yy_current_state == 62);
1524
1525 return yy_is_jam ? 0 : yy_current_state;
1526 }
1527
1528 static void yyunput (int c, register char * yy_bp , yyscan_t yyscanner)
1529 {
1530 register char *yy_cp;
1531 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1532
1533 yy_cp = yyg->yy_c_buf_p;
1534
1535 /* undo effects of setting up yytext */
1536 *yy_cp = yyg->yy_hold_char;
1537
1538 if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
1539 { /* need to shift things up to make room */
1540 /* +2 for EOB chars. */
1541 register int number_to_move = yyg->yy_n_chars + 2;
1542 register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
1543 YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
1544 register char *source =
1545 &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
1546
1547 while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1548 *--dest = *--source;
1549
1550 yy_cp += (int) (dest - source);
1551 yy_bp += (int) (dest - source);
1552 YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
1553 yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
1554
1555 if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
1556 YY_FATAL_ERROR( "flex scanner push-back overflow" );
1557 }
1558
1559 *--yy_cp = (char) c;
1560
1561 yyg->yytext_ptr = yy_bp;
1562 yyg->yy_hold_char = *yy_cp;
1563 yyg->yy_c_buf_p = yy_cp;
1564 }
1565
1566 #ifndef YY_NO_INPUT
1567 #ifdef __cplusplus
1568 static int yyinput (yyscan_t yyscanner)
1569 #else
1570 static int input (yyscan_t yyscanner)
1571 #endif
1572
1573 {
1574 int c;
1575 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1576
1577 *yyg->yy_c_buf_p = yyg->yy_hold_char;
1578
1579 if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
1580 {
1581 /* yy_c_buf_p now points to the character we want to return.
1582 * If this occurs *before* the EOB characters, then it's a
1583 * valid NUL; if not, then we've hit the end of the buffer.
1584 */
1585 if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
1586 /* This was really a NUL. */
1587 *yyg->yy_c_buf_p = '\0';
1588
1589 else
1590 { /* need more input */
1591 int offset = yyg->yy_c_buf_p - yyg->yytext_ptr;
1592 ++yyg->yy_c_buf_p;
1593
1594 switch ( yy_get_next_buffer( yyscanner ) )
1595 {
1596 case EOB_ACT_LAST_MATCH:
1597 /* This happens because yy_g_n_b()
1598 * sees that we've accumulated a
1599 * token and flags that we need to
1600 * try matching the token before
1601 * proceeding. But for input(),
1602 * there's no matching to consider.
1603 * So convert the EOB_ACT_LAST_MATCH
1604 * to EOB_ACT_END_OF_FILE.
1605 */
1606
1607 /* Reset buffer status. */
1608 ast_yyrestart(yyin ,yyscanner);
1609
1610 /*FALLTHROUGH*/
1611
1612 case EOB_ACT_END_OF_FILE:
1613 {
1614 if ( ast_yywrap(yyscanner ) )
1615 return EOF;
1616
1617 if ( ! yyg->yy_did_buffer_switch_on_eof )
1618 YY_NEW_FILE;
1619 #ifdef __cplusplus
1620 return yyinput(yyscanner);
1621 #else
1622 return input(yyscanner);
1623 #endif
1624 }
1625
1626 case EOB_ACT_CONTINUE_SCAN:
1627 yyg->yy_c_buf_p = yyg->yytext_ptr + offset;
1628 break;
1629 }
1630 }
1631 }
1632
1633 c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */
1634 *yyg->yy_c_buf_p = '\0'; /* preserve yytext */
1635 yyg->yy_hold_char = *++yyg->yy_c_buf_p;
1636
1637 return c;
1638 }
1639 #endif /* ifndef YY_NO_INPUT */
1640
1641 /** Immediately switch to a different input stream.
1642 * @param input_file A readable stream.
1643 * @param yyscanner The scanner object.
1644 * @note This function does not reset the start condition to @c INITIAL .
1645 */
1646 void ast_yyrestart (FILE * input_file , yyscan_t yyscanner)
1647 {
1648 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1649
1650 if ( ! YY_CURRENT_BUFFER ){
1651 ast_yyensure_buffer_stack (yyscanner);
1652 YY_CURRENT_BUFFER_LVALUE =
1653 ast_yy_create_buffer(yyin,YY_BUF_SIZE ,yyscanner);
1654 }
1655
1656 ast_yy_init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner);
1657 ast_yy_load_buffer_state(yyscanner );
1658 }
1659
1660 /** Switch to a different input buffer.
1661 * @param new_buffer The new input buffer.
1662 * @param yyscanner The scanner object.
1663 */
1664 void ast_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
1665 {
1666 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1667
1668 /* TODO. We should be able to replace this entire function body
1669 * with
1670 * ast_yypop_buffer_state();
1671 * ast_yypush_buffer_state(new_buffer);
1672 */
1673 ast_yyensure_buffer_stack (yyscanner);
1674 if ( YY_CURRENT_BUFFER == new_buffer )
1675 return;
1676
1677 if ( YY_CURRENT_BUFFER )
1678 {
1679 /* Flush out information for old buffer. */
1680 *yyg->yy_c_buf_p = yyg->yy_hold_char;
1681 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
1682 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
1683 }
1684
1685 YY_CURRENT_BUFFER_LVALUE = new_buffer;
1686 ast_yy_load_buffer_state(yyscanner );
1687
1688 /* We don't actually know whether we did this switch during
1689 * EOF (ast_yywrap()) processing, but the only time this flag
1690 * is looked at is after ast_yywrap() is called, so it's safe
1691 * to go ahead and always set it.
1692 */
1693 yyg->yy_did_buffer_switch_on_eof = 1;
1694 }
1695
1696 static void ast_yy_load_buffer_state (yyscan_t yyscanner)
1697 {
1698 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1699 yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1700 yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
1701 yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
1702 yyg->yy_hold_char = *yyg->yy_c_buf_p;
1703 }
1704
1705 /** Allocate and initialize an input buffer state.
1706 * @param file A readable stream.
1707 * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
1708 * @param yyscanner The scanner object.
1709 * @return the allocated buffer state.
1710 */
1711 YY_BUFFER_STATE ast_yy_create_buffer (FILE * file, int size , yyscan_t yyscanner)
1712 {
1713 YY_BUFFER_STATE b;
1714
1715 b = (YY_BUFFER_STATE) ast_yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner );
1716 if ( ! b )
1717 YY_FATAL_ERROR( "out of dynamic memory in ast_yy_create_buffer()" );
1718
1719 b->yy_buf_size = size;
1720
1721 /* yy_ch_buf has to be 2 characters longer than the size given because
1722 * we need to put in 2 end-of-buffer characters.
1723 */
1724 b->yy_ch_buf = (char *) ast_yyalloc(b->yy_buf_size + 2 ,yyscanner );
1725 if ( ! b->yy_ch_buf )
1726 YY_FATAL_ERROR( "out of dynamic memory in ast_yy_create_buffer()" );
1727
1728 b->yy_is_our_buffer = 1;
1729
1730 ast_yy_init_buffer(b,file ,yyscanner);
1731
1732 return b;
1733 }
1734
1735 /** Destroy the buffer.
1736 * @param b a buffer created with ast_yy_create_buffer()
1737 * @param yyscanner The scanner object.
1738 */
1739 void ast_yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner)
1740 {
1741 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1742
1743 if ( ! b )
1744 return;
1745
1746 if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
1747 YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
1748
1749 if ( b->yy_is_our_buffer )
1750 ast_yyfree((void *) b->yy_ch_buf ,yyscanner );
1751
1752 ast_yyfree((void *) b ,yyscanner );
1753 }
1754
1755 #ifndef __cplusplus
1756 extern int isatty (int );
1757 #endif /* __cplusplus */
1758
1759 /* Initializes or reinitializes a buffer.
1760 * This function is sometimes called more than once on the same buffer,
1761 * such as during a ast_yyrestart() or at EOF.
1762 */
1763 static void ast_yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner)
1764
1765 {
1766 int oerrno = errno;
1767 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1768
1769 ast_yy_flush_buffer(b ,yyscanner);
1770
1771 b->yy_input_file = file;
1772 b->yy_fill_buffer = 1;
1773
1774 /* If b is the current buffer, then ast_yy_init_buffer was _probably_
1775 * called from ast_yyrestart() or through yy_get_next_buffer.
1776 * In that case, we don't want to reset the lineno or column.
1777 */
1778 if (b != YY_CURRENT_BUFFER){
1779 b->yy_bs_lineno = 1;
1780 b->yy_bs_column = 0;
1781 }
1782
1783 b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
1784
1785 errno = oerrno;
1786 }
1787
1788 /** Discard all buffered characters. On the next scan, YY_INPUT will be called.
1789 * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
1790 * @param yyscanner The scanner object.
1791 */
1792 void ast_yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner)
1793 {
1794 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1795 if ( ! b )
1796 return;
1797
1798 b->yy_n_chars = 0;
1799
1800 /* We always need two end-of-buffer characters. The first causes
1801 * a transition to the end-of-buffer state. The second causes
1802 * a jam in that state.
1803 */
1804 b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1805 b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1806
1807 b->yy_buf_pos = &b->yy_ch_buf[0];
1808
1809 b->yy_at_bol = 1;
1810 b->yy_buffer_status = YY_BUFFER_NEW;
1811
1812 if ( b == YY_CURRENT_BUFFER )
1813 ast_yy_load_buffer_state(yyscanner );
1814 }
1815
1816 /** Pushes the new state onto the stack. The new state becomes
1817 * the current state. This function will allocate the stack
1818 * if necessary.
1819 * @param new_buffer The new state.
1820 * @param yyscanner The scanner object.
1821 */
1822 void ast_yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
1823 {
1824 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1825 if (new_buffer == NULL)
1826 return;
1827
1828 ast_yyensure_buffer_stack(yyscanner);
1829
1830 /* This block is copied from ast_yy_switch_to_buffer. */
1831 if ( YY_CURRENT_BUFFER )
1832 {
1833 /* Flush out information for old buffer. */
1834 *yyg->yy_c_buf_p = yyg->yy_hold_char;
1835 YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
1836 YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
1837 }
1838
1839 /* Only push if top exists. Otherwise, replace top. */
1840 if (YY_CURRENT_BUFFER)
1841 yyg->yy_buffer_stack_top++;
1842 YY_CURRENT_BUFFER_LVALUE = new_buffer;
1843
1844 /* copied from ast_yy_switch_to_buffer. */
1845 ast_yy_load_buffer_state(yyscanner );
1846 yyg->yy_did_buffer_switch_on_eof = 1;
1847 }
1848
1849 /** Removes and deletes the top of the stack, if present.
1850 * The next element becomes the new top.
1851 * @param yyscanner The scanner object.
1852 */
1853 void ast_yypop_buffer_state (yyscan_t yyscanner)
1854 {
1855 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1856 if (!YY_CURRENT_BUFFER)
1857 return;
1858
1859 ast_yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner);
1860 YY_CURRENT_BUFFER_LVALUE = NULL;
1861 if (yyg->yy_buffer_stack_top > 0)
1862 --yyg->yy_buffer_stack_top;
1863
1864 if (YY_CURRENT_BUFFER) {
1865 ast_yy_load_buffer_state(yyscanner );
1866 yyg->yy_did_buffer_switch_on_eof = 1;
1867 }
1868 }
1869
1870 /* Allocates the stack if it does not exist.
1871 * Guarantees space for at least one push.
1872 */
1873 static void ast_yyensure_buffer_stack (yyscan_t yyscanner)
1874 {
1875 int num_to_alloc;
1876 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1877
1878 if (!yyg->yy_buffer_stack) {
1879
1880 /* First allocation is just for 2 elements, since we don't know if this
1881 * scanner will even need a stack. We use 2 instead of 1 to avoid an
1882 * immediate realloc on the next call.
1883 */
1884 num_to_alloc = 1;
1885 yyg->yy_buffer_stack = (struct yy_buffer_state**)ast_yyalloc
1886 (num_to_alloc * sizeof(struct yy_buffer_state*)
1887 , yyscanner);
1888 if ( ! yyg->yy_buffer_stack )
1889 YY_FATAL_ERROR( "out of dynamic memory in ast_yyensure_buffer_stack()" );
1890
1891 memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*));
1892
1893 yyg->yy_buffer_stack_max = num_to_alloc;
1894 yyg->yy_buffer_stack_top = 0;
1895 return;
1896 }
1897
1898 if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){
1899
1900 /* Increase the buffer to prepare for a possible push. */
1901 int grow_size = 8 /* arbitrary grow size */;
1902
1903 num_to_alloc = yyg->yy_buffer_stack_max + grow_size;
1904 yyg->yy_buffer_stack = (struct yy_buffer_state**)ast_yyrealloc
1905 (yyg->yy_buffer_stack,
1906 num_to_alloc * sizeof(struct yy_buffer_state*)
1907 , yyscanner);
1908 if ( ! yyg->yy_buffer_stack )
1909 YY_FATAL_ERROR( "out of dynamic memory in ast_yyensure_buffer_stack()" );
1910
1911 /* zero only the new slots.*/
1912 memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*));
1913 yyg->yy_buffer_stack_max = num_to_alloc;
1914 }
1915 }
1916
1917 /** Setup the input buffer state to scan directly from a user-specified character buffer.
1918 * @param base the character buffer
1919 * @param size the size in bytes of the character buffer
1920 * @param yyscanner The scanner object.
1921 * @return the newly allocated buffer state object.
1922 */
1923 YY_BUFFER_STATE ast_yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner)
1924 {
1925 YY_BUFFER_STATE b;
1926
1927 if ( size < 2 ||
1928 base[size-2] != YY_END_OF_BUFFER_CHAR ||
1929 base[size-1] != YY_END_OF_BUFFER_CHAR )
1930 /* They forgot to leave room for the EOB's. */
1931 return 0;
1932
1933 b = (YY_BUFFER_STATE) ast_yyalloc(sizeof( struct yy_buffer_state ) ,yyscanner );
1934 if ( ! b )
1935 YY_FATAL_ERROR( "out of dynamic memory in ast_yy_scan_buffer()" );
1936
1937 b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
1938 b->yy_buf_pos = b->yy_ch_buf = base;
1939 b->yy_is_our_buffer = 0;
1940 b->yy_input_file = 0;
1941 b->yy_n_chars = b->yy_buf_size;
1942 b->yy_is_interactive = 0;
1943 b->yy_at_bol = 1;
1944 b->yy_fill_buffer = 0;
1945 b->yy_buffer_status = YY_BUFFER_NEW;
1946
1947 ast_yy_switch_to_buffer(b ,yyscanner );
1948
1949 return b;
1950 }
1951
1952 /** Setup the input buffer state to scan a string. The next call to ast_yylex() will
1953 * scan from a @e copy of @a str.
1954 * @param yystr a NUL-terminated string to scan
1955 * @param yyscanner The scanner object.
1956 * @return the newly allocated buffer state object.
1957 * @note If you want to scan bytes that may contain NUL values, then use
1958 * ast_yy_scan_bytes() instead.
1959 */
1960 YY_BUFFER_STATE ast_yy_scan_string (yyconst char * yystr , yyscan_t yyscanner)
1961 {
1962
1963 return ast_yy_scan_bytes(yystr,strlen(yystr) ,yyscanner);
1964 }
1965
1966 /** Setup the input buffer state to scan the given bytes. The next call to ast_yylex() will
1967 * scan from a @e copy of @a bytes.
1968 * @param bytes the byte buffer to scan
1969 * @param len the number of bytes in the buffer pointed to by @a bytes.
1970 * @param yyscanner The scanner object.
1971 * @return the newly allocated buffer state object.
1972 */
1973 YY_BUFFER_STATE ast_yy_scan_bytes (yyconst char * yybytes, int _yybytes_len , yyscan_t yyscanner)
1974 {
1975 YY_BUFFER_STATE b;
1976 char *buf;
1977 yy_size_t n;
1978 int i;
1979
1980 /* Get memory for full buffer, including space for trailing EOB's. */
1981 n = _yybytes_len + 2;
1982 buf = (char *) ast_yyalloc(n ,yyscanner );
1983 if ( ! buf )
1984 YY_FATAL_ERROR( "out of dynamic memory in ast_yy_scan_bytes()" );
1985
1986 for ( i = 0; i < _yybytes_len; ++i )
1987 buf[i] = yybytes[i];
1988
1989 buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
1990
1991 b = ast_yy_scan_buffer(buf,n ,yyscanner);
1992 if ( ! b )
1993 YY_FATAL_ERROR( "bad buffer in ast_yy_scan_bytes()" );
1994
1995 /* It's okay to grow etc. this buffer, and we should throw it
1996 * away when we're done.
1997 */
1998 b->yy_is_our_buffer = 1;
1999
2000 return b;
2001 }
2002
2003 #ifndef YY_EXIT_FAILURE
2004 #define YY_EXIT_FAILURE 2
2005 #endif
2006
2007 static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner)
2008 {
2009 (void) fprintf( stderr, "%s\n", msg );
2010 exit( YY_EXIT_FAILURE );
2011 }
2012
2013 /* Redefine yyless() so it works in section 3 code. */
2014
2015 #undef yyless
2016 #define yyless(n) \
2017 do \
2018 { \
2019 /* Undo effects of setting up yytext. */ \
2020 int yyless_macro_arg = (n); \
2021 YY_LESS_LINENO(yyless_macro_arg);\
2022 yytext[yyleng] = yyg->yy_hold_char; \
2023 yyg->yy_c_buf_p = yytext + yyless_macro_arg; \
2024 yyg->yy_hold_char = *yyg->yy_c_buf_p; \
2025 *yyg->yy_c_buf_p = '\0'; \
2026 yyleng = yyless_macro_arg; \
2027 } \
2028 while ( 0 )
2029
2030 /* Accessor methods (get/set functions) to struct members. */
2031
2032 /** Get the user-defined data for this scanner.
2033 * @param yyscanner The scanner object.
2034 */
2035 YY_EXTRA_TYPE ast_yyget_extra (yyscan_t yyscanner)
2036 {
2037 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2038 return yyextra;
2039 }
2040
2041 /** Get the current line number.
2042 * @param yyscanner The scanner object.
2043 */
2044 int ast_yyget_lineno (yyscan_t yyscanner)
2045 {
2046 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2047
2048 if (! YY_CURRENT_BUFFER)
2049 return 0;
2050
2051 return yylineno;
2052 }
2053
2054 /** Get the current column number.
2055 * @param yyscanner The scanner object.
2056 */
2057 int ast_yyget_column (yyscan_t yyscanner)
2058 {
2059 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2060
2061 if (! YY_CURRENT_BUFFER)
2062 return 0;
2063
2064 return yycolumn;
2065 }
2066
2067 /** Get the input stream.
2068 * @param yyscanner The scanner object.
2069 */
2070 FILE *ast_yyget_in (yyscan_t yyscanner)
2071 {
2072 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2073 return yyin;
2074 }
2075
2076 /** Get the output stream.
2077 * @param yyscanner The scanner object.
2078 */
2079 FILE *ast_yyget_out (yyscan_t yyscanner)
2080 {
2081 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2082 return yyout;
2083 }
2084
2085 /** Get the length of the current token.
2086 * @param yyscanner The scanner object.
2087 */
2088 int ast_yyget_leng (yyscan_t yyscanner)
2089 {
2090 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2091 return yyleng;
2092 }
2093
2094 /** Get the current token.
2095 * @param yyscanner The scanner object.
2096 */
2097
2098 char *ast_yyget_text (yyscan_t yyscanner)
2099 {
2100 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2101 return yytext;
2102 }
2103
2104 /** Set the user-defined data. This data is never touched by the scanner.
2105 * @param user_defined The data to be associated with this scanner.
2106 * @param yyscanner The scanner object.
2107 */
2108 void ast_yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner)
2109 {
2110 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2111 yyextra = user_defined ;
2112 }
2113
2114 /** Set the current line number.
2115 * @param line_number
2116 * @param yyscanner The scanner object.
2117 */
2118 void ast_yyset_lineno (int line_number , yyscan_t yyscanner)
2119 {
2120 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2121
2122 /* lineno is only valid if an input buffer exists. */
2123 if (! YY_CURRENT_BUFFER )
2124 yy_fatal_error( "ast_yyset_lineno called with no buffer" , yyscanner);
2125
2126 yylineno = line_number;
2127 }
2128
2129 /** Set the current column.
2130 * @param line_number
2131 * @param yyscanner The scanner object.
2132 */
2133 void ast_yyset_column (int column_no , yyscan_t yyscanner)
2134 {
2135 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2136
2137 /* column is only valid if an input buffer exists. */
2138 if (! YY_CURRENT_BUFFER )
2139 yy_fatal_error( "ast_yyset_column called with no buffer" , yyscanner);
2140
2141 yycolumn = column_no;
2142 }
2143
2144 /** Set the input stream. This does not discard the current
2145 * input buffer.
2146 * @param in_str A readable stream.
2147 * @param yyscanner The scanner object.
2148 * @see ast_yy_switch_to_buffer
2149 */
2150 void ast_yyset_in (FILE * in_str , yyscan_t yyscanner)
2151 {
2152 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2153 yyin = in_str ;
2154 }
2155
2156 void ast_yyset_out (FILE * out_str , yyscan_t yyscanner)
2157 {
2158 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2159 yyout = out_str ;
2160 }
2161
2162 int ast_yyget_debug (yyscan_t yyscanner)
2163 {
2164 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2165 return yy_flex_debug;
2166 }
2167
2168 void ast_yyset_debug (int bdebug , yyscan_t yyscanner)
2169 {
2170 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2171 yy_flex_debug = bdebug ;
2172 }
2173
2174 /* Accessor methods for yylval and yylloc */
2175
2176 YYSTYPE * ast_yyget_lval (yyscan_t yyscanner)
2177 {
2178 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2179 return yylval;
2180 }
2181
2182 void ast_yyset_lval (YYSTYPE * yylval_param , yyscan_t yyscanner)
2183 {
2184 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2185 yylval = yylval_param;
2186 }
2187
2188 YYLTYPE *ast_yyget_lloc (yyscan_t yyscanner)
2189 {
2190 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2191 return yylloc;
2192 }
2193
2194 void ast_yyset_lloc (YYLTYPE * yylloc_param , yyscan_t yyscanner)
2195 {
2196 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2197 yylloc = yylloc_param;
2198 }
2199
2200 /* User-visible API */
2201
2202 /* ast_yylex_init is special because it creates the scanner itself, so it is
2203 * the ONLY reentrant function that doesn't take the scanner as the last argument.
2204 * That's why we explicitly handle the declaration, instead of using our macros.
2205 */
2206
2207 int ast_yylex_init(yyscan_t* ptr_yy_globals)
2208
2209 {
2210 if (ptr_yy_globals == NULL){
2211 errno = EINVAL;
2212 return 1;
2213 }
2214
2215 *ptr_yy_globals = (yyscan_t) ast_yyalloc ( sizeof( struct yyguts_t ), NULL );
2216
2217 if (*ptr_yy_globals == NULL){
2218 errno = ENOMEM;
2219 return 1;
2220 }
2221
2222 /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */
2223 memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
2224
2225 return yy_init_globals ( *ptr_yy_globals );
2226 }
2227
2228 /* ast_yylex_init_extra has the same functionality as ast_yylex_init, but follows the
2229 * convention of taking the scanner as the last argument. Note however, that
2230 * this is a *pointer* to a scanner, as it will be allocated by this call (and
2231 * is the reason, too, why this function also must handle its own declaration).
2232 * The user defined value in the first argument will be available to ast_yyalloc in
2233 * the yyextra field.
2234 */
2235
2236 int ast_yylex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals )
2237
2238 {
2239 struct yyguts_t dummy_yyguts;
2240
2241 ast_yyset_extra (yy_user_defined, &dummy_yyguts);
2242
2243 if (ptr_yy_globals == NULL){
2244 errno = EINVAL;
2245 return 1;
2246 }
2247
2248 *ptr_yy_globals = (yyscan_t) ast_yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts );
2249
2250 if (*ptr_yy_globals == NULL){
2251 errno = ENOMEM;
2252 return 1;
2253 }
2254
2255 /* By setting to 0xAA, we expose bugs in
2256 yy_init_globals. Leave at 0x00 for releases. */
2257 memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
2258
2259 ast_yyset_extra (yy_user_defined, *ptr_yy_globals);
2260
2261 return yy_init_globals ( *ptr_yy_globals );
2262 }
2263
2264 static int yy_init_globals (yyscan_t yyscanner)
2265 {
2266 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2267 /* Initialization is the same as for the non-reentrant scanner.
2268 * This function is called from ast_yylex_destroy(), so don't allocate here.
2269 */
2270
2271 yyg->yy_buffer_stack = 0;
2272 yyg->yy_buffer_stack_top = 0;
2273 yyg->yy_buffer_stack_max = 0;
2274 yyg->yy_c_buf_p = (char *) 0;
2275 yyg->yy_init = 0;
2276 yyg->yy_start = 0;
2277
2278 yyg->yy_start_stack_ptr = 0;
2279 yyg->yy_start_stack_depth = 0;
2280 yyg->yy_start_stack = NULL;
2281
2282 /* Defined in main.c */
2283 #ifdef YY_STDINIT
2284 yyin = stdin;
2285 yyout = stdout;
2286 #else
2287 yyin = (FILE *) 0;
2288 yyout = (FILE *) 0;
2289 #endif
2290
2291 /* For future reference: Set errno on error, since we are called by
2292 * ast_yylex_init()
2293 */
2294 return 0;
2295 }
2296
2297 /* ast_yylex_destroy is for both reentrant and non-reentrant scanners. */
2298 int ast_yylex_destroy (yyscan_t yyscanner)
2299 {
2300 struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2301
2302 /* Pop the buffer stack, destroying each element. */
2303 while(YY_CURRENT_BUFFER){
2304 ast_yy_delete_buffer(YY_CURRENT_BUFFER ,yyscanner );
2305 YY_CURRENT_BUFFER_LVALUE = NULL;
2306 ast_yypop_buffer_state(yyscanner);
2307 }
2308
2309 /* Destroy the stack itself. */
2310 ast_yyfree(yyg->yy_buffer_stack ,yyscanner);
2311 yyg->yy_buffer_stack = NULL;
2312
2313 /* Destroy the start condition stack. */
2314 ast_yyfree(yyg->yy_start_stack ,yyscanner );
2315 yyg->yy_start_stack = NULL;
2316
2317 /* Reset the globals. This is important in a non-reentrant scanner so the next time
2318 * ast_yylex() is called, initialization will occur. */
2319 yy_init_globals( yyscanner);
2320
2321 /* Destroy the main struct (reentrant only). */
2322 ast_yyfree ( yyscanner , yyscanner );
2323 yyscanner = NULL;
2324 return 0;
2325 }
2326
2327 /*
2328 * Internal utility routines.
2329 */
2330
2331 #ifndef yytext_ptr
2332 static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner)
2333 {
2334 register int i;
2335 for ( i = 0; i < n; ++i )
2336 s1[i] = s2[i];
2337 }
2338 #endif
2339
2340 #ifdef YY_NEED_STRLEN
2341 static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner)
2342 {
2343 register int n;
2344 for ( n = 0; s[n]; ++n )
2345 ;
2346
2347 return n;
2348 }
2349 #endif
2350
2351 void *ast_yyalloc (yy_size_t size , yyscan_t yyscanner)
2352 {
2353 return (void *) malloc( size );
2354 }
2355
2356 void *ast_yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner)
2357 {
2358 /* The cast to (char *) in the following accommodates both
2359 * implementations that use char* generic pointers, and those
2360 * that use void* generic pointers. It works with the latter
2361 * because both ANSI C and C++ allow castless assignment from
2362 * any pointer type to void*, and deal with argument conversions
2363 * as though doing an assignment.
2364 */
2365 return (void *) realloc( (char *) ptr, size );
2366 }
2367
2368 #define YYTABLES_NAME "yytables"
2369
2370 #line 236 "ast_expr2.fl"
2371
2372
2373
2374 /* I'm putting the interface routine to the whole parse here in the flexer input file
2375 mainly because of all the flexer initialization that has to be done. Shouldn't matter
2376 where it is, as long as it's somewhere. I didn't want to define a prototype for the
2377 ast_yy_scan_string in the .y file, because then, I'd have to define YY_BUFFER_STATE there...
2378 UGH! that would be inappropriate. */
2379
2380 int ast_yyparse(void *); /* need to/should define this prototype for the call to yyparse */
2381 int ast_yyerror(const char *, YYLTYPE *, struct parse_io *); /* likewise */
2382
2383 void ast_yyfree(void *ptr, yyscan_t yyscanner)
2384 {
2385 /* the normal generated ast_yyfree func just frees its first arg;
2386 this get complaints on some systems, as sometimes this
2387 arg is a nil ptr! It's usually not fatal, but is irritating! */
2388 free( (char *) ptr );
2389 }
2390
2391 int ast_expr(char *expr, char *buf, int length, struct ast_channel *chan)
2392 {
2393 struct parse_io io = { .string = expr, .chan = chan };
2394 int return_value = 0;
2395
2396 ast_yylex_init(&io.scanner);
2397
2398 ast_yy_scan_string(expr, io.scanner);
2399
2400 ast_yyparse ((void *) &io);
2401
2402 ast_yylex_destroy(io.scanner);
2403
2404 if (!io.val) {
2405 if (length > 1) {
2406 strcpy(buf, "0");
2407 return_value = 1;
2408 }
2409 } else {
2410 if (io.val->type == AST_EXPR_number) {
2411 int res_length;
2412
2413 res_length = snprintf(buf, length, FP___PRINTF, io.val->u.i);
2414 return_value = (res_length <= length) ? res_length : length;
2415 } else {
2416 if (io.val->u.s)
2417 #if defined(STANDALONE) || defined(LOW_MEMORY) || defined(STANDALONE)
2418 strncpy(buf, io.val->u.s, length - 1);
2419 #else /* !STANDALONE && !LOW_MEMORY */
2420 ast_copy_string(buf, io.val->u.s, length);
2421 #endif /* STANDALONE || LOW_MEMORY */
2422 else
2423 buf[0] = 0;
2424 return_value = strlen(buf);
2425 free(io.val->u.s);
2426 }
2427 free(io.val);
2428 }
2429 return return_value;
2430 }
2431
2432 #ifndef STANDALONE
2433 int ast_str_expr(struct ast_str **str, ssize_t maxlen, struct ast_channel *chan, char *expr)
2434 {
2435 struct parse_io io = { .string = expr, .chan = chan };
2436
2437 ast_yylex_init(&io.scanner);
2438 ast_yy_scan_string(expr, io.scanner);
2439 ast_yyparse ((void *) &io);
2440 ast_yylex_destroy(io.scanner);
2441
2442 if (!io.val) {
2443 ast_str_set(str, maxlen, "0");
2444 } else {
2445 if (io.val->type == AST_EXPR_number) {
2446 ast_str_set(str, maxlen, FP___PRINTF, io.val->u.i);
2447 } else if (io.val->u.s) {
2448 ast_str_set(str, maxlen, "%s", io.val->u.s);
2449 free(io.val->u.s);
2450 }
2451 free(io.val);
2452 }
2453 return ast_str_strlen(*str);
2454 }
2455 #endif
2456
2457
2458 char extra_error_message[4095];
2459 int extra_error_message_supplied = 0;
2460 void ast_expr_register_extra_error_info(char *message);
2461 void ast_expr_clear_extra_error_info(void);
2462
2463 void ast_expr_register_extra_error_info(char *message)
2464 {
2465 extra_error_message_supplied=1;
2466 strcpy(extra_error_message, message);
2467 }
2468
2469 void ast_expr_clear_extra_error_info(void)
2470 {
2471 extra_error_message_supplied=0;
2472 extra_error_message[0] = 0;
2473 }
2474
2475 static const char * const expr2_token_equivs1[] =
2476 {
2477 "TOKEN",
2478 "TOK_COND",
2479 "TOK_COLONCOLON",
2480 "TOK_OR",
2481 "TOK_AND",
2482 "TOK_EQ",
2483 "TOK_GT",
2484 "TOK_LT",
2485 "TOK_GE",
2486 "TOK_LE",
2487 "TOK_NE",
2488 "TOK_PLUS",
2489 "TOK_MINUS",
2490 "TOK_MULT",
2491 "TOK_DIV",
2492 "TOK_MOD",
2493 "TOK_COMPL",
2494 "TOK_COLON",
2495 "TOK_EQTILDE",
2496 "TOK_COMMA",
2497 "TOK_RP",
2498 "TOK_LP"
2499 };
2500
2501 static const char * const expr2_token_equivs2[] =
2502 {
2503 "<token>",
2504 "?",
2505 "::",
2506 "|",
2507 "&",
2508 "=",
2509 ">",
2510 "<",
2511 ">=",
2512 "<=",
2513 "!=",
2514 "+",
2515 "-",
2516 "*",
2517 "/",
2518 "%",
2519 "!",
2520 ":",
2521 "=~",
2522 ",",
2523 ")",
2524 "("
2525 };
2526
2527
2528 static char *expr2_token_subst(const char *mess)
2529 {
2530 /* calc a length, malloc, fill, and return; yyerror had better free it! */
2531 int len=0,i;
2532 const char *p;
2533 char *res, *s;
2534 const char *t;
2535 int expr2_token_equivs_entries = sizeof(expr2_token_equivs1)/sizeof(char*);
2536
2537 for (p=mess; *p; p++) {
2538 for (i=0; i<expr2_token_equivs_entries; i++) {
2539 if ( strncmp(p,expr2_token_equivs1[i],strlen(expr2_token_equivs1[i])) == 0 )
2540 {
2541 len+=strlen(expr2_token_equivs2[i])+2;
2542 p += strlen(expr2_token_equivs1[i])-1;
2543 break;
2544 }
2545 }
2546 len++;
2547 }
2548 res = (char*)malloc(len+1);
2549 res[0] = 0;
2550 s = res;
2551 for (p=mess; *p;) {
2552 int found = 0;
2553 for (i=0; i<expr2_token_equivs_entries; i++) {
2554 if ( strncmp(p,expr2_token_equivs1[i],strlen(expr2_token_equivs1[i])) == 0 ) {
2555 *s++ = '\'';
2556 for (t=expr2_token_equivs2[i]; *t;) {
2557 *s++ = *t++;
2558 }
2559 *s++ = '\'';
2560 p += strlen(expr2_token_equivs1[i]);
2561 found = 1;
2562 break;
2563 }
2564 }
2565 if( !found )
2566 *s++ = *p++;
2567 }
2568 *s++ = 0;
2569 return res;
2570 }
2571
2572 int ast_yyerror (const char *s, yyltype *loc, struct parse_io *parseio )
2573 {
2574 struct yyguts_t * yyg = (struct yyguts_t*)(parseio->scanner);
2575 char spacebuf[8000]; /* best safe than sorry */
2576 int i=0;
2577 char *s2 = expr2_token_subst(s);
2578 spacebuf[0] = 0;
2579
2580 for (i = 0; i < (int)(yytext - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf); i++) {
2581 spacebuf[i] = ' ';
2582 }
2583 /* uh... assuming yyg is defined, then I can use the yycolumn macro,
2584 which is the same thing as... get this:
2585 yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]->yy_bs_column
2586 I was tempted to just use yy_buf_pos in the STATE, but..., well:
2587 a. the yy_buf_pos is the current position in the buffer, which
2588 may not relate to the entire string/buffer because of the
2589 buffering.
2590 b. but, analysis of the situation is that when you use the
2591 ast_yy_scan_string func, it creates a single buffer the size of
2592 string, so the two would be the same...
2593 so, in the end, the yycolumn macro is available, shorter, therefore easier. */
2594
2595 spacebuf[i++] = '^';
2596 spacebuf[i] = 0;
2597
2598 #ifdef STANDALONE3
2599 /* easier to read in the standalone version */
2600 printf("ast_yyerror(): %s syntax error: %s; Input:\n%s\n%s\n",
2601 (extra_error_message_supplied ? extra_error_message : ""), s2, parseio->string, spacebuf);
2602 #else
2603 ast_log(LOG_WARNING,"ast_yyerror(): %s syntax error: %s; Input:\n%s\n%s\n",
2604 (extra_error_message_supplied ? extra_error_message : ""), s2, parseio->string, spacebuf);
2605 #endif
2606 #ifndef STANDALONE
2607 ast_log(LOG_WARNING,"If you have questions, please refer to https://docs.asterisk.org/Configuration/Dialplan/Variables/Channel-Variables/\n");
2608 #endif
2609 free(s2);
2610 return(0);
2611 }
2612