if (rc != MEMCACHED_SUCCESS)
{
std::cerr << "Failed to parse argument #" << x << " " << argv[x] << std::endl;
- std::cerr << "Error message from parser was:\t" << buffer << std::endl;
+ std::cerr << buffer << std::endl;
return EXIT_FAILURE;
}
}
ptr->server_failure_counter= 0;
ptr->next_retry= 0;
}
+ else if (memcached_has_current_error(*ptr))
+ {
+ ptr->server_failure_counter++;
+ set_last_disconnected_host(ptr);
+ }
else
{
memcached_set_error(*ptr, rc, MEMCACHED_AT);
--- /dev/null
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * Configure Scripting Language
+ *
+ * Copyright (C) 2011 Data Differential, http://datadifferential.com/
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * The names of its contributors may not be used to endorse or
+ * promote products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#pragma once
+
+#include <libmemcached/common.h>
+
--- /dev/null
+/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
+ *
+ * Configure Scripting Language
+ *
+ * Copyright (C) 2011 Data Differential, http://datadifferential.com/
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * * Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following disclaimer
+ * in the documentation and/or other materials provided with the
+ * distribution.
+ *
+ * * The names of its contributors may not be used to endorse or
+ * promote products derived from this software without specific prior
+ * written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ *
+ */
+
+#include <libmemcached/csl/common.h>
+#include <libmemcached/csl/context.h>
+
+void Context::abort(const char *error_arg, yytokentype last_token, const char *last_token_str)
+{
+ rc= MEMCACHED_PARSE_ERROR;
+ (void)last_token;
+ (void)last_token_str;
+
+ if (error_arg)
+ {
+ memcached_set_parser_error(*memc, MEMCACHED_AT, "Error occured while parsing: %s", error_arg);
+ return;
+ }
+
+ memcached_set_parser_error(*memc, MEMCACHED_AT, "Error occured while parsing: %s", memcached_strerror(NULL, MEMCACHED_PARSE_ERROR));
+}
+
+void Context::error(const char *error_arg, yytokentype last_token, const char *last_token_str)
+{
+ rc= MEMCACHED_PARSE_ERROR;
+ if (not error_arg)
+ {
+ memcached_set_parser_error(*memc, MEMCACHED_AT, "Unknown error occured during parsing (%s)", last_token_str ? last_token_str : " ");
+ return;
+ }
+
+ if (error_arg and strcmp(error_arg, "memory exhausted") == 0)
+ {
+ (void)memcached_set_error(*memc, MEMCACHED_MEMORY_ALLOCATION_FAILURE, MEMCACHED_AT, memcached_string_make_from_cstr(error_arg));
+ return;
+ }
+
+ // We now test if it is something other then a syntax error, if it we
+ // return a generic message
+ if (error_arg and strcmp(error_arg, "syntax error") == 0)
+ { }
+ else if (error_arg)
+ {
+ memcached_set_parser_error(*memc, MEMCACHED_AT, "Error occured during parsing (%s)", error_arg);
+ return;
+ }
+
+ if (last_token == UNKNOWN_OPTION and begin)
+ {
+ memcached_set_parser_error(*memc, MEMCACHED_AT, "Unknown option: %s", begin);
+ }
+ else if (last_token == UNKNOWN)
+ {
+ memcached_set_parser_error(*memc, MEMCACHED_AT, "Error occured durring parsing, an unknown token was found.");
+ }
+ else
+ {
+ memcached_set_parser_error(*memc, MEMCACHED_AT, "Error occured while parsing (%s)", last_token_str ? last_token_str : " ");
+ }
+}
+
+const char *Context::set_hostname(const char *str, size_t size)
+{
+ size_t copy_length= size_t(NI_MAXHOST) > size ? size : size_t(NI_MAXHOST);
+ memcpy(_hostname, str, copy_length);
+ _hostname[copy_length]= 0;
+
+ return _hostname;
+}
+
#pragma once
-#include <libmemcached/common.h>
+#include <libmemcached/csl/common.h>
+#include <libmemcached/csl/parser.h>
class Context
{
public:
Context(const char *option_string, size_t option_string_length, memcached_st *memc_arg,
memcached_return_t &rc_arg) :
+ previous_token(END),
scanner(NULL),
begin(NULL),
pos(0),
return _is_server;
}
- const char *set_hostname(const char *str, size_t size)
- {
- size_t copy_length= (size_t)NI_MAXHOST > size ? size : (size_t)NI_MAXHOST;
- memcpy(_hostname, str, copy_length);
- _hostname[copy_length]= 0;
-
- return _hostname;
- }
+ const char *set_hostname(const char *str, size_t size);
const char *hostname()
{
return _hostname;
}
- void abort(const char *error)
- {
- if (rc == MEMCACHED_SUCCESS)
- rc= MEMCACHED_PARSE_ERROR;
-
- memcached_string_st *error_string= memcached_string_create(memc, NULL, 1024);
- memcached_string_append(error_string, memcached_literal_param("Error occured while parsing: "));
- memcached_string_append(error_string, memcached_string_make_from_cstr(begin));
- memcached_string_append(error_string, memcached_literal_param(" ("));
-
- if (rc == MEMCACHED_PARSE_ERROR and error)
- {
- memcached_string_append(error_string, memcached_string_make_from_cstr(error));
- }
- else
- {
- memcached_string_append(error_string, memcached_string_make_from_cstr(memcached_strerror(NULL, rc)));
- }
- memcached_string_append(error_string, memcached_literal_param(")"));
-
- memcached_set_error(*memc, rc, MEMCACHED_AT, memcached_string_value(error_string), memcached_string_length(error_string));
-
- memcached_string_free(error_string);
- }
+ void abort(const char *, yytokentype, const char *);
+ void error(const char *, yytokentype, const char* );
~Context()
{
destroy_scanner();
}
+ yytokentype previous_token;
void *scanner;
const char *buf;
const char *begin;
libmemcached/csl/parser.output
noinst_HEADERS+= \
+ libmemcached/csl/common.h \
libmemcached/csl/context.h \
libmemcached/csl/parser.h \
libmemcached/csl/scanner.h \
libmemcached/csl/symbol.h
libmemcached_libmemcached_la_SOURCES+= \
+ libmemcached/csl/context.cc \
libmemcached/csl/parser.cc \
libmemcached/csl/scanner.cc
#line 36 "libmemcached/csl/parser.yy"
-#include <libmemcached/common.h>
+#include <libmemcached/csl/common.h>
#include <libmemcached/options.hpp>
#include <libmemcached/csl/context.h>
#include <libmemcached/csl/symbol.h>
#include <libmemcached/csl/scanner.h>
-#include <iostream>
-
#pragma GCC diagnostic ignored "-Wold-style-cast"
int conf_lex(YYSTYPE* lvalp, void* scanner);
-#define parser_abort(A, B) do { (A)->abort((B)); YYABORT; } while (0)
+#define select_yychar(__context) yychar == UNKNOWN ? ( (__context)->previous_token == END ? UNKNOWN : (__context)->previous_token ) : yychar
+
+#define stryytname(__yytokentype) ((__yytokentype) < YYNTOKENS ) ? yytname[(__yytokentype)] : ""
-inline void config_error(Context *context, yyscan_t *scanner, const char *error)
+#define parser_abort(__context, __error_message) do { (__context)->abort((__error_message), yytokentype(select_yychar(__context)), stryytname(YYTRANSLATE(select_yychar(__context)))); YYABORT; } while (0)
+
+// This is bison calling error.
+inline void __config_error(Context *context, yyscan_t *scanner, const char *error, int last_token, const char *last_token_str)
{
if (not context->end())
- context->abort(error);
+ {
+ context->error(error, yytokentype(last_token), last_token_str);
+ }
+ else
+ {
+ context->error(error, yytokentype(last_token), last_token_str);
+ }
}
+#define config_error(__context, __scanner, __error_msg) do { __config_error((__context), (__scanner), (__error_msg), select_yychar(__context), stryytname(YYTRANSLATE(select_yychar(__context)))); } while (0)
+
+
/* Line 189 of yacc.c */
-#line 106 "libmemcached/csl/parser.cc"
+#line 118 "libmemcached/csl/parser.cc"
/* Enabling traces. */
#ifndef YYDEBUG
/* Line 264 of yacc.c */
-#line 218 "libmemcached/csl/parser.cc"
+#line 230 "libmemcached/csl/parser.cc"
#ifdef short
# undef short
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
static const yytype_uint16 yyrline[] =
{
- 0, 158, 158, 159, 163, 165, 167, 169, 174, 179,
- 183, 187, 198, 206, 214, 221, 225, 229, 233, 237,
- 244, 251, 262, 269, 276, 283, 289, 293, 297, 301,
- 305, 309, 313, 317, 321, 325, 329, 333, 340, 344,
- 348, 352, 356, 360, 364, 368, 372, 376, 380, 384,
- 391, 392, 397, 398, 403, 407, 411, 415, 419, 423,
- 427, 431, 435, 442, 446, 453, 457, 461
+ 0, 170, 170, 171, 175, 177, 179, 181, 186, 191,
+ 195, 199, 210, 218, 226, 233, 237, 241, 245, 249,
+ 256, 263, 274, 281, 288, 295, 301, 305, 309, 313,
+ 317, 321, 325, 329, 333, 337, 341, 345, 352, 356,
+ 360, 364, 368, 372, 376, 380, 384, 388, 392, 396,
+ 403, 404, 409, 410, 415, 419, 423, 427, 431, 435,
+ 439, 443, 447, 454, 458, 465, 469, 473
};
#endif
case 4:
/* Line 1464 of yacc.c */
-#line 164 "libmemcached/csl/parser.yy"
+#line 176 "libmemcached/csl/parser.yy"
{ ;}
break;
case 5:
/* Line 1464 of yacc.c */
-#line 166 "libmemcached/csl/parser.yy"
+#line 178 "libmemcached/csl/parser.yy"
{ ;}
break;
case 6:
/* Line 1464 of yacc.c */
-#line 168 "libmemcached/csl/parser.yy"
+#line 180 "libmemcached/csl/parser.yy"
{ ;}
break;
case 7:
/* Line 1464 of yacc.c */
-#line 170 "libmemcached/csl/parser.yy"
+#line 182 "libmemcached/csl/parser.yy"
{
context->set_end();
YYACCEPT;
case 8:
/* Line 1464 of yacc.c */
-#line 175 "libmemcached/csl/parser.yy"
+#line 187 "libmemcached/csl/parser.yy"
{
context->rc= MEMCACHED_PARSE_USER_ERROR;
parser_abort(context, NULL);
case 9:
/* Line 1464 of yacc.c */
-#line 180 "libmemcached/csl/parser.yy"
+#line 192 "libmemcached/csl/parser.yy"
{
memcached_reset(context->memc);
;}
case 10:
/* Line 1464 of yacc.c */
-#line 184 "libmemcached/csl/parser.yy"
+#line 196 "libmemcached/csl/parser.yy"
{
yydebug= 1;
;}
case 11:
/* Line 1464 of yacc.c */
-#line 188 "libmemcached/csl/parser.yy"
+#line 200 "libmemcached/csl/parser.yy"
{
if ((context->rc= memcached_parse_configure_file(*context->memc, (yyvsp[(3) - (3)].string).c_str, (yyvsp[(3) - (3)].string).size)) != MEMCACHED_SUCCESS)
{
case 12:
/* Line 1464 of yacc.c */
-#line 199 "libmemcached/csl/parser.yy"
+#line 211 "libmemcached/csl/parser.yy"
{
if (memcached_failed(context->rc= memcached_server_add_with_weight(context->memc, (yyvsp[(2) - (4)].server).c_str, (yyvsp[(3) - (4)].number), (yyvsp[(4) - (4)].number))))
{
case 13:
/* Line 1464 of yacc.c */
-#line 207 "libmemcached/csl/parser.yy"
+#line 219 "libmemcached/csl/parser.yy"
{
if (memcached_failed(context->rc= memcached_server_add_with_weight(context->memc, (yyvsp[(2) - (4)].server).c_str, (yyvsp[(3) - (4)].number), (yyvsp[(4) - (4)].number))))
{
case 14:
/* Line 1464 of yacc.c */
-#line 215 "libmemcached/csl/parser.yy"
+#line 227 "libmemcached/csl/parser.yy"
{
if (memcached_failed(context->rc= memcached_server_add_unix_socket_with_weight(context->memc, (yyvsp[(2) - (3)].string).c_str, (yyvsp[(3) - (3)].number))))
{
case 15:
/* Line 1464 of yacc.c */
-#line 222 "libmemcached/csl/parser.yy"
+#line 234 "libmemcached/csl/parser.yy"
{
memcached_set_configuration_file(context->memc, (yyvsp[(2) - (2)].string).c_str, (yyvsp[(2) - (2)].string).size);
;}
case 16:
/* Line 1464 of yacc.c */
-#line 226 "libmemcached/csl/parser.yy"
+#line 238 "libmemcached/csl/parser.yy"
{
context->memc->configure.initial_pool_size= (yyvsp[(2) - (2)].number);
;}
case 17:
/* Line 1464 of yacc.c */
-#line 230 "libmemcached/csl/parser.yy"
+#line 242 "libmemcached/csl/parser.yy"
{
context->memc->configure.max_pool_size= (yyvsp[(2) - (2)].number);
;}
case 19:
/* Line 1464 of yacc.c */
-#line 238 "libmemcached/csl/parser.yy"
+#line 250 "libmemcached/csl/parser.yy"
{
if ((context->rc= memcached_set_namespace(context->memc, (yyvsp[(2) - (2)].string).c_str, (yyvsp[(2) - (2)].string).size)) != MEMCACHED_SUCCESS)
{
case 20:
/* Line 1464 of yacc.c */
-#line 245 "libmemcached/csl/parser.yy"
+#line 257 "libmemcached/csl/parser.yy"
{
if ((context->rc= memcached_behavior_set(context->memc, MEMCACHED_BEHAVIOR_DISTRIBUTION, (yyvsp[(2) - (2)].distribution))) != MEMCACHED_SUCCESS)
{
case 21:
/* Line 1464 of yacc.c */
-#line 252 "libmemcached/csl/parser.yy"
+#line 264 "libmemcached/csl/parser.yy"
{
if ((context->rc= memcached_behavior_set(context->memc, MEMCACHED_BEHAVIOR_DISTRIBUTION, (yyvsp[(2) - (4)].distribution))) != MEMCACHED_SUCCESS)
{
case 22:
/* Line 1464 of yacc.c */
-#line 263 "libmemcached/csl/parser.yy"
+#line 275 "libmemcached/csl/parser.yy"
{
if ((context->rc= memcached_behavior_set(context->memc, MEMCACHED_BEHAVIOR_HASH, (yyvsp[(2) - (2)].hash))) != MEMCACHED_SUCCESS)
{
case 23:
/* Line 1464 of yacc.c */
-#line 270 "libmemcached/csl/parser.yy"
+#line 282 "libmemcached/csl/parser.yy"
{
if ((context->rc= memcached_behavior_set(context->memc, (yyvsp[(1) - (2)].behavior), (yyvsp[(2) - (2)].number))) != MEMCACHED_SUCCESS)
{
case 24:
/* Line 1464 of yacc.c */
-#line 277 "libmemcached/csl/parser.yy"
+#line 289 "libmemcached/csl/parser.yy"
{
if ((context->rc= memcached_behavior_set(context->memc, (yyvsp[(1) - (1)].behavior), true)) != MEMCACHED_SUCCESS)
{
case 25:
/* Line 1464 of yacc.c */
-#line 284 "libmemcached/csl/parser.yy"
+#line 296 "libmemcached/csl/parser.yy"
{
;}
break;
case 26:
/* Line 1464 of yacc.c */
-#line 290 "libmemcached/csl/parser.yy"
+#line 302 "libmemcached/csl/parser.yy"
{
(yyval.behavior)= MEMCACHED_BEHAVIOR_REMOVE_FAILED_SERVERS;
;}
case 27:
/* Line 1464 of yacc.c */
-#line 294 "libmemcached/csl/parser.yy"
+#line 306 "libmemcached/csl/parser.yy"
{
(yyval.behavior)= MEMCACHED_BEHAVIOR_CONNECT_TIMEOUT;
;}
case 28:
/* Line 1464 of yacc.c */
-#line 298 "libmemcached/csl/parser.yy"
+#line 310 "libmemcached/csl/parser.yy"
{
(yyval.behavior)= MEMCACHED_BEHAVIOR_IO_MSG_WATERMARK;
;}
case 29:
/* Line 1464 of yacc.c */
-#line 302 "libmemcached/csl/parser.yy"
+#line 314 "libmemcached/csl/parser.yy"
{
(yyval.behavior)= MEMCACHED_BEHAVIOR_IO_BYTES_WATERMARK;
;}
case 30:
/* Line 1464 of yacc.c */
-#line 306 "libmemcached/csl/parser.yy"
+#line 318 "libmemcached/csl/parser.yy"
{
(yyval.behavior)= MEMCACHED_BEHAVIOR_IO_KEY_PREFETCH;
;}
case 31:
/* Line 1464 of yacc.c */
-#line 310 "libmemcached/csl/parser.yy"
+#line 322 "libmemcached/csl/parser.yy"
{
(yyval.behavior)= MEMCACHED_BEHAVIOR_NUMBER_OF_REPLICAS;
;}
case 32:
/* Line 1464 of yacc.c */
-#line 314 "libmemcached/csl/parser.yy"
+#line 326 "libmemcached/csl/parser.yy"
{
(yyval.behavior)= MEMCACHED_BEHAVIOR_POLL_TIMEOUT;
;}
case 33:
/* Line 1464 of yacc.c */
-#line 318 "libmemcached/csl/parser.yy"
+#line 330 "libmemcached/csl/parser.yy"
{
(yyval.behavior)= MEMCACHED_BEHAVIOR_RCV_TIMEOUT;
;}
case 34:
/* Line 1464 of yacc.c */
-#line 322 "libmemcached/csl/parser.yy"
+#line 334 "libmemcached/csl/parser.yy"
{
(yyval.behavior)= MEMCACHED_BEHAVIOR_RETRY_TIMEOUT;
;}
case 35:
/* Line 1464 of yacc.c */
-#line 326 "libmemcached/csl/parser.yy"
+#line 338 "libmemcached/csl/parser.yy"
{
(yyval.behavior)= MEMCACHED_BEHAVIOR_SND_TIMEOUT;
;}
case 36:
/* Line 1464 of yacc.c */
-#line 330 "libmemcached/csl/parser.yy"
+#line 342 "libmemcached/csl/parser.yy"
{
(yyval.behavior)= MEMCACHED_BEHAVIOR_SOCKET_RECV_SIZE;
;}
case 37:
/* Line 1464 of yacc.c */
-#line 334 "libmemcached/csl/parser.yy"
+#line 346 "libmemcached/csl/parser.yy"
{
(yyval.behavior)= MEMCACHED_BEHAVIOR_SOCKET_SEND_SIZE;
;}
case 38:
/* Line 1464 of yacc.c */
-#line 341 "libmemcached/csl/parser.yy"
+#line 353 "libmemcached/csl/parser.yy"
{
(yyval.behavior)= MEMCACHED_BEHAVIOR_BINARY_PROTOCOL;
;}
case 39:
/* Line 1464 of yacc.c */
-#line 345 "libmemcached/csl/parser.yy"
+#line 357 "libmemcached/csl/parser.yy"
{
(yyval.behavior)= MEMCACHED_BEHAVIOR_BUFFER_REQUESTS;
;}
case 40:
/* Line 1464 of yacc.c */
-#line 349 "libmemcached/csl/parser.yy"
+#line 361 "libmemcached/csl/parser.yy"
{
(yyval.behavior)= MEMCACHED_BEHAVIOR_HASH_WITH_PREFIX_KEY;
;}
case 41:
/* Line 1464 of yacc.c */
-#line 353 "libmemcached/csl/parser.yy"
+#line 365 "libmemcached/csl/parser.yy"
{
(yyval.behavior)= MEMCACHED_BEHAVIOR_NOREPLY;
;}
case 42:
/* Line 1464 of yacc.c */
-#line 357 "libmemcached/csl/parser.yy"
+#line 369 "libmemcached/csl/parser.yy"
{
(yyval.behavior)= MEMCACHED_BEHAVIOR_RANDOMIZE_REPLICA_READ;
;}
case 43:
/* Line 1464 of yacc.c */
-#line 361 "libmemcached/csl/parser.yy"
+#line 373 "libmemcached/csl/parser.yy"
{
(yyval.behavior)= MEMCACHED_BEHAVIOR_SORT_HOSTS;
;}
case 44:
/* Line 1464 of yacc.c */
-#line 365 "libmemcached/csl/parser.yy"
+#line 377 "libmemcached/csl/parser.yy"
{
(yyval.behavior)= MEMCACHED_BEHAVIOR_SUPPORT_CAS;
;}
case 45:
/* Line 1464 of yacc.c */
-#line 369 "libmemcached/csl/parser.yy"
+#line 381 "libmemcached/csl/parser.yy"
{
(yyval.behavior)= MEMCACHED_BEHAVIOR_TCP_NODELAY;
;}
case 46:
/* Line 1464 of yacc.c */
-#line 373 "libmemcached/csl/parser.yy"
+#line 385 "libmemcached/csl/parser.yy"
{
(yyval.behavior)= MEMCACHED_BEHAVIOR_TCP_KEEPALIVE;
;}
case 47:
/* Line 1464 of yacc.c */
-#line 377 "libmemcached/csl/parser.yy"
+#line 389 "libmemcached/csl/parser.yy"
{
(yyval.behavior)= MEMCACHED_BEHAVIOR_TCP_KEEPIDLE;
;}
case 48:
/* Line 1464 of yacc.c */
-#line 381 "libmemcached/csl/parser.yy"
+#line 393 "libmemcached/csl/parser.yy"
{
(yyval.behavior)= MEMCACHED_BEHAVIOR_USE_UDP;
;}
case 49:
/* Line 1464 of yacc.c */
-#line 385 "libmemcached/csl/parser.yy"
+#line 397 "libmemcached/csl/parser.yy"
{
(yyval.behavior)= MEMCACHED_BEHAVIOR_VERIFY_KEY;
;}
case 50:
/* Line 1464 of yacc.c */
-#line 391 "libmemcached/csl/parser.yy"
+#line 403 "libmemcached/csl/parser.yy"
{ (yyval.number)= MEMCACHED_DEFAULT_PORT;;}
break;
case 51:
/* Line 1464 of yacc.c */
-#line 393 "libmemcached/csl/parser.yy"
+#line 405 "libmemcached/csl/parser.yy"
{ ;}
break;
case 52:
/* Line 1464 of yacc.c */
-#line 397 "libmemcached/csl/parser.yy"
+#line 409 "libmemcached/csl/parser.yy"
{ (yyval.number)= 1; ;}
break;
case 53:
/* Line 1464 of yacc.c */
-#line 399 "libmemcached/csl/parser.yy"
+#line 411 "libmemcached/csl/parser.yy"
{ ;}
break;
case 54:
/* Line 1464 of yacc.c */
-#line 404 "libmemcached/csl/parser.yy"
+#line 416 "libmemcached/csl/parser.yy"
{
(yyval.hash)= MEMCACHED_HASH_MD5;
;}
case 55:
/* Line 1464 of yacc.c */
-#line 408 "libmemcached/csl/parser.yy"
+#line 420 "libmemcached/csl/parser.yy"
{
(yyval.hash)= MEMCACHED_HASH_CRC;
;}
case 56:
/* Line 1464 of yacc.c */
-#line 412 "libmemcached/csl/parser.yy"
+#line 424 "libmemcached/csl/parser.yy"
{
(yyval.hash)= MEMCACHED_HASH_FNV1_64;
;}
case 57:
/* Line 1464 of yacc.c */
-#line 416 "libmemcached/csl/parser.yy"
+#line 428 "libmemcached/csl/parser.yy"
{
(yyval.hash)= MEMCACHED_HASH_FNV1A_64;
;}
case 58:
/* Line 1464 of yacc.c */
-#line 420 "libmemcached/csl/parser.yy"
+#line 432 "libmemcached/csl/parser.yy"
{
(yyval.hash)= MEMCACHED_HASH_FNV1_32;
;}
case 59:
/* Line 1464 of yacc.c */
-#line 424 "libmemcached/csl/parser.yy"
+#line 436 "libmemcached/csl/parser.yy"
{
(yyval.hash)= MEMCACHED_HASH_FNV1A_32;
;}
case 60:
/* Line 1464 of yacc.c */
-#line 428 "libmemcached/csl/parser.yy"
+#line 440 "libmemcached/csl/parser.yy"
{
(yyval.hash)= MEMCACHED_HASH_HSIEH;
;}
case 61:
/* Line 1464 of yacc.c */
-#line 432 "libmemcached/csl/parser.yy"
+#line 444 "libmemcached/csl/parser.yy"
{
(yyval.hash)= MEMCACHED_HASH_MURMUR;
;}
case 62:
/* Line 1464 of yacc.c */
-#line 436 "libmemcached/csl/parser.yy"
+#line 448 "libmemcached/csl/parser.yy"
{
(yyval.hash)= MEMCACHED_HASH_JENKINS;
;}
case 63:
/* Line 1464 of yacc.c */
-#line 443 "libmemcached/csl/parser.yy"
+#line 455 "libmemcached/csl/parser.yy"
{
(yyval.string)= (yyvsp[(1) - (1)].string);
;}
case 64:
/* Line 1464 of yacc.c */
-#line 447 "libmemcached/csl/parser.yy"
+#line 459 "libmemcached/csl/parser.yy"
{
(yyval.string)= (yyvsp[(1) - (1)].string);
;}
case 65:
/* Line 1464 of yacc.c */
-#line 454 "libmemcached/csl/parser.yy"
+#line 466 "libmemcached/csl/parser.yy"
{
(yyval.distribution)= MEMCACHED_DISTRIBUTION_CONSISTENT;
;}
case 66:
/* Line 1464 of yacc.c */
-#line 458 "libmemcached/csl/parser.yy"
+#line 470 "libmemcached/csl/parser.yy"
{
(yyval.distribution)= MEMCACHED_DISTRIBUTION_MODULA;
;}
case 67:
/* Line 1464 of yacc.c */
-#line 462 "libmemcached/csl/parser.yy"
+#line 474 "libmemcached/csl/parser.yy"
{
(yyval.distribution)= MEMCACHED_DISTRIBUTION_RANDOM;
;}
/* Line 1464 of yacc.c */
-#line 2115 "libmemcached/csl/parser.cc"
+#line 2127 "libmemcached/csl/parser.cc"
default: break;
}
YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
/* Line 1684 of yacc.c */
-#line 467 "libmemcached/csl/parser.yy"
+#line 479 "libmemcached/csl/parser.yy"
void Context::start()
%{
-#include <libmemcached/common.h>
+#include <libmemcached/csl/common.h>
#include <libmemcached/options.hpp>
#include <libmemcached/csl/context.h>
#include <libmemcached/csl/symbol.h>
#include <libmemcached/csl/scanner.h>
-#include <iostream>
-
#pragma GCC diagnostic ignored "-Wold-style-cast"
int conf_lex(YYSTYPE* lvalp, void* scanner);
-#define parser_abort(A, B) do { (A)->abort((B)); YYABORT; } while (0)
+#define select_yychar(__context) yychar == UNKNOWN ? ( (__context)->previous_token == END ? UNKNOWN : (__context)->previous_token ) : yychar
+
+#define stryytname(__yytokentype) ((__yytokentype) < YYNTOKENS ) ? yytname[(__yytokentype)] : ""
+
+#define parser_abort(__context, __error_message) do { (__context)->abort((__error_message), yytokentype(select_yychar(__context)), stryytname(YYTRANSLATE(select_yychar(__context)))); YYABORT; } while (0)
-inline void config_error(Context *context, yyscan_t *scanner, const char *error)
+// This is bison calling error.
+inline void __config_error(Context *context, yyscan_t *scanner, const char *error, int last_token, const char *last_token_str)
{
if (not context->end())
- context->abort(error);
+ {
+ context->error(error, yytokentype(last_token), last_token_str);
+ }
+ else
+ {
+ context->error(error, yytokentype(last_token), last_token_str);
+ }
}
+#define config_error(__context, __scanner, __error_msg) do { __config_error((__context), (__scanner), (__error_msg), select_yychar(__context), stryytname(YYTRANSLATE(select_yychar(__context)))); } while (0)
+
+
%}
%token COMMENT
#line 2 "libmemcached/csl/scanner.cc"
#line 22 "libmemcached/csl/scanner.l"
-#include <libmemcached/common.h>
+#include <libmemcached/csl/common.h>
#include <libmemcached/csl/context.h>
#include <libmemcached/csl/parser.h>
#include <libmemcached/csl/symbol.h>
case 7:
YY_RULE_SETUP
#line 92 "libmemcached/csl/scanner.l"
-{ yyextra->begin= yytext; yyextra->set_server(); return SERVER; }
+{ yyextra->begin= yytext; yyextra->set_server(); return yyextra->previous_token= SERVER; }
YY_BREAK
case 8:
YY_RULE_SETUP
#line 94 "libmemcached/csl/scanner.l"
-{ yyextra->begin= yytext; return SOCKET; }
+{ yyextra->begin= yytext; return yyextra->previous_token= SOCKET; }
YY_BREAK
case 9:
YY_RULE_SETUP
#line 96 "libmemcached/csl/scanner.l"
-{ yyextra->begin= yytext; return BINARY_PROTOCOL; }
+{ yyextra->begin= yytext; return yyextra->previous_token= BINARY_PROTOCOL; }
YY_BREAK
case 10:
YY_RULE_SETUP
#line 97 "libmemcached/csl/scanner.l"
-{ yyextra->begin= yytext; return BUFFER_REQUESTS; }
+{ yyextra->begin= yytext; return yyextra->previous_token= BUFFER_REQUESTS; }
YY_BREAK
case 11:
YY_RULE_SETUP
#line 98 "libmemcached/csl/scanner.l"
-{ yyextra->begin= yytext; return CONFIGURE_FILE; }
+{ yyextra->begin= yytext; return yyextra->previous_token= CONFIGURE_FILE; }
YY_BREAK
case 12:
YY_RULE_SETUP
#line 99 "libmemcached/csl/scanner.l"
-{ yyextra->begin= yytext; return CONNECT_TIMEOUT; }
+{ yyextra->begin= yytext; return yyextra->previous_token= CONNECT_TIMEOUT; }
YY_BREAK
case 13:
YY_RULE_SETUP
#line 100 "libmemcached/csl/scanner.l"
-{ yyextra->begin= yytext; return DISTRIBUTION; }
+{ yyextra->begin= yytext; return yyextra->previous_token= DISTRIBUTION; }
YY_BREAK
case 14:
YY_RULE_SETUP
#line 101 "libmemcached/csl/scanner.l"
-{ yyextra->begin= yytext; return HASH_WITH_NAMESPACE; }
+{ yyextra->begin= yytext; return yyextra->previous_token= HASH_WITH_NAMESPACE; }
YY_BREAK
case 15:
YY_RULE_SETUP
#line 102 "libmemcached/csl/scanner.l"
-{ yyextra->begin= yytext; return HASH; }
+{ yyextra->begin= yytext; return yyextra->previous_token= HASH; }
YY_BREAK
case 16:
YY_RULE_SETUP
#line 103 "libmemcached/csl/scanner.l"
-{ yyextra->begin= yytext; return IO_BYTES_WATERMARK; }
+{ yyextra->begin= yytext; return yyextra->previous_token= IO_BYTES_WATERMARK; }
YY_BREAK
case 17:
YY_RULE_SETUP
#line 104 "libmemcached/csl/scanner.l"
-{ yyextra->begin= yytext; return IO_KEY_PREFETCH; }
+{ yyextra->begin= yytext; return yyextra->previous_token= IO_KEY_PREFETCH; }
YY_BREAK
case 18:
YY_RULE_SETUP
#line 105 "libmemcached/csl/scanner.l"
-{ yyextra->begin= yytext; return IO_MSG_WATERMARK; }
+{ yyextra->begin= yytext; return yyextra->previous_token= IO_MSG_WATERMARK; }
YY_BREAK
case 19:
YY_RULE_SETUP
#line 106 "libmemcached/csl/scanner.l"
-{ yyextra->begin= yytext; return NOREPLY; }
+{ yyextra->begin= yytext; return yyextra->previous_token= NOREPLY; }
YY_BREAK
case 20:
YY_RULE_SETUP
#line 107 "libmemcached/csl/scanner.l"
-{ yyextra->begin= yytext; return NUMBER_OF_REPLICAS; }
+{ yyextra->begin= yytext; return yyextra->previous_token= NUMBER_OF_REPLICAS; }
YY_BREAK
case 21:
YY_RULE_SETUP
#line 108 "libmemcached/csl/scanner.l"
-{ yyextra->begin= yytext; return POLL_TIMEOUT; }
+{ yyextra->begin= yytext; return yyextra->previous_token= POLL_TIMEOUT; }
YY_BREAK
case 22:
YY_RULE_SETUP
#line 109 "libmemcached/csl/scanner.l"
-{ yyextra->begin= yytext; return RANDOMIZE_REPLICA_READ; }
+{ yyextra->begin= yytext; return yyextra->previous_token= RANDOMIZE_REPLICA_READ; }
YY_BREAK
case 23:
YY_RULE_SETUP
#line 110 "libmemcached/csl/scanner.l"
-{ yyextra->begin= yytext; return RCV_TIMEOUT; }
+{ yyextra->begin= yytext; return yyextra->previous_token= RCV_TIMEOUT; }
YY_BREAK
case 24:
YY_RULE_SETUP
#line 111 "libmemcached/csl/scanner.l"
-{ yyextra->begin= yytext; return REMOVE_FAILED_SERVERS; }
+{ yyextra->begin= yytext; return yyextra->previous_token= REMOVE_FAILED_SERVERS; }
YY_BREAK
case 25:
YY_RULE_SETUP
#line 112 "libmemcached/csl/scanner.l"
-{ yyextra->begin= yytext; return RETRY_TIMEOUT; }
+{ yyextra->begin= yytext; return yyextra->previous_token= RETRY_TIMEOUT; }
YY_BREAK
case 26:
YY_RULE_SETUP
#line 113 "libmemcached/csl/scanner.l"
-{ yyextra->begin= yytext; return SND_TIMEOUT; }
+{ yyextra->begin= yytext; return yyextra->previous_token= SND_TIMEOUT; }
YY_BREAK
case 27:
YY_RULE_SETUP
#line 114 "libmemcached/csl/scanner.l"
-{ yyextra->begin= yytext; return SOCKET_RECV_SIZE; }
+{ yyextra->begin= yytext; return yyextra->previous_token= SOCKET_RECV_SIZE; }
YY_BREAK
case 28:
YY_RULE_SETUP
#line 115 "libmemcached/csl/scanner.l"
-{ yyextra->begin= yytext; return SOCKET_SEND_SIZE; }
+{ yyextra->begin= yytext; return yyextra->previous_token= SOCKET_SEND_SIZE; }
YY_BREAK
case 29:
YY_RULE_SETUP
#line 116 "libmemcached/csl/scanner.l"
-{ yyextra->begin= yytext; return SORT_HOSTS; }
+{ yyextra->begin= yytext; return yyextra->previous_token= SORT_HOSTS; }
YY_BREAK
case 30:
YY_RULE_SETUP
#line 117 "libmemcached/csl/scanner.l"
-{ yyextra->begin= yytext; return SUPPORT_CAS; }
+{ yyextra->begin= yytext; return yyextra->previous_token= SUPPORT_CAS; }
YY_BREAK
case 31:
YY_RULE_SETUP
#line 118 "libmemcached/csl/scanner.l"
-{ yyextra->begin= yytext; return _TCP_KEEPALIVE; }
+{ yyextra->begin= yytext; return yyextra->previous_token= _TCP_KEEPALIVE; }
YY_BREAK
case 32:
YY_RULE_SETUP
#line 119 "libmemcached/csl/scanner.l"
-{ yyextra->begin= yytext; return _TCP_KEEPIDLE; }
+{ yyextra->begin= yytext; return yyextra->previous_token= _TCP_KEEPIDLE; }
YY_BREAK
case 33:
YY_RULE_SETUP
#line 120 "libmemcached/csl/scanner.l"
-{ yyextra->begin= yytext; return _TCP_NODELAY; }
+{ yyextra->begin= yytext; return yyextra->previous_token= _TCP_NODELAY; }
YY_BREAK
case 34:
YY_RULE_SETUP
#line 121 "libmemcached/csl/scanner.l"
-{ yyextra->begin= yytext; return USE_UDP; }
+{ yyextra->begin= yytext; return yyextra->previous_token= USE_UDP; }
YY_BREAK
case 35:
YY_RULE_SETUP
#line 122 "libmemcached/csl/scanner.l"
-{ yyextra->begin= yytext; return USER_DATA; }
+{ yyextra->begin= yytext; return yyextra->previous_token= USER_DATA; }
YY_BREAK
case 36:
YY_RULE_SETUP
#line 123 "libmemcached/csl/scanner.l"
-{ yyextra->begin= yytext; return VERIFY_KEY; }
+{ yyextra->begin= yytext; return yyextra->previous_token= VERIFY_KEY; }
YY_BREAK
case 37:
YY_RULE_SETUP
#line 125 "libmemcached/csl/scanner.l"
-{ yyextra->begin= yytext; return POOL_MIN; }
+{ yyextra->begin= yytext; return yyextra->previous_token= POOL_MIN; }
YY_BREAK
case 38:
YY_RULE_SETUP
#line 126 "libmemcached/csl/scanner.l"
-{ yyextra->begin= yytext; return POOL_MAX; }
+{ yyextra->begin= yytext; return yyextra->previous_token= POOL_MAX; }
YY_BREAK
case 39:
YY_RULE_SETUP
#line 128 "libmemcached/csl/scanner.l"
-{ yyextra->begin= yytext; return NAMESPACE; }
+{ yyextra->begin= yytext; return yyextra->previous_token= NAMESPACE; }
YY_BREAK
case 40:
YY_RULE_SETUP
#line 130 "libmemcached/csl/scanner.l"
-{ yyextra->begin= yytext; return INCLUDE; }
+{ yyextra->begin= yytext; return yyextra->previous_token= INCLUDE; }
YY_BREAK
case 41:
YY_RULE_SETUP
#line 131 "libmemcached/csl/scanner.l"
-{ yyextra->begin= yytext; return RESET; }
+{ yyextra->begin= yytext; return yyextra->previous_token= RESET; }
YY_BREAK
case 42:
YY_RULE_SETUP
#line 132 "libmemcached/csl/scanner.l"
-{ yyextra->begin= yytext; return PARSER_DEBUG; }
+{ yyextra->begin= yytext; return yyextra->previous_token= PARSER_DEBUG; }
YY_BREAK
case 43:
YY_RULE_SETUP
#line 133 "libmemcached/csl/scanner.l"
-{ yyextra->begin= yytext; return SERVERS; }
+{ yyextra->begin= yytext; return yyextra->previous_token= SERVERS; }
YY_BREAK
case 44:
YY_RULE_SETUP
#line 134 "libmemcached/csl/scanner.l"
-{ yyextra->begin= yytext; return END; }
+{ yyextra->begin= yytext; return yyextra->previous_token= END; }
YY_BREAK
case 45:
YY_RULE_SETUP
#line 135 "libmemcached/csl/scanner.l"
-{ yyextra->begin= yytext; return ERROR; }
+{ yyextra->begin= yytext; return yyextra->previous_token= ERROR; }
YY_BREAK
case 46:
YY_RULE_SETUP
#line 137 "libmemcached/csl/scanner.l"
-{ return TRUE; }
+{ return yyextra->previous_token= TRUE; }
YY_BREAK
case 47:
YY_RULE_SETUP
#line 138 "libmemcached/csl/scanner.l"
-{ return FALSE; }
+{ return yyextra->previous_token= FALSE; }
YY_BREAK
case 48:
YY_RULE_SETUP
#line 6 "libmemcached/csl/scanner.h"
#line 22 "libmemcached/csl/scanner.l"
-#include <libmemcached/common.h>
+#include <libmemcached/csl/common.h>
#include <libmemcached/csl/context.h>
#include <libmemcached/csl/parser.h>
#include <libmemcached/csl/symbol.h>
%top{
-#include <libmemcached/common.h>
+#include <libmemcached/csl/common.h>
#include <libmemcached/csl/context.h>
#include <libmemcached/csl/parser.h>
#include <libmemcached/csl/symbol.h>
return COMMENT;
}
-"--SERVER=" { yyextra->begin= yytext; yyextra->set_server(); return SERVER; }
-
-"--SOCKET=" { yyextra->begin= yytext; return SOCKET; }
-
-"--BINARY-PROTOCOL" { yyextra->begin= yytext; return BINARY_PROTOCOL; }
-"--BUFFER-REQUESTS" { yyextra->begin= yytext; return BUFFER_REQUESTS; }
-"--CONFIGURE-FILE=" { yyextra->begin= yytext; return CONFIGURE_FILE; }
-"--CONNECT-TIMEOUT=" { yyextra->begin= yytext; return CONNECT_TIMEOUT; }
-"--DISTRIBUTION=" { yyextra->begin= yytext; return DISTRIBUTION; }
-"--HASH-WITH-NAMESPACE" { yyextra->begin= yytext; return HASH_WITH_NAMESPACE; }
-"--HASH=" { yyextra->begin= yytext; return HASH; }
-"--IO-BYTES-WATERMARK=" { yyextra->begin= yytext; return IO_BYTES_WATERMARK; }
-"--IO-KEY-PREFETCH=" { yyextra->begin= yytext; return IO_KEY_PREFETCH; }
-"--IO-MSG-WATERMARK=" { yyextra->begin= yytext; return IO_MSG_WATERMARK; }
-"--NOREPLY" { yyextra->begin= yytext; return NOREPLY; }
-"--NUMBER-OF-REPLICAS=" { yyextra->begin= yytext; return NUMBER_OF_REPLICAS; }
-"--POLL-TIMEOUT=" { yyextra->begin= yytext; return POLL_TIMEOUT; }
-"--RANDOMIZE-REPLICA-READ" { yyextra->begin= yytext; return RANDOMIZE_REPLICA_READ; }
-"--RCV-TIMEOUT=" { yyextra->begin= yytext; return RCV_TIMEOUT; }
-"--REMOVE-FAILED-SERVERS=" { yyextra->begin= yytext; return REMOVE_FAILED_SERVERS; }
-"--RETRY-TIMEOUT=" { yyextra->begin= yytext; return RETRY_TIMEOUT; }
-"--SND-TIMEOUT=" { yyextra->begin= yytext; return SND_TIMEOUT; }
-"--SOCKET-RECV-SIZE=" { yyextra->begin= yytext; return SOCKET_RECV_SIZE; }
-"--SOCKET-SEND-SIZE=" { yyextra->begin= yytext; return SOCKET_SEND_SIZE; }
-"--SORT-HOSTS" { yyextra->begin= yytext; return SORT_HOSTS; }
-"--SUPPORT-CAS" { yyextra->begin= yytext; return SUPPORT_CAS; }
-"--TCP-KEEPALIVE" { yyextra->begin= yytext; return _TCP_KEEPALIVE; }
-"--TCP-KEEPIDLE" { yyextra->begin= yytext; return _TCP_KEEPIDLE; }
-"--TCP-NODELAY" { yyextra->begin= yytext; return _TCP_NODELAY; }
-"--USE-UDP" { yyextra->begin= yytext; return USE_UDP; }
-"--USER-DATA" { yyextra->begin= yytext; return USER_DATA; }
-"--VERIFY-KEY" { yyextra->begin= yytext; return VERIFY_KEY; }
-
-"--POOL-MIN=" { yyextra->begin= yytext; return POOL_MIN; }
-"--POOL-MAX=" { yyextra->begin= yytext; return POOL_MAX; }
-
-"--NAMESPACE=" { yyextra->begin= yytext; return NAMESPACE; }
-
-INCLUDE { yyextra->begin= yytext; return INCLUDE; }
-RESET { yyextra->begin= yytext; return RESET; }
-DEBUG { yyextra->begin= yytext; return PARSER_DEBUG; }
-SERVERS { yyextra->begin= yytext; return SERVERS; }
-END { yyextra->begin= yytext; return END; }
-ERROR { yyextra->begin= yytext; return ERROR; }
-
-TRUE { return TRUE; }
-FALSE { return FALSE; }
+"--SERVER=" { yyextra->begin= yytext; yyextra->set_server(); return yyextra->previous_token= SERVER; }
+
+"--SOCKET=" { yyextra->begin= yytext; return yyextra->previous_token= SOCKET; }
+
+"--BINARY-PROTOCOL" { yyextra->begin= yytext; return yyextra->previous_token= BINARY_PROTOCOL; }
+"--BUFFER-REQUESTS" { yyextra->begin= yytext; return yyextra->previous_token= BUFFER_REQUESTS; }
+"--CONFIGURE-FILE=" { yyextra->begin= yytext; return yyextra->previous_token= CONFIGURE_FILE; }
+"--CONNECT-TIMEOUT=" { yyextra->begin= yytext; return yyextra->previous_token= CONNECT_TIMEOUT; }
+"--DISTRIBUTION=" { yyextra->begin= yytext; return yyextra->previous_token= DISTRIBUTION; }
+"--HASH-WITH-NAMESPACE" { yyextra->begin= yytext; return yyextra->previous_token= HASH_WITH_NAMESPACE; }
+"--HASH=" { yyextra->begin= yytext; return yyextra->previous_token= HASH; }
+"--IO-BYTES-WATERMARK=" { yyextra->begin= yytext; return yyextra->previous_token= IO_BYTES_WATERMARK; }
+"--IO-KEY-PREFETCH=" { yyextra->begin= yytext; return yyextra->previous_token= IO_KEY_PREFETCH; }
+"--IO-MSG-WATERMARK=" { yyextra->begin= yytext; return yyextra->previous_token= IO_MSG_WATERMARK; }
+"--NOREPLY" { yyextra->begin= yytext; return yyextra->previous_token= NOREPLY; }
+"--NUMBER-OF-REPLICAS=" { yyextra->begin= yytext; return yyextra->previous_token= NUMBER_OF_REPLICAS; }
+"--POLL-TIMEOUT=" { yyextra->begin= yytext; return yyextra->previous_token= POLL_TIMEOUT; }
+"--RANDOMIZE-REPLICA-READ" { yyextra->begin= yytext; return yyextra->previous_token= RANDOMIZE_REPLICA_READ; }
+"--RCV-TIMEOUT=" { yyextra->begin= yytext; return yyextra->previous_token= RCV_TIMEOUT; }
+"--REMOVE-FAILED-SERVERS=" { yyextra->begin= yytext; return yyextra->previous_token= REMOVE_FAILED_SERVERS; }
+"--RETRY-TIMEOUT=" { yyextra->begin= yytext; return yyextra->previous_token= RETRY_TIMEOUT; }
+"--SND-TIMEOUT=" { yyextra->begin= yytext; return yyextra->previous_token= SND_TIMEOUT; }
+"--SOCKET-RECV-SIZE=" { yyextra->begin= yytext; return yyextra->previous_token= SOCKET_RECV_SIZE; }
+"--SOCKET-SEND-SIZE=" { yyextra->begin= yytext; return yyextra->previous_token= SOCKET_SEND_SIZE; }
+"--SORT-HOSTS" { yyextra->begin= yytext; return yyextra->previous_token= SORT_HOSTS; }
+"--SUPPORT-CAS" { yyextra->begin= yytext; return yyextra->previous_token= SUPPORT_CAS; }
+"--TCP-KEEPALIVE" { yyextra->begin= yytext; return yyextra->previous_token= _TCP_KEEPALIVE; }
+"--TCP-KEEPIDLE" { yyextra->begin= yytext; return yyextra->previous_token= _TCP_KEEPIDLE; }
+"--TCP-NODELAY" { yyextra->begin= yytext; return yyextra->previous_token= _TCP_NODELAY; }
+"--USE-UDP" { yyextra->begin= yytext; return yyextra->previous_token= USE_UDP; }
+"--USER-DATA" { yyextra->begin= yytext; return yyextra->previous_token= USER_DATA; }
+"--VERIFY-KEY" { yyextra->begin= yytext; return yyextra->previous_token= VERIFY_KEY; }
+
+"--POOL-MIN=" { yyextra->begin= yytext; return yyextra->previous_token= POOL_MIN; }
+"--POOL-MAX=" { yyextra->begin= yytext; return yyextra->previous_token= POOL_MAX; }
+
+"--NAMESPACE=" { yyextra->begin= yytext; return yyextra->previous_token= NAMESPACE; }
+
+INCLUDE { yyextra->begin= yytext; return yyextra->previous_token= INCLUDE; }
+RESET { yyextra->begin= yytext; return yyextra->previous_token= RESET; }
+DEBUG { yyextra->begin= yytext; return yyextra->previous_token= PARSER_DEBUG; }
+SERVERS { yyextra->begin= yytext; return yyextra->previous_token= SERVERS; }
+END { yyextra->begin= yytext; return yyextra->previous_token= END; }
+ERROR { yyextra->begin= yytext; return yyextra->previous_token= ERROR; }
+
+TRUE { return yyextra->previous_token= TRUE; }
+FALSE { return yyextra->previous_token= FALSE; }
"--"[[:alnum:]]* {
const char *c_str;
size_t size;
};
-
-#if 0
-#include <iostream>
-inline std::ostream& operator<<(std::ostream& output, const server_t& arg)
-{
- output.write(arg.c_str, arg.size);
- output << ':' << arg.port;
- output << '+' << arg.weight;
- return output;
-}
-#endif
*/
#include <libmemcached/common.h>
+#include <cstdarg>
#define MAX_ERROR_LENGTH 2048
struct memcached_error_t
errmsg_ptr,
at);
}
+ else if (rc == MEMCACHED_PARSE_ERROR and str and str->size)
+ {
+ error->size= (int)snprintf(error->message, MAX_ERROR_LENGTH, "%.*s -> %s",
+ int(str->size), str->c_str, at);
+ }
else if (str and str->size)
{
error->size= (int)snprintf(error->message, MAX_ERROR_LENGTH, "%s, %.*s -> %s",
return rc;
}
+memcached_return_t memcached_set_parser_error(memcached_st& memc,
+ const char *at,
+ const char *format, ...)
+{
+ va_list args;
+
+ char buffer[BUFSIZ];
+ va_start(args, format);
+ int length= vsnprintf(buffer, sizeof(buffer), format, args);
+ va_end(args);
+
+ return memcached_set_error(memc, MEMCACHED_PARSE_ERROR, at, buffer, length);
+}
+
memcached_return_t memcached_set_error(memcached_server_st& self, memcached_return_t rc, const char *at, memcached_string_t& str)
{
assert_msg(rc != MEMCACHED_ERRNO, "Programmer error, MEMCACHED_ERRNO was set to be returned to client");
#endif
LIBMEMCACHED_API
- const char *memcached_last_error_message(memcached_st *memc);
+ const char *memcached_last_error_message(memcached_st *);
LIBMEMCACHED_API
- void memcached_error_print(const memcached_st *self);
+ void memcached_error_print(const memcached_st *);
LIBMEMCACHED_API
- memcached_return_t memcached_last_error(memcached_st *memc);
+ memcached_return_t memcached_last_error(memcached_st *);
LIBMEMCACHED_API
- int memcached_last_error_errno(memcached_st *memc);
+ int memcached_last_error_errno(memcached_st *);
LIBMEMCACHED_API
const char *memcached_server_error(memcached_server_instance_st ptr);
*
*/
-#pragma once
-
#include <libmemcached/error.h>
+#pragma once
+
#ifdef __cplusplus
#define STRINGIFY(x) #x
#define TOSTRING(x) STRINGIFY(x)
#define MEMCACHED_AT __FILE__ ":" TOSTRING(__LINE__)
+LIBMEMCACHED_LOCAL
+memcached_return_t memcached_set_parser_error(memcached_st& memc,
+ const char *at,
+ const char *format, ...);
+
LIBMEMCACHED_LOCAL
memcached_return_t memcached_set_error(memcached_st&, memcached_return_t rc, const char *at);