xapian-core  2.0.0
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 "word-breaker.h"
#include <algorithm>
#include <cstring>
#include <limits>
#include <list>
#include <string>
#include <string_view>
#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   42
 
#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   42
 
#define YYNRULE   59
 
#define YYNTOKEN   26
 
#define YY_MAX_SHIFT   41
 
#define YY_MIN_SHIFTREDUCE   83
 
#define YY_MAX_SHIFTREDUCE   141
 
#define YY_ERROR_ACTION   142
 
#define YY_ACCEPT_ACTION   143
 
#define YY_NO_ACTION   144
 
#define YY_MIN_REDUCE   145
 
#define YY_MAX_REDUCE   203
 
#define yytestcase(X)
 
#define YY_ACTTAB_COUNT   (352)
 
#define YY_SHIFT_COUNT   (41)
 
#define YY_SHIFT_MIN   (0)
 
#define YY_SHIFT_MAX   (339)
 
#define YY_REDUCE_COUNT   (16)
 
#define YY_REDUCE_MIN   (-36)
 
#define YY_REDUCE_MAX   (301)
 
#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, const State &state)
 
unsigned check_infix (unsigned ch)
 
unsigned check_infix_digit (unsigned ch)
 
static void yy_parse_failed (yyParser *)
 
bool is_extended_wildcard (unsigned ch, unsigned flags)
 
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

static constexpr unsigned NO_EDIT_DISTANCE = unsigned(-1)
 
static constexpr unsigned DEFAULT_EDIT_DISTANCE = 2
 
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 1616 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

Definition at line 1637 of file queryparser_internal.cc.

◆ ParseARG_PDECL

#define ParseARG_PDECL   ,State * state

Definition at line 1636 of file queryparser_internal.cc.

◆ ParseARG_SDECL

#define ParseARG_SDECL   State * state;

Definition at line 1635 of file queryparser_internal.cc.

◆ ParseARG_STORE

#define ParseARG_STORE   yypParser->state = state

Definition at line 1638 of file queryparser_internal.cc.

◆ ParseTOKENTYPE

#define ParseTOKENTYPE   Term *

Definition at line 1622 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:650
Definition: unittest.cc:660

Definition at line 1549 of file queryparser_internal.cc.

◆ YY_ACCEPT_ACTION

#define YY_ACCEPT_ACTION   143

Definition at line 1646 of file queryparser_internal.cc.

◆ YY_ACTTAB_COUNT

#define YY_ACTTAB_COUNT   (352)

Definition at line 1715 of file queryparser_internal.cc.

◆ YY_ERROR_ACTION

#define YY_ERROR_ACTION   142

Definition at line 1645 of file queryparser_internal.cc.

◆ YY_MAX_REDUCE

#define YY_MAX_REDUCE   203

Definition at line 1649 of file queryparser_internal.cc.

◆ YY_MAX_SHIFT

#define YY_MAX_SHIFT   41

Definition at line 1642 of file queryparser_internal.cc.

◆ YY_MAX_SHIFTREDUCE

#define YY_MAX_SHIFTREDUCE   141

Definition at line 1644 of file queryparser_internal.cc.

◆ YY_MIN_REDUCE

#define YY_MIN_REDUCE   145

Definition at line 1648 of file queryparser_internal.cc.

◆ YY_MIN_SHIFTREDUCE

#define YY_MIN_SHIFTREDUCE   83

Definition at line 1643 of file queryparser_internal.cc.

◆ YY_NO_ACTION

#define YY_NO_ACTION   144

Definition at line 1647 of file queryparser_internal.cc.

◆ YY_REDUCE_COUNT

#define YY_REDUCE_COUNT   (16)

Definition at line 1803 of file queryparser_internal.cc.

◆ YY_REDUCE_MAX

#define YY_REDUCE_MAX   (301)

Definition at line 1805 of file queryparser_internal.cc.

◆ YY_REDUCE_MIN

#define YY_REDUCE_MIN   (-36)

Definition at line 1804 of file queryparser_internal.cc.

◆ YY_SHIFT_COUNT

#define YY_SHIFT_COUNT   (41)

Definition at line 1793 of file queryparser_internal.cc.

◆ YY_SHIFT_MAX

#define YY_SHIFT_MAX   (339)

Definition at line 1795 of file queryparser_internal.cc.

◆ YY_SHIFT_MIN

#define YY_SHIFT_MIN   (0)

Definition at line 1794 of file queryparser_internal.cc.

◆ YYACTIONTYPE

#define YYACTIONTYPE   unsigned char

Definition at line 1621 of file queryparser_internal.cc.

◆ YYCODETYPE

#define YYCODETYPE   unsigned char

Definition at line 1619 of file queryparser_internal.cc.

◆ YYMALLOCARGTYPE

#define YYMALLOCARGTYPE   size_t

