1 /* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
5 * Copyright (C) 2011 Data Differential, http://datadifferential.com/
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions are
12 * * Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
15 * * Redistributions in binary form must reproduce the above
16 * copyright notice, this list of conditions and the following disclaimer
17 * in the documentation and/or other materials provided with the
20 * * The names of its contributors may not be used to endorse or
21 * promote products derived from this software without specific prior
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
25 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
26 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
27 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
28 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
29 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
30 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
31 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
32 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
33 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
34 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
43 #include <libmemcached/options/type.h>
44 #include <libmemcached/options/string.h>
45 #include <libmemcached/options/symbol.h>
47 #pragma GCC diagnostic ignored "-Wold-style-cast"
48 #include <libmemcached/options/scanner.h>
50 inline int libmemcached_error(YYLTYPE *locp, type_st *parser, yyscan_t *scanner, const char *str)
52 std::cerr << str << std::endl;
63 %output "libmemcached/options/parser.cc"
64 %defines "libmemcached/options/parser.h"
65 %lex-param { yyscan_t *scanner }
66 %name-prefix="libmemcached_"
67 %parse-param { type_st *parser }
68 %parse-param { yyscan_t *scanner }
83 %token <number> NUMBER
85 %token <string> IDENTIFIER
86 %token <string> SERVER_WITH_PORT
87 %token <string> IPADDRESS
88 %token <string> IPADDRESS_WITH_PORT
97 | statement expression
105 (void) memcached_server_add_parsed(parser->memc, $3.c_str, $3.length, $3.port, 0);
107 | SERVERS '=' server_list
111 memcached_behavior_set(parser->memc, MEMCACHED_BEHAVIOR_TCP_NODELAY, true);
115 memcached_behavior_set(parser->memc, MEMCACHED_BEHAVIOR_VERIFY_KEY, true);
122 (void) memcached_server_add_parsed(parser->memc, $1.c_str, $1.length, $1.port, 0);
124 | server_list ',' server
126 (void) memcached_server_add_parsed(parser->memc, $3.c_str, $3.length, $3.port, 0);
131 SERVER_WITH_PORT NUMBER
134 $$.length= $1.length -1;
140 $$.length= $1.length;
141 $$.port= MEMCACHED_DEFAULT_PORT;
143 | IPADDRESS_WITH_PORT NUMBER
146 $$.length= $1.length -1;
152 $$.length= $1.length;
153 $$.port= MEMCACHED_DEFAULT_PORT;