blob: 69f75e9525f3f8c388a55ba5872b34158e6544aa [file] [log] [blame]
drh348784e2000-05-29 20:41:49 +00001/*
2** Copyright (c) 1999, 2000 D. Richard Hipp
3**
4** This program is free software; you can redistribute it and/or
5** modify it under the terms of the GNU General Public
6** License as published by the Free Software Foundation; either
7** version 2 of the License, or (at your option) any later version.
8**
9** This program is distributed in the hope that it will be useful,
10** but WITHOUT ANY WARRANTY; without even the implied warranty of
11** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12** General Public License for more details.
13**
14** You should have received a copy of the GNU General Public
15** License along with this library; if not, write to the
16** Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17** Boston, MA 02111-1307, USA.
18**
19** Author contact information:
20** drh@hwaci.com
21** http://www.hwaci.com/drh/
22**
23*************************************************************************
24** This file contains SQLite's grammar for SQL. Process this file
25** using the lemon parser generator to generate C code that runs
26** the parser. Lemon will also generate a header file containing
27** numeric codes for all of the tokens.
28**
drh4cfa7932000-06-08 15:10:46 +000029** @(#) $Id: parse.y,v 1.18 2000/06/08 15:10:47 drh Exp $
drh348784e2000-05-29 20:41:49 +000030*/
31%token_prefix TK_
32%token_type {Token}
33%extra_argument {Parse *pParse}
34%syntax_error {
35 sqliteSetNString(&pParse->zErrMsg,"syntax error near \"",0,TOKEN.z,TOKEN.n,
36 "\"", 1, 0);
37 pParse->sErrToken = TOKEN;
38}
39%name sqliteParser
40%include {
41#include "sqliteInt.h"
42#include "parse.h"
43}
44
45
46// Input is zero or more commands.
47input ::= cmdlist.
48
49// These are extra tokens used by the lexer but never seen by the
50// parser. We put them in a rule so that the parser generator will
51// add them to the sqliteTokens.h output file.
52//
53input ::= END_OF_FILE ILLEGAL SPACE UNCLOSED_STRING COMMENT FUNCTION
drh22827922000-06-06 17:27:05 +000054 UMINUS FIELD AGG_FUNCTION.
drh348784e2000-05-29 20:41:49 +000055
56// A list of commands is zero or more commands
57//
58cmdlist ::= ecmd.
59cmdlist ::= cmdlist SEMI ecmd.
60ecmd ::= explain cmd. {sqliteExec(pParse);}
61ecmd ::= cmd. {sqliteExec(pParse);}
62ecmd ::= .
63explain ::= EXPLAIN. {pParse->explain = 1;}
64
65// The first form of a command is a CREATE TABLE statement.
66//
67cmd ::= create_table create_table_args.
drh982cef72000-05-30 16:27:03 +000068create_table ::= CREATE(X) TABLE id(Y). {sqliteStartTable(pParse,&X,&Y);}
drh348784e2000-05-29 20:41:49 +000069create_table_args ::= LP columnlist conslist_opt RP(X).
70 {sqliteEndTable(pParse,&X);}
71columnlist ::= columnlist COMMA column.
72columnlist ::= column.
73
74// About the only information used for a column is the name of the
75// column. The type is always just "text". But the code will accept
76// an elaborate typename. Perhaps someday we'll do something with it.
77//
78column ::= columnid type carglist.
drh982cef72000-05-30 16:27:03 +000079columnid ::= id(X). {sqliteAddColumn(pParse,&X);}
80%type id {Token}
81id(A) ::= ID(X). {A = X;}
82id(A) ::= STRING(X). {A = X;}
drh348784e2000-05-29 20:41:49 +000083type ::= typename.
84type ::= typename LP signed RP.
85type ::= typename LP signed COMMA signed RP.
drh4cfa7932000-06-08 15:10:46 +000086typename ::= id.
87typename ::= typename id.
drh348784e2000-05-29 20:41:49 +000088signed ::= INTEGER.
89signed ::= PLUS INTEGER.
90signed ::= MINUS INTEGER.
91carglist ::= carglist carg.
92carglist ::= .
drh4cfa7932000-06-08 15:10:46 +000093carg ::= CONSTRAINT id ccons.
drh348784e2000-05-29 20:41:49 +000094carg ::= ccons.
drh7020f652000-06-03 18:06:52 +000095carg ::= DEFAULT STRING(X). {sqliteAddDefaultValue(pParse,&X,0);}
96carg ::= DEFAULT ID(X). {sqliteAddDefaultValue(pParse,&X,0);}
97carg ::= DEFAULT INTEGER(X). {sqliteAddDefaultValue(pParse,&X,0);}
98carg ::= DEFAULT PLUS INTEGER(X). {sqliteAddDefaultValue(pParse,&X,0);}
99carg ::= DEFAULT MINUS INTEGER(X). {sqliteAddDefaultValue(pParse,&X,1);}
100carg ::= DEFAULT FLOAT(X). {sqliteAddDefaultValue(pParse,&X,0);}
101carg ::= DEFAULT PLUS FLOAT(X). {sqliteAddDefaultValue(pParse,&X,0);}
102carg ::= DEFAULT MINUS FLOAT(X). {sqliteAddDefaultValue(pParse,&X,1);}
103carg ::= DEFAULT NULL.
drh348784e2000-05-29 20:41:49 +0000104
105// In addition to the type name, we also care about the primary key.
106//
107ccons ::= NOT NULL.
108ccons ::= PRIMARY KEY sortorder.
109 {sqliteCreateIndex(pParse,0,0,0,0,0);}
110ccons ::= UNIQUE.
drh4794b982000-06-06 13:54:14 +0000111ccons ::= CHECK LP expr RP.
drh348784e2000-05-29 20:41:49 +0000112
113// For the time being, the only constraint we care about is the primary
114// key.
115//
116conslist_opt ::= .
117conslist_opt ::= COMMA conslist.
118conslist ::= conslist COMMA tcons.
119conslist ::= tcons.
drh4cfa7932000-06-08 15:10:46 +0000120tcons ::= CONSTRAINT id tcons2.
drh348784e2000-05-29 20:41:49 +0000121tcons ::= tcons2.
122tcons2 ::= PRIMARY KEY LP idxlist(X) RP.
123 {sqliteCreateIndex(pParse,0,0,X,0,0);}
124tcons2 ::= UNIQUE LP idlist RP.
125tcons2 ::= CHECK expr.
drh982cef72000-05-30 16:27:03 +0000126idlist ::= idlist COMMA id.
127idlist ::= id.
drh348784e2000-05-29 20:41:49 +0000128
129// The next command format is dropping tables.
130//
drh982cef72000-05-30 16:27:03 +0000131cmd ::= DROP TABLE id(X). {sqliteDropTable(pParse,&X);}
drh348784e2000-05-29 20:41:49 +0000132
133// The select statement
134//
drh9bb61fe2000-06-05 16:01:39 +0000135cmd ::= select(X). {
drhfef52082000-06-06 01:50:43 +0000136 sqliteSelect(pParse, X, SRT_Callback, 0);
drh9bb61fe2000-06-05 16:01:39 +0000137 sqliteSelectDelete(X);
138}
drhefb72512000-05-31 20:00:52 +0000139
drh9bb61fe2000-06-05 16:01:39 +0000140%type select {Select*}
141%destructor select {sqliteSelectDelete($$);}
drh82c3d632000-06-06 21:56:07 +0000142%type oneselect {Select*}
143%destructor oneselect {sqliteSelectDelete($$);}
drh9bb61fe2000-06-05 16:01:39 +0000144
drh82c3d632000-06-06 21:56:07 +0000145select(A) ::= oneselect(X). {A = X;}
146select(A) ::= select(X) joinop(Y) oneselect(Z). {
147 Z->op = Y;
148 Z->pPrior = X;
149 A = Z;
150}
151%type joinop {int}
152joinop(A) ::= UNION. {A = TK_UNION;}
153joinop(A) ::= UNION ALL. {A = TK_ALL;}
154joinop(A) ::= INTERSECT. {A = TK_INTERSECT;}
155joinop(A) ::= EXCEPT. {A = TK_EXCEPT;}
156oneselect(A) ::= SELECT distinct(D) selcollist(W) from(X) where_opt(Y)
157 groupby_opt(P) having_opt(Q) orderby_opt(Z). {
drh22827922000-06-06 17:27:05 +0000158 A = sqliteSelectNew(W,X,Y,P,Q,Z,D);
drh9bb61fe2000-06-05 16:01:39 +0000159}
160
161// The "distinct" nonterminal is true (1) if the DISTINCT keyword is
162// present and false (0) if it is not.
163//
drhefb72512000-05-31 20:00:52 +0000164%type distinct {int}
drhefb72512000-05-31 20:00:52 +0000165distinct(A) ::= DISTINCT. {A = 1;}
drhfef52082000-06-06 01:50:43 +0000166distinct(A) ::= ALL. {A = 0;}
drhefb72512000-05-31 20:00:52 +0000167distinct(A) ::= . {A = 0;}
drh348784e2000-05-29 20:41:49 +0000168
drh9bb61fe2000-06-05 16:01:39 +0000169// selcollist is a list of expressions that are to become the return
170// values of the SELECT statement. In the case of "SELECT * FROM ..."
171// the selcollist value is NULL.
172//
drh348784e2000-05-29 20:41:49 +0000173%type selcollist {ExprList*}
174%destructor selcollist {sqliteExprListDelete($$);}
175%type sclp {ExprList*}
176%destructor sclp {sqliteExprListDelete($$);}
drh348784e2000-05-29 20:41:49 +0000177sclp(A) ::= selcollist(X) COMMA. {A = X;}
178sclp(A) ::= . {A = 0;}
drh9bb61fe2000-06-05 16:01:39 +0000179selcollist(A) ::= STAR. {A = 0;}
drh348784e2000-05-29 20:41:49 +0000180selcollist(A) ::= sclp(P) expr(X). {A = sqliteExprListAppend(P,X,0);}
drh4cfa7932000-06-08 15:10:46 +0000181selcollist(A) ::= sclp(P) expr(X) as id(Y). {A = sqliteExprListAppend(P,X,&Y);}
drh9bb61fe2000-06-05 16:01:39 +0000182as ::= .
183as ::= AS.
184
drh348784e2000-05-29 20:41:49 +0000185
186%type seltablist {IdList*}
187%destructor seltablist {sqliteIdListDelete($$);}
188%type stl_prefix {IdList*}
189%destructor stl_prefix {sqliteIdListDelete($$);}
190%type from {IdList*}
191%destructor from {sqliteIdListDelete($$);}
192
193from(A) ::= FROM seltablist(X). {A = X;}
194stl_prefix(A) ::= seltablist(X) COMMA. {A = X;}
195stl_prefix(A) ::= . {A = 0;}
drh982cef72000-05-30 16:27:03 +0000196seltablist(A) ::= stl_prefix(X) id(Y). {A = sqliteIdListAppend(X,&Y);}
197seltablist(A) ::= stl_prefix(X) id(Y) AS id(Z).
drh348784e2000-05-29 20:41:49 +0000198 {A = sqliteIdListAppend(X,&Y);
199 sqliteIdListAddAlias(A,&Z);}
200
201%type orderby_opt {ExprList*}
202%destructor orderby_opt {sqliteExprListDelete($$);}
203%type sortlist {ExprList*}
204%destructor sortlist {sqliteExprListDelete($$);}
205%type sortitem {Expr*}
206%destructor sortitem {sqliteExprDelete($$);}
207
208orderby_opt(A) ::= . {A = 0;}
209orderby_opt(A) ::= ORDER BY sortlist(X). {A = X;}
drh9bb61fe2000-06-05 16:01:39 +0000210sortlist(A) ::= sortlist(X) COMMA sortitem(Y) sortorder(Z). {
211 A = sqliteExprListAppend(X,Y,0);
drhd8bc7082000-06-07 23:51:50 +0000212 A->a[A->nExpr-1].sortOrder = Z; /* 0 for ascending order, 1 for decending */
drh9bb61fe2000-06-05 16:01:39 +0000213}
214sortlist(A) ::= sortitem(Y) sortorder(Z). {
215 A = sqliteExprListAppend(0,Y,0);
drhd8bc7082000-06-07 23:51:50 +0000216 A->a[0].sortOrder = Z;
drh9bb61fe2000-06-05 16:01:39 +0000217}
drhda9d6c42000-05-31 18:20:14 +0000218sortitem(A) ::= expr(X). {A = X;}
drh348784e2000-05-29 20:41:49 +0000219
220%type sortorder {int}
221
222sortorder(A) ::= ASC. {A = 0;}
223sortorder(A) ::= DESC. {A = 1;}
224sortorder(A) ::= . {A = 0;}
225
drh22827922000-06-06 17:27:05 +0000226%type groupby_opt {ExprList*}
227%destructor groupby_opt {sqliteExprListDelete($$);}
228groupby_opt(A) ::= . {A = 0;}
229groupby_opt(A) ::= GROUP BY exprlist(X). {A = X;}
230
231%type having_opt {Expr*}
232%destructor having_opt {sqliteExprDelete($$);}
233having_opt(A) ::= . {A = 0;}
234having_opt(A) ::= HAVING expr(X). {A = X;}
235
drh82c3d632000-06-06 21:56:07 +0000236
drh4cfa7932000-06-08 15:10:46 +0000237cmd ::= DELETE FROM id(X) where_opt(Y).
drh348784e2000-05-29 20:41:49 +0000238 {sqliteDeleteFrom(pParse, &X, Y);}
239
240%type where_opt {Expr*}
241%destructor where_opt {sqliteExprDelete($$);}
242
243where_opt(A) ::= . {A = 0;}
244where_opt(A) ::= WHERE expr(X). {A = X;}
245
246%type setlist {ExprList*}
247%destructor setlist {sqliteExprListDelete($$);}
248
drh4cfa7932000-06-08 15:10:46 +0000249cmd ::= UPDATE id(X) SET setlist(Y) where_opt(Z).
drh348784e2000-05-29 20:41:49 +0000250 {sqliteUpdate(pParse,&X,Y,Z);}
251
drh4cfa7932000-06-08 15:10:46 +0000252setlist(A) ::= id(X) EQ expr(Y) COMMA setlist(Z).
drh348784e2000-05-29 20:41:49 +0000253 {A = sqliteExprListAppend(Z,Y,&X);}
drh4cfa7932000-06-08 15:10:46 +0000254setlist(A) ::= id(X) EQ expr(Y). {A = sqliteExprListAppend(0,Y,&X);}
drh348784e2000-05-29 20:41:49 +0000255
drh4cfa7932000-06-08 15:10:46 +0000256cmd ::= INSERT INTO id(X) fieldlist_opt(F) VALUES LP itemlist(Y) RP.
drh5974a302000-06-07 14:42:26 +0000257 {sqliteInsert(pParse, &X, Y, 0, F);}
drh4cfa7932000-06-08 15:10:46 +0000258cmd ::= INSERT INTO id(X) fieldlist_opt(F) select(S).
drh5974a302000-06-07 14:42:26 +0000259 {sqliteInsert(pParse, &X, 0, S, F);}
drh348784e2000-05-29 20:41:49 +0000260
261
262%type itemlist {ExprList*}
263%destructor itemlist {sqliteExprListDelete($$);}
264%type item {Expr*}
265%destructor item {sqliteExprDelete($$);}
266
267itemlist(A) ::= itemlist(X) COMMA item(Y). {A = sqliteExprListAppend(X,Y,0);}
268itemlist(A) ::= item(X). {A = sqliteExprListAppend(0,X,0);}
269item(A) ::= INTEGER(X). {A = sqliteExpr(TK_INTEGER, 0, 0, &X);}
drh7020f652000-06-03 18:06:52 +0000270item(A) ::= PLUS INTEGER(X). {A = sqliteExpr(TK_INTEGER, 0, 0, &X);}
271item(A) ::= MINUS INTEGER(X). {
drh6e142f52000-06-08 13:36:40 +0000272 A = sqliteExpr(TK_UMINUS, 0, 0, 0);
273 A->pLeft = sqliteExpr(TK_INTEGER, 0, 0, &X);
drh7020f652000-06-03 18:06:52 +0000274}
drh348784e2000-05-29 20:41:49 +0000275item(A) ::= FLOAT(X). {A = sqliteExpr(TK_FLOAT, 0, 0, &X);}
drh7020f652000-06-03 18:06:52 +0000276item(A) ::= PLUS FLOAT(X). {A = sqliteExpr(TK_FLOAT, 0, 0, &X);}
277item(A) ::= MINUS FLOAT(X). {
drh6e142f52000-06-08 13:36:40 +0000278 A = sqliteExpr(TK_UMINUS, 0, 0, 0);
279 A->pLeft = sqliteExpr(TK_FLOAT, 0, 0, &X);
drh7020f652000-06-03 18:06:52 +0000280}
drh348784e2000-05-29 20:41:49 +0000281item(A) ::= STRING(X). {A = sqliteExpr(TK_STRING, 0, 0, &X);}
drh8be51132000-06-03 19:19:41 +0000282item(A) ::= NULL. {A = sqliteExpr(TK_NULL, 0, 0, 0);}
drh348784e2000-05-29 20:41:49 +0000283
284%type fieldlist_opt {IdList*}
285%destructor fieldlist_opt {sqliteIdListDelete($$);}
286%type fieldlist {IdList*}
287%destructor fieldlist {sqliteIdListDelete($$);}
288
289fieldlist_opt(A) ::= . {A = 0;}
290fieldlist_opt(A) ::= LP fieldlist(X) RP. {A = X;}
drh4cfa7932000-06-08 15:10:46 +0000291fieldlist(A) ::= fieldlist(X) COMMA id(Y). {A = sqliteIdListAppend(X,&Y);}
292fieldlist(A) ::= id(Y). {A = sqliteIdListAppend(0,&Y);}
drh348784e2000-05-29 20:41:49 +0000293
294%left OR.
295%left AND.
drh8be51132000-06-03 19:19:41 +0000296%right NOT.
drhfef52082000-06-06 01:50:43 +0000297%left EQ NE ISNULL NOTNULL IS LIKE GLOB BETWEEN IN.
drh348784e2000-05-29 20:41:49 +0000298%left GT GE LT LE.
299%left PLUS MINUS.
300%left STAR SLASH PERCENT.
drh8be51132000-06-03 19:19:41 +0000301%right UMINUS.
drh348784e2000-05-29 20:41:49 +0000302
303%type expr {Expr*}
304%destructor expr {sqliteExprDelete($$);}
305
306expr(A) ::= LP expr(X) RP. {A = X;}
307expr(A) ::= ID(X). {A = sqliteExpr(TK_ID, 0, 0, &X);}
308expr(A) ::= NULL. {A = sqliteExpr(TK_NULL, 0, 0, 0);}
drh4cfa7932000-06-08 15:10:46 +0000309expr(A) ::= id(X) DOT id(Y). {Expr *temp1 = sqliteExpr(TK_ID, 0, 0, &X);
drh348784e2000-05-29 20:41:49 +0000310 Expr *temp2 = sqliteExpr(TK_ID, 0, 0, &Y);
311 A = sqliteExpr(TK_DOT, temp1, temp2, 0);}
312expr(A) ::= INTEGER(X). {A = sqliteExpr(TK_INTEGER, 0, 0, &X);}
313expr(A) ::= FLOAT(X). {A = sqliteExpr(TK_FLOAT, 0, 0, &X);}
314expr(A) ::= STRING(X). {A = sqliteExpr(TK_STRING, 0, 0, &X);}
drhcce7d172000-05-31 15:34:51 +0000315expr(A) ::= ID(X) LP exprlist(Y) RP. {A = sqliteExprFunction(Y, &X);}
316expr(A) ::= ID(X) LP STAR RP. {A = sqliteExprFunction(0, &X);}
drh348784e2000-05-29 20:41:49 +0000317expr(A) ::= expr(X) AND expr(Y). {A = sqliteExpr(TK_AND, X, Y, 0);}
318expr(A) ::= expr(X) OR expr(Y). {A = sqliteExpr(TK_OR, X, Y, 0);}
319expr(A) ::= expr(X) LT expr(Y). {A = sqliteExpr(TK_LT, X, Y, 0);}
320expr(A) ::= expr(X) GT expr(Y). {A = sqliteExpr(TK_GT, X, Y, 0);}
321expr(A) ::= expr(X) LE expr(Y). {A = sqliteExpr(TK_LE, X, Y, 0);}
322expr(A) ::= expr(X) GE expr(Y). {A = sqliteExpr(TK_GE, X, Y, 0);}
323expr(A) ::= expr(X) NE expr(Y). {A = sqliteExpr(TK_NE, X, Y, 0);}
324expr(A) ::= expr(X) EQ expr(Y). {A = sqliteExpr(TK_EQ, X, Y, 0);}
drhdce2cbe2000-05-31 02:27:49 +0000325expr(A) ::= expr(X) LIKE expr(Y). {A = sqliteExpr(TK_LIKE, X, Y, 0);}
drh4794b982000-06-06 13:54:14 +0000326expr(A) ::= expr(X) NOT LIKE expr(Y). {
327 A = sqliteExpr(TK_LIKE, X, Y, 0);
328 A = sqliteExpr(TK_NOT, A, 0, 0);
329}
drhfef52082000-06-06 01:50:43 +0000330expr(A) ::= expr(X) GLOB expr(Y). {A = sqliteExpr(TK_GLOB,X,Y,0);}
drh4794b982000-06-06 13:54:14 +0000331expr(A) ::= expr(X) NOT GLOB expr(Y). {
332 A = sqliteExpr(TK_GLOB, X, Y, 0);
333 A = sqliteExpr(TK_NOT, A, 0, 0);
334}
drh348784e2000-05-29 20:41:49 +0000335expr(A) ::= expr(X) PLUS expr(Y). {A = sqliteExpr(TK_PLUS, X, Y, 0);}
336expr(A) ::= expr(X) MINUS expr(Y). {A = sqliteExpr(TK_MINUS, X, Y, 0);}
337expr(A) ::= expr(X) STAR expr(Y). {A = sqliteExpr(TK_STAR, X, Y, 0);}
338expr(A) ::= expr(X) SLASH expr(Y). {A = sqliteExpr(TK_SLASH, X, Y, 0);}
339expr(A) ::= expr(X) ISNULL. {A = sqliteExpr(TK_ISNULL, X, 0, 0);}
340expr(A) ::= expr(X) NOTNULL. {A = sqliteExpr(TK_NOTNULL, X, 0, 0);}
341expr(A) ::= NOT expr(X). {A = sqliteExpr(TK_NOT, X, 0, 0);}
drh8be51132000-06-03 19:19:41 +0000342expr(A) ::= MINUS expr(X). [UMINUS] {A = sqliteExpr(TK_UMINUS, X, 0, 0);}
343expr(A) ::= PLUS expr(X). [UMINUS] {A = X;}
drh19a775c2000-06-05 18:54:46 +0000344expr(A) ::= LP select(X) RP. {
345 A = sqliteExpr(TK_SELECT, 0, 0, 0);
346 A->pSelect = X;
347}
drhfef52082000-06-06 01:50:43 +0000348expr(A) ::= expr(W) BETWEEN expr(X) AND expr(Y). {
349 ExprList *pList = sqliteExprListAppend(0, X, 0);
350 pList = sqliteExprListAppend(pList, Y, 0);
351 A = sqliteExpr(TK_BETWEEN, W, 0, 0);
352 A->pList = pList;
353}
drh4794b982000-06-06 13:54:14 +0000354expr(A) ::= expr(W) NOT BETWEEN expr(X) AND expr(Y). {
355 ExprList *pList = sqliteExprListAppend(0, X, 0);
356 pList = sqliteExprListAppend(pList, Y, 0);
357 A = sqliteExpr(TK_BETWEEN, W, 0, 0);
358 A->pList = pList;
359 A = sqliteExpr(TK_NOT, A, 0, 0);
360}
drhfef52082000-06-06 01:50:43 +0000361expr(A) ::= expr(X) IN LP exprlist(Y) RP. {
362 A = sqliteExpr(TK_IN, X, 0, 0);
363 A->pList = Y;
364}
365expr(A) ::= expr(X) IN LP select(Y) RP. {
366 A = sqliteExpr(TK_IN, X, 0, 0);
367 A->pSelect = Y;
368}
drh4794b982000-06-06 13:54:14 +0000369expr(A) ::= expr(X) NOT IN LP exprlist(Y) RP. {
370 A = sqliteExpr(TK_IN, X, 0, 0);
371 A->pList = Y;
372 A = sqliteExpr(TK_NOT, A, 0, 0);
373}
374expr(A) ::= expr(X) NOT IN LP select(Y) RP. {
375 A = sqliteExpr(TK_IN, X, 0, 0);
376 A->pSelect = Y;
377 A = sqliteExpr(TK_NOT, A, 0, 0);
378}
drhfef52082000-06-06 01:50:43 +0000379
380
drh348784e2000-05-29 20:41:49 +0000381
382%type exprlist {ExprList*}
383%destructor exprlist {sqliteExprListDelete($$);}
384%type expritem {Expr*}
385%destructor expritem {sqliteExprDelete($$);}
386
drh348784e2000-05-29 20:41:49 +0000387exprlist(A) ::= exprlist(X) COMMA expritem(Y).
388 {A = sqliteExprListAppend(X,Y,0);}
389exprlist(A) ::= expritem(X). {A = sqliteExprListAppend(0,X,0);}
390expritem(A) ::= expr(X). {A = X;}
391expritem(A) ::= . {A = 0;}
drhcce7d172000-05-31 15:34:51 +0000392
drh348784e2000-05-29 20:41:49 +0000393
drh4cfa7932000-06-08 15:10:46 +0000394cmd ::= CREATE(S) uniqueflag INDEX id(X) ON id(Y) LP idxlist(Z) RP(E).
drh348784e2000-05-29 20:41:49 +0000395 {sqliteCreateIndex(pParse, &X, &Y, Z, &S, &E);}
396uniqueflag ::= UNIQUE.
397uniqueflag ::= .
398
399%type idxlist {IdList*}
400%destructor idxlist {sqliteIdListDelete($$);}
401%type idxitem {Token}
402
403idxlist(A) ::= idxlist(X) COMMA idxitem(Y).
404 {A = sqliteIdListAppend(X,&Y);}
405idxlist(A) ::= idxitem(Y).
406 {A = sqliteIdListAppend(0,&Y);}
drh4cfa7932000-06-08 15:10:46 +0000407idxitem(A) ::= id(X). {A = X;}
drh348784e2000-05-29 20:41:49 +0000408
drh982cef72000-05-30 16:27:03 +0000409cmd ::= DROP INDEX id(X). {sqliteDropIndex(pParse, &X);}
410
411cmd ::= COPY id(X) FROM id(Y) USING DELIMITERS STRING(Z).
412 {sqliteCopy(pParse,&X,&Y,&Z);}
413cmd ::= COPY id(X) FROM id(Y).
414 {sqliteCopy(pParse,&X,&Y,0);}
drhdce2cbe2000-05-31 02:27:49 +0000415
416cmd ::= VACUUM. {sqliteVacuum(pParse,0);}
417cmd ::= VACUUM id(X). {sqliteVacuum(pParse,&X);}