Asterisk - The Open Source Telephony Project  21.4.1
Data Structures | Macros | Typedefs | Enumerations | Functions | Variables
main/ast_expr2f.c File Reference

Dialplan Expression Lexical Scanner. More...

#include "asterisk.h"
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
#include <sys/types.h>
#include <locale.h>
#include <ctype.h>
#include <regex.h>
#include <limits.h>
#include "asterisk/ast_expr.h"
#include "asterisk/logger.h"
#include "asterisk/strings.h"
#include "asterisk/channel.h"
#include "ast_expr2.h"
#include <unistd.h>

Go to the source code of this file.

Data Structures

struct  parse_io
 
struct  val
 
struct  yy_buffer_state
 
struct  yy_trans_info
 
struct  yyguts_t
 

Macros

#define ast_yywrap(n)   1
 
#define ASTMM_LIBC   ASTMM_REDIRECT
 
#define BEGIN   yyg->yy_start = 1 + 2 *
 
#define ECHO   do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0)
 
#define EOB_ACT_CONTINUE_SCAN   0
 
#define EOB_ACT_END_OF_FILE   1
 
#define EOB_ACT_LAST_MATCH   2
 
#define FLEX_BETA
 
#define FLEX_SCANNER
 
#define FLEXINT_H
 
#define FP___FMOD   fmod
 
#define FP___PRINTF   "%.16g"
 
#define FP___STRTOD   strtod
 
#define FP___TYPE   double
 
#define INITIAL   0
 
#define INT16_MAX   (32767)
 
#define INT16_MIN   (-32767-1)
 
#define INT32_MAX   (2147483647)
 
#define INT32_MIN   (-2147483647-1)
 
#define INT8_MAX   (127)
 
#define INT8_MIN   (-128)
 
#define REJECT   reject_used_but_not_detected
 
#define SET_COLUMNS
 
#define SET_NUMERIC_STRING
 
#define SET_STRING
 
#define trail   2
 
#define UINT16_MAX   (65535U)
 
#define UINT32_MAX   (4294967295U)
 
#define UINT8_MAX   (255U)
 
#define unput(c)   yyunput( c, yyg->yytext_ptr , yyscanner )
 
#define var   1
 
#define YY_AT_BOL()   (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
 
#define YY_BREAK   break;
 
#define YY_BUF_SIZE   16384
 
#define YY_BUFFER_EOF_PENDING   2
 
#define YY_BUFFER_NEW   0
 
#define YY_BUFFER_NORMAL   1
 
#define YY_CURRENT_BUFFER
 
#define YY_CURRENT_BUFFER_LVALUE   yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]
 
#define YY_DECL
 
#define YY_DECL_IS_OURS   1
 
#define YY_DO_BEFORE_ACTION
 
#define YY_END_OF_BUFFER   39
 
#define YY_END_OF_BUFFER_CHAR   0
 
#define YY_EXIT_FAILURE   2
 
#define YY_EXTRA_TYPE   void *
 
#define YY_FATAL_ERROR(msg)   yy_fatal_error( msg , yyscanner)
 
#define yy_flex_debug   yyg->yy_flex_debug_r
 
#define YY_FLEX_MAJOR_VERSION   2
 
#define YY_FLEX_MINOR_VERSION   5
 
#define YY_FLEX_SUBMINOR_VERSION   35
 
#define YY_FLUSH_BUFFER   ast_yy_flush_buffer(YY_CURRENT_BUFFER ,yyscanner)
 
#define YY_INPUT(buf, result, max_size)
 
#define YY_INT_ALIGNED   short int
 
#define YY_LESS_LINENO(n)
 
#define YY_MORE_ADJ   yyg->yy_more_len
 
#define yy_new_buffer   ast_yy_create_buffer
 
#define YY_NEW_FILE   ast_yyrestart(yyin ,yyscanner )
 
#define YY_NULL   0
 
#define YY_NUM_RULES   38
 
#define YY_READ_BUF_SIZE   8192
 
#define YY_RESTORE_YY_MORE_OFFSET
 
