I've mentioned before on the list that a bit more context in parse error
messages would be helpful in our application. I hacked something quick that
seems to work for us, posting it in case anyone else finds it useful or would
like to improve on it.
****************************************************************************
/*
** The following code executes when a syntax error first occurs.
*/
static void yy_syntax_error(
yyParser *yypParser, /* The parser */
int yymajor, /* The major type of the error token */
YYMINORTYPE yyminor /* The minor type of the error token */
){
sqlite3ParserARG_FETCH;
#define TOKEN (yyminor.yy0)
Token msg;
msg.z = pParse->zTail;
msg.n = pParse->sLastToken.z - pParse->zTail + pParse->sLastToken.n;
if(msg.n > 36)
{
msg.z = msg.z + msg.n - 36;
msg.n = 36;
}
assert( msg.z[0] );
sqlite3ErrorMsg(pParse, "near \"%T<--here\": syntax error", &msg);
UNUSED_PARAMETER(yymajor); /* Silence some compiler warnings */
assert( TOKEN.z[0] ); /* The tokenizer always gives us a token */
/*sqlite3ErrorMsg(pParse, "near \"%T\": syntax error", &TOKEN); */
sqlite3ParserARG_STORE; /* Suppress warning about unused %extra_argument
variable */
}
*************************************************************************
----------------------------------------------------------------------
This message, and any attachments, is for the intended recipient(s) only, may
contain information that is privileged, confidential and/or proprietary and
subject to important terms and conditions available at
http://www.bankofamerica.com/emaildisclaimer. If you are not the intended
recipient, please delete this message.
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users