a/src/query/wasaparse.ypp b/src/query/wasaparse.ypp
...
...
26
static void qualify(Rcl::SearchDataClauseDist *, const string &);
26
static void qualify(Rcl::SearchDataClauseDist *, const string &);
27
27
28
static void addSubQuery(WasaParserDriver *d,
28
static void addSubQuery(WasaParserDriver *d,
29
                        Rcl::SearchData *sd, Rcl::SearchData *sq)
29
                        Rcl::SearchData *sd, Rcl::SearchData *sq)
30
{
30
{
31
    if (sd && sq)
32
        sd->addClause(
31
    sd->addClause(new Rcl::SearchDataClauseSub(STD_SHARED_PTR<Rcl::SearchData>(sq)));
33
            new Rcl::SearchDataClauseSub(STD_SHARED_PTR<Rcl::SearchData>(sq)));
32
}
34
}
33
35
34
%}
36
%}
35
37
36
%skeleton "lalr1.cc"
38
%skeleton "lalr1.cc"
...
...
52
%type <cl> fieldexpr
54
%type <cl> fieldexpr
53
%type <cl> term
55
%type <cl> term
54
%type <sd> query
56
%type <sd> query
55
%type <str> complexfieldname
57
%type <str> complexfieldname
56
58
57
                          /* Non operator tokens need precedence because of the possibility of
59
/* Non operator tokens need precedence because of the possibility of
58
                             concatenation which needs to have lower prec than OR */
60
   concatenation which needs to have lower prec than OR */
59
%left <str> WORD
61
%left <str> WORD
60
%left <str> QUOTED
62
%left <str> QUOTED
61
%left <str> QUALIFIERS
63
%left <str> QUALIFIERS
62
%left AND UCONCAT '(' '-'
64
%left AND UCONCAT '(' '-'
63
%left OR
65
%left OR
...
...
66
68
67
%%
69
%%
68
70
69
topquery: query
71
topquery: query
70
{
72
{
71
    LOGP("END PARSING\n");
73
    // It's possible that we end up with no query (e.g.: because just a
74
    // date filter was set, no terms). Allocate an empty query so that we
75
    // have something to set the global criteria on (this will yield a
76
    // Xapian search like <alldocuments> FILTER xxx
77
    if ($1 == 0)
78
        d->m_result = new Rcl::SearchData(Rcl::SCLT_AND, d->m_stemlang);
79
    else
72
    d->m_result = $1;
80
        d->m_result = $1;
73
}
81
}
74
82
75
query: 
83
query: 
76
query query %prec UCONCAT
84
query query %prec UCONCAT
77
{
85
{
78
    LOGP("q: query query\n");
86
    LOGP("q: query query\n");
87
    Rcl::SearchData *sd = 0;
88
    if ($1 || $2) {
79
    Rcl::SearchData *sd = new Rcl::SearchData(Rcl::SCLT_AND, d->m_stemlang);
89
        sd = new Rcl::SearchData(Rcl::SCLT_AND, d->m_stemlang);
80
    addSubQuery(d, sd, $1);
90
        addSubQuery(d, sd, $1);
81
    addSubQuery(d, sd, $2);
91
        addSubQuery(d, sd, $2);
92
    }
82
    $$ = sd;
93
    $$ = sd;
83
}
94
}
84
| query AND query
95
| query AND query
85
{
96
{
86
    LOGP("q: query AND query\n");
97
    LOGP("q: query AND query\n");
98
    Rcl::SearchData *sd = 0;
99
    if ($1 || $3) {
87
    Rcl::SearchData *sd = new Rcl::SearchData(Rcl::SCLT_AND, d->m_stemlang);
100
        sd = new Rcl::SearchData(Rcl::SCLT_AND, d->m_stemlang);
88
    addSubQuery(d, sd, $1);
101
        addSubQuery(d, sd, $1);
89
    addSubQuery(d, sd, $3);
102
        addSubQuery(d, sd, $3);
103
    }
90
    $$ = sd;
104
    $$ = sd;
91
}
105
}
92
| query OR query
106
| query OR query
93
{
107
{
94
    LOGP("q: query OR query\n");
108
    LOGP("query: query OR query\n");
95
    Rcl::SearchData *top = new Rcl::SearchData(Rcl::SCLT_AND, d->m_stemlang);
109
    Rcl::SearchData *top = 0;
110
    if ($1 || $3) {
96
    Rcl::SearchData *sd = new Rcl::SearchData(Rcl::SCLT_OR, d->m_stemlang);
111
       top = new Rcl::SearchData(Rcl::SCLT_OR, d->m_stemlang);
97
    addSubQuery(d, sd, $1);
98
    addSubQuery(d, sd, $3);
99
    addSubQuery(d, top, sd);
112
       addSubQuery(d, top, $1);
113
       addSubQuery(d, top, $3);
114
    }
100
    $$ = top;
115
    $$ = top;
101
}
116
}
102
| '(' query ')' 
117
| '(' query ')' 
103
{
118
{
104
    LOGP("q: ( query )\n");
119
    LOGP("q: ( query )\n");
...
...
107
|
122
|
108
fieldexpr %prec UCONCAT
123
fieldexpr %prec UCONCAT
109
{
124
{
110
    LOGP("q: fieldexpr\n");
125
    LOGP("q: fieldexpr\n");
111
    Rcl::SearchData *sd = new Rcl::SearchData(Rcl::SCLT_AND, d->m_stemlang);
126
    Rcl::SearchData *sd = new Rcl::SearchData(Rcl::SCLT_AND, d->m_stemlang);
112
    d->addClause(sd, $1);
127
    if (d->addClause(sd, $1)) {
113
    $$ = sd;
128
        $$ = sd;
129
    } else {
130
        delete sd;
131
        $$ = 0;
132
    }
114
}
133
}
115
;
134
;
116
135
117
fieldexpr: term 
136
fieldexpr: term 
118
{
137
{