#define YY_RULE_SETUP   YY_USER_ACTION
 
#define YY_SC_TO_UI(c)   ((unsigned int) (unsigned char) c)
 
#define yy_set_bol(at_bol)
 
#define yy_set_interactive(is_interactive)
 
#define YY_SKIP_YYWRAP
 
#define YY_START   ((yyg->yy_start - 1) / 2)
 
#define YY_START_STACK_INCR   25
 
#define YY_STATE_BUF_SIZE   ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
 
#define YY_STATE_EOF(state)   (YY_END_OF_BUFFER + state + 1)
 
#define YY_STRUCT_YY_BUFFER_STATE
 
#define YY_TYPEDEF_YY_BUFFER_STATE
 
#define YY_TYPEDEF_YY_SCANNER_T
 
#define YY_TYPEDEF_YY_SIZE_T
 
#define YY_USER_ACTION
 
#define yycolumn   (YY_CURRENT_BUFFER_LVALUE->yy_bs_column)
 
#define yyconst
 
#define yyextra   yyg->yyextra_r
 
#define yyin   yyg->yyin_r
 
#define yyleng   yyg->yyleng_r
 
#define yyless(n)
 
#define yyless(n)
 
#define yylineno   (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno)
 
#define yylloc   yyg->yylloc_r
 
#define yylval   yyg->yylval_r
 
#define yymore()   (yyg->yy_more_flag = 1)
 
#define yyout   yyg->yyout_r
 
#define YYSTATE   YY_START
 
#define YYTABLES_NAME   "yytables"
 
#define yyterminate()   return YY_NULL
 
#define yytext   yyg->yytext_r
 
#define yytext_ptr   yytext_r
 

Typedefs

typedef short int flex_int16_t
 
typedef int flex_int32_t
 
typedef signed char flex_int8_t
 
typedef unsigned short int flex_uint16_t
 
typedef unsigned int flex_uint32_t
 
typedef unsigned char flex_uint8_t
 
typedef struct yy_buffer_stateYY_BUFFER_STATE
 
typedef unsigned char YY_CHAR
 
typedef size_t yy_size_t
 
typedef int yy_state_type
 
typedef void * yyscan_t
 

Enumerations

enum  valtype {
  AST_EXPR_number, AST_EXPR_numeric_string, AST_EXPR_string, AST_EXPR_number,
  AST_EXPR_numeric_string, AST_EXPR_string, AST_EXPR_number, AST_EXPR_numeric_string,
  AST_EXPR_string, AST_EXPR_number, AST_EXPR_numeric_string, AST_EXPR_string
}
 

Functions

int ast_expr (char *expr, char *buf, int length, struct ast_channel *chan)
 Evaluate the given expression. More...
 
void ast_expr_clear_extra_error_info (void)
 
void ast_expr_register_extra_error_info (char *message)
 
int ast_str_expr (struct ast_str **str, ssize_t maxlen, struct ast_channel *chan, char *expr)
 Evaluate the given expression. More...
 
YY_BUFFER_STATE ast_yy_create_buffer (FILE *file, int size, yyscan_t yyscanner)
 
void ast_yy_delete_buffer (YY_BUFFER_STATE b, yyscan_t yyscanner)
 
void ast_yy_flush_buffer (YY_BUFFER_STATE b, yyscan_t yyscanner)
 
static void ast_yy_init_buffer (YY_BUFFER_STATE b, FILE *file, yyscan_t yyscanner)
 
static void ast_yy_load_buffer_state (yyscan_t yyscanner)
 
YY_BUFFER_STATE ast_yy_scan_buffer (char *base, yy_size_t size, yyscan_t yyscanner)
 
YY_BUFFER_STATE ast_yy_scan_bytes (yyconst char *bytes, int len, yyscan_t yyscanner)
 
YY_BUFFER_STATE ast_yy_scan_string (yyconst char *yy_str, yyscan_t yyscanner)
 
void ast_yy_switch_to_buffer (YY_BUFFER_STATE new_buffer, yyscan_t yyscanner)
 
void * ast_yyalloc (yy_size_t, yyscan_t yyscanner)
 
