# as an optimization. During parsing, things like expression operators
# are coded with TK_ values such as TK_ADD, TK_DIVIDE, and so forth. Later
# during code generation, we need to generate corresponding opcodes like
# OP_Add and OP_Divide. By making TK_ADD==OP_Add and TK_DIVIDE==OP_Divide,
# code to translation from one to the other is avoided. This makes the
# code generator run (infinitesimally) faster and more importantly it makes
# the total library smaller.
#
# Remember the TK_ values from the parse.h file
/^#define TK_/ {
tk[$2] = $3
}

# as an optimization. During parsing, things like expression operators
# are coded with TK_ values such as TK_ADD, TK_DIVIDE, and so forth. Later
# during code generation, we need to generate corresponding opcodes like
# OP_Add and OP_Divide. By making TK_ADD==OP_Add and TK_DIVIDE==OP_Divide,
# code to translation from one to the other is avoided. This makes the
# code generator run (infinitesimally) faster and more importantly it makes
# the total library smaller.
## This script also scans for lines of the form:## case OP_aaaa: /* no-push */## When the no-push comment is found on an opcode, it means that that# opcode does not leave a result on the stack. But identifying which# opcodes leave results on the stack it is possible to determine a# much smaller upper bound on the size of the stack. This allows# a smaller stack to be allocated, which is important to embedded# systems with limited memory space. This script generates a series# of "NOPUSH_MASK" defines that contain bitmaps of opcodes that leave# results on the stack. The NOPUSH_MASK defines are used in vdbeaux.c# to help determine the maximum stack size.
#
# Remember the TK_ values from the parse.h file
/^#define TK_/ {
tk[$2] = $3
}

**
*************************************************************************
** 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.184 2005/11/14 22:29:05 drh Exp $
*/
// All token codes are small integers with #defines that begin with "TK_"
%token_prefix TK_
// The type of the data attached to each token is Token. This is also the
// default type for non-terminals.
................................................................................
/*
** An instance of this structure holds the ATTACH key and the key type.
*/
struct AttachKey { int type; Token key; };
} // end %include
// These are extra tokens used by the lexer but never seen by the// parser. We put them in a rule so that the parser generator will// add them to the parse.h output file.//%nonassoc END_OF_FILE ILLEGAL SPACE UNCLOSED_STRING COMMENT FUNCTION COLUMN AGG_FUNCTION AGG_COLUMN CONST_FUNC.// Extra tokens used by the code generator by never seen by the parser.%nonassoc TO_TEXT TO_BLOB TO_NUMERIC TO_INT TO_REAL.
// Input is a single SQL command
input ::= cmdlist.
cmdlist ::= cmdlist ecmd.
cmdlist ::= ecmd.
cmdx ::= cmd. { sqlite3FinishCoding(pParse); }
ecmd ::= SEMI.
ecmd ::= explain cmdx SEMI.