Regen initparse.c with the current byacc with -l.

This commit is contained in:
joerg 2013-04-06 15:27:26 +00:00
parent 31db473bdd
commit 5c58779bec
1 changed files with 228 additions and 196 deletions

View File

@ -17,27 +17,10 @@ static const char yysccsid[] = "@(#)yaccpar 1.9 (Berkeley) 02/21/93";
#define yyerrok (yyerrflag = 0) #define yyerrok (yyerrflag = 0)
#define YYRECOVERING() (yyerrflag != 0) #define YYRECOVERING() (yyerrflag != 0)
/* compatibility with bison */
#ifdef YYPARSE_PARAM
/* compatibility with FreeBSD */
# ifdef YYPARSE_PARAM_TYPE
# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
# else
# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
# endif
#else
# define YYPARSE_DECL() yyparse(void)
#endif
/* Pure parsers. */
#define YYPURE 0
#ifdef YYLEX_PARAM
# define YYLEX yylex(YYLEX_PARAM)
#else
# define YYLEX yylex()
#endif
#define YYPREFIX "yy" #define YYPREFIX "yy"
#define YYPURE 0
/* Copyright (c) 1990 The Regents of the University of California. */ /* Copyright (c) 1990 The Regents of the University of California. */
/* All rights reserved. */ /* All rights reserved. */
@ -118,6 +101,43 @@ int previous_continued_action; /* whether the previous rule's action was '|' */
*/ */
#define YYSTYPE int #define YYSTYPE int
#ifndef YYSTYPE
typedef int YYSTYPE;
#endif
/* compatibility with bison */
#ifdef YYPARSE_PARAM
/* compatibility with FreeBSD */
# ifdef YYPARSE_PARAM_TYPE
# define YYPARSE_DECL() yyparse(YYPARSE_PARAM_TYPE YYPARSE_PARAM)
# else
# define YYPARSE_DECL() yyparse(void *YYPARSE_PARAM)
# endif
#else
# define YYPARSE_DECL() yyparse(void)
#endif
/* Parameters sent to lex. */
#ifdef YYLEX_PARAM
# define YYLEX_DECL() yylex(void *YYLEX_PARAM)
# define YYLEX yylex(YYLEX_PARAM)
#else
# define YYLEX_DECL() yylex(void)
# define YYLEX yylex()
#endif
/* Parameters sent to yyerror. */
#ifndef YYERROR_DECL
#define YYERROR_DECL() yyerror(const char *s)
#endif
#ifndef YYERROR_CALL
#define YYERROR_CALL(msg) yyerror(msg)
#endif
extern int YYPARSE_DECL();
#define CHAR 257 #define CHAR 257
#define NUMBER 258 #define NUMBER 258
#define SECTEND 259 #define SECTEND 259
@ -461,16 +481,14 @@ static const char *yyrule[] = {
}; };
#endif #endif
#ifndef YYSTYPE
typedef int YYSTYPE;
#endif
#if YYDEBUG
#include <stdio.h>
#endif
extern int YYPARSE_DECL(); int yydebug;
static int yygrowstack(short **, short **, short **, int yynerrs;
YYSTYPE **, YYSTYPE **, unsigned *);
int yyerrflag;
int yychar;
YYSTYPE yyval;
YYSTYPE yylval;
/* define the initial stack-sizes */ /* define the initial stack-sizes */
#ifdef YYSTACKSIZE #ifdef YYSTACKSIZE
@ -487,12 +505,16 @@ static int yygrowstack(short **, short **, short **,
#define YYINITSTACKSIZE 500 #define YYINITSTACKSIZE 500
int yydebug; typedef struct {
int yyerrflag; unsigned stacksize;
int yynerrs; short *s_base;
int yychar; short *s_mark;
YYSTYPE yylval; short *s_last;
YYSTYPE *l_base;
YYSTYPE *l_mark;
} YYSTACKDATA;
/* variables for the parser stack */
static YYSTACKDATA yystack;
/* build_eof_action - build the "<<EOF>>" action for the active start /* build_eof_action - build the "<<EOF>>" action for the active start
@ -514,6 +536,10 @@ void build_eof_action()
else else
{ {
sceof[scon_stk[i]] = true; sceof[scon_stk[i]] = true;
if (previous_continued_action /* && previous action was regular */)
add_action("YY_RULE_SETUP\n");
snprintf( action_text, sizeof(action_text), "case YY_STATE_EOF(%s):\n", snprintf( action_text, sizeof(action_text), "case YY_STATE_EOF(%s):\n",
scname[scon_stk[i]] ); scname[scon_stk[i]] );
add_action( action_text ); add_action( action_text );
@ -631,40 +657,60 @@ void yyerror( msg )
const char *msg; const char *msg;
{ {
} }
#if YYDEBUG
#include <stdio.h> /* needed for printf */
#endif
#include <stdlib.h> /* needed for malloc, etc */
#include <string.h> /* needed for memset */
/* allocate initial stack or double stack size, up to YYMAXDEPTH */ /* allocate initial stack or double stack size, up to YYMAXDEPTH */
static int yygrowstack(short **yyss, short **yyssp, short **yysslim, static int yygrowstack(YYSTACKDATA *data)
YYSTYPE **yyvs, YYSTYPE **yyvsp, unsigned *yystacksize)
{ {
int i; int i;
unsigned newsize; unsigned newsize;
short *newss; short *newss;
YYSTYPE *newvs; YYSTYPE *newvs;
if ((newsize = *yystacksize) == 0) if ((newsize = data->stacksize) == 0)
newsize = YYINITSTACKSIZE; newsize = YYINITSTACKSIZE;
else if (newsize >= YYMAXDEPTH) else if (newsize >= YYMAXDEPTH)
return -1; return -1;
else if ((newsize *= 2) > YYMAXDEPTH) else if ((newsize *= 2) > YYMAXDEPTH)
newsize = YYMAXDEPTH; newsize = YYMAXDEPTH;
i = *yyssp - *yyss; i = (int) (data->s_mark - data->s_base);
newss = (short *)realloc(*yyss, newsize * sizeof(*newss)); newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
if (newss == 0) if (newss == 0)
return -1; return -1;
*yyss = newss; data->s_base = newss;
*yyssp = newss + i; data->s_mark = newss + i;
newvs = (YYSTYPE *)realloc(*yyvs, newsize * sizeof(*newvs));
newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
if (newvs == 0) if (newvs == 0)
return -1; return -1;
*yyvs = newvs; data->l_base = newvs;
*yyvsp = newvs + i; data->l_mark = newvs + i;
*yystacksize = newsize;
*yysslim = *yyss + newsize - 1; data->stacksize = newsize;
data->s_last = data->s_base + newsize - 1;
return 0; return 0;
} }
#if YYPURE || defined(YY_NO_LEAKS)
static void yyfreestack(YYSTACKDATA *data)
{
free(data->s_base);
free(data->l_base);
memset(data, 0, sizeof(*data));
}
#else
#define yyfreestack(data) /* nothing */
#endif
#define YYABORT goto yyabort #define YYABORT goto yyabort
#define YYREJECT goto yyabort #define YYREJECT goto yyabort
#define YYACCEPT goto yyaccept #define YYACCEPT goto yyaccept
@ -674,15 +720,6 @@ int
YYPARSE_DECL() YYPARSE_DECL()
{ {
int yym, yyn, yystate; int yym, yyn, yystate;
YYSTYPE yyval;
/* variables for the parser stack */
short *yyssp;
short *yyss;
short *yysslim;
YYSTYPE *yyvs;
YYSTYPE *yyvsp;
unsigned yystacksize;
#if YYDEBUG #if YYDEBUG
const char *yys; const char *yys;
@ -699,19 +736,21 @@ YYPARSE_DECL()
yychar = YYEMPTY; yychar = YYEMPTY;
yystate = 0; yystate = 0;
yystacksize = 0; #if YYPURE
yyvs = yyvsp = NULL; memset(&yystack, 0, sizeof(yystack));
yyss = yyssp = NULL; #endif
if (yygrowstack(&yyss, &yyssp, &yysslim, &yyvs, &yyvsp, &yystacksize))
goto yyoverflow; if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow;
yystack.s_mark = yystack.s_base;
yystack.l_mark = yystack.l_base;
yystate = 0; yystate = 0;
*yyssp = 0; *yystack.s_mark = 0;
yyloop: yyloop:
if ((yyn = yydefred[yystate]) != 0) goto yyreduce; if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
if (yychar < 0) if (yychar < 0)
{ {
if ((yychar = yylex()) < 0) yychar = 0; if ((yychar = YYLEX) < 0) yychar = 0;
#if YYDEBUG #if YYDEBUG
if (yydebug) if (yydebug)
{ {
@ -731,14 +770,13 @@ yyloop:
printf("%sdebug: state %d, shifting to state %d\n", printf("%sdebug: state %d, shifting to state %d\n",
YYPREFIX, yystate, yytable[yyn]); YYPREFIX, yystate, yytable[yyn]);
#endif #endif
if (yyssp >= yysslim && yygrowstack(&yyss, &yyssp, &yysslim, if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
&yyvs, &yyvsp, &yystacksize))
{ {
goto yyoverflow; goto yyoverflow;
} }
yystate = yytable[yyn]; yystate = yytable[yyn];
*++yyssp = yytable[yyn]; *++yystack.s_mark = yytable[yyn];
*++yyvsp = yylval; *++yystack.l_mark = yylval;
yychar = YYEMPTY; yychar = YYEMPTY;
if (yyerrflag > 0) --yyerrflag; if (yyerrflag > 0) --yyerrflag;
goto yyloop; goto yyloop;
@ -764,22 +802,21 @@ yyinrecovery:
yyerrflag = 3; yyerrflag = 3;
for (;;) for (;;)
{ {
if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 && if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE) yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
{ {
#if YYDEBUG #if YYDEBUG
if (yydebug) if (yydebug)
printf("%sdebug: state %d, error recovery shifting\ printf("%sdebug: state %d, error recovery shifting\
to state %d\n", YYPREFIX, *yyssp, yytable[yyn]); to state %d\n", YYPREFIX, *yystack.s_mark, yytable[yyn]);
#endif #endif
if (yyssp >= yysslim && yygrowstack(&yyss, &yyssp, if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
&yysslim, &yyvs, &yyvsp, &yystacksize))
{ {
goto yyoverflow; goto yyoverflow;
} }
yystate = yytable[yyn]; yystate = yytable[yyn];
*++yyssp = yytable[yyn]; *++yystack.s_mark = yytable[yyn];
*++yyvsp = yylval; *++yystack.l_mark = yylval;
goto yyloop; goto yyloop;
} }
else else
@ -787,11 +824,11 @@ yyinrecovery:
#if YYDEBUG #if YYDEBUG
if (yydebug) if (yydebug)
printf("%sdebug: error recovery discarding state %d\n", printf("%sdebug: error recovery discarding state %d\n",
YYPREFIX, *yyssp); YYPREFIX, *yystack.s_mark);
#endif #endif
if (yyssp <= yyss) goto yyabort; if (yystack.s_mark <= yystack.s_base) goto yyabort;
--yyssp; --yystack.s_mark;
--yyvsp; --yystack.l_mark;
} }
} }
} }
@ -820,7 +857,7 @@ yyreduce:
#endif #endif
yym = yylen[yyn]; yym = yylen[yyn];
if (yym) if (yym)
yyval = yyvsp[1-yym]; yyval = yystack.l_mark[1-yym];
else else
memset(&yyval, 0, sizeof yyval); memset(&yyval, 0, sizeof yyval);
switch (yyn) switch (yyn)
@ -907,10 +944,10 @@ case 21:
{ tablesext = true; tablesfilename = copy_string( nmstr ); } { tablesext = true; tablesfilename = copy_string( nmstr ); }
break; break;
case 22: case 22:
{ scon_stk_ptr = yyvsp[-3]; } { scon_stk_ptr = yystack.l_mark[-3]; }
break; break;
case 23: case 23:
{ scon_stk_ptr = yyvsp[-3]; } { scon_stk_ptr = yystack.l_mark[-3]; }
break; break;
case 25: case 25:
{ {
@ -926,7 +963,7 @@ case 25:
break; break;
case 26: case 26:
{ {
pat = yyvsp[0]; pat = yystack.l_mark[0];
finish_rule( pat, variable_trail_rule, finish_rule( pat, variable_trail_rule,
headcnt, trailcnt , previous_continued_action); headcnt, trailcnt , previous_continued_action);
@ -962,7 +999,7 @@ case 26:
break; break;
case 27: case 27:
{ {
pat = yyvsp[0]; pat = yystack.l_mark[0];
finish_rule( pat, variable_trail_rule, finish_rule( pat, variable_trail_rule,
headcnt, trailcnt , previous_continued_action); headcnt, trailcnt , previous_continued_action);
@ -1014,7 +1051,7 @@ case 30:
{ yyval = scon_stk_ptr; } { yyval = scon_stk_ptr; }
break; break;
case 31: case 31:
{ yyval = yyvsp[-2]; } { yyval = yystack.l_mark[-2]; }
break; break;
case 32: case 32:
{ {
@ -1063,15 +1100,15 @@ case 37:
break; break;
case 38: case 38:
{ {
if ( transchar[lastst[yyvsp[0]]] != SYM_EPSILON ) if ( transchar[lastst[yystack.l_mark[0]]] != SYM_EPSILON )
/* Provide final transition \now/ so it /* Provide final transition \now/ so it
* will be marked as a trailing context * will be marked as a trailing context
* state. * state.
*/ */
yyvsp[0] = link_machines( yyvsp[0], yystack.l_mark[0] = link_machines( yystack.l_mark[0],
mkstate( SYM_EPSILON ) ); mkstate( SYM_EPSILON ) );
mark_beginning_as_normal( yyvsp[0] ); mark_beginning_as_normal( yystack.l_mark[0] );
current_state_type = STATE_NORMAL; current_state_type = STATE_NORMAL;
if ( previous_continued_action ) if ( previous_continued_action )
@ -1106,7 +1143,7 @@ case 38:
* trail rule, and add_accept() can create * trail rule, and add_accept() can create
* a new state ... * a new state ...
*/ */
add_accept( yyvsp[-1], add_accept( yystack.l_mark[-1],
num_rules | YY_TRAILING_HEAD_MASK ); num_rules | YY_TRAILING_HEAD_MASK );
variable_trail_rule = true; variable_trail_rule = true;
} }
@ -1114,7 +1151,7 @@ case 38:
else else
trailcnt = rulelen; trailcnt = rulelen;
yyval = link_machines( yyvsp[-1], yyvsp[0] ); yyval = link_machines( yystack.l_mark[-1], yystack.l_mark[0] );
} }
break; break;
case 39: case 39:
@ -1151,7 +1188,7 @@ case 40:
/* Again, see the comment in the rule for /* Again, see the comment in the rule for
* "re2 re" above. * "re2 re" above.
*/ */
add_accept( yyvsp[-1], add_accept( yystack.l_mark[-1],
num_rules | YY_TRAILING_HEAD_MASK ); num_rules | YY_TRAILING_HEAD_MASK );
variable_trail_rule = true; variable_trail_rule = true;
} }
@ -1159,13 +1196,13 @@ case 40:
trlcontxt = true; trlcontxt = true;
eps = mkstate( SYM_EPSILON ); eps = mkstate( SYM_EPSILON );
yyval = link_machines( yyvsp[-1], yyval = link_machines( yystack.l_mark[-1],
link_machines( eps, mkstate( '\n' ) ) ); link_machines( eps, mkstate( '\n' ) ) );
} }
break; break;
case 41: case 41:
{ {
yyval = yyvsp[0]; yyval = yystack.l_mark[0];
if ( trlcontxt ) if ( trlcontxt )
{ {
@ -1182,11 +1219,11 @@ break;
case 42: case 42:
{ {
varlength = true; varlength = true;
yyval = mkor( yyvsp[-2], yyvsp[0] ); yyval = mkor( yystack.l_mark[-2], yystack.l_mark[0] );
} }
break; break;
case 43: case 43:
{ yyval = yyvsp[0]; } { yyval = yystack.l_mark[0]; }
break; break;
case 44: case 44:
{ {
@ -1211,7 +1248,7 @@ case 44:
rulelen = 0; rulelen = 0;
current_state_type = STATE_TRAILING_CONTEXT; current_state_type = STATE_TRAILING_CONTEXT;
yyval = yyvsp[-1]; yyval = yystack.l_mark[-1];
} }
break; break;
case 45: case 45:
@ -1219,37 +1256,37 @@ case 45:
/* This is where concatenation of adjacent patterns /* This is where concatenation of adjacent patterns
* gets done. * gets done.
*/ */
yyval = link_machines( yyvsp[-1], yyvsp[0] ); yyval = link_machines( yystack.l_mark[-1], yystack.l_mark[0] );
} }
break; break;
case 46: case 46:
{ yyval = yyvsp[0]; } { yyval = yystack.l_mark[0]; }
break; break;
case 47: case 47:
{ {
varlength = true; varlength = true;
if ( yyvsp[-3] > yyvsp[-1] || yyvsp[-3] < 0 ) if ( yystack.l_mark[-3] > yystack.l_mark[-1] || yystack.l_mark[-3] < 0 )
{ {
synerr( _("bad iteration values") ); synerr( _("bad iteration values") );
yyval = yyvsp[-5]; yyval = yystack.l_mark[-5];
} }
else else
{ {
if ( yyvsp[-3] == 0 ) if ( yystack.l_mark[-3] == 0 )
{ {
if ( yyvsp[-1] <= 0 ) if ( yystack.l_mark[-1] <= 0 )
{ {
synerr( synerr(
_("bad iteration values") ); _("bad iteration values") );
yyval = yyvsp[-5]; yyval = yystack.l_mark[-5];
} }
else else
yyval = mkopt( yyval = mkopt(
mkrep( yyvsp[-5], 1, yyvsp[-1] ) ); mkrep( yystack.l_mark[-5], 1, yystack.l_mark[-1] ) );
} }
else else
yyval = mkrep( yyvsp[-5], yyvsp[-3], yyvsp[-1] ); yyval = mkrep( yystack.l_mark[-5], yystack.l_mark[-3], yystack.l_mark[-1] );
} }
} }
break; break;
@ -1257,14 +1294,14 @@ case 48:
{ {
varlength = true; varlength = true;
if ( yyvsp[-2] <= 0 ) if ( yystack.l_mark[-2] <= 0 )
{ {
synerr( _("iteration value must be positive") ); synerr( _("iteration value must be positive") );
yyval = yyvsp[-4]; yyval = yystack.l_mark[-4];
} }
else else
yyval = mkrep( yyvsp[-4], yyvsp[-2], INFINITE_REPEAT ); yyval = mkrep( yystack.l_mark[-4], yystack.l_mark[-2], INFINITE_REPEAT );
} }
break; break;
case 49: case 49:
@ -1275,62 +1312,62 @@ case 49:
*/ */
varlength = true; varlength = true;
if ( yyvsp[-1] <= 0 ) if ( yystack.l_mark[-1] <= 0 )
{ {
synerr( _("iteration value must be positive") synerr( _("iteration value must be positive")
); );
yyval = yyvsp[-3]; yyval = yystack.l_mark[-3];
} }
else else
yyval = link_machines( yyvsp[-3], yyval = link_machines( yystack.l_mark[-3],
copysingl( yyvsp[-3], yyvsp[-1] - 1 ) ); copysingl( yystack.l_mark[-3], yystack.l_mark[-1] - 1 ) );
} }
break; break;
case 50: case 50:
{ {
varlength = true; varlength = true;
yyval = mkclos( yyvsp[-1] ); yyval = mkclos( yystack.l_mark[-1] );
} }
break; break;
case 51: case 51:
{ {
varlength = true; varlength = true;
yyval = mkposcl( yyvsp[-1] ); yyval = mkposcl( yystack.l_mark[-1] );
} }
break; break;
case 52: case 52:
{ {
varlength = true; varlength = true;
yyval = mkopt( yyvsp[-1] ); yyval = mkopt( yystack.l_mark[-1] );
} }
break; break;
case 53: case 53:
{ {
varlength = true; varlength = true;
if ( yyvsp[-3] > yyvsp[-1] || yyvsp[-3] < 0 ) if ( yystack.l_mark[-3] > yystack.l_mark[-1] || yystack.l_mark[-3] < 0 )
{ {
synerr( _("bad iteration values") ); synerr( _("bad iteration values") );
yyval = yyvsp[-5]; yyval = yystack.l_mark[-5];
} }
else else
{ {
if ( yyvsp[-3] == 0 ) if ( yystack.l_mark[-3] == 0 )
{ {
if ( yyvsp[-1] <= 0 ) if ( yystack.l_mark[-1] <= 0 )
{ {
synerr( synerr(
_("bad iteration values") ); _("bad iteration values") );
yyval = yyvsp[-5]; yyval = yystack.l_mark[-5];
} }
else else
yyval = mkopt( yyval = mkopt(
mkrep( yyvsp[-5], 1, yyvsp[-1] ) ); mkrep( yystack.l_mark[-5], 1, yystack.l_mark[-1] ) );
} }
else else
yyval = mkrep( yyvsp[-5], yyvsp[-3], yyvsp[-1] ); yyval = mkrep( yystack.l_mark[-5], yystack.l_mark[-3], yystack.l_mark[-1] );
} }
} }
break; break;
@ -1338,14 +1375,14 @@ case 54:
{ {
varlength = true; varlength = true;
if ( yyvsp[-2] <= 0 ) if ( yystack.l_mark[-2] <= 0 )
{ {
synerr( _("iteration value must be positive") ); synerr( _("iteration value must be positive") );
yyval = yyvsp[-4]; yyval = yystack.l_mark[-4];
} }
else else
yyval = mkrep( yyvsp[-4], yyvsp[-2], INFINITE_REPEAT ); yyval = mkrep( yystack.l_mark[-4], yystack.l_mark[-2], INFINITE_REPEAT );
} }
break; break;
case 55: case 55:
@ -1356,15 +1393,15 @@ case 55:
*/ */
varlength = true; varlength = true;
if ( yyvsp[-1] <= 0 ) if ( yystack.l_mark[-1] <= 0 )
{ {
synerr( _("iteration value must be positive") ); synerr( _("iteration value must be positive") );
yyval = yyvsp[-3]; yyval = yystack.l_mark[-3];
} }
else else
yyval = link_machines( yyvsp[-3], yyval = link_machines( yystack.l_mark[-3],
copysingl( yyvsp[-3], yyvsp[-1] - 1 ) ); copysingl( yystack.l_mark[-3], yystack.l_mark[-1] - 1 ) );
} }
break; break;
case 56: case 56:
@ -1403,67 +1440,65 @@ case 56:
break; break;
case 57: case 57:
{ {
/* Sort characters for fast searching. We /* Sort characters for fast searching.
* use a shell sort since this list could
* be large.
*/ */
cshell( ccltbl + cclmap[yyvsp[0]], ccllen[yyvsp[0]], true ); qsort( ccltbl + cclmap[yystack.l_mark[0]], ccllen[yystack.l_mark[0]], sizeof (*ccltbl), cclcmp );
if ( useecs ) if ( useecs )
mkeccl( ccltbl + cclmap[yyvsp[0]], ccllen[yyvsp[0]], mkeccl( ccltbl + cclmap[yystack.l_mark[0]], ccllen[yystack.l_mark[0]],
nextecm, ecgroup, csize, csize ); nextecm, ecgroup, csize, csize );
++rulelen; ++rulelen;
if (ccl_has_nl[yyvsp[0]]) if (ccl_has_nl[yystack.l_mark[0]])
rule_has_nl[num_rules] = true; rule_has_nl[num_rules] = true;
yyval = mkstate( -yyvsp[0] ); yyval = mkstate( -yystack.l_mark[0] );
} }
break; break;
case 58: case 58:
{ {
++rulelen; ++rulelen;
if (ccl_has_nl[yyvsp[0]]) if (ccl_has_nl[yystack.l_mark[0]])
rule_has_nl[num_rules] = true; rule_has_nl[num_rules] = true;
yyval = mkstate( -yyvsp[0] ); yyval = mkstate( -yystack.l_mark[0] );
} }
break; break;
case 59: case 59:
{ yyval = yyvsp[-1]; } { yyval = yystack.l_mark[-1]; }
break; break;
case 60: case 60:
{ yyval = yyvsp[-1]; } { yyval = yystack.l_mark[-1]; }
break; break;
case 61: case 61:
{ {
++rulelen; ++rulelen;
if (yyvsp[0] == nlch) if (yystack.l_mark[0] == nlch)
rule_has_nl[num_rules] = true; rule_has_nl[num_rules] = true;
if (sf_case_ins() && has_case(yyvsp[0])) if (sf_case_ins() && has_case(yystack.l_mark[0]))
/* create an alternation, as in (a|A) */ /* create an alternation, as in (a|A) */
yyval = mkor (mkstate(yyvsp[0]), mkstate(reverse_case(yyvsp[0]))); yyval = mkor (mkstate(yystack.l_mark[0]), mkstate(reverse_case(yystack.l_mark[0])));
else else
yyval = mkstate( yyvsp[0] ); yyval = mkstate( yystack.l_mark[0] );
} }
break; break;
case 62: case 62:
{ yyval = ccl_set_diff (yyvsp[-2], yyvsp[0]); } { yyval = ccl_set_diff (yystack.l_mark[-2], yystack.l_mark[0]); }
break; break;
case 63: case 63:
{ yyval = ccl_set_union (yyvsp[-2], yyvsp[0]); } { yyval = ccl_set_union (yystack.l_mark[-2], yystack.l_mark[0]); }
break; break;
case 65: case 65:
{ yyval = yyvsp[-1]; } { yyval = yystack.l_mark[-1]; }
break; break;
case 66: case 66:
{ {
cclnegate( yyvsp[-1] ); cclnegate( yystack.l_mark[-1] );
yyval = yyvsp[-1]; yyval = yystack.l_mark[-1];
} }
break; break;
case 67: case 67:
@ -1477,78 +1512,78 @@ case 67:
* sure what range the user is trying to express. * sure what range the user is trying to express.
* Examples: [@-z] or [S-t] * Examples: [@-z] or [S-t]
*/ */
if (has_case (yyvsp[-2]) != has_case (yyvsp[0]) if (has_case (yystack.l_mark[-2]) != has_case (yystack.l_mark[0])
|| (has_case (yyvsp[-2]) && (b_islower (yyvsp[-2]) != b_islower (yyvsp[0]))) || (has_case (yystack.l_mark[-2]) && (b_islower (yystack.l_mark[-2]) != b_islower (yystack.l_mark[0])))
|| (has_case (yyvsp[-2]) && (b_isupper (yyvsp[-2]) != b_isupper (yyvsp[0])))) || (has_case (yystack.l_mark[-2]) && (b_isupper (yystack.l_mark[-2]) != b_isupper (yystack.l_mark[0]))))
format_warn3 ( format_warn3 (
_("the character range [%c-%c] is ambiguous in a case-insensitive scanner"), _("the character range [%c-%c] is ambiguous in a case-insensitive scanner"),
yyvsp[-2], yyvsp[0]); yystack.l_mark[-2], yystack.l_mark[0]);
/* If the range spans uppercase characters but not /* If the range spans uppercase characters but not
* lowercase (or vice-versa), then should we automatically * lowercase (or vice-versa), then should we automatically
* include lowercase characters in the range? * include lowercase characters in the range?
* Example: [@-_] spans [a-z] but not [A-Z] * Example: [@-_] spans [a-z] but not [A-Z]
*/ */
else if (!has_case (yyvsp[-2]) && !has_case (yyvsp[0]) && !range_covers_case (yyvsp[-2], yyvsp[0])) else if (!has_case (yystack.l_mark[-2]) && !has_case (yystack.l_mark[0]) && !range_covers_case (yystack.l_mark[-2], yystack.l_mark[0]))
format_warn3 ( format_warn3 (
_("the character range [%c-%c] is ambiguous in a case-insensitive scanner"), _("the character range [%c-%c] is ambiguous in a case-insensitive scanner"),
yyvsp[-2], yyvsp[0]); yystack.l_mark[-2], yystack.l_mark[0]);
} }
if ( yyvsp[-2] > yyvsp[0] ) if ( yystack.l_mark[-2] > yystack.l_mark[0] )
synerr( _("negative range in character class") ); synerr( _("negative range in character class") );
else else
{ {
for ( i = yyvsp[-2]; i <= yyvsp[0]; ++i ) for ( i = yystack.l_mark[-2]; i <= yystack.l_mark[0]; ++i )
ccladd( yyvsp[-3], i ); ccladd( yystack.l_mark[-3], i );
/* Keep track if this ccl is staying in /* Keep track if this ccl is staying in
* alphabetical order. * alphabetical order.
*/ */
cclsorted = cclsorted && (yyvsp[-2] > lastchar); cclsorted = cclsorted && (yystack.l_mark[-2] > lastchar);
lastchar = yyvsp[0]; lastchar = yystack.l_mark[0];
/* Do it again for upper/lowercase */ /* Do it again for upper/lowercase */
if (sf_case_ins() && has_case(yyvsp[-2]) && has_case(yyvsp[0])){ if (sf_case_ins() && has_case(yystack.l_mark[-2]) && has_case(yystack.l_mark[0])){
yyvsp[-2] = reverse_case (yyvsp[-2]); yystack.l_mark[-2] = reverse_case (yystack.l_mark[-2]);
yyvsp[0] = reverse_case (yyvsp[0]); yystack.l_mark[0] = reverse_case (yystack.l_mark[0]);
for ( i = yyvsp[-2]; i <= yyvsp[0]; ++i ) for ( i = yystack.l_mark[-2]; i <= yystack.l_mark[0]; ++i )
ccladd( yyvsp[-3], i ); ccladd( yystack.l_mark[-3], i );
cclsorted = cclsorted && (yyvsp[-2] > lastchar); cclsorted = cclsorted && (yystack.l_mark[-2] > lastchar);
lastchar = yyvsp[0]; lastchar = yystack.l_mark[0];
} }
} }
yyval = yyvsp[-3]; yyval = yystack.l_mark[-3];
} }
break; break;
case 68: case 68:
{ {
ccladd( yyvsp[-1], yyvsp[0] ); ccladd( yystack.l_mark[-1], yystack.l_mark[0] );
cclsorted = cclsorted && (yyvsp[0] > lastchar); cclsorted = cclsorted && (yystack.l_mark[0] > lastchar);
lastchar = yyvsp[0]; lastchar = yystack.l_mark[0];
/* Do it again for upper/lowercase */ /* Do it again for upper/lowercase */
if (sf_case_ins() && has_case(yyvsp[0])){ if (sf_case_ins() && has_case(yystack.l_mark[0])){
yyvsp[0] = reverse_case (yyvsp[0]); yystack.l_mark[0] = reverse_case (yystack.l_mark[0]);
ccladd (yyvsp[-1], yyvsp[0]); ccladd (yystack.l_mark[-1], yystack.l_mark[0]);
cclsorted = cclsorted && (yyvsp[0] > lastchar); cclsorted = cclsorted && (yystack.l_mark[0] > lastchar);
lastchar = yyvsp[0]; lastchar = yystack.l_mark[0];
} }
yyval = yyvsp[-1]; yyval = yystack.l_mark[-1];
} }
break; break;
case 69: case 69:
{ {
/* Too hard to properly maintain cclsorted. */ /* Too hard to properly maintain cclsorted. */
cclsorted = false; cclsorted = false;
yyval = yyvsp[-1]; yyval = yystack.l_mark[-1];
} }
break; break;
case 70: case 70:
@ -1650,26 +1685,26 @@ case 94:
break; break;
case 95: case 95:
{ {
if ( yyvsp[0] == nlch ) if ( yystack.l_mark[0] == nlch )
rule_has_nl[num_rules] = true; rule_has_nl[num_rules] = true;
++rulelen; ++rulelen;
if (sf_case_ins() && has_case(yyvsp[0])) if (sf_case_ins() && has_case(yystack.l_mark[0]))
yyval = mkor (mkstate(yyvsp[0]), mkstate(reverse_case(yyvsp[0]))); yyval = mkor (mkstate(yystack.l_mark[0]), mkstate(reverse_case(yystack.l_mark[0])));
else else
yyval = mkstate (yyvsp[0]); yyval = mkstate (yystack.l_mark[0]);
yyval = link_machines( yyvsp[-1], yyval); yyval = link_machines( yystack.l_mark[-1], yyval);
} }
break; break;
case 96: case 96:
{ yyval = mkstate( SYM_EPSILON ); } { yyval = mkstate( SYM_EPSILON ); }
break; break;
} }
yyssp -= yym; yystack.s_mark -= yym;
yystate = *yyssp; yystate = *yystack.s_mark;
yyvsp -= yym; yystack.l_mark -= yym;
yym = yylhs[yyn]; yym = yylhs[yyn];
if (yystate == 0 && yym == 0) if (yystate == 0 && yym == 0)
{ {
@ -1679,11 +1714,11 @@ break;
state %d\n", YYPREFIX, YYFINAL); state %d\n", YYPREFIX, YYFINAL);
#endif #endif
yystate = YYFINAL; yystate = YYFINAL;
*++yyssp = YYFINAL; *++yystack.s_mark = YYFINAL;
*++yyvsp = yyval; *++yystack.l_mark = yyval;
if (yychar < 0) if (yychar < 0)
{ {
if ((yychar = yylex()) < 0) yychar = 0; if ((yychar = YYLEX) < 0) yychar = 0;
#if YYDEBUG #if YYDEBUG
if (yydebug) if (yydebug)
{ {
@ -1706,27 +1741,24 @@ break;
#if YYDEBUG #if YYDEBUG
if (yydebug) if (yydebug)
printf("%sdebug: after reduction, shifting from state %d \ printf("%sdebug: after reduction, shifting from state %d \
to state %d\n", YYPREFIX, *yyssp, yystate); to state %d\n", YYPREFIX, *yystack.s_mark, yystate);
#endif #endif
if (yyssp >= yysslim && yygrowstack(&yyss, &yyssp, if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
&yysslim, &yyvs, &yyvsp, &yystacksize))
{ {
goto yyoverflow; goto yyoverflow;
} }
*++yyssp = (short) yystate; *++yystack.s_mark = (short) yystate;
*++yyvsp = yyval; *++yystack.l_mark = yyval;
goto yyloop; goto yyloop;
yyoverflow: yyoverflow:
yyerror("yacc stack overflow"); yyerror("yacc stack overflow");
yyabort: yyabort:
free(yyss); yyfreestack(&yystack);
free(yyvs);
return (1); return (1);
yyaccept: yyaccept:
free(yyss); yyfreestack(&yystack);
free(yyvs);
return (0); return (0);
} }