static void ast_yyensure_buffer_stack (yyscan_t yyscanner)
 
int ast_yyerror (const char *, YYLTYPE *, struct parse_io *)
 
int ast_yyerror (const char *s, yyltype *loc, struct parse_io *parseio)
 
void ast_yyfree (void *, yyscan_t yyscanner)
 
int ast_yyget_column (yyscan_t yyscanner)
 
int ast_yyget_debug (yyscan_t yyscanner)
 
YY_EXTRA_TYPE ast_yyget_extra (yyscan_t yyscanner)
 
FILE * ast_yyget_in (yyscan_t yyscanner)
 
int ast_yyget_leng (yyscan_t yyscanner)
 
int ast_yyget_lineno (yyscan_t yyscanner)
 
YYLTYPEast_yyget_lloc (yyscan_t yyscanner)
 
YYSTYPEast_yyget_lval (yyscan_t yyscanner)
 
FILE * ast_yyget_out (yyscan_t yyscanner)
 
char * ast_yyget_text (yyscan_t yyscanner)
 
int ast_yylex (YYSTYPE *yylval_param, YYLTYPE *yylloc_param, yyscan_t yyscanner)
 
int ast_yylex_destroy (yyscan_t yyscanner)
 
int ast_yylex_init (yyscan_t *scanner)
 
int ast_yylex_init_extra (YY_EXTRA_TYPE user_defined, yyscan_t *scanner)
 
int ast_yyparse (void *)
 
void ast_yypop_buffer_state (yyscan_t yyscanner)
 
void ast_yypush_buffer_state (YY_BUFFER_STATE new_buffer, yyscan_t yyscanner)
 
void * ast_yyrealloc (void *, yy_size_t, yyscan_t yyscanner)
 
void ast_yyrestart (FILE *input_file, yyscan_t yyscanner)
 
void ast_yyset_column (int column_no, yyscan_t yyscanner)
 
void ast_yyset_debug (int debug_flag, yyscan_t yyscanner)
 
void ast_yyset_extra (YY_EXTRA_TYPE user_defined, yyscan_t yyscanner)
 
void ast_yyset_in (FILE *in_str, yyscan_t yyscanner)
 
void ast_yyset_lineno (int line_number, yyscan_t yyscanner)
 
void ast_yyset_lloc (YYLTYPE *yylloc_param, yyscan_t yyscanner)
 
void ast_yyset_lval (YYSTYPE *yylval_param, yyscan_t yyscanner)
 
void ast_yyset_out (FILE *out_str, yyscan_t yyscanner)
 
static char * expr2_token_subst (const char *mess)
 
 if (!yyg->yy_init)
 
static int input (yyscan_t yyscanner)
 
int isatty (int)
 
 while (1)
 
static void yy_fatal_error (yyconst char msg[], yyscan_t yyscanner)
 
static void yy_fatal_error (yyconst char *msg, yyscan_t yyscanner)
 
static int yy_get_next_buffer (yyscan_t yyscanner)
 
static yy_state_type yy_get_previous_state (yyscan_t yyscanner)
 
static int yy_init_globals (yyscan_t yyscanner)
 
static yy_state_type yy_try_NUL_trans (yy_state_type current_state, yyscan_t yyscanner)
 
static void yyunput (int c, char *buf_ptr, yyscan_t yyscanner)
 
static void yyunput (int c, register char *yy_bp, yyscan_t yyscanner)
 

Variables

static int curlycount = 0
 
static const char *const expr2_token_equivs1 []
 
static const char *const expr2_token_equivs2 []
 
char extra_error_message [4095]
 
int extra_error_message_supplied = 0
 
static yyconst flex_int16_t yy_accept [63]
 
register int yy_act
 
static yyconst flex_int16_t yy_base [70]
 
register char * yy_bp
 
static yyconst flex_int16_t yy_chk [159]
 
register char * yy_cp
 
 YY_DECL
 
static yyconst flex_int16_t yy_def [70]
 
static yyconst flex_int32_t yy_ec [256]
 
