lemon: Sync with upstream, Jun 28, 2017
Change-Id: I4c6dbd018302fdf176e955e0e5e735a7aee22b10 Reviewed-on: https://code.wireshark.org/review/26669 Petri-Dish: Anders Broman <a.broman58@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
parent
6733df6e70
commit
85a0646490
|
@ -1530,8 +1530,7 @@ static char **azDefine = 0; /* Name of the -D macros */
|
||||||
/* This routine is called with the argument to each -D command-line option.
|
/* This routine is called with the argument to each -D command-line option.
|
||||||
** Add the macro defined to the azDefine array.
|
** Add the macro defined to the azDefine array.
|
||||||
*/
|
*/
|
||||||
static void handle_D_option(void *arg){
|
static void handle_D_option(char *z) {
|
||||||
char *z = (char *)arg;
|
|
||||||
char **paz;
|
char **paz;
|
||||||
nDefine++;
|
nDefine++;
|
||||||
azDefine = (char **) realloc(azDefine, sizeof(azDefine[0])*nDefine);
|
azDefine = (char **) realloc(azDefine, sizeof(azDefine[0])*nDefine);
|
||||||
|
@ -1551,8 +1550,7 @@ static void handle_D_option(void *arg){
|
||||||
}
|
}
|
||||||
|
|
||||||
static char *user_templatename = NULL;
|
static char *user_templatename = NULL;
|
||||||
static void handle_T_option(void *arg){
|
static void handle_T_option(char *z) {
|
||||||
char *z = (char *)arg;
|
|
||||||
user_templatename = (char *) malloc( lemonStrlen(z)+1 );
|
user_templatename = (char *) malloc( lemonStrlen(z)+1 );
|
||||||
MemoryCheck(user_templatename);
|
MemoryCheck(user_templatename);
|
||||||
lemon_strcpy(user_templatename, z);
|
lemon_strcpy(user_templatename, z);
|
||||||
|
@ -3373,8 +3371,15 @@ PRIVATE int compute_action(struct lemon *lemp, struct action *ap)
|
||||||
{
|
{
|
||||||
int act;
|
int act;
|
||||||
switch( ap->type ){
|
switch( ap->type ){
|
||||||
case SHIFT: act = ap->x.stp->statenum; break;
|
case SHIFT: act = ap->x.stp->statenum; break;
|
||||||
case SHIFTREDUCE: act = ap->x.rp->iRule + lemp->nstate; break;
|
case SHIFTREDUCE: {
|
||||||
|
act = ap->x.rp->iRule + lemp->nstate;
|
||||||
|
/* Since a SHIFT is inherient after a prior REDUCE, convert any
|
||||||
|
** SHIFTREDUCE action with a nonterminal on the LHS into a simple
|
||||||
|
** REDUCE action: */
|
||||||
|
if (ap->sp->index >= lemp->nterminal) act += lemp->nrule;
|
||||||
|
break;
|
||||||
|
}
|
||||||
case REDUCE: act = ap->x.rp->iRule + lemp->nstate+lemp->nrule; break;
|
case REDUCE: act = ap->x.rp->iRule + lemp->nstate+lemp->nrule; break;
|
||||||
case ERROR: act = lemp->nstate + lemp->nrule*2; break;
|
case ERROR: act = lemp->nstate + lemp->nrule*2; break;
|
||||||
case ACCEPT: act = lemp->nstate + lemp->nrule*2 + 1; break;
|
case ACCEPT: act = lemp->nstate + lemp->nrule*2 + 1; break;
|
||||||
|
@ -4494,7 +4499,7 @@ void ReportTable(
|
||||||
** sequentually beginning with 0.
|
** sequentually beginning with 0.
|
||||||
*/
|
*/
|
||||||
for(rp=lemp->rule; rp; rp=rp->next){
|
for(rp=lemp->rule; rp; rp=rp->next){
|
||||||
fprintf(out," { %d, %d },\n",rp->lhs->index,rp->nrhs); lineno++;
|
fprintf(out, " { %d, %d },\n", rp->lhs->index, -rp->nrhs); lineno++;
|
||||||
}
|
}
|
||||||
tplt_xfer(lemp->name,in,out,&lineno);
|
tplt_xfer(lemp->name,in,out,&lineno);
|
||||||
|
|
||||||
|
|
|
@ -221,6 +221,7 @@ struct yyParser {
|
||||||
yyStackEntry yystk0; /* First stack entry */
|
yyStackEntry yystk0; /* First stack entry */
|
||||||
#else
|
#else
|
||||||
yyStackEntry yystack[YYSTACKDEPTH]; /* The parser's stack */
|
yyStackEntry yystack[YYSTACKDEPTH]; /* The parser's stack */
|
||||||
|
yyStackEntry *yystackEnd; /* Last entry in the stack */
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
typedef struct yyParser yyParser;
|
typedef struct yyParser yyParser;
|
||||||
|
@ -338,6 +339,9 @@ static void ParseInit(void *yypParser){
|
||||||
pParser->yytos = pParser->yystack;
|
pParser->yytos = pParser->yystack;
|
||||||
pParser->yystack[0].stateno = 0;
|
pParser->yystack[0].stateno = 0;
|
||||||
pParser->yystack[0].major = 0;
|
pParser->yystack[0].major = 0;
|
||||||
|
#if YYSTACKDEPTH>0
|
||||||
|
pParser->yystackEnd = &pParser->yystack[YYSTACKDEPTH - 1];
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef Parse_ENGINEALWAYSONSTACK
|
#ifndef Parse_ENGINEALWAYSONSTACK
|
||||||
|
@ -607,7 +611,7 @@ static void yy_shift(
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if YYSTACKDEPTH>0
|
#if YYSTACKDEPTH>0
|
||||||
if( yypParser->yytos>=&yypParser->yystack[YYSTACKDEPTH] ){
|
if (yypParser->yytos>yypParser->yystackEnd) {
|
||||||
yypParser->yytos--;
|
yypParser->yytos--;
|
||||||
yyStackOverflow(yypParser);
|
yyStackOverflow(yypParser);
|
||||||
return;
|
return;
|
||||||
|
@ -635,8 +639,8 @@ static void yy_shift(
|
||||||
** is used during the reduce.
|
** is used during the reduce.
|
||||||
*/
|
*/
|
||||||
static const struct {
|
static const struct {
|
||||||
YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */
|
YYCODETYPE lhs; /* Symbol on the left-hand side of the rule */
|
||||||
unsigned char nrhs; /* Number of right-hand side symbols in the rule */
|
signed char nrhs; /* Negative of the number of RHS symbols in the rule */
|
||||||
} yyRuleInfo[] = {
|
} yyRuleInfo[] = {
|
||||||
%%
|
%%
|
||||||
};
|
};
|
||||||
|
@ -661,7 +665,7 @@ static void yy_reduce(
|
||||||
if( yyTraceFILE && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){
|
if( yyTraceFILE && yyruleno<(int)(sizeof(yyRuleName)/sizeof(yyRuleName[0])) ){
|
||||||
yysize = yyRuleInfo[yyruleno].nrhs;
|
yysize = yyRuleInfo[yyruleno].nrhs;
|
||||||
fprintf(yyTraceFILE, "%sReduce [%s], go to state %d.\n", yyTracePrompt,
|
fprintf(yyTraceFILE, "%sReduce [%s], go to state %d.\n", yyTracePrompt,
|
||||||
yyRuleName[yyruleno], yymsp[-yysize].stateno);
|
yyRuleName[yyruleno], yymsp[yysize].stateno);
|
||||||
}
|
}
|
||||||
#endif /* NDEBUG */
|
#endif /* NDEBUG */
|
||||||
|
|
||||||
|
@ -676,7 +680,7 @@ static void yy_reduce(
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#if YYSTACKDEPTH>0
|
#if YYSTACKDEPTH>0
|
||||||
if( yypParser->yytos>=&yypParser->yystack[YYSTACKDEPTH-1] ){
|
if (yypParser->yytos >= yypParser->yystackEnd) {
|
||||||
yyStackOverflow(yypParser);
|
yyStackOverflow(yypParser);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -707,20 +711,24 @@ static void yy_reduce(
|
||||||
assert( yyruleno<sizeof(yyRuleInfo)/sizeof(yyRuleInfo[0]) );
|
assert( yyruleno<sizeof(yyRuleInfo)/sizeof(yyRuleInfo[0]) );
|
||||||
yygoto = yyRuleInfo[yyruleno].lhs;
|
yygoto = yyRuleInfo[yyruleno].lhs;
|
||||||
yysize = yyRuleInfo[yyruleno].nrhs;
|
yysize = yyRuleInfo[yyruleno].nrhs;
|
||||||
yyact = yy_find_reduce_action(yymsp[-yysize].stateno,(YYCODETYPE)yygoto);
|
yyact = yy_find_reduce_action(yymsp[yysize].stateno, (YYCODETYPE)yygoto);
|
||||||
if( yyact <= YY_MAX_SHIFTREDUCE ){
|
|
||||||
if( yyact>YY_MAX_SHIFT ){
|
/* There are no SHIFTREDUCE actions on nonterminals because the table
|
||||||
yyact += YY_MIN_REDUCE - YY_MIN_SHIFTREDUCE;
|
** generator has simplified them to pure REDUCE actions. */
|
||||||
}
|
assert(!(yyact>YY_MAX_SHIFT && yyact <= YY_MAX_SHIFTREDUCE));
|
||||||
yymsp -= yysize-1;
|
|
||||||
yypParser->yytos = yymsp;
|
/* It is not possible for a REDUCE to be followed by an error */
|
||||||
yymsp->stateno = (YYACTIONTYPE)yyact;
|
assert(yyact != YY_ERROR_ACTION);
|
||||||
yymsp->major = (YYCODETYPE)yygoto;
|
|
||||||
yyTraceShift(yypParser, yyact);
|
if (yyact == YY_ACCEPT_ACTION) {
|
||||||
}else{
|
yypParser->yytos += yysize;
|
||||||
assert( yyact == YY_ACCEPT_ACTION );
|
yy_accept(yypParser);
|
||||||
yypParser->yytos -= yysize;
|
} else {
|
||||||
yy_accept(yypParser);
|
yymsp += yysize + 1;
|
||||||
|
yypParser->yytos = yymsp;
|
||||||
|
yymsp->stateno = (YYACTIONTYPE)yyact;
|
||||||
|
yymsp->major = (YYCODETYPE)yygoto;
|
||||||
|
yyTraceShift(yypParser, yyact);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue