Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Size optimization in the parser. (CVS 2004) |
---|---|
Downloads: | Tarball | ZIP archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
8e2ae2449882f70fe4e77c100193c053 |
User & Date: | drh 2004-10-06 14:39:29.000 |
Context
2004-10-06
| ||
15:03 | Move some work out of the makefiles and into awk scripts in separate files. Ticket #940. (CVS 2005) (check-in: 4d0f29d54c user: drh tags: trunk) | |
14:39 | Size optimization in the parser. (CVS 2004) (check-in: 8e2ae24498 user: drh tags: trunk) | |
14:39 | Fix the ".import" command of the command-line shell so that it ignores \n and \r at the end of a line. Ticket #939. (CVS 2003) (check-in: dcbf4817a7 user: drh tags: trunk) | |
Changes
Changes to src/parse.y.
︙ | ︙ | |||
10 11 12 13 14 15 16 | ** ************************************************************************* ** This file contains SQLite's grammar for SQL. Process this file ** using the lemon parser generator to generate C code that runs ** the parser. Lemon will also generate a header file containing ** numeric codes for all of the tokens. ** | | | 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | ** ************************************************************************* ** This file contains SQLite's grammar for SQL. Process this file ** using the lemon parser generator to generate C code that runs ** the parser. Lemon will also generate a header file containing ** numeric codes for all of the tokens. ** ** @(#) $Id: parse.y,v 1.143 2004/10/06 14:39:29 drh Exp $ */ %token_prefix TK_ %token_type {Token} %default_type {Token} %extra_argument {Parse *pParse} %syntax_error { if( pParse->zErrMsg==0 ){ |
︙ | ︙ | |||
38 39 40 41 42 43 44 45 46 47 48 49 50 51 | ** An instance of this structure holds information about the ** LIMIT clause of a SELECT statement. */ struct LimitVal { int limit; /* The LIMIT value. -1 if there is no limit */ int offset; /* The OFFSET. 0 if there is none */ }; /* ** An instance of the following structure describes the event of a ** TRIGGER. "a" is the event type, one of TK_UPDATE, TK_INSERT, ** TK_DELETE, or TK_INSTEAD. If the event is of the form ** ** UPDATE ON (a,b,c) | > > > > > > > > > | 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 | ** An instance of this structure holds information about the ** LIMIT clause of a SELECT statement. */ struct LimitVal { int limit; /* The LIMIT value. -1 if there is no limit */ int offset; /* The OFFSET. 0 if there is none */ }; /* ** An instance of this structure is used to store the LIKE, ** GLOB, NOT LIKE, and NOT GLOB operators. */ struct LikeOp { int opcode; /* Either TK_GLOB or TK_LIKE */ int not; /* True if the NOT keyword is present */ }; /* ** An instance of the following structure describes the event of a ** TRIGGER. "a" is the event type, one of TK_UPDATE, TK_INSERT, ** TK_DELETE, or TK_INSTEAD. If the event is of the form ** ** UPDATE ON (a,b,c) |
︙ | ︙ | |||
593 594 595 596 597 598 599 | expr(A) ::= expr(X) BITOR(OP) expr(Y). {A = sqlite3Expr(@OP, X, Y, 0);} expr(A) ::= expr(X) LSHIFT(OP) expr(Y). {A = sqlite3Expr(@OP, X, Y, 0);} expr(A) ::= expr(X) RSHIFT(OP) expr(Y). {A = sqlite3Expr(@OP, X, Y, 0);} expr(A) ::= expr(X) likeop(OP) expr(Y). [LIKE] { ExprList *pList = sqlite3ExprListAppend(0, Y, 0); pList = sqlite3ExprListAppend(pList, X, 0); A = sqlite3ExprFunction(pList, 0); | | < < < < < < < | | | | | > > | 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 | expr(A) ::= expr(X) BITOR(OP) expr(Y). {A = sqlite3Expr(@OP, X, Y, 0);} expr(A) ::= expr(X) LSHIFT(OP) expr(Y). {A = sqlite3Expr(@OP, X, Y, 0);} expr(A) ::= expr(X) RSHIFT(OP) expr(Y). {A = sqlite3Expr(@OP, X, Y, 0);} expr(A) ::= expr(X) likeop(OP) expr(Y). [LIKE] { ExprList *pList = sqlite3ExprListAppend(0, Y, 0); pList = sqlite3ExprListAppend(pList, X, 0); A = sqlite3ExprFunction(pList, 0); if( A ) A->op = OP.opcode; if( OP.not ) A = sqlite3Expr(TK_NOT, A, 0, 0); sqlite3ExprSpan(A, &X->span, &Y->span); } %type likeop {struct LikeOp} likeop(A) ::= LIKE. {A.opcode = TK_LIKE; A.not = 0;} likeop(A) ::= GLOB. {A.opcode = TK_GLOB; A.not = 0;} likeop(A) ::= NOT LIKE. {A.opcode = TK_LIKE; A.not = 1;} likeop(A) ::= NOT GLOB. {A.opcode = TK_GLOB; A.not = 1;} expr(A) ::= expr(X) PLUS(OP) expr(Y). {A = sqlite3Expr(@OP, X, Y, 0);} expr(A) ::= expr(X) MINUS(OP) expr(Y). {A = sqlite3Expr(@OP, X, Y, 0);} expr(A) ::= expr(X) STAR(OP) expr(Y). {A = sqlite3Expr(@OP, X, Y, 0);} expr(A) ::= expr(X) SLASH(OP) expr(Y). {A = sqlite3Expr(@OP, X, Y, 0);} expr(A) ::= expr(X) REM(OP) expr(Y). {A = sqlite3Expr(@OP, X, Y, 0);} expr(A) ::= expr(X) CONCAT(OP) expr(Y). {A = sqlite3Expr(@OP, X, Y, 0);} expr(A) ::= expr(X) ISNULL(E). { |
︙ | ︙ | |||
654 655 656 657 658 659 660 | sqlite3ExprSpan(A,&B,&X->span); } expr(A) ::= LP(B) select(X) RP(E). { A = sqlite3Expr(TK_SELECT, 0, 0, 0); if( A ) A->pSelect = X; sqlite3ExprSpan(A,&B,&E); } | > | < < | < < < | | > > > | < < < | < < < < < < < | | | < < < < < < | | 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 | sqlite3ExprSpan(A,&B,&X->span); } expr(A) ::= LP(B) select(X) RP(E). { A = sqlite3Expr(TK_SELECT, 0, 0, 0); if( A ) A->pSelect = X; sqlite3ExprSpan(A,&B,&E); } %type between_op {int} between_op(A) ::= BETWEEN. {A = 0;} between_op(A) ::= NOT BETWEEN. {A = 1;} expr(A) ::= expr(W) between_op(N) expr(X) AND expr(Y). [BETWEEN] { ExprList *pList = sqlite3ExprListAppend(0, X, 0); pList = sqlite3ExprListAppend(pList, Y, 0); A = sqlite3Expr(TK_BETWEEN, W, 0, 0); if( A ) A->pList = pList; if( N ) A = sqlite3Expr(TK_NOT, A, 0, 0); sqlite3ExprSpan(A,&W->span,&Y->span); } %type in_op {int} in_op(A) ::= IN. {A = 0;} in_op(A) ::= NOT IN. {A = 1;} expr(A) ::= expr(X) in_op(N) LP exprlist(Y) RP(E). [IN] { A = sqlite3Expr(TK_IN, X, 0, 0); if( A ) A->pList = Y; if( N ) A = sqlite3Expr(TK_NOT, A, 0, 0); sqlite3ExprSpan(A,&X->span,&E); } expr(A) ::= expr(X) in_op(N) LP select(Y) RP(E). [IN] { A = sqlite3Expr(TK_IN, X, 0, 0); if( A ) A->pSelect = Y; if( N ) A = sqlite3Expr(TK_NOT, A, 0, 0); sqlite3ExprSpan(A,&X->span,&E); } expr(A) ::= expr(X) in_op(N) nm(Y) dbnm(D). [IN] { SrcList *pSrc = sqlite3SrcListAppend(0, &Y, &D); A = sqlite3Expr(TK_IN, X, 0, 0); if( A ) A->pSelect = sqlite3SelectNew(0,pSrc,0,0,0,0,0,-1,0); if( N ) A = sqlite3Expr(TK_NOT, A, 0, 0); sqlite3ExprSpan(A,&X->span,D.z?&D:&Y); } /* CASE expressions */ expr(A) ::= CASE(C) case_operand(X) case_exprlist(Y) case_else(Z) END(E). { A = sqlite3Expr(TK_CASE, X, Z, 0); |
︙ | ︙ |