xapian-core  1.4.19
Classes | Macros | Typedefs | Functions | Variables
queryparser_internal.cc File Reference

build a Xapian::Query object from a user query string More...

#include <config.h>
#include "queryparser_internal.h"
#include "api/queryinternal.h"
#include "omassert.h"
#include "str.h"
#include "stringutils.h"
#include "xapian/error.h"
#include "xapian/unicode.h"
#include "queryparser_token.h"
#include "cjk-tokenizer.h"
#include <algorithm>
#include <cstring>
#include <limits>
#include <list>
#include <string>
#include <vector>
#include "debuglog.h"
+ Include dependency graph for queryparser_internal.cc:

Go to the source code of this file.

Classes

class  Term
 Class used to pass information about a token from lexer to parser. More...
 
class  State
 Parser State shared between the lexer and the parser. More...
 
class  SynonymIterator
 
struct  ProbQuery
 
class  TermGroup
 A group of terms separated only by whitespace. More...
 
class  Terms
 Some terms which form a positional sub-query. More...
 
union  YYMINORTYPE
 
struct  yyStackEntry
 
struct  yyParser
 

Macros

#define Parse_ENGINEALWAYSONSTACK
 
#define VET_BOOL_ARGS(A, B, OP_TXT)
 
#define INTERFACE   1
 
#define YYCODETYPE   unsigned char
 
#define YYNOCODE   40
 
#define YYACTIONTYPE   unsigned char
 
#define ParseTOKENTYPE   Term *
 
#define YYSTACKDEPTH   100
 
#define ParseARG_SDECL   State * state;
 
#define ParseARG_PDECL   ,State * state
 
#define ParseARG_FETCH   State * state = yypParser->state
 
#define ParseARG_STORE   yypParser->state = state
 
#define YYNSTATE   35
 
#define YYNRULE   56
 
#define YYNTOKEN   24
 
#define YY_MAX_SHIFT   34
 
#define YY_MIN_SHIFTREDUCE   77
 
#define YY_MAX_SHIFTREDUCE   132
 
#define YY_ERROR_ACTION   133
 
#define YY_ACCEPT_ACTION   134
 
#define YY_NO_ACTION   135
 
#define YY_MIN_REDUCE   136
 
#define YY_MAX_REDUCE   191
 
#define yytestcase(X)
 
#define YY_ACTTAB_COUNT   (326)
 
#define YY_SHIFT_COUNT   (34)
 
#define YY_SHIFT_MIN   (0)
 
#define YY_SHIFT_MAX   (311)
 
#define YY_REDUCE_COUNT   (14)
 
#define YY_REDUCE_MIN   (-25)
 
#define YY_REDUCE_MAX   (265)
 
#define YYMALLOCARGTYPE   size_t
 
#define yyTraceShift(X, Y, Z)
 
#define TOKEN   yyminor
 

Typedefs

typedef struct yyParser yyParser
 

Functions

bool U_isupper (unsigned ch)
 
bool U_isdigit (unsigned ch)
 
bool U_isalpha (unsigned ch)
 
bool is_not_whitespace (unsigned ch)
 
bool is_not_wordchar (unsigned ch)
 
bool is_digit (unsigned ch)
 
bool is_suffix (unsigned ch)
 
bool is_double_quote (unsigned ch)
 
bool prefix_needs_colon (const string &prefix, unsigned ch)
 
bool is_positional (Xapian::Query::op op)
 
static void add_to_query (Query *&q, Query::op op, Query *term)
 
static void add_to_query (Query *&q, Query::op op, const Query &term)
 
bool is_phrase_generator (unsigned ch)
 
bool is_stem_preventer (unsigned ch)
 
bool should_stem (const string &term)
 
unsigned check_infix (unsigned ch)
 
unsigned check_infix_digit (unsigned ch)
 
static void yy_parse_failed (yyParser *)
 
static void ParseInit (yyParser *pParser)
 
static void ParseFinalize (yyParser *pParser)
 
static void yy_destructor (yyParser *yypParser, YYCODETYPE yymajor, YYMINORTYPE *yypminor)
 
static void yy_pop_parser_stack (yyParser *pParser)
 
static unsigned int yy_find_shift_action (yyParser *pParser, YYCODETYPE iLookAhead)
 
static int yy_find_reduce_action (int stateno, YYCODETYPE iLookAhead)
 
static void yy_shift (yyParser *yypParser, int yyNewState, int yyMajor, ParseTOKENTYPE yyMinor)
 
static void yy_accept (yyParser *)
 