static yyconst flex_int32_t yy_meta [29]
 
static yyconst flex_int16_t yy_nxt [159]
 
struct yyguts_tyyg = (struct yyguts_t*)yyscanner
 
 yylloc = yylloc_param
 
 yylval = yylval_param
 

Detailed Description

Dialplan Expression Lexical Scanner.

Definition in file main/ast_expr2f.c.

Macro Definition Documentation

#define SET_COLUMNS
Value:
do { \
yylloc_param->first_column = (int)(yyg->yytext_r - YY_CURRENT_BUFFER_LVALUE->yy_ch_buf); \
yylloc_param->last_column += yyleng - 1; \
yylloc_param->first_line = yylloc_param->last_line = 1; \
} while (0)

Definition at line 571 of file main/ast_expr2f.c.

#define SET_NUMERIC_STRING
Value:
do { \
yylval_param->val = calloc(1, sizeof(struct val)); \
yylval_param->val->type = AST_EXPR_numeric_string; \
yylval_param->val->u.s = strdup(yytext); \
} while (0)

Definition at line 583 of file main/ast_expr2f.c.

#define SET_STRING
Value:
do { \
yylval_param->val = calloc(1, sizeof(struct val)); \
yylval_param->val->type = AST_EXPR_string; \
yylval_param->val->u.s = strdup(yytext); \
} while (0)

Definition at line 577 of file main/ast_expr2f.c.

#define YY_CURRENT_BUFFER
Value:
: NULL)
YY_BUFFER_STATE * yy_buffer_stack
size_t yy_buffer_stack_top

Definition at line 274 of file main/ast_expr2f.c.

#define YY_DECL
Value:
int ast_yylex \
(YYSTYPE * yylval_param, YYLTYPE * yylloc_param , yyscan_t yyscanner)

Definition at line 817 of file main/ast_expr2f.c.

Function Documentation

int ast_expr ( char *  expr,
char *  buf,
int  length,
struct ast_channel chan 
)

Evaluate the given expression.

Parameters
exprAn expression
bufResult buffer
lengthSize of the result buffer, in bytes
chanChannel to use for evaluating included dialplan functions, if any
Returns
Length of the result string, in bytes

Definition at line 2391 of file main/ast_expr2f.c.

References ast_copy_string(), and ast_yy_scan_string().

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 }
void ast_copy_string(char *dst, const char *src, size_t size)
Size-limited null-terminating string copy.
Definition: strings.h:425
YY_BUFFER_STATE ast_yy_scan_string(yyconst char *yy_str, yyscan_t yyscanner)
int ast_str_expr ( struct ast_str **  str,
ssize_t  maxlen,
struct ast_channel chan,
char *  expr 
)

Evaluate the given expression.

Parameters
strDynamic result buffer
maxlen<0 if the size of the buffer should remain constant, >0 if the size of the buffer should expand to that many bytes, maximum, or 0 for unlimited expansion of the result buffer
chanChannel to use for evaluating included dialplan functions, if any
exprAn expression
Returns
Length of the result string, in bytes

Definition at line 2433 of file main/ast_expr2f.c.

References ast_str_set(), ast_str_strlen(), and ast_yy_scan_string().

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 }
int ast_str_set(struct ast_str **buf, ssize_t max_len, const char *fmt,...)
Set a dynamic string using variable arguments.
Definition: strings.h:1113
size_t ast_str_strlen(const struct ast_str *buf)
Returns the current length of the string stored within buf.
Definition: strings.h:730
YY_BUFFER_STATE ast_yy_scan_string(yyconst char *yy_str, yyscan_t yyscanner)
YY_BUFFER_STATE ast_yy_create_buffer ( FILE *  file,
int  size,
yyscan_t  yyscanner 
)

Allocate and initialize an input buffer state.

Parameters
fileA readable stream.
sizeThe character buffer size in bytes. When in doubt, use YY_BUF_SIZE.
yyscannerThe scanner object.
Returns
the allocated buffer state.

Definition at line 1711 of file main/ast_expr2f.c.

