Fix comment typos and improve clarity of presention in Lemon. The output
should be identical. FossilOrigin-Name: b91a5b8297756289d45c8fce0d3399c253517eb0
This commit is contained in:
parent
6831474341
commit
711c9810dc
12
manifest
12
manifest
@ -1,5 +1,5 @@
|
||||
C Update\sthe\sconfigure\sscript\swith\sadditional\shints\son\sthe\slocation\sof\ntclConfig.sh,\shints\sneeded\sby\sthe\slatest\sversions\sof\sXcode.
|
||||
D 2016-05-23T00:10:58.949
|
||||
C Fix\scomment\stypos\sand\simprove\sclarity\sof\spresention\sin\sLemon.\s\sThe\soutput\nshould\sbe\sidentical.
|
||||
D 2016-05-23T14:24:31.372
|
||||
F Makefile.in f59e0763ff448719fc1bd25513882b0567286317
|
||||
F Makefile.linux-gcc 7bc79876b875010e8c8f9502eb935ca92aa3c434
|
||||
F Makefile.msc 306d73e854b1a92ea06e5d1e637faa5c44de53c7
|
||||
@ -1420,7 +1420,7 @@ F tool/fuzzershell.c 94019b185caceffc9f7c7b678a6489e42bc2aefa
|
||||
F tool/genfkey.README cf68fddd4643bbe3ff8e31b8b6d8b0a1b85e20f4
|
||||
F tool/genfkey.test 4196a8928b78f51d54ef58e99e99401ab2f0a7e5
|
||||
F tool/getlock.c f4c39b651370156cae979501a7b156bdba50e7ce
|
||||
F tool/lemon.c f38a55106d79b7a4c063abb958517d6c47dc6ac7
|
||||
F tool/lemon.c b622032dd14dc1315fedb81d73f4658354329fca
|
||||
F tool/lempar.c 404ea3dc27dbeed343f0e61b1d36e97b9f5f0fb6
|
||||
F tool/loadfts.c c3c64e4d5e90e8ba41159232c2189dba4be7b862
|
||||
F tool/logest.c 11346aa019e2e77a00902aa7d0cabd27bd2e8cca
|
||||
@ -1492,7 +1492,7 @@ F vsixtest/vsixtest.tcl 6a9a6ab600c25a91a7acc6293828957a386a8a93
|
||||
F vsixtest/vsixtest.vcxproj.data 2ed517e100c66dc455b492e1a33350c1b20fbcdc
|
||||
F vsixtest/vsixtest.vcxproj.filters 37e51ffedcdb064aad6ff33b6148725226cd608e
|
||||
F vsixtest/vsixtest_TemporaryKey.pfx e5b1b036facdb453873e7084e1cae9102ccc67a0
|
||||
P dec1307581216e01ad508ffe4455b957e3356654
|
||||
R 335eb72f63a6d15e3459420d579ffc36
|
||||
P 90411a28168f6dacf08242a25bed7d6269041417
|
||||
R 996821eb90ee3795d9bf03c89106b9e7
|
||||
U drh
|
||||
Z 180e9fbd5ff0ebef42d9658da1e8cd36
|
||||
Z b4115b7928b4702f985a5c5bf63f70fa
|
||||
|
@ -1 +1 @@
|
||||
90411a28168f6dacf08242a25bed7d6269041417
|
||||
b91a5b8297756289d45c8fce0d3399c253517eb0
|
47
tool/lemon.c
47
tool/lemon.c
@ -288,6 +288,8 @@ 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 */
|
||||
@ -349,7 +351,7 @@ struct state {
|
||||
struct config *bp; /* The basis configurations for this state */
|
||||
struct config *cfp; /* All configurations in this set */
|
||||
int statenum; /* Sequential number for this state */
|
||||
struct action *ap; /* Array of actions for this state */
|
||||
struct action *ap; /* List of actions for this state */
|
||||
int nTknAct, nNtAct; /* Number of actions on terminals and nonterminals */
|
||||
int iTknOfst, iNtOfst; /* yy_action[] offset for terminals and nonterms */
|
||||
int iDfltReduce; /* Default action is to REDUCE by this rule */
|
||||
@ -1499,7 +1501,7 @@ static void handle_T_option(char *z){
|
||||
lemon_strcpy(user_templatename, z);
|
||||
}
|
||||
|
||||
/* Merge together to lists of rules order by rule.iRule */
|
||||
/* Merge together to lists of rules ordered by rule.iRule */
|
||||
static struct rule *Rule_merge(struct rule *pA, struct rule *pB){
|
||||
struct rule *pFirst = 0;
|
||||
struct rule **ppPrev = &pFirst;
|
||||
@ -1642,7 +1644,10 @@ int main(int argc, char **argv)
|
||||
for(i=1; ISUPPER(lem.symbols[i]->name[0]); i++);
|
||||
lem.nterminal = i;
|
||||
|
||||
/* Assign sequential rule numbers */
|
||||
/* Assign sequential rule numbers. Start with 0. Put rules that have no
|
||||
** reduce action C-code associated with them last, so that the switch()
|
||||
** statement that selects reduction actions will have a smaller jump table.
|
||||
*/
|
||||
for(i=0, rp=lem.rule; rp; rp=rp->next){
|
||||
rp->iRule = rp->code ? i++ : -1;
|
||||
}
|
||||
@ -2211,6 +2216,7 @@ to follow the previous rule.");
|
||||
}else{
|
||||
psp->prevrule->line = psp->tokenlineno;
|
||||
psp->prevrule->code = &x[1];
|
||||
psp->prevrule->noCode = 0;
|
||||
}
|
||||
}else if( x[0]=='[' ){
|
||||
psp->state = PRECEDENCE_MARK_1;
|
||||
@ -2317,6 +2323,7 @@ to follow the previous rule.");
|
||||
rp->lhsalias = psp->lhsalias;
|
||||
rp->nrhs = psp->nrhs;
|
||||
rp->code = 0;
|
||||
rp->noCode = 1;
|
||||
rp->precsym = 0;
|
||||
rp->index = psp->gp->nrule++;
|
||||
rp->nextlhs = rp->lhs->rule;
|
||||
@ -3527,9 +3534,8 @@ PRIVATE char *append_str(const char *zText, int n, int p1, int p2){
|
||||
}
|
||||
|
||||
/*
|
||||
** zCode is a string that is the action associated with a rule. Expand
|
||||
** the symbols in this string so that the refer to elements of the parser
|
||||
** stack.
|
||||
** Write and transform the rp->code string so that symbols are expanded.
|
||||
** Populate the rp->codePrefix and rp->codeSuffix strings, as appropriate.
|
||||
**
|
||||
** Return 1 if the expanded code requires that "yylhsminor" local variable
|
||||
** to be defined.
|
||||
@ -3553,6 +3559,9 @@ PRIVATE int translate_code(struct lemon *lemp, struct rule *rp){
|
||||
static char newlinestr[2] = { '\n', '\0' };
|
||||
rp->code = newlinestr;
|
||||
rp->line = rp->ruleline;
|
||||
rp->noCode = 1;
|
||||
}else{
|
||||
rp->noCode = 0;
|
||||
}
|
||||
|
||||
|
||||
@ -3568,6 +3577,7 @@ PRIVATE int translate_code(struct lemon *lemp, struct rule *rp){
|
||||
append_str(" yy_destructor(yypParser,%d,&yymsp[%d].minor);\n", 0,
|
||||
rp->rhs[0]->index,1-rp->nrhs);
|
||||
rp->codePrefix = Strsafe(append_str(0,0,0,0));
|
||||
rp->noCode = 0;
|
||||
}
|
||||
}else if( rp->lhsalias==0 ){
|
||||
/* There is no LHS value symbol. */
|
||||
@ -3715,7 +3725,10 @@ PRIVATE int translate_code(struct lemon *lemp, struct rule *rp){
|
||||
|
||||
/* Suffix code generation complete */
|
||||
cp = append_str(0,0,0,0);
|
||||
if( cp && cp[0] ) rp->codeSuffix = Strsafe(cp);
|
||||
if( cp && cp[0] ){
|
||||
rp->codeSuffix = Strsafe(cp);
|
||||
rp->noCode = 0;
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
@ -4396,13 +4409,9 @@ void ReportTable(
|
||||
/* First output rules other than the default: rule */
|
||||
for(rp=lemp->rule; rp; rp=rp->next){
|
||||
struct rule *rp2; /* Other rules with the same action */
|
||||
if( rp->code==0 ) continue;
|
||||
if( rp->code[0]=='\n'
|
||||
&& rp->code[1]==0
|
||||
&& rp->codePrefix==0
|
||||
&& rp->codeSuffix==0
|
||||
){
|
||||
/* No actions, so this will be part of the "default:" rule */
|
||||
if( rp->codeEmitted ) continue;
|
||||
if( rp->noCode ){
|
||||
/* No C code actions, so this will be part of the "default:" rule */
|
||||
continue;
|
||||
}
|
||||
fprintf(out," case %d: /* ", rp->iRule);
|
||||
@ -4414,21 +4423,19 @@ void ReportTable(
|
||||
fprintf(out," case %d: /* ", rp2->iRule);
|
||||
writeRuleText(out, rp2);
|
||||
fprintf(out," */ yytestcase(yyruleno==%d);\n", rp2->iRule); lineno++;
|
||||
rp2->code = 0;
|
||||
rp2->codeEmitted = 1;
|
||||
}
|
||||
}
|
||||
emit_code(out,rp,lemp,&lineno);
|
||||
fprintf(out," break;\n"); lineno++;
|
||||
rp->code = 0;
|
||||
rp->codeEmitted = 1;
|
||||
}
|
||||
/* Finally, output the default: rule. We choose as the default: all
|
||||
** empty actions. */
|
||||
fprintf(out," default:\n"); lineno++;
|
||||
for(rp=lemp->rule; rp; rp=rp->next){
|
||||
if( rp->code==0 ) continue;
|
||||
assert( rp->code[0]=='\n' && rp->code[1]==0 );
|
||||
assert( rp->codePrefix==0 );
|
||||
assert( rp->codeSuffix==0 );
|
||||
if( rp->codeEmitted ) continue;
|
||||
assert( rp->noCode );
|
||||
fprintf(out," /* (%d) ", rp->iRule);
|
||||
writeRuleText(out, rp);
|
||||
fprintf(out, " */ yytestcase(yyruleno==%d);\n", rp->iRule); lineno++;
|
||||
|
Loading…
x
Reference in New Issue
Block a user