Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10)

Side by Side Diff: third_party/sqlite/sqlite-src-3100200/ext/fts5/fts5parse.y

Issue 1610543003: [sql] Import reference version of SQLite 3.10.2. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 /*
2 ** 2014 May 31
3 **
4 ** The author disclaims copyright to this source code. In place of
5 ** a legal notice, here is a blessing:
6 **
7 ** May you do good and not evil.
8 ** May you find forgiveness for yourself and forgive others.
9 ** May you share freely, never taking more than you give.
10 **
11 ******************************************************************************
12 **
13 */
14
15
16 // All token codes are small integers with #defines that begin with "TK_"
17 %token_prefix FTS5_
18
19 // The type of the data attached to each token is Token. This is also the
20 // default type for non-terminals.
21 //
22 %token_type {Fts5Token}
23 %default_type {Fts5Token}
24
25 // The generated parser function takes a 4th argument as follows:
26 %extra_argument {Fts5Parse *pParse}
27
28 // This code runs whenever there is a syntax error
29 //
30 %syntax_error {
31 sqlite3Fts5ParseError(
32 pParse, "fts5: syntax error near \"%.*s\"",TOKEN.n,TOKEN.p
33 );
34 }
35 %stack_overflow {
36 assert( 0 );
37 }
38
39 // The name of the generated procedure that implements the parser
40 // is as follows:
41 %name sqlite3Fts5Parser
42
43 // The following text is included near the beginning of the C source
44 // code file that implements the parser.
45 //
46 %include {
47 #include "fts5Int.h"
48 #include "fts5parse.h"
49
50 /*
51 ** Disable all error recovery processing in the parser push-down
52 ** automaton.
53 */
54 #define YYNOERRORRECOVERY 1
55
56 /*
57 ** Make yytestcase() the same as testcase()
58 */
59 #define yytestcase(X) testcase(X)
60
61 /*
62 ** Indicate that sqlite3ParserFree() will never be called with a null
63 ** pointer.
64 */
65 #define YYPARSEFREENOTNULL 1
66
67 /*
68 ** Alternative datatype for the argument to the malloc() routine passed
69 ** into sqlite3ParserAlloc(). The default is size_t.
70 */
71 #define YYMALLOCARGTYPE u64
72
73 } // end %include
74
75 %left OR.
76 %left AND.
77 %left NOT.
78 %left TERM.
79 %left COLON.
80
81 input ::= expr(X). { sqlite3Fts5ParseFinished(pParse, X); }
82 %destructor input { (void)pParse; }
83
84 %type cnearset {Fts5ExprNode*}
85 %type expr {Fts5ExprNode*}
86 %type exprlist {Fts5ExprNode*}
87 %destructor cnearset { sqlite3Fts5ParseNodeFree($$); }
88 %destructor expr { sqlite3Fts5ParseNodeFree($$); }
89 %destructor exprlist { sqlite3Fts5ParseNodeFree($$); }
90
91 expr(A) ::= expr(X) AND expr(Y). {
92 A = sqlite3Fts5ParseNode(pParse, FTS5_AND, X, Y, 0);
93 }
94 expr(A) ::= expr(X) OR expr(Y). {
95 A = sqlite3Fts5ParseNode(pParse, FTS5_OR, X, Y, 0);
96 }
97 expr(A) ::= expr(X) NOT expr(Y). {
98 A = sqlite3Fts5ParseNode(pParse, FTS5_NOT, X, Y, 0);
99 }
100
101 expr(A) ::= LP expr(X) RP. {A = X;}
102 expr(A) ::= exprlist(X). {A = X;}
103
104 exprlist(A) ::= cnearset(X). {A = X;}
105 exprlist(A) ::= exprlist(X) cnearset(Y). {
106 A = sqlite3Fts5ParseNode(pParse, FTS5_AND, X, Y, 0);
107 }
108
109 cnearset(A) ::= nearset(X). {
110 A = sqlite3Fts5ParseNode(pParse, FTS5_STRING, 0, 0, X);
111 }
112 cnearset(A) ::= colset(X) COLON nearset(Y). {
113 sqlite3Fts5ParseSetColset(pParse, Y, X);
114 A = sqlite3Fts5ParseNode(pParse, FTS5_STRING, 0, 0, Y);
115 }
116
117 %type colset {Fts5Colset*}
118 %destructor colset { sqlite3_free($$); }
119 %type colsetlist {Fts5Colset*}
120 %destructor colsetlist { sqlite3_free($$); }
121
122 colset(A) ::= LCP colsetlist(X) RCP. { A = X; }
123 colset(A) ::= STRING(X). {
124 A = sqlite3Fts5ParseColset(pParse, 0, &X);
125 }
126
127 colsetlist(A) ::= colsetlist(Y) STRING(X). {
128 A = sqlite3Fts5ParseColset(pParse, Y, &X); }
129 colsetlist(A) ::= STRING(X). {
130 A = sqlite3Fts5ParseColset(pParse, 0, &X);
131 }
132
133
134 %type nearset {Fts5ExprNearset*}
135 %type nearphrases {Fts5ExprNearset*}
136 %destructor nearset { sqlite3Fts5ParseNearsetFree($$); }
137 %destructor nearphrases { sqlite3Fts5ParseNearsetFree($$); }
138
139 nearset(A) ::= phrase(X). { A = sqlite3Fts5ParseNearset(pParse, 0, X); }
140 nearset(A) ::= STRING(X) LP nearphrases(Y) neardist_opt(Z) RP. {
141 sqlite3Fts5ParseNear(pParse, &X);
142 sqlite3Fts5ParseSetDistance(pParse, Y, &Z);
143 A = Y;
144 }
145
146 nearphrases(A) ::= phrase(X). {
147 A = sqlite3Fts5ParseNearset(pParse, 0, X);
148 }
149 nearphrases(A) ::= nearphrases(X) phrase(Y). {
150 A = sqlite3Fts5ParseNearset(pParse, X, Y);
151 }
152
153 /*
154 ** The optional ", <integer>" at the end of the NEAR() arguments.
155 */
156 neardist_opt(A) ::= . { A.p = 0; A.n = 0; }
157 neardist_opt(A) ::= COMMA STRING(X). { A = X; }
158
159 /*
160 ** A phrase. A set of primitives connected by "+" operators. Examples:
161 **
162 ** "the" + "quick brown" + fo *
163 ** "the quick brown fo" *
164 ** the+quick+brown+fo*
165 */
166 %type phrase {Fts5ExprPhrase*}
167 %destructor phrase { sqlite3Fts5ParsePhraseFree($$); }
168
169 phrase(A) ::= phrase(X) PLUS STRING(Y) star_opt(Z). {
170 A = sqlite3Fts5ParseTerm(pParse, X, &Y, Z);
171 }
172 phrase(A) ::= STRING(Y) star_opt(Z). {
173 A = sqlite3Fts5ParseTerm(pParse, 0, &Y, Z);
174 }
175
176 /*
177 ** Optional "*" character.
178 */
179 %type star_opt {int}
180
181 star_opt(A) ::= STAR. { A = 1; }
182 star_opt(A) ::= . { A = 0; }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698