Referenced by ast_yyrestart().

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 }
void ast_yy_delete_buffer ( YY_BUFFER_STATE  b,
yyscan_t  yyscanner 
)

Destroy the buffer.

Parameters
ba buffer created with ast_yy_create_buffer()
yyscannerThe scanner object.

Definition at line 1739 of file main/ast_expr2f.c.

Referenced by ast_yypop_buffer_state().

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 }
void ast_yy_flush_buffer ( YY_BUFFER_STATE  b,
yyscan_t  yyscanner 
)

Discard all buffered characters. On the next scan, YY_INPUT will be called.

Parameters
bthe buffer state to be flushed, usually YY_CURRENT_BUFFER.
yyscannerThe scanner object.

Definition at line 1792 of file main/ast_expr2f.c.

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 }
YY_BUFFER_STATE ast_yy_scan_buffer ( char *  base,
yy_size_t  size,
yyscan_t  yyscanner 
)

Setup the input buffer state to scan directly from a user-specified character buffer.

Parameters
basethe character buffer
sizethe size in bytes of the character buffer
yyscannerThe scanner object.
Returns
the newly allocated buffer state object.

Definition at line 1923 of file main/ast_expr2f.c.

References ast_yy_switch_to_buffer().

Referenced by ast_yy_scan_bytes().

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 }
void ast_yy_switch_to_buffer(YY_BUFFER_STATE new_buffer, yyscan_t yyscanner)
YY_BUFFER_STATE ast_yy_scan_bytes ( yyconst char *  yybytes,
int  _yybytes_len,
yyscan_t  yyscanner 
)

Setup the input buffer state to scan the given bytes. The next call to ast_yylex() will scan from a copy of bytes.

Parameters
bytesthe byte buffer to scan
lenthe number of bytes in the buffer pointed to by bytes.
yyscannerThe scanner object.
Returns
the newly allocated buffer state object.

Definition at line 1973 of file main/ast_expr2f.c.

References ast_yy_scan_buffer().

Referenced by ast_yy_scan_string().

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 }
YY_BUFFER_STATE ast_yy_scan_buffer(char *base, yy_size_t size, yyscan_t yyscanner)
YY_BUFFER_STATE ast_yy_scan_string ( yyconst char *  yystr,
yyscan_t  yyscanner 
)

Setup the input buffer state to scan a string. The next call to ast_yylex() will scan from a copy of str.

Parameters
yystra NUL-terminated string to scan
yyscannerThe scanner object.
Returns
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.

Definition at line 1960 of file main/ast_expr2f.c.

References ast_yy_scan_bytes().

Referenced by ast_expr(), and ast_str_expr().

1961 {
1962 
1963  return ast_yy_scan_bytes(yystr,strlen(yystr) ,yyscanner);
1964 }
YY_BUFFER_STATE ast_yy_scan_bytes(yyconst char *bytes, int len, yyscan_t yyscanner)
void ast_yy_switch_to_buffer ( YY_BUFFER_STATE  new_buffer,
yyscan_t  yyscanner 
)

Switch to a different input buffer.

Parameters
new_bufferThe new input buffer.
yyscannerThe scanner object.

Definition at line 1664 of file main/ast_expr2f.c.

Referenced by ast_yy_scan_buffer().

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 }
int ast_yyget_column ( yyscan_t  yyscanner)

Get the current column number.

Parameters
yyscannerThe scanner object.

Definition at line 2057 of file main/ast_expr2f.c.

2058 {
2059  struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2060 
2061  if (! YY_CURRENT_BUFFER)
2062  return 0;
2063 
2064  return yycolumn;
2065 }
YY_EXTRA_TYPE ast_yyget_extra ( yyscan_t  yyscanner)

Get the user-defined data for this scanner.

Parameters
yyscannerThe scanner object.

Definition at line 2035 of file main/ast_expr2f.c.

2036 {
2037  struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2038  return yyextra;
2039 }
FILE * ast_yyget_in ( yyscan_t  yyscanner)

Get the input stream.

Parameters
yyscannerThe scanner object.

Definition at line 2070 of file main/ast_expr2f.c.