static void yy_reduce (yyParser *yypParser, unsigned int yyruleno, int yyLookahead, ParseTOKENTYPE yyLookaheadToken)
 
static void yy_syntax_error (yyParser *yypParser, int yymajor, ParseTOKENTYPE yyminor)
 
static void Parse (yyParser *yypParser, int yymajor, ParseTOKENTYPE yyminor ParseARG_PDECL)
 

Variables

const unsigned UNICODE_IGNORE = numeric_limits<unsigned>::max()
 Value representing "ignore this" when returned by check_infix() or check_infix_digit(). More...
 
static const YYACTIONTYPE yy_action []
 
static const YYCODETYPE yy_lookahead []
 
static const unsigned short int yy_shift_ofst []
 
static const short yy_reduce_ofst []
 
static const YYACTIONTYPE yy_default []
 
struct {
   YYCODETYPE   lhs
 
   signed char   nrhs
 
yyRuleInfo []
 

Detailed Description

build a Xapian::Query object from a user query string

Definition in file queryparser_internal.cc.

Macro Definition Documentation

◆ INTERFACE

#define INTERFACE   1

Definition at line 1270 of file queryparser_internal.cc.

◆ Parse_ENGINEALWAYSONSTACK

#define Parse_ENGINEALWAYSONSTACK

Definition at line 78 of file queryparser_internal.cc.

◆ ParseARG_FETCH

#define ParseARG_FETCH   State * state = yypParser->state

◆ ParseARG_PDECL

#define ParseARG_PDECL   ,State * state

Definition at line 1290 of file queryparser_internal.cc.

◆ ParseARG_SDECL

#define ParseARG_SDECL   State * state;

Definition at line 1289 of file queryparser_internal.cc.

◆ ParseARG_STORE

#define ParseARG_STORE   yypParser->state = state

◆ ParseTOKENTYPE

#define ParseTOKENTYPE   Term *

Definition at line 1276 of file queryparser_internal.cc.

◆ TOKEN

#define TOKEN   yyminor

◆ VET_BOOL_ARGS

#define VET_BOOL_ARGS (   A,
  B,
  OP_TXT 
)
Value:
do {\
if (!A || !B) {\
state->error = "Syntax: <expression> " OP_TXT " <expression>";\
yy_parse_failed(yypParser);\
return;\
}\
} while (0)
Definition: unittest.cc:682
Definition: unittest.cc:672

Definition at line 1203 of file queryparser_internal.cc.

Referenced by yy_reduce().

◆ YY_ACCEPT_ACTION

#define YY_ACCEPT_ACTION   134

Definition at line 1300 of file queryparser_internal.cc.

Referenced by Parse().

◆ YY_ACTTAB_COUNT

#define YY_ACTTAB_COUNT   (326)

Definition at line 1369 of file queryparser_internal.cc.

Referenced by yy_find_reduce_action(), and yy_find_shift_action().

◆ YY_ERROR_ACTION

#define YY_ERROR_ACTION   133

Definition at line 1299 of file queryparser_internal.cc.

Referenced by Parse(), and yy_reduce().

◆ YY_MAX_REDUCE

#define YY_MAX_REDUCE   191

Definition at line 1303 of file queryparser_internal.cc.

◆ YY_MAX_SHIFT

#define YY_MAX_SHIFT   34

Definition at line 1296 of file queryparser_internal.cc.

Referenced by yy_find_shift_action(), yy_reduce(), and yy_shift().

◆ YY_MAX_SHIFTREDUCE

#define YY_MAX_SHIFTREDUCE   132

Definition at line 1298 of file queryparser_internal.cc.

Referenced by Parse(), and yy_reduce().

◆ YY_MIN_REDUCE

#define YY_MIN_REDUCE   136

Definition at line 1302 of file queryparser_internal.cc.

Referenced by Parse(), yy_find_reduce_action(), and yy_shift().

◆ YY_MIN_SHIFTREDUCE

#define YY_MIN_SHIFTREDUCE   77

Definition at line 1297 of file queryparser_internal.cc.

Referenced by yy_shift().

◆ YY_NO_ACTION

#define YY_NO_ACTION   135

Definition at line 1301 of file queryparser_internal.cc.

◆ YY_REDUCE_COUNT

#define YY_REDUCE_COUNT   (14)

Definition at line 1450 of file queryparser_internal.cc.

Referenced by yy_find_reduce_action().

◆ YY_REDUCE_MAX

#define YY_REDUCE_MAX   (265)

