whistlepig 0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README +86 -0
- data/ext/whistlepig/defaults.h +28 -0
- data/ext/whistlepig/entry.c +181 -0
- data/ext/whistlepig/entry.h +66 -0
- data/ext/whistlepig/error.c +24 -0
- data/ext/whistlepig/error.h +94 -0
- data/ext/whistlepig/extconf.rb +6 -0
- data/ext/whistlepig/index.c +294 -0
- data/ext/whistlepig/index.h +88 -0
- data/ext/whistlepig/khash.h +316 -0
- data/ext/whistlepig/mmap-obj.c +76 -0
- data/ext/whistlepig/mmap-obj.h +52 -0
- data/ext/whistlepig/query-parser.c +37 -0
- data/ext/whistlepig/query-parser.h +25 -0
- data/ext/whistlepig/query-parser.lex.c +2249 -0
- data/ext/whistlepig/query-parser.lex.h +359 -0
- data/ext/whistlepig/query-parser.tab.c +1757 -0
- data/ext/whistlepig/query-parser.tab.h +85 -0
- data/ext/whistlepig/query.c +194 -0
- data/ext/whistlepig/query.h +78 -0
- data/ext/whistlepig/search.c +746 -0
- data/ext/whistlepig/search.h +76 -0
- data/ext/whistlepig/segment.c +615 -0
- data/ext/whistlepig/segment.h +137 -0
- data/ext/whistlepig/stringmap.c +278 -0
- data/ext/whistlepig/stringmap.h +82 -0
- data/ext/whistlepig/stringpool.c +44 -0
- data/ext/whistlepig/stringpool.h +58 -0
- data/ext/whistlepig/termhash.c +294 -0
- data/ext/whistlepig/termhash.h +79 -0
- data/ext/whistlepig/tokenizer.lex.c +2263 -0
- data/ext/whistlepig/tokenizer.lex.h +360 -0
- data/ext/whistlepig/whistlepig.h +15 -0
- data/ext/whistlepig/whistlepigc.c +537 -0
- data/lib/whistlepig.rb +119 -0
- metadata +103 -0
@@ -0,0 +1,360 @@
|
|
1
|
+
#ifndef yyHEADER_H
|
2
|
+
#define yyHEADER_H 1
|
3
|
+
#define yyIN_HEADER 1
|
4
|
+
|
5
|
+
#line 6 "tokenizer.lex.h"
|
6
|
+
#line 2 "tokenizer.lex"
|
7
|
+
#define TOK_DONE 0
|
8
|
+
#define TOK_NUMBER 1
|
9
|
+
#define TOK_WORD 2
|
10
|
+
|
11
|
+
#include "segment.h"
|
12
|
+
|
13
|
+
typedef struct lexinfo {
|
14
|
+
pos_t start;
|
15
|
+
pos_t end;
|
16
|
+
} lexinfo;
|
17
|
+
|
18
|
+
|
19
|
+
|
20
|
+
#line 21 "tokenizer.lex.h"
|
21
|
+
|
22
|
+
#define YY_INT_ALIGNED short int
|
23
|
+
|
24
|
+
/* A lexical scanner generated by flex */
|
25
|
+
|
26
|
+
#define FLEX_SCANNER
|
27
|
+
#define YY_FLEX_MAJOR_VERSION 2
|
28
|
+
#define YY_FLEX_MINOR_VERSION 5
|
29
|
+
#define YY_FLEX_SUBMINOR_VERSION 35
|
30
|
+
#if YY_FLEX_SUBMINOR_VERSION > 0
|
31
|
+
#define FLEX_BETA
|
32
|
+
#endif
|
33
|
+
|
34
|
+
/* First, we deal with platform-specific or compiler-specific issues. */
|
35
|
+
|
36
|
+
/* begin standard C headers. */
|
37
|
+
#include <stdio.h>
|
38
|
+
#include <string.h>
|
39
|
+
#include <errno.h>
|
40
|
+
#include <stdlib.h>
|
41
|
+
|
42
|
+
/* end standard C headers. */
|
43
|
+
|
44
|
+
/* flex integer type definitions */
|
45
|
+
|
46
|
+
#ifndef FLEXINT_H
|
47
|
+
#define FLEXINT_H
|
48
|
+
|
49
|
+
/* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
|
50
|
+
|
51
|
+
#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
|
52
|
+
|
53
|
+
/* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
|
54
|
+
* if you want the limit (max/min) macros for int types.
|
55
|
+
*/
|
56
|
+
#ifndef __STDC_LIMIT_MACROS
|
57
|
+
#define __STDC_LIMIT_MACROS 1
|
58
|
+
#endif
|
59
|
+
|
60
|
+
#include <inttypes.h>
|
61
|
+
typedef int8_t flex_int8_t;
|
62
|
+
typedef uint8_t flex_uint8_t;
|
63
|
+
typedef int16_t flex_int16_t;
|
64
|
+
typedef uint16_t flex_uint16_t;
|
65
|
+
typedef int32_t flex_int32_t;
|
66
|
+
typedef uint32_t flex_uint32_t;
|
67
|
+
#else
|
68
|
+
typedef signed char flex_int8_t;
|
69
|
+
typedef short int flex_int16_t;
|
70
|
+
typedef int flex_int32_t;
|
71
|
+
typedef unsigned char flex_uint8_t;
|
72
|
+
typedef unsigned short int flex_uint16_t;
|
73
|
+
typedef unsigned int flex_uint32_t;
|
74
|
+
|
75
|
+
/* Limits of integral types. */
|
76
|
+
#ifndef INT8_MIN
|
77
|
+
#define INT8_MIN (-128)
|
78
|
+
#endif
|
79
|
+
#ifndef INT16_MIN
|
80
|
+
#define INT16_MIN (-32767-1)
|
81
|
+
#endif
|
82
|
+
#ifndef INT32_MIN
|
83
|
+
#define INT32_MIN (-2147483647-1)
|
84
|
+
#endif
|
85
|
+
#ifndef INT8_MAX
|
86
|
+
#define INT8_MAX (127)
|
87
|
+
#endif
|
88
|
+
#ifndef INT16_MAX
|
89
|
+
#define INT16_MAX (32767)
|
90
|
+
#endif
|
91
|
+
#ifndef INT32_MAX
|
92
|
+
#define INT32_MAX (2147483647)
|
93
|
+
#endif
|
94
|
+
#ifndef UINT8_MAX
|
95
|
+
#define UINT8_MAX (255U)
|
96
|
+
#endif
|
97
|
+
#ifndef UINT16_MAX
|
98
|
+
#define UINT16_MAX (65535U)
|
99
|
+
#endif
|
100
|
+
#ifndef UINT32_MAX
|
101
|
+
#define UINT32_MAX (4294967295U)
|
102
|
+
#endif
|
103
|
+
|
104
|
+
#endif /* ! C99 */
|
105
|
+
|
106
|
+
#endif /* ! FLEXINT_H */
|
107
|
+
|
108
|
+
#ifdef __cplusplus
|
109
|
+
|
110
|
+
/* The "const" storage-class-modifier is valid. */
|
111
|
+
#define YY_USE_CONST
|
112
|
+
|
113
|
+
#else /* ! __cplusplus */
|
114
|
+
|
115
|
+
/* C99 requires __STDC__ to be defined as 1. */
|
116
|
+
#if defined (__STDC__)
|
117
|
+
|
118
|
+
#define YY_USE_CONST
|
119
|
+
|
120
|
+
#endif /* defined (__STDC__) */
|
121
|
+
#endif /* ! __cplusplus */
|
122
|
+
|
123
|
+
#ifdef YY_USE_CONST
|
124
|
+
#define yyconst const
|
125
|
+
#else
|
126
|
+
#define yyconst
|
127
|
+
#endif
|
128
|
+
|
129
|
+
/* An opaque pointer. */
|
130
|
+
#ifndef YY_TYPEDEF_YY_SCANNER_T
|
131
|
+
#define YY_TYPEDEF_YY_SCANNER_T
|
132
|
+
typedef void* yyscan_t;
|
133
|
+
#endif
|
134
|
+
|
135
|
+
/* For convenience, these vars (plus the bison vars far below)
|
136
|
+
are macros in the reentrant scanner. */
|
137
|
+
#define yyin yyg->yyin_r
|
138
|
+
#define yyout yyg->yyout_r
|
139
|
+
#define yyextra yyg->yyextra_r
|
140
|
+
#define yyleng yyg->yyleng_r
|
141
|
+
#define yytext yyg->yytext_r
|
142
|
+
#define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno)
|
143
|
+
#define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column)
|
144
|
+
#define yy_flex_debug yyg->yy_flex_debug_r
|
145
|
+
|
146
|
+
/* Size of default input buffer. */
|
147
|
+
#ifndef YY_BUF_SIZE
|
148
|
+
#ifdef __ia64__
|
149
|
+
/* On IA-64, the buffer size is 16k, not 8k.
|
150
|
+
* Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
|
151
|
+
* Ditto for the __ia64__ case accordingly.
|
152
|
+
*/
|
153
|
+
#define YY_BUF_SIZE 32768
|
154
|
+
#else
|
155
|
+
#define YY_BUF_SIZE 16384
|
156
|
+
#endif /* __ia64__ */
|
157
|
+
#endif
|
158
|
+
|
159
|
+
#ifndef YY_TYPEDEF_YY_BUFFER_STATE
|
160
|
+
#define YY_TYPEDEF_YY_BUFFER_STATE
|
161
|
+
typedef struct yy_buffer_state *YY_BUFFER_STATE;
|
162
|
+
#endif
|
163
|
+
|
164
|
+
#ifndef YY_TYPEDEF_YY_SIZE_T
|
165
|
+
#define YY_TYPEDEF_YY_SIZE_T
|
166
|
+
typedef size_t yy_size_t;
|
167
|
+
#endif
|
168
|
+
|
169
|
+
#ifndef YY_STRUCT_YY_BUFFER_STATE
|
170
|
+
#define YY_STRUCT_YY_BUFFER_STATE
|
171
|
+
struct yy_buffer_state
|
172
|
+
{
|
173
|
+
FILE *yy_input_file;
|
174
|
+
|
175
|
+
char *yy_ch_buf; /* input buffer */
|
176
|
+
char *yy_buf_pos; /* current position in input buffer */
|
177
|
+
|
178
|
+
/* Size of input buffer in bytes, not including room for EOB
|
179
|
+
* characters.
|
180
|
+
*/
|
181
|
+
yy_size_t yy_buf_size;
|
182
|
+
|
183
|
+
/* Number of characters read into yy_ch_buf, not including EOB
|
184
|
+
* characters.
|
185
|
+
*/
|
186
|
+
int yy_n_chars;
|
187
|
+
|
188
|
+
/* Whether we "own" the buffer - i.e., we know we created it,
|
189
|
+
* and can realloc() it to grow it, and should free() it to
|
190
|
+
* delete it.
|
191
|
+
*/
|
192
|
+
int yy_is_our_buffer;
|
193
|
+
|
194
|
+
/* Whether this is an "interactive" input source; if so, and
|
195
|
+
* if we're using stdio for input, then we want to use getc()
|
196
|
+
* instead of fread(), to make sure we stop fetching input after
|
197
|
+
* each newline.
|
198
|
+
*/
|
199
|
+
int yy_is_interactive;
|
200
|
+
|
201
|
+
/* Whether we're considered to be at the beginning of a line.
|
202
|
+
* If so, '^' rules will be active on the next match, otherwise
|
203
|
+
* not.
|
204
|
+
*/
|
205
|
+
int yy_at_bol;
|
206
|
+
|
207
|
+
int yy_bs_lineno; /**< The line count. */
|
208
|
+
int yy_bs_column; /**< The column count. */
|
209
|
+
|
210
|
+
/* Whether to try to fill the input buffer when we reach the
|
211
|
+
* end of it.
|
212
|
+
*/
|
213
|
+
int yy_fill_buffer;
|
214
|
+
|
215
|
+
int yy_buffer_status;
|
216
|
+
|
217
|
+
};
|
218
|
+
#endif /* !YY_STRUCT_YY_BUFFER_STATE */
|
219
|
+
|
220
|
+
void yyrestart (FILE *input_file ,yyscan_t yyscanner );
|
221
|
+
void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
|
222
|
+
YY_BUFFER_STATE yy_create_buffer (FILE *file,int size ,yyscan_t yyscanner );
|
223
|
+
void yy_delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
|
224
|
+
void yy_flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
|
225
|
+
void yypush_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
|
226
|
+
void yypop_buffer_state (yyscan_t yyscanner );
|
227
|
+
|
228
|
+
YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner );
|
229
|
+
YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str ,yyscan_t yyscanner );
|
230
|
+
YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner );
|
231
|
+
|
232
|
+
void *yyalloc (yy_size_t ,yyscan_t yyscanner );
|
233
|
+
void *yyrealloc (void *,yy_size_t ,yyscan_t yyscanner );
|
234
|
+
void yyfree (void * ,yyscan_t yyscanner );
|
235
|
+
|
236
|
+
/* Begin user sect3 */
|
237
|
+
|
238
|
+
#define yywrap(n) 1
|
239
|
+
#define YY_SKIP_YYWRAP
|
240
|
+
|
241
|
+
#define yytext_ptr yytext_r
|
242
|
+
|
243
|
+
#ifdef YY_HEADER_EXPORT_START_CONDITIONS
|
244
|
+
#define INITIAL 0
|
245
|
+
|
246
|
+
#endif
|
247
|
+
|
248
|
+
#ifndef YY_NO_UNISTD_H
|
249
|
+
/* Special case for "unistd.h", since it is non-ANSI. We include it way
|
250
|
+
* down here because we want the user's section 1 to have been scanned first.
|
251
|
+
* The user has a chance to override it with an option.
|
252
|
+
*/
|
253
|
+
#include <unistd.h>
|
254
|
+
#endif
|
255
|
+
|
256
|
+
#define YY_EXTRA_TYPE struct lexinfo*
|
257
|
+
|
258
|
+
int yylex_init (yyscan_t* scanner);
|
259
|
+
|
260
|
+
int yylex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner);
|
261
|
+
|
262
|
+
/* Accessor methods to globals.
|
263
|
+
These are made visible to non-reentrant scanners for convenience. */
|
264
|
+
|
265
|
+
int yylex_destroy (yyscan_t yyscanner );
|
266
|
+
|
267
|
+
int yyget_debug (yyscan_t yyscanner );
|
268
|
+
|
269
|
+
void yyset_debug (int debug_flag ,yyscan_t yyscanner );
|
270
|
+
|
271
|
+
YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner );
|
272
|
+
|
273
|
+
void yyset_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner );
|
274
|
+
|
275
|
+
FILE *yyget_in (yyscan_t yyscanner );
|
276
|
+
|
277
|
+
void yyset_in (FILE * in_str ,yyscan_t yyscanner );
|
278
|
+
|
279
|
+
FILE *yyget_out (yyscan_t yyscanner );
|
280
|
+
|
281
|
+
void yyset_out (FILE * out_str ,yyscan_t yyscanner );
|
282
|
+
|
283
|
+
int yyget_leng (yyscan_t yyscanner );
|
284
|
+
|
285
|
+
char *yyget_text (yyscan_t yyscanner );
|
286
|
+
|
287
|
+
int yyget_lineno (yyscan_t yyscanner );
|
288
|
+
|
289
|
+
void yyset_lineno (int line_number ,yyscan_t yyscanner );
|
290
|
+
|
291
|
+
/* Macros after this point can all be overridden by user definitions in
|
292
|
+
* section 1.
|
293
|
+
*/
|
294
|
+
|
295
|
+
#ifndef YY_SKIP_YYWRAP
|
296
|
+
#ifdef __cplusplus
|
297
|
+
extern "C" int yywrap (yyscan_t yyscanner );
|
298
|
+
#else
|
299
|
+
extern int yywrap (yyscan_t yyscanner );
|
300
|
+
#endif
|
301
|
+
#endif
|
302
|
+
|
303
|
+
#ifndef yytext_ptr
|
304
|
+
static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner);
|
305
|
+
#endif
|
306
|
+
|
307
|
+
#ifdef YY_NEED_STRLEN
|
308
|
+
static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner);
|
309
|
+
#endif
|
310
|
+
|
311
|
+
#ifndef YY_NO_INPUT
|
312
|
+
|
313
|
+
#endif
|
314
|
+
|
315
|
+
/* Amount of stuff to slurp up with each read. */
|
316
|
+
#ifndef YY_READ_BUF_SIZE
|
317
|
+
#ifdef __ia64__
|
318
|
+
/* On IA-64, the buffer size is 16k, not 8k */
|
319
|
+
#define YY_READ_BUF_SIZE 16384
|
320
|
+
#else
|
321
|
+
#define YY_READ_BUF_SIZE 8192
|
322
|
+
#endif /* __ia64__ */
|
323
|
+
#endif
|
324
|
+
|
325
|
+
/* Number of entries by which start-condition stack grows. */
|
326
|
+
#ifndef YY_START_STACK_INCR
|
327
|
+
#define YY_START_STACK_INCR 25
|
328
|
+
#endif
|
329
|
+
|
330
|
+
/* Default declaration of generated scanner - a define so the user can
|
331
|
+
* easily add parameters.
|
332
|
+
*/
|
333
|
+
#ifndef YY_DECL
|
334
|
+
#define YY_DECL_IS_OURS 1
|
335
|
+
|
336
|
+
extern int yylex (yyscan_t yyscanner);
|
337
|
+
|
338
|
+
#define YY_DECL int yylex (yyscan_t yyscanner)
|
339
|
+
#endif /* !YY_DECL */
|
340
|
+
|
341
|
+
/* yy_get_previous_state - get the state just before the EOB char was reached */
|
342
|
+
|
343
|
+
#undef YY_NEW_FILE
|
344
|
+
#undef YY_FLUSH_BUFFER
|
345
|
+
#undef yy_set_bol
|
346
|
+
#undef yy_new_buffer
|
347
|
+
#undef yy_set_interactive
|
348
|
+
#undef YY_DO_BEFORE_ACTION
|
349
|
+
|
350
|
+
#ifdef YY_DECL_IS_OURS
|
351
|
+
#undef YY_DECL_IS_OURS
|
352
|
+
#undef YY_DECL
|
353
|
+
#endif
|
354
|
+
|
355
|
+
#line 51 "tokenizer.lex"
|
356
|
+
|
357
|
+
|
358
|
+
#line 359 "tokenizer.lex.h"
|
359
|
+
#undef yyIN_HEADER
|
360
|
+
#endif /* yyHEADER_H */
|
@@ -0,0 +1,15 @@
|
|
1
|
+
#ifndef WHISTLEPIG_H_
|
2
|
+
#define WHISTLEPIG_H_
|
3
|
+
|
4
|
+
// whistlepig main header file
|
5
|
+
// (c) 2011 William Morgan. See COPYING for license terms.
|
6
|
+
//
|
7
|
+
// requires everything you'll need to use whistlepig as a client.
|
8
|
+
|
9
|
+
#include "defaults.h"
|
10
|
+
#include "index.h"
|
11
|
+
#include "query.h"
|
12
|
+
#include "query-parser.h"
|
13
|
+
#include "error.h"
|
14
|
+
|
15
|
+
#endif
|