mirror of
https://github.com/sqlite/sqlite.git
synced 2025-07-29 08:01:23 +03:00
Enhance LEMON to provide the ability to mark a rules as one that will never
reduce due to intervention of actions. Use this new capability to designate the EXPLAIN rule as NEVER-REDUCES. FossilOrigin-Name: 136cdefb2f7b582ff1771ac7f9e733dc24c357605526cbfb1834937697c8a922
This commit is contained in:
13
tool/lemon.c
13
tool/lemon.c
@ -292,13 +292,15 @@ struct rule {
|
||||
const char *code; /* The code executed when this rule is reduced */
|
||||
const char *codePrefix; /* Setup code before code[] above */
|
||||
const char *codeSuffix; /* Breakdown code after code[] above */
|
||||
int noCode; /* True if this rule has no associated C code */
|
||||
int codeEmitted; /* True if the code has been emitted already */
|
||||
struct symbol *precsym; /* Precedence symbol for this rule */
|
||||
int index; /* An index number for this rule */
|
||||
int iRule; /* Rule number as used in the generated tables */
|
||||
Boolean noCode; /* True if this rule has no associated C code */
|
||||
Boolean codeEmitted; /* True if the code has been emitted already */
|
||||
Boolean canReduce; /* True if this rule is ever reduced */
|
||||
Boolean doesReduce; /* Reduce actions occur after optimization */
|
||||
Boolean neverReduce; /* Reduce is theoretically possible, but prevented
|
||||
** by actions or other outside implementation */
|
||||
struct rule *nextlhs; /* Next rule with the same LHS */
|
||||
struct rule *next; /* Next rule in the global list */
|
||||
};
|
||||
@ -2278,6 +2280,8 @@ fragment which begins on this line.");
|
||||
"Code fragment beginning on this line is not the first \
|
||||
to follow the previous rule.");
|
||||
psp->errorcnt++;
|
||||
}else if( strcmp(x, "{NEVER-REDUCE")==0 ){
|
||||
psp->prevrule->neverReduce = 1;
|
||||
}else{
|
||||
psp->prevrule->line = psp->tokenlineno;
|
||||
psp->prevrule->code = &x[1];
|
||||
@ -4745,7 +4749,10 @@ void ReportTable(
|
||||
assert( rp->noCode );
|
||||
fprintf(out," /* (%d) ", rp->iRule);
|
||||
writeRuleText(out, rp);
|
||||
if( rp->doesReduce ){
|
||||
if( rp->neverReduce ){
|
||||
fprintf(out, " (NEVER REDUCES) */ assert(yyruleno!=%d);\n",
|
||||
rp->iRule); lineno++;
|
||||
}else if( rp->doesReduce ){
|
||||
fprintf(out, " */ yytestcase(yyruleno==%d);\n", rp->iRule); lineno++;
|
||||
}else{
|
||||
fprintf(out, " (OPTIMIZED OUT) */ assert(yyruleno!=%d);\n",
|
||||
|
Reference in New Issue
Block a user