Definition at line 1452 of file queryparser_internal.cc.

◆ YY_REDUCE_MIN

#define YY_REDUCE_MIN   (-25)

Definition at line 1451 of file queryparser_internal.cc.

◆ YY_SHIFT_COUNT

#define YY_SHIFT_COUNT   (34)

Definition at line 1441 of file queryparser_internal.cc.

Referenced by yy_find_shift_action().

◆ YY_SHIFT_MAX

#define YY_SHIFT_MAX   (311)

Definition at line 1443 of file queryparser_internal.cc.

Referenced by yy_find_shift_action().

◆ YY_SHIFT_MIN

#define YY_SHIFT_MIN   (0)

Definition at line 1442 of file queryparser_internal.cc.

Referenced by yy_find_shift_action().

◆ YYACTIONTYPE

#define YYACTIONTYPE   unsigned char

Definition at line 1275 of file queryparser_internal.cc.

Referenced by yy_reduce().

◆ YYCODETYPE

#define YYCODETYPE   unsigned char

Definition at line 1273 of file queryparser_internal.cc.

Referenced by yy_find_shift_action(), and yy_reduce().

◆ YYMALLOCARGTYPE

#define YYMALLOCARGTYPE   size_t

Definition at line 1678 of file queryparser_internal.cc.

◆ YYNOCODE

#define YYNOCODE   40

Definition at line 1274 of file queryparser_internal.cc.

Referenced by Parse(), yy_find_reduce_action(), and yy_find_shift_action().

◆ YYNRULE

#define YYNRULE   56

Definition at line 1294 of file queryparser_internal.cc.

◆ YYNSTATE

#define YYNSTATE   35

Definition at line 1293 of file queryparser_internal.cc.

Referenced by ParseFinalize(), and yy_find_reduce_action().

◆ YYNTOKEN

#define YYNTOKEN   24

Definition at line 1295 of file queryparser_internal.cc.

Referenced by ParseFinalize(), and yy_find_shift_action().

◆ YYSTACKDEPTH

#define YYSTACKDEPTH   100

Definition at line 1287 of file queryparser_internal.cc.

Referenced by ParseInit().

◆ yytestcase

#define yytestcase (   X)

Definition at line 1315 of file queryparser_internal.cc.

Referenced by yy_reduce().

◆ yyTraceShift

#define yyTraceShift (   X,
  Y,
 
)

Definition at line 2046 of file queryparser_internal.cc.

Referenced by yy_find_reduce_action(), yy_reduce(), and yy_shift().

Typedef Documentation

◆ yyParser

typedef struct yyParser yyParser

Definition at line 1538 of file queryparser_internal.cc.

Function Documentation

◆ add_to_query() [1/2]

static void add_to_query ( Query *&  q,
Query::op  op,
Query term 
)
static

Definition at line 447 of file queryparser_internal.cc.

References Assert.

Referenced by Terms::as_opwindow_query(), and yy_reduce().

◆ add_to_query() [2/2]

static void add_to_query ( Query *&  q,
Query::op  op,
const Query term 
)
static

Definition at line 465 of file queryparser_internal.cc.

◆ check_infix()

unsigned check_infix ( unsigned  ch)
inline

◆ check_infix_digit()

unsigned check_infix_digit ( unsigned  ch)
inline

◆ is_digit()

bool is_digit ( unsigned  ch)
inline

◆ is_double_quote()

bool is_double_quote ( unsigned  ch)
inline

Definition at line 126 of file queryparser_internal.cc.

Referenced by Xapian::QueryParser::Internal::parse_query().

◆ is_not_whitespace()

bool is_not_whitespace ( unsigned  ch)
inline

◆ is_not_wordchar()

bool is_not_wordchar ( unsigned  ch)
inline

◆ is_phrase_generator()

bool is_phrase_generator ( unsigned  ch)
inline

Definition at line 570 of file queryparser_internal.cc.

Referenced by Xapian::QueryParser::Internal::parse_query().

◆ is_positional()

bool is_positional ( Xapian::Query::op  op)
inline

◆ is_stem_preventer()

bool is_stem_preventer ( unsigned  ch)
inline

Definition at line 579 of file queryparser_internal.cc.

Referenced by Xapian::QueryParser::Internal::parse_query().

◆ is_suffix()

bool is_suffix ( unsigned  ch)
inline

Definition at line 121 of file queryparser_internal.cc.

Referenced by Xapian::QueryParser::Internal::parse_term().

◆ Parse()

