#include <config.h>#include "omassert.h"#include "queryparser_internal.h"#include <xapian/error.h>#include <xapian/unicode.h>#include "str.h"#include "stringutils.h"#include "queryparser_token.h"#include "cjk-tokenizer.h"#include <algorithm>#include <limits>#include <list>#include <string>#include <string.h>#include "debuglog.h"

Go to the source code of this file.
Classes | |
| struct | filter_group_id |
| A structure identifying a group of filter terms or a value range. More... | |
| 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 | ParserHandler |
| 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 |
Defines | |
| #define | BOOL_OP_TO_QUERY(E, A, OP, 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 77 |
| #define | YYNRULE 56 |
| #define | YY_NO_ACTION (YYNSTATE+YYNRULE+2) |
| #define | YY_ACCEPT_ACTION (YYNSTATE+YYNRULE+1) |
| #define | YY_ERROR_ACTION (YYNSTATE+YYNRULE) |
| #define | yytestcase(X) |
| #define | YY_SHIFT_USE_DFLT (-4) |
| #define | YY_SHIFT_MAX 34 |
| #define | YY_REDUCE_USE_DFLT (-26) |
| #define | YY_REDUCE_MAX 14 |
| #define | YY_SZ_ACTTAB (int)(sizeof(yy_action)/sizeof(yy_action[0])) |
| #define | TOKEN (yyminor.yy0) |
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 | 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 yyParser * | ParseAlloc () |
| static void | ParseFree (yyParser *) |
| static void | Parse (yyParser *, int, Term *, State *) |
| static void | yy_parse_failed (yyParser *) |
| static void | yy_destructor (yyParser *yypParser, YYCODETYPE yymajor, YYMINORTYPE *yypminor) |
| static int | yy_pop_parser_stack (yyParser *pParser) |
| static 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, YYMINORTYPE *yypMinor) |
| static void | yy_accept (yyParser *) |
| static void | yy_reduce (yyParser *yypParser, int yyruleno) |
| static void | yy_syntax_error (yyParser *yypParser, int yymajor, YYMINORTYPE yyminor) |
| static void | Parse (yyParser *yypParser, int yymajor, ParseTOKENTYPE yyminorParseARG_PDECL) |
Variables | |
| const unsigned | UNICODE_IGNORE = numeric_limits<unsigned>::max() |
| Value representing "ignore this" when returned by check_infix() or check_infix_digit(). | |
| static const YYACTIONTYPE | yy_action [] |
| static const YYCODETYPE | yy_lookahead [] |
| static const short | yy_shift_ofst [] |
| static const short | yy_reduce_ofst [] |
| static const YYACTIONTYPE | yy_default [] |
| struct { | |
| YYCODETYPE lhs | |
| unsigned char nrhs | |
| } | yyRuleInfo [] |
| #define BOOL_OP_TO_QUERY | ( | E, | |||
| A, | |||||
| OP, | |||||
| B, | |||||
| OP_TXT | ) |
Value:
do {\ if (!A || !B) {\ state->error = "Syntax: <expression> "OP_TXT" <expression>";\ yy_parse_failed(yypParser);\ return;\ }\ E = new Query(OP, *A, *B);\ delete A;\ delete B;\ } while (0)
Definition at line 1626 of file queryparser_internal.cc.
Referenced by yy_reduce().
| #define INTERFACE 1 |
Definition at line 1652 of file queryparser_internal.cc.
| #define ParseARG_FETCH State * state = yypParser->state |
Definition at line 1706 of file queryparser_internal.cc.
Referenced by yy_accept(), yy_destructor(), yy_parse_failed(), yy_reduce(), and yy_syntax_error().
| #define ParseARG_PDECL ,State * state |
Definition at line 1705 of file queryparser_internal.cc.
| #define ParseARG_SDECL State * state; |
Definition at line 1704 of file queryparser_internal.cc.
| #define ParseARG_STORE yypParser->state = state |
Definition at line 1707 of file queryparser_internal.cc.
Referenced by Parse(), yy_accept(), yy_destructor(), yy_parse_failed(), and yy_syntax_error().
| #define ParseTOKENTYPE Term * |
Definition at line 1691 of file queryparser_internal.cc.
| #define TOKEN (yyminor.yy0) |
| #define YY_ACCEPT_ACTION (YYNSTATE+YYNRULE+1) |
Definition at line 1711 of file queryparser_internal.cc.
| #define YY_ERROR_ACTION (YYNSTATE+YYNRULE) |
| #define YY_NO_ACTION (YYNSTATE+YYNRULE+2) |
Definition at line 1710 of file queryparser_internal.cc.
| #define YY_REDUCE_MAX 14 |
| #define YY_REDUCE_USE_DFLT (-26) |
| #define YY_SHIFT_MAX 34 |
| #define YY_SHIFT_USE_DFLT (-4) |
Definition at line 1867 of file queryparser_internal.cc.
Referenced by yy_find_reduce_action(), and yy_find_shift_action().
| #define YYACTIONTYPE unsigned char |
Definition at line 1690 of file queryparser_internal.cc.
| #define YYCODETYPE unsigned char |
Definition at line 1688 of file queryparser_internal.cc.
Referenced by Parse(), yy_find_shift_action(), yy_pop_parser_stack(), and yy_reduce().
| #define YYNOCODE 40 |
Definition at line 1689 of file queryparser_internal.cc.
Referenced by Parse(), yy_find_reduce_action(), and yy_find_shift_action().
| #define YYNRULE 56 |
| #define YYNSTATE 77 |
| #define YYSTACKDEPTH 100 |
Definition at line 1702 of file queryparser_internal.cc.
| #define yytestcase | ( | X | ) |
Definition at line 1920 of file queryparser_internal.cc.
Definition at line 369 of file queryparser_internal.cc.
Definition at line 357 of file queryparser_internal.cc.
References Assert.
Referenced by Terms::as_opwindow_query(), and yy_reduce().
| unsigned check_infix | ( | unsigned | ch | ) | [inline] |
| unsigned check_infix_digit | ( | unsigned | ch | ) | [inline] |
| bool is_digit | ( | unsigned | ch | ) | [inline] |
Definition at line 88 of file queryparser_internal.cc.
References Xapian::Unicode::DECIMAL_DIGIT_NUMBER, and Xapian::Unicode::Internal::get_category().
| bool is_not_whitespace | ( | unsigned | ch | ) | [inline] |
| bool is_not_wordchar | ( | unsigned | ch | ) | [inline] |
| bool is_phrase_generator | ( | unsigned | ch | ) | [inline] |
Definition at line 483 of file queryparser_internal.cc.
| bool is_positional | ( | Xapian::Query::op | op | ) | [inline] |
Definition at line 110 of file queryparser_internal.cc.
References Xapian::Query::OP_NEAR, and Xapian::Query::OP_PHRASE.
Referenced by TermGroup::as_group(), and yy_reduce().
| bool is_stem_preventer | ( | unsigned | ch | ) | [inline] |
Definition at line 492 of file queryparser_internal.cc.
| bool is_suffix | ( | unsigned | ch | ) | [inline] |
Definition at line 95 of file queryparser_internal.cc.
Referenced by Xapian::QueryParser::Internal::parse_term().
| static void Parse | ( | yyParser * | yypParser, | |
| int | yymajor, | |||
| ParseTOKENTYPE yyminor | ParseARG_PDECL | |||
| ) | [static] |
Definition at line 2965 of file queryparser_internal.cc.
References Assert, LOGLINE, ParseARG_STORE, YYMINORTYPE::yy0, yy_destructor(), YY_ERROR_ACTION, yy_find_reduce_action(), yy_find_shift_action(), yy_parse_failed(), yy_pop_parser_stack(), yy_reduce(), yy_shift(), yy_syntax_error(), YYCODETYPE, yyParser::yyerrcnt, YYNOCODE, YYNRULE, YYNSTATE, and yyParser::yystack.
| static yyParser * ParseAlloc | ( | ) | [static] |
Definition at line 2037 of file queryparser_internal.cc.
| static void ParseFree | ( | yyParser * | pParser | ) | [static] |
Definition at line 2163 of file queryparser_internal.cc.
References yy_pop_parser_stack(), and yyParser::yystack.
Referenced by ParserHandler::~ParserHandler().
| bool prefix_needs_colon | ( | const string & | prefix, | |
| unsigned | ch | |||
| ) | [inline] |
Definition at line 100 of file queryparser_internal.cc.
References U_isupper().
Referenced by Term::get_query_with_synonyms(), and Term::make_term().
| bool should_stem | ( | const string & | term | ) | [inline] |
Definition at line 498 of file queryparser_internal.cc.
References Xapian::Unicode::Internal::get_category(), Xapian::Unicode::LOWERCASE_LETTER, Xapian::Unicode::MODIFIER_LETTER, Xapian::Unicode::OTHER_LETTER, and Xapian::Unicode::TITLECASE_LETTER.
| bool U_isalpha | ( | unsigned | ch | ) | [inline] |
| bool U_isdigit | ( | unsigned | ch | ) | [inline] |
| bool U_isupper | ( | unsigned | ch | ) | [inline] |
Definition at line 59 of file queryparser_internal.cc.
References C_isupper().
Referenced by prefix_needs_colon().
| static void yy_accept | ( | yyParser * | yypParser | ) | [static] |
Definition at line 2935 of file queryparser_internal.cc.
References LOGLINE, ParseARG_FETCH, ParseARG_STORE, yy_pop_parser_stack(), and yyParser::yystack.
Referenced by yy_reduce().
| static void yy_destructor | ( | yyParser * | yypParser, | |
| YYCODETYPE | yymajor, | |||
| YYMINORTYPE * | yypminor | |||
| ) | [static] |
Definition at line 2046 of file queryparser_internal.cc.
References ParseARG_FETCH, ParseARG_STORE, YYMINORTYPE::yy0, YYMINORTYPE::yy14, YYMINORTYPE::yy32, YYMINORTYPE::yy39, and YYMINORTYPE::yy40.
Referenced by Parse(), yy_pop_parser_stack(), and yy_reduce().
| static int yy_find_reduce_action | ( | int | stateno, | |
| YYCODETYPE | iLookAhead | |||
| ) | [static] |
Definition at line 2229 of file queryparser_internal.cc.
References Assert, YY_REDUCE_MAX, YY_REDUCE_USE_DFLT, YY_SZ_ACTTAB, and YYNOCODE.
Referenced by Parse(), and yy_reduce().
| static int yy_find_shift_action | ( | yyParser * | pParser, | |
| YYCODETYPE | iLookAhead | |||
| ) | [static] |
Definition at line 2179 of file queryparser_internal.cc.
References Assert, LOGLINE, YY_SHIFT_MAX, YY_SHIFT_USE_DFLT, YY_SZ_ACTTAB, YYCODETYPE, YYNOCODE, and yyParser::yystack.
Referenced by Parse().
| static void yy_parse_failed | ( | yyParser * | yypParser | ) | [static] |
Definition at line 2896 of file queryparser_internal.cc.
References LOGLINE, ParseARG_FETCH, ParseARG_STORE, yy_pop_parser_stack(), and yyParser::yystack.
Referenced by Parse(), yy_reduce(), and yy_syntax_error().
| static int yy_pop_parser_stack | ( | yyParser * | pParser | ) | [static] |
Definition at line 2143 of file queryparser_internal.cc.
References LOGLINE, yyStackEntry::major, yyStackEntry::minor, yy_destructor(), YYCODETYPE, and yyParser::yystack.
Referenced by Parse(), ParseFree(), yy_accept(), and yy_parse_failed().
| static void yy_reduce | ( | yyParser * | yypParser, | |
| int | yyruleno | |||
| ) | [static] |
Definition at line 2355 of file queryparser_internal.cc.
References ProbQuery::add_filter(), ProbQuery::add_filter_range(), Terms::add_positional_term(), TermGroup::add_term(), add_to_query(), Terms::adjust_window(), ProbQuery::append_filter(), ProbQuery::append_filter_range(), Terms::as_adj_query(), TermGroup::as_group(), Terms::as_near_query(), Terms::as_phrase_query(), Assert, BOOL_OP_TO_QUERY, Xapian::Query::empty(), ProbQuery::filter, ProbQuery::hate, is_positional(), LOGLINE, ProbQuery::love, ProbQuery::merge_filters(), yyStackEntry::minor, ParseARG_FETCH, ProbQuery::query, TermGroup::set_empty_ok(), YYMINORTYPE::yy0, YYMINORTYPE::yy14, YYMINORTYPE::yy32, YYMINORTYPE::yy39, YYMINORTYPE::yy40, yy_accept(), yy_destructor(), yy_find_reduce_action(), yy_parse_failed(), yy_shift(), YYCODETYPE, YYNRULE, YYNSTATE, yyRuleInfo, yyParser::yystack, and yytestcase.
Referenced by Parse().
| static void yy_shift | ( | yyParser * | yypParser, | |
| int | yyNewState, | |||
| int | yyMajor, | |||
| YYMINORTYPE * | yypMinor | |||
| ) | [static] |
Definition at line 2259 of file queryparser_internal.cc.
References LOGLINE, and yyParser::yystack.
Referenced by Parse(), and yy_reduce().
| static void yy_syntax_error | ( | yyParser * | yypParser, | |
| int | yymajor, | |||
| YYMINORTYPE | yyminor | |||
| ) | [static] |
Definition at line 2916 of file queryparser_internal.cc.
References ParseARG_FETCH, ParseARG_STORE, and yy_parse_failed().
Referenced by Parse().
| YYCODETYPE lhs |
Definition at line 2288 of file queryparser_internal.cc.
| unsigned char nrhs |
Definition at line 2289 of file queryparser_internal.cc.
| const unsigned UNICODE_IGNORE = numeric_limits<unsigned>::max() |
Value representing "ignore this" when returned by check_infix() or check_infix_digit().
Definition at line 512 of file queryparser_internal.cc.
Referenced by check_infix(), and check_infix_digit().
const YYACTIONTYPE yy_action[] [static] |
Definition at line 1773 of file queryparser_internal.cc.
const YYACTIONTYPE yy_default[] [static] |
Initial value:
{
87, 87, 87, 87, 87, 87, 87, 87, 88, 133,
133, 133, 133, 105, 133, 106, 107, 133, 106, 133,
108, 84, 133, 85, 114, 86, 133, 133, 113, 115,
133, 116, 133, 86, 133, 79, 80, 81, 86, 93,
124, 126, 129, 131, 107, 110, 111, 112, 122, 123,
120, 121, 125, 127, 128, 130, 132, 117, 89, 90,
91, 95, 103, 109, 118, 119, 97, 99, 101, 92,
94, 102, 96, 98, 100, 82, 83,
}
Definition at line 1857 of file queryparser_internal.cc.
const YYCODETYPE yy_lookahead[] [static] |
Definition at line 1808 of file queryparser_internal.cc.
const short yy_reduce_ofst[] [static] |
Initial value:
{
-25, 27, 40, 53, 66, 79, 92, 105, 220, 229,
239, 248, 257, 265, -12,
}
Definition at line 1853 of file queryparser_internal.cc.
const short yy_shift_ofst[] [static] |
Initial value:
{
30, 9, 136, 136, 136, 136, 136, 136, 152, 180,
192, 204, 216, 228, 39, 173, 304, 31, 175, 302,
175, 309, 171, 11, 126, 23, -3, 20, 26, 37,
25, 67, 32, 125, 75,
}
Definition at line 1845 of file queryparser_internal.cc.
struct { ... } yyRuleInfo[] [static] |
Referenced by yy_reduce().