17 #include <my_global.h>
23 #define YYSTYPE_IS_DECLARED
24 #include <../sql/sql_yacc.h>
27 #include <welcome_copyright_notice.h>
38 #define MY_MAX_TOKEN 1000
41 const char *m_token_string;
46 int max_token_seen= 0;
48 char char_tokens[256];
50 int tok_pfs_generic_value= 0;
51 int tok_pfs_generic_value_list= 0;
52 int tok_pfs_row_single_value= 0;
53 int tok_pfs_row_single_value_list= 0;
54 int tok_pfs_row_multiple_value= 0;
55 int tok_pfs_row_multiple_value_list= 0;
56 int tok_pfs_unused= 0;
58 void set_token(
int tok,
const char *str)
62 fprintf(stderr,
"Bad token found\n");
66 if (tok > max_token_seen)
71 if (max_token_seen >= MY_MAX_TOKEN)
73 fprintf(stderr,
"Added that many new keywords ? Increase MY_MAX_TOKEN\n");
77 compiled_token_array[tok].m_token_string= str;
78 compiled_token_array[tok].m_token_length= strlen(str);
90 for (tok= 0; tok < MY_MAX_TOKEN; tok++)
92 compiled_token_array[tok].m_token_string=
"(unknown)";
93 compiled_token_array[tok].m_token_length= 9;
99 for (tok=0; tok < 256; tok++)
101 str= & char_tokens[tok];
103 compiled_token_array[tok].m_token_string= str;
104 compiled_token_array[tok].m_token_length= 1;
113 set_token(TABLE_REF_PRIORITY,
"TABLE_REF_PRIORITY");
119 set_token(WITH_CUBE_SYM,
"WITH CUBE");
120 set_token(WITH_ROLLUP_SYM,
"WITH ROLLUP");
121 set_token(NOT2_SYM,
"!");
122 set_token(OR2_SYM,
"|");
123 set_token(PARAM_MARKER,
"?");
124 set_token(SET_VAR,
":=");
125 set_token(UNDERSCORE_CHARSET,
"(_charset)");
126 set_token(END_OF_INPUT,
"");
133 set_token(BIN_NUM,
"(bin)");
134 set_token(DECIMAL_NUM,
"(decimal)");
135 set_token(FLOAT_NUM,
"(float)");
136 set_token(HEX_NUM,
"(hex)");
137 set_token(LEX_HOSTNAME,
"(hostname)");
138 set_token(LONG_NUM,
"(long)");
139 set_token(NUM,
"(num)");
140 set_token(TEXT_STRING,
"(text)");
141 set_token(NCHAR_STRING,
"(nchar)");
142 set_token(ULONGLONG_NUM,
"(ulonglong)");
147 set_token(IDENT,
"(id)");
148 set_token(IDENT_QUOTED,
"(id_quoted)");
153 set_token(LOCATOR_SYM,
"LOCATOR");
154 set_token(SERVER_OPTIONS,
"SERVER_OPTIONS");
155 set_token(UDF_RETURNS_SYM,
"UDF_RETURNS");
160 for (i= 0; i<
sizeof(symbols)/
sizeof(symbols[0]); i++)
162 set_token(symbols[i].tok, symbols[i].
name);
168 for (i= 0; i<
sizeof(sql_functions)/
sizeof(sql_functions[0]); i++)
170 set_token(sql_functions[i].tok, sql_functions[i].
name);
179 tok_pfs_generic_value= max_token_seen;
180 set_token(tok_pfs_generic_value,
"?");
183 tok_pfs_generic_value_list= max_token_seen;
184 set_token(tok_pfs_generic_value_list,
"?, ...");
187 tok_pfs_row_single_value= max_token_seen;
188 set_token(tok_pfs_row_single_value,
"(?)");
191 tok_pfs_row_single_value_list= max_token_seen;
192 set_token(tok_pfs_row_single_value_list,
"(?) /* , ... */");
195 tok_pfs_row_multiple_value= max_token_seen;
196 set_token(tok_pfs_row_multiple_value,
"(...)");
199 tok_pfs_row_multiple_value_list= max_token_seen;
200 set_token(tok_pfs_row_multiple_value_list,
"(...) /* , ... */");
203 tok_pfs_unused= max_token_seen;
204 set_token(tok_pfs_unused,
"UNUSED");
211 printf(
"lex_token_string lex_token_array[]=\n");
213 printf(
"/* PART 1: character tokens. */\n");
215 for (tok= 0; tok<256; tok++)
217 printf(
"/* %03d */ { \"\\x%02x\", 1},\n", tok, tok);
220 printf(
"/* PART 2: named tokens. */\n");
222 for (tok= 256; tok<= max_token_seen; tok++)
224 printf(
"/* %03d */ { \"%s\", %d},\n",
226 compiled_token_array[tok].m_token_string,
227 compiled_token_array[tok].m_token_length);
230 printf(
"/* DUMMY */ { \"\", 0}\n");
233 printf(
"/* PFS specific tokens. */\n");
234 printf(
"#define TOK_PFS_GENERIC_VALUE %d\n", tok_pfs_generic_value);
235 printf(
"#define TOK_PFS_GENERIC_VALUE_LIST %d\n", tok_pfs_generic_value_list);
236 printf(
"#define TOK_PFS_ROW_SINGLE_VALUE %d\n", tok_pfs_row_single_value);
237 printf(
"#define TOK_PFS_ROW_SINGLE_VALUE_LIST %d\n", tok_pfs_row_single_value_list);
238 printf(
"#define TOK_PFS_ROW_MULTIPLE_VALUE %d\n", tok_pfs_row_multiple_value);
239 printf(
"#define TOK_PFS_ROW_MULTIPLE_VALUE_LIST %d\n", tok_pfs_row_multiple_value_list);
240 printf(
"#define TOK_PFS_UNUSED %d\n", tok_pfs_unused);
243 int main(
int argc,
char **argv)
246 puts(ORACLE_WELCOME_COPYRIGHT_NOTICE(
"2011"));
250 printf(
" This file is generated, do not edit.\n");
251 printf(
" See file storage/perfschema/gen_pfs_lex_token.cc.\n");
253 printf(
"struct lex_token_string\n");
255 printf(
" const char *m_token_string;\n");
256 printf(
" int m_token_length;\n");
258 printf(
"typedef struct lex_token_string lex_token_string;\n");