static void Parse ( yyParser yypParser,
int  yymajor,
ParseTOKENTYPE yyminor  ParseARG_PDECL 
)
static

◆ ParseFinalize()

static void ParseFinalize ( yyParser pParser)
static

◆ ParseInit()

static void ParseInit ( yyParser pParser)
static

Definition at line 1684 of file queryparser_internal.cc.

References yyParser::yyerrcnt, yyParser::yystack, and YYSTACKDEPTH.

Referenced by yyParser::yyParser().

◆ prefix_needs_colon()

bool prefix_needs_colon ( const string &  prefix,
unsigned  ch 
)
inline

◆ should_stem()

bool should_stem ( const string &  term)
inline

◆ U_isalpha()

bool U_isalpha ( unsigned  ch)
inline

◆ U_isdigit()

bool U_isdigit ( unsigned  ch)
inline

Definition at line 90 of file queryparser_internal.cc.

Referenced by Xapian::QueryParser::Internal::parse_query().

◆ U_isupper()

bool U_isupper ( unsigned  ch)
inline

◆ yy_accept()

static void yy_accept ( yyParser yypParser)
static

◆ yy_destructor()

static void yy_destructor ( yyParser yypParser,
YYCODETYPE  yymajor,
YYMINORTYPE yypminor 
)
static

◆ yy_find_reduce_action()

static int yy_find_reduce_action ( int  stateno,
YYCODETYPE  iLookAhead 
)
static

◆ yy_find_shift_action()

static unsigned int yy_find_shift_action ( yyParser pParser,
YYCODETYPE  iLookAhead 
)
static

◆ yy_parse_failed()

static void yy_parse_failed ( yyParser yypParser)
static

◆ yy_pop_parser_stack()

static void yy_pop_parser_stack ( yyParser pParser)
static

◆ yy_reduce()

static void yy_reduce ( yyParser yypParser,
unsigned int  yyruleno,
int  yyLookahead,
ParseTOKENTYPE  yyLookaheadToken 
)
static

◆ yy_shift()

static void yy_shift ( yyParser yypParser,
int  yyNewState,
int  yyMajor,
ParseTOKENTYPE  yyMinor 
)
static

◆ yy_syntax_error()

static void yy_syntax_error ( yyParser yypParser,
int  yymajor,
ParseTOKENTYPE  yyminor 
)
static

Definition at line 2757 of file queryparser_internal.cc.

References ParseARG_FETCH, ParseARG_STORE, and yy_parse_failed().

Referenced by Parse().

Variable Documentation

◆ lhs

Definition at line 2075 of file queryparser_internal.cc.

◆ nrhs

signed char nrhs

Definition at line 2076 of file queryparser_internal.cc.

Referenced by yy_reduce().

◆ UNICODE_IGNORE

const unsigned UNICODE_IGNORE = numeric_limits<unsigned>::max()

◆ yy_action

const YYACTIONTYPE yy_action[]
static

Definition at line 1370 of file queryparser_internal.cc.

Referenced by yy_find_reduce_action(), and yy_find_shift_action().

◆ yy_default

const YYACTIONTYPE yy_default[]
static
Initial value:
= {
144, 144, 144, 144, 144, 144, 144, 144, 145, 133,
133, 133, 133, 160, 133, 161, 190, 162, 133, 161,
133, 133, 142, 167, 143, 133, 187, 133, 169, 133,
168, 166, 133, 133, 187,
}

Definition at line 1457 of file queryparser_internal.cc.

Referenced by yy_find_reduce_action(), and yy_find_shift_action().

◆ yy_lookahead

const YYCODETYPE yy_lookahead[]
static

◆ yy_reduce_ofst

const short yy_reduce_ofst[]
static
Initial value:
= {
-25, 27, 40, 53, 66, 79, 92, 105, 220, 229,
239, 248, 257, 265, -19,
}

Definition at line 1453 of file queryparser_internal.cc.

Referenced by yy_find_reduce_action().

◆ yy_shift_ofst

const unsigned short int yy_shift_ofst[]
static
Initial value:
= {
30, 9, 136, 136, 136, 136, 136, 136, 152, 180,
192, 204, 216, 228, 11, 173, 304, 175, 26, 175,
308, 171, 311, 126, 32, 4, 1, 20, 2, 28,
45, 47, 62, 75, 100,
}

Definition at line 1444 of file queryparser_internal.cc.

Referenced by ParseFinalize(), and yy_find_shift_action().

◆ yyRuleInfo

const { ... } yyRuleInfo[]

Referenced by yy_reduce().