Definition at line 2037 of file queryparser_internal.cc.

◆ YYNOCODE

#define YYNOCODE   42

Definition at line 1620 of file queryparser_internal.cc.

◆ YYNRULE

#define YYNRULE   59

Definition at line 1640 of file queryparser_internal.cc.

◆ YYNSTATE

#define YYNSTATE   42

Definition at line 1639 of file queryparser_internal.cc.

◆ YYNTOKEN

#define YYNTOKEN   26

Definition at line 1641 of file queryparser_internal.cc.

◆ YYSTACKDEPTH

#define YYSTACKDEPTH   100

Definition at line 1633 of file queryparser_internal.cc.

◆ yytestcase

#define yytestcase (   X)

Definition at line 1661 of file queryparser_internal.cc.

◆ yyTraceShift

#define yyTraceShift (   X,
  Y,
 
)

Definition at line 2407 of file queryparser_internal.cc.

Typedef Documentation

◆ yyParser

typedef struct yyParser yyParser

Definition at line 1872 of file queryparser_internal.cc.

Function Documentation

◆ add_to_query() [1/2]

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

Definition at line 513 of file queryparser_internal.cc.

References term.

◆ add_to_query() [2/2]

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

Definition at line 495 of file queryparser_internal.cc.

References Assert, and term.

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

◆ 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 132 of file queryparser_internal.cc.

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

◆ is_extended_wildcard()

bool is_extended_wildcard ( unsigned  ch,
unsigned  flags 
)
inline

◆ 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 669 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 678 of file queryparser_internal.cc.

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

◆ is_suffix()

bool is_suffix ( unsigned  ch)
inline

Definition at line 127 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

Definition at line 2209 of file queryparser_internal.cc.

References yy_pop_parser_stack(), and yyParser::yystack.

Referenced by yyParser::~yyParser().

◆ ParseInit()

static void ParseInit ( yyParser pParser)
static

Definition at line 2043 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,
const State state 
)
inline

◆ U_isalpha()

bool U_isalpha ( unsigned  ch)
inline

Definition at line 98 of file queryparser_internal.cc.

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

◆ U_isdigit()

bool U_isdigit ( unsigned  ch)
inline

◆ 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

Definition at line 2413 of file queryparser_internal.cc.

References YY_MAX_SHIFT, YY_MIN_REDUCE, YY_MIN_SHIFTREDUCE, yyParser::yystack, and yyTraceShift.

Referenced by Parse().

◆ yy_syntax_error()

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

Definition at line 3152 of file queryparser_internal.cc.

References ParseARG_FETCH, ParseARG_STORE, and yy_parse_failed().

Referenced by Parse().

Variable Documentation

◆ DEFAULT_EDIT_DISTANCE

constexpr unsigned DEFAULT_EDIT_DISTANCE = 2
staticconstexpr

Definition at line 85 of file queryparser_internal.cc.

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

◆ lhs

Definition at line 2436 of file queryparser_internal.cc.

◆ NO_EDIT_DISTANCE

constexpr unsigned NO_EDIT_DISTANCE = unsigned(-1)
staticconstexpr

Definition at line 84 of file queryparser_internal.cc.

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

◆ nrhs

signed char nrhs

Definition at line 2437 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 1716 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:
= {
154, 154, 154, 154, 154, 154, 154, 154, 154, 155,
142, 142, 142, 142, 170, 142, 142, 171, 202, 142,
172, 142, 171, 151, 142, 142, 152, 142, 178, 150,
149, 199, 142, 180, 142, 179, 177, 142, 142, 148,
147, 199,
}

Definition at line 1810 of file queryparser_internal.cc.

Referenced by yy_find_reduce_action(), and yy_find_shift_action().

◆ yy_lookahead

const YYCODETYPE yy_lookahead[]
static

Definition at line 1754 of file queryparser_internal.cc.

Referenced by yy_find_reduce_action(), and yy_find_shift_action().

◆ yy_reduce_ofst

const short yy_reduce_ofst[]
static
Initial value:
= {
21, 35, 65, 78, 91, 104, 117, 130, 143, 254,
265, 274, 283, 292, 301, -36, -35,
}

Definition at line 1806 of file queryparser_internal.cc.

Referenced by yy_find_reduce_action().

◆ yy_shift_ofst

const unsigned short int yy_shift_ofst[]
static
Initial value:
= {
23, 0, 68, 68, 68, 68, 68, 68, 68, 176,
207, 219, 231, 243, 255, 22, 22, 199, 278, 25,
201, 6, 201, 339, 295, 304, 205, 70, 57, 26,
26, 10, 44, 55, 67, 1, 63, 88, 101, 26,
26, 2,
}

Definition at line 1796 of file queryparser_internal.cc.

Referenced by yy_find_shift_action().

◆ 

const { ... } yyRuleInfo[]

Referenced by yy_reduce().