2071 {
2072  struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2073  return yyin;
2074 }
int ast_yyget_leng ( yyscan_t  yyscanner)

Get the length of the current token.

Parameters
yyscannerThe scanner object.

Definition at line 2088 of file main/ast_expr2f.c.

2089 {
2090  struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2091  return yyleng;
2092 }
int ast_yyget_lineno ( yyscan_t  yyscanner)

Get the current line number.

Parameters
yyscannerThe scanner object.

Definition at line 2044 of file main/ast_expr2f.c.

2045 {
2046  struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2047 
2048  if (! YY_CURRENT_BUFFER)
2049  return 0;
2050 
2051  return yylineno;
2052 }
FILE * ast_yyget_out ( yyscan_t  yyscanner)

Get the output stream.

Parameters
yyscannerThe scanner object.

Definition at line 2079 of file main/ast_expr2f.c.

2080 {
2081  struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2082  return yyout;
2083 }
char * ast_yyget_text ( yyscan_t  yyscanner)

Get the current token.

Parameters
yyscannerThe scanner object.

Definition at line 2098 of file main/ast_expr2f.c.

2099 {
2100  struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2101  return yytext;
2102 }
void ast_yypop_buffer_state ( yyscan_t  yyscanner)

Removes and deletes the top of the stack, if present. The next element becomes the new top.

Parameters
yyscannerThe scanner object.

Definition at line 1853 of file main/ast_expr2f.c.

References ast_yy_delete_buffer(), and yyguts_t::yy_buffer_stack_top.

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 }
void ast_yy_delete_buffer(YY_BUFFER_STATE b, yyscan_t yyscanner)
size_t yy_buffer_stack_top
void ast_yypush_buffer_state ( YY_BUFFER_STATE  new_buffer,
yyscan_t  yyscanner 
)

Pushes the new state onto the stack. The new state becomes the current state. This function will allocate the stack if necessary.

Parameters
new_bufferThe new state.
yyscannerThe scanner object.

Definition at line 1822 of file main/ast_expr2f.c.

References yyguts_t::yy_buffer_stack_top.

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 }
size_t yy_buffer_stack_top
void ast_yyrestart ( FILE *  input_file,
yyscan_t  yyscanner 
)

Immediately switch to a different input stream.

Parameters
input_fileA readable stream.
yyscannerThe scanner object.
Note
This function does not reset the start condition to INITIAL .

Definition at line 1646 of file main/ast_expr2f.c.

References ast_yy_create_buffer().

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 }
YY_BUFFER_STATE ast_yy_create_buffer(FILE *file, int size, yyscan_t yyscanner)
void ast_yyset_column ( int  column_no,
yyscan_t  yyscanner 
)

Set the current column.

Parameters
line_number
yyscannerThe scanner object.

Definition at line 2133 of file main/ast_expr2f.c.

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 }
void ast_yyset_extra ( YY_EXTRA_TYPE  user_defined,
yyscan_t  yyscanner 
)

Set the user-defined data. This data is never touched by the scanner.

Parameters
user_definedThe data to be associated with this scanner.
yyscannerThe scanner object.

Definition at line 2108 of file main/ast_expr2f.c.

2109 {
2110  struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2111  yyextra = user_defined ;
2112 }
void ast_yyset_in ( FILE *  in_str,
yyscan_t  yyscanner 
)

Set the input stream. This does not discard the current input buffer.

Parameters
in_strA readable stream.
yyscannerThe scanner object.
See also
ast_yy_switch_to_buffer

Definition at line 2150 of file main/ast_expr2f.c.

2151 {
2152  struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2153  yyin = in_str ;
2154 }
void ast_yyset_lineno ( int  line_number,
yyscan_t  yyscanner 
)

Set the current line number.

Parameters
line_number
yyscannerThe scanner object.

Definition at line 2118 of file main/ast_expr2f.c.

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 }

Variable Documentation

YY_DECL
Initial value:
{
register yy_state_type yy_current_state

The main scanner function which does all the work.

Definition at line 839 of file main/ast_expr2f.c.