OLD | NEW |
1 /* | 1 /* |
2 ** 2014 May 31 | 2 ** 2014 May 31 |
3 ** | 3 ** |
4 ** The author disclaims copyright to this source code. In place of | 4 ** The author disclaims copyright to this source code. In place of |
5 ** a legal notice, here is a blessing: | 5 ** a legal notice, here is a blessing: |
6 ** | 6 ** |
7 ** May you do good and not evil. | 7 ** May you do good and not evil. |
8 ** May you find forgiveness for yourself and forgive others. | 8 ** May you find forgiveness for yourself and forgive others. |
9 ** May you share freely, never taking more than you give. | 9 ** May you share freely, never taking more than you give. |
10 ** | 10 ** |
(...skipping 10 matching lines...) Expand all Loading... |
21 // | 21 // |
22 %token_type {Fts5Token} | 22 %token_type {Fts5Token} |
23 %default_type {Fts5Token} | 23 %default_type {Fts5Token} |
24 | 24 |
25 // The generated parser function takes a 4th argument as follows: | 25 // The generated parser function takes a 4th argument as follows: |
26 %extra_argument {Fts5Parse *pParse} | 26 %extra_argument {Fts5Parse *pParse} |
27 | 27 |
28 // This code runs whenever there is a syntax error | 28 // This code runs whenever there is a syntax error |
29 // | 29 // |
30 %syntax_error { | 30 %syntax_error { |
| 31 UNUSED_PARAM(yymajor); /* Silence a compiler warning */ |
31 sqlite3Fts5ParseError( | 32 sqlite3Fts5ParseError( |
32 pParse, "fts5: syntax error near \"%.*s\"",TOKEN.n,TOKEN.p | 33 pParse, "fts5: syntax error near \"%.*s\"",TOKEN.n,TOKEN.p |
33 ); | 34 ); |
34 } | 35 } |
35 %stack_overflow { | 36 %stack_overflow { |
36 assert( 0 ); | 37 sqlite3Fts5ParseError(pParse, "fts5: parser stack overflow"); |
37 } | 38 } |
38 | 39 |
39 // The name of the generated procedure that implements the parser | 40 // The name of the generated procedure that implements the parser |
40 // is as follows: | 41 // is as follows: |
41 %name sqlite3Fts5Parser | 42 %name sqlite3Fts5Parser |
42 | 43 |
43 // The following text is included near the beginning of the C source | 44 // The following text is included near the beginning of the C source |
44 // code file that implements the parser. | 45 // code file that implements the parser. |
45 // | 46 // |
46 %include { | 47 %include { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 } | 97 } |
97 expr(A) ::= expr(X) NOT expr(Y). { | 98 expr(A) ::= expr(X) NOT expr(Y). { |
98 A = sqlite3Fts5ParseNode(pParse, FTS5_NOT, X, Y, 0); | 99 A = sqlite3Fts5ParseNode(pParse, FTS5_NOT, X, Y, 0); |
99 } | 100 } |
100 | 101 |
101 expr(A) ::= LP expr(X) RP. {A = X;} | 102 expr(A) ::= LP expr(X) RP. {A = X;} |
102 expr(A) ::= exprlist(X). {A = X;} | 103 expr(A) ::= exprlist(X). {A = X;} |
103 | 104 |
104 exprlist(A) ::= cnearset(X). {A = X;} | 105 exprlist(A) ::= cnearset(X). {A = X;} |
105 exprlist(A) ::= exprlist(X) cnearset(Y). { | 106 exprlist(A) ::= exprlist(X) cnearset(Y). { |
106 A = sqlite3Fts5ParseNode(pParse, FTS5_AND, X, Y, 0); | 107 A = sqlite3Fts5ParseImplicitAnd(pParse, X, Y); |
107 } | 108 } |
108 | 109 |
109 cnearset(A) ::= nearset(X). { | 110 cnearset(A) ::= nearset(X). { |
110 A = sqlite3Fts5ParseNode(pParse, FTS5_STRING, 0, 0, X); | 111 A = sqlite3Fts5ParseNode(pParse, FTS5_STRING, 0, 0, X); |
111 } | 112 } |
112 cnearset(A) ::= colset(X) COLON nearset(Y). { | 113 cnearset(A) ::= colset(X) COLON nearset(Y). { |
113 sqlite3Fts5ParseSetColset(pParse, Y, X); | 114 sqlite3Fts5ParseSetColset(pParse, Y, X); |
114 A = sqlite3Fts5ParseNode(pParse, FTS5_STRING, 0, 0, Y); | 115 A = sqlite3Fts5ParseNode(pParse, FTS5_STRING, 0, 0, Y); |
115 } | 116 } |
116 | 117 |
117 %type colset {Fts5Colset*} | 118 %type colset {Fts5Colset*} |
118 %destructor colset { sqlite3_free($$); } | 119 %destructor colset { sqlite3_free($$); } |
119 %type colsetlist {Fts5Colset*} | 120 %type colsetlist {Fts5Colset*} |
120 %destructor colsetlist { sqlite3_free($$); } | 121 %destructor colsetlist { sqlite3_free($$); } |
121 | 122 |
| 123 colset(A) ::= MINUS LCP colsetlist(X) RCP. { |
| 124 A = sqlite3Fts5ParseColsetInvert(pParse, X); |
| 125 } |
122 colset(A) ::= LCP colsetlist(X) RCP. { A = X; } | 126 colset(A) ::= LCP colsetlist(X) RCP. { A = X; } |
123 colset(A) ::= STRING(X). { | 127 colset(A) ::= STRING(X). { |
124 A = sqlite3Fts5ParseColset(pParse, 0, &X); | 128 A = sqlite3Fts5ParseColset(pParse, 0, &X); |
125 } | 129 } |
| 130 colset(A) ::= MINUS STRING(X). { |
| 131 A = sqlite3Fts5ParseColset(pParse, 0, &X); |
| 132 A = sqlite3Fts5ParseColsetInvert(pParse, A); |
| 133 } |
126 | 134 |
127 colsetlist(A) ::= colsetlist(Y) STRING(X). { | 135 colsetlist(A) ::= colsetlist(Y) STRING(X). { |
128 A = sqlite3Fts5ParseColset(pParse, Y, &X); } | 136 A = sqlite3Fts5ParseColset(pParse, Y, &X); } |
129 colsetlist(A) ::= STRING(X). { | 137 colsetlist(A) ::= STRING(X). { |
130 A = sqlite3Fts5ParseColset(pParse, 0, &X); | 138 A = sqlite3Fts5ParseColset(pParse, 0, &X); |
131 } | 139 } |
132 | 140 |
133 | |
134 %type nearset {Fts5ExprNearset*} | 141 %type nearset {Fts5ExprNearset*} |
135 %type nearphrases {Fts5ExprNearset*} | 142 %type nearphrases {Fts5ExprNearset*} |
136 %destructor nearset { sqlite3Fts5ParseNearsetFree($$); } | 143 %destructor nearset { sqlite3Fts5ParseNearsetFree($$); } |
137 %destructor nearphrases { sqlite3Fts5ParseNearsetFree($$); } | 144 %destructor nearphrases { sqlite3Fts5ParseNearsetFree($$); } |
138 | 145 |
139 nearset(A) ::= phrase(X). { A = sqlite3Fts5ParseNearset(pParse, 0, X); } | 146 nearset(A) ::= phrase(X). { A = sqlite3Fts5ParseNearset(pParse, 0, X); } |
140 nearset(A) ::= STRING(X) LP nearphrases(Y) neardist_opt(Z) RP. { | 147 nearset(A) ::= STRING(X) LP nearphrases(Y) neardist_opt(Z) RP. { |
141 sqlite3Fts5ParseNear(pParse, &X); | 148 sqlite3Fts5ParseNear(pParse, &X); |
142 sqlite3Fts5ParseSetDistance(pParse, Y, &Z); | 149 sqlite3Fts5ParseSetDistance(pParse, Y, &Z); |
143 A = Y; | 150 A = Y; |
(...skipping 29 matching lines...) Expand all Loading... |
173 A = sqlite3Fts5ParseTerm(pParse, 0, &Y, Z); | 180 A = sqlite3Fts5ParseTerm(pParse, 0, &Y, Z); |
174 } | 181 } |
175 | 182 |
176 /* | 183 /* |
177 ** Optional "*" character. | 184 ** Optional "*" character. |
178 */ | 185 */ |
179 %type star_opt {int} | 186 %type star_opt {int} |
180 | 187 |
181 star_opt(A) ::= STAR. { A = 1; } | 188 star_opt(A) ::= STAR. { A = 1; } |
182 star_opt(A) ::= . { A = 0; } | 189 star_opt(A) ::= . { A = 0; } |
OLD | NEW |