Fix UUID and issue on older Debian systems.
[awesomized/libmemcached] / libmemcached / csl / scanner.l
1 /* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
2 *
3 * Libmemcached library
4 *
5 * Copyright (C) 2012 Data Differential, http://datadifferential.com/
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions are
9 * met:
10 *
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 *
14 * * Redistributions in binary form must reproduce the above
15 * copyright notice, this list of conditions and the following disclaimer
16 * in the documentation and/or other materials provided with the
17 * distribution.
18 *
19 * * The names of its contributors may not be used to endorse or
20 * promote products derived from this software without specific prior
21 * written permission.
22 *
23 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
24 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
25 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
26 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
27 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
28 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
29 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 *
35 */
36
37
38 %top{
39
40 #include <libmemcached/csl/common.h>
41 #include <libmemcached/csl/context.h>
42 #include <libmemcached/csl/parser.h>
43 #include <libmemcached/csl/symbol.h>
44
45 #ifndef __INTEL_COMPILER
46 #pragma GCC diagnostic ignored "-Wold-style-cast"
47 #pragma GCC diagnostic ignored "-Wsign-compare"
48 #pragma GCC diagnostic ignored "-Wunused-parameter"
49 #pragma GCC diagnostic ignored "-Wmissing-declarations"
50 #pragma GCC diagnostic ignored "-Wunused-result"
51 #pragma GCC diagnostic ignored "-Wmissing-noreturn"
52 #endif
53
54 #ifdef __clang__
55 #pragma GCC diagnostic ignored "-Wshorten-64-to-32"
56 #endif
57
58 #ifndef __INTEL_COMPILER
59 #ifndef __clang__
60 #pragma GCC diagnostic ignored "-Wlogical-op"
61 #endif
62 #endif
63
64 #define YY_EXTRA_TYPE Context*
65
66 }
67
68
69 %{
70 #include <cstdlib>
71 #include <cstring>
72
73 #define PARAM yyget_extra(yyscanner)
74
75 #define get_lex_chars(buffer, result, max_size, context) \
76 { \
77 if (context->pos >= context->length) \
78 { \
79 result= YY_NULL; \
80 } \
81 else \
82 { \
83 result= (int)(context->length - context->pos); \
84 (size_t)result > (size_t)max_size ? result= max_size : 0; \
85 memcpy(buffer, context->buf + context->pos, result); \
86 context->pos += result; \
87 } \
88 }
89
90 #define YY_FATAL_ERROR(msg) \
91 { \
92 }
93
94
95 #define YY_INPUT(buffer, result, max_size) get_lex_chars(buffer, result, max_size, PARAM)
96
97 %}
98
99 %option 8bit
100 %option bison-bridge
101 %option never-interactive
102 %option case-insensitive
103 %option noinput
104 %option nounput
105 %option noyywrap
106 %option outfile="libmemcached/csl/scanner.cc" header-file="libmemcached/csl/scanner.h"
107 %option perf-report
108 %option prefix="config_"
109 %option reentrant
110 %option warn
111
112 %%
113
114
115 =|,|[ ] { return yytext[0];}
116
117 [[:digit:]]+ { yylval->number= atoi(yytext); return (NUMBER); }
118
119 :[[:digit:]]{1,5} { yylval->number= atoi(yytext +1); return PORT; }
120
121 "/?"[[:digit:]]{1,5} { yylval->number= atoi(yytext +2); return WEIGHT_START; }
122
123 [\t\r\n] ; /* skip whitespace */
124
125
126 ^#.*$ {
127 return COMMENT;
128 }
129
130 "--SERVER=" { yyextra->begin= yytext; yyextra->set_server(); return yyextra->previous_token= SERVER; }
131
132 "--SOCKET=" { yyextra->begin= yytext; return yyextra->previous_token= SOCKET; }
133
134 "--BINARY-PROTOCOL" { yyextra->begin= yytext; return yyextra->previous_token= BINARY_PROTOCOL; }
135 "--BUFFER-REQUESTS" { yyextra->begin= yytext; return yyextra->previous_token= BUFFER_REQUESTS; }
136 "--CONFIGURE-FILE=" { yyextra->begin= yytext; return yyextra->previous_token= CONFIGURE_FILE; }
137 "--CONNECT-TIMEOUT=" { yyextra->begin= yytext; return yyextra->previous_token= CONNECT_TIMEOUT; }
138 "--DISTRIBUTION=" { yyextra->begin= yytext; return yyextra->previous_token= DISTRIBUTION; }
139 "--HASH-WITH-NAMESPACE" { yyextra->begin= yytext; return yyextra->previous_token= HASH_WITH_NAMESPACE; }
140 "--HASH=" { yyextra->begin= yytext; return yyextra->previous_token= HASH; }
141 "--IO-BYTES-WATERMARK=" { yyextra->begin= yytext; return yyextra->previous_token= IO_BYTES_WATERMARK; }
142 "--IO-KEY-PREFETCH=" { yyextra->begin= yytext; return yyextra->previous_token= IO_KEY_PREFETCH; }
143 "--IO-MSG-WATERMARK=" { yyextra->begin= yytext; return yyextra->previous_token= IO_MSG_WATERMARK; }
144 "--NOREPLY" { yyextra->begin= yytext; return yyextra->previous_token= NOREPLY; }
145 "--NUMBER-OF-REPLICAS=" { yyextra->begin= yytext; return yyextra->previous_token= NUMBER_OF_REPLICAS; }
146 "--POLL-TIMEOUT=" { yyextra->begin= yytext; return yyextra->previous_token= POLL_TIMEOUT; }
147 "--RANDOMIZE-REPLICA-READ" { yyextra->begin= yytext; return yyextra->previous_token= RANDOMIZE_REPLICA_READ; }
148 "--RCV-TIMEOUT=" { yyextra->begin= yytext; return yyextra->previous_token= RCV_TIMEOUT; }
149 "--REMOVE-FAILED-SERVERS=" { yyextra->begin= yytext; return yyextra->previous_token= REMOVE_FAILED_SERVERS; }
150 "--RETRY-TIMEOUT=" { yyextra->begin= yytext; return yyextra->previous_token= RETRY_TIMEOUT; }
151 "--SND-TIMEOUT=" { yyextra->begin= yytext; return yyextra->previous_token= SND_TIMEOUT; }
152 "--SOCKET-RECV-SIZE=" { yyextra->begin= yytext; return yyextra->previous_token= SOCKET_RECV_SIZE; }
153 "--SOCKET-SEND-SIZE=" { yyextra->begin= yytext; return yyextra->previous_token= SOCKET_SEND_SIZE; }
154 "--SORT-HOSTS" { yyextra->begin= yytext; return yyextra->previous_token= SORT_HOSTS; }
155 "--SUPPORT-CAS" { yyextra->begin= yytext; return yyextra->previous_token= SUPPORT_CAS; }
156 "--TCP-KEEPALIVE" { yyextra->begin= yytext; return yyextra->previous_token= _TCP_KEEPALIVE; }
157 "--TCP-KEEPIDLE" { yyextra->begin= yytext; return yyextra->previous_token= _TCP_KEEPIDLE; }
158 "--TCP-NODELAY" { yyextra->begin= yytext; return yyextra->previous_token= _TCP_NODELAY; }
159 "--USE-UDP" { yyextra->begin= yytext; return yyextra->previous_token= USE_UDP; }
160 "--USER-DATA" { yyextra->begin= yytext; return yyextra->previous_token= USER_DATA; }
161 "--VERIFY-KEY" { yyextra->begin= yytext; return yyextra->previous_token= VERIFY_KEY; }
162
163 "--POOL-MIN=" { yyextra->begin= yytext; return yyextra->previous_token= POOL_MIN; }
164 "--POOL-MAX=" { yyextra->begin= yytext; return yyextra->previous_token= POOL_MAX; }
165
166 "--NAMESPACE=" { yyextra->begin= yytext; return yyextra->previous_token= NAMESPACE; }
167
168 "--FETCH-VERSION" { yyextra->begin= yytext; return yyextra->previous_token= FETCH_VERSION; }
169
170 INCLUDE { yyextra->begin= yytext; return yyextra->previous_token= INCLUDE; }
171 RESET { yyextra->begin= yytext; return yyextra->previous_token= RESET; }
172 DEBUG { yyextra->begin= yytext; return yyextra->previous_token= PARSER_DEBUG; }
173 SERVERS { yyextra->begin= yytext; return yyextra->previous_token= SERVERS; }
174 END { yyextra->begin= yytext; return yyextra->previous_token= END; }
175 ERROR { yyextra->begin= yytext; return yyextra->previous_token= ERROR; }
176
177 TRUE { return yyextra->previous_token= TRUE; }
178 FALSE { return yyextra->previous_token= FALSE; }
179
180
181 "--"[[:alnum:]]* {
182 yyextra->begin= yytext;
183 return UNKNOWN_OPTION;
184 }
185
186 CONSISTENT { return CONSISTENT; }
187 MODULA { return MODULA; }
188 RANDOM { return RANDOM; }
189
190 MD5 { return MD5; }
191 CRC { return CRC; }
192 FNV1_64 { return FNV1_64; }
193 FNV1A_64 { return FNV1A_64; }
194 FNV1_32 { return FNV1_32; }
195 FNV1A_32 { return FNV1A_32; }
196 HSIEH { return HSIEH; }
197 MURMUR { return MURMUR; }
198 JENKINS { return JENKINS; }
199
200 (([[:digit:]]{1,3}"."){3}([[:digit:]]{1,3})) {
201 yyextra->hostname(yytext, yyleng, yylval->server);
202 return IPADDRESS;
203 }
204
205 [[:alnum:]]["."[:alnum:]_-]+[[:alnum:]] {
206 if (yyextra->is_server())
207 {
208 yyextra->hostname(yytext, yyleng, yylval->server);
209
210 return HOSTNAME;
211 }
212
213 yyextra->string_buffer(yytext, yyleng, yylval->string);
214
215 return STRING;
216 }
217
218 L?\"(\\.|[^\\"])*\" {
219 yyget_text(yyscanner)[yyleng -1]= 0;
220 yyextra->string_buffer(yytext +1, yyleng -2, yylval->string);
221 return QUOTED_STRING;
222 }
223
224 . {
225 yyextra->begin= yytext;
226 return UNKNOWN;
227 }
228
229 %%
230
231 void Context::init_scanner()
232 {
233 yylex_init(&scanner);
234 yyset_extra(this, scanner);
235 }
236
237 void Context::destroy_scanner()
238 {
239 (void)yy_fatal_error; // Removes warning about unused yy_fatal_error()
240 yylex_destroy(scanner);
241 }
242