Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/external/bsd/flex/dist Regen initparse.c with the current by...
details: https://anonhg.NetBSD.org/src/rev/30bece6912d1
branches: trunk
changeset: 785925:30bece6912d1
user: joerg <joerg%NetBSD.org@localhost>
date: Sat Apr 06 15:27:26 2013 +0000
description:
Regen initparse.c with the current byacc with -l.
diffstat:
external/bsd/flex/dist/initparse.c | 420 +++++++++++++++++++-----------------
1 files changed, 226 insertions(+), 194 deletions(-)
diffs (truncated from 906 to 300 lines):
diff -r 57ddf774530b -r 30bece6912d1 external/bsd/flex/dist/initparse.c
--- a/external/bsd/flex/dist/initparse.c Sat Apr 06 15:27:05 2013 +0000
+++ b/external/bsd/flex/dist/initparse.c Sat Apr 06 15:27:26 2013 +0000
@@ -17,27 +17,10 @@
#define yyerrok (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
+#define YYPREFIX "yy"
-/* Pure parsers. */
#define YYPURE 0
-#ifdef YYLEX_PARAM
-# define YYLEX yylex(YYLEX_PARAM)
-#else
-# define YYLEX yylex()
-#endif
-#define YYPREFIX "yy"
/* Copyright (c) 1990 The Regents of the University of California. */
/* All rights reserved. */
@@ -118,6 +101,43 @@
*/
#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 NUMBER 258
#define SECTEND 259
@@ -461,16 +481,14 @@
};
#endif
-#ifndef YYSTYPE
-typedef int YYSTYPE;
-#endif
-#if YYDEBUG
-#include <stdio.h>
-#endif
+
+int yydebug;
+int yynerrs;
-extern int YYPARSE_DECL();
-static int yygrowstack(short **, short **, short **,
- YYSTYPE **, YYSTYPE **, unsigned *);
+int yyerrflag;
+int yychar;
+YYSTYPE yyval;
+YYSTYPE yylval;
/* define the initial stack-sizes */
#ifdef YYSTACKSIZE
@@ -487,12 +505,16 @@
#define YYINITSTACKSIZE 500
-int yydebug;
-int yyerrflag;
- int yynerrs;
- int yychar;
- YYSTYPE yylval;
-
+typedef struct {
+ unsigned stacksize;
+ short *s_base;
+ short *s_mark;
+ 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
@@ -514,6 +536,10 @@
else
{
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",
scname[scon_stk[i]] );
add_action( action_text );
@@ -631,40 +657,60 @@
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 */
-static int yygrowstack(short **yyss, short **yyssp, short **yysslim,
- YYSTYPE **yyvs, YYSTYPE **yyvsp, unsigned *yystacksize)
+static int yygrowstack(YYSTACKDATA *data)
{
int i;
unsigned newsize;
short *newss;
YYSTYPE *newvs;
- if ((newsize = *yystacksize) == 0)
+ if ((newsize = data->stacksize) == 0)
newsize = YYINITSTACKSIZE;
else if (newsize >= YYMAXDEPTH)
return -1;
else if ((newsize *= 2) > YYMAXDEPTH)
newsize = YYMAXDEPTH;
- i = *yyssp - *yyss;
- newss = (short *)realloc(*yyss, newsize * sizeof(*newss));
+ i = (int) (data->s_mark - data->s_base);
+ newss = (short *)realloc(data->s_base, newsize * sizeof(*newss));
if (newss == 0)
return -1;
- *yyss = newss;
- *yyssp = newss + i;
- newvs = (YYSTYPE *)realloc(*yyvs, newsize * sizeof(*newvs));
+ data->s_base = newss;
+ data->s_mark = newss + i;
+
+ newvs = (YYSTYPE *)realloc(data->l_base, newsize * sizeof(*newvs));
if (newvs == 0)
return -1;
- *yyvs = newvs;
- *yyvsp = newvs + i;
- *yystacksize = newsize;
- *yysslim = *yyss + newsize - 1;
+ data->l_base = newvs;
+ data->l_mark = newvs + i;
+
+ data->stacksize = newsize;
+ data->s_last = data->s_base + newsize - 1;
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 YYREJECT goto yyabort
#define YYACCEPT goto yyaccept
@@ -674,15 +720,6 @@
YYPARSE_DECL()
{
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
const char *yys;
@@ -699,19 +736,21 @@
yychar = YYEMPTY;
yystate = 0;
- yystacksize = 0;
- yyvs = yyvsp = NULL;
- yyss = yyssp = NULL;
- if (yygrowstack(&yyss, &yyssp, &yysslim, &yyvs, &yyvsp, &yystacksize))
- goto yyoverflow;
+#if YYPURE
+ memset(&yystack, 0, sizeof(yystack));
+#endif
+
+ if (yystack.s_base == NULL && yygrowstack(&yystack)) goto yyoverflow;
+ yystack.s_mark = yystack.s_base;
+ yystack.l_mark = yystack.l_base;
yystate = 0;
- *yyssp = 0;
+ *yystack.s_mark = 0;
yyloop:
if ((yyn = yydefred[yystate]) != 0) goto yyreduce;
if (yychar < 0)
{
- if ((yychar = yylex()) < 0) yychar = 0;
+ if ((yychar = YYLEX) < 0) yychar = 0;
#if YYDEBUG
if (yydebug)
{
@@ -731,14 +770,13 @@
printf("%sdebug: state %d, shifting to state %d\n",
YYPREFIX, yystate, yytable[yyn]);
#endif
- if (yyssp >= yysslim && yygrowstack(&yyss, &yyssp, &yysslim,
- &yyvs, &yyvsp, &yystacksize))
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
{
goto yyoverflow;
}
yystate = yytable[yyn];
- *++yyssp = yytable[yyn];
- *++yyvsp = yylval;
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
yychar = YYEMPTY;
if (yyerrflag > 0) --yyerrflag;
goto yyloop;
@@ -764,22 +802,21 @@
yyerrflag = 3;
for (;;)
{
- if ((yyn = yysindex[*yyssp]) && (yyn += YYERRCODE) >= 0 &&
+ if ((yyn = yysindex[*yystack.s_mark]) && (yyn += YYERRCODE) >= 0 &&
yyn <= YYTABLESIZE && yycheck[yyn] == YYERRCODE)
{
#if YYDEBUG
if (yydebug)
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
- if (yyssp >= yysslim && yygrowstack(&yyss, &yyssp,
- &yysslim, &yyvs, &yyvsp, &yystacksize))
+ if (yystack.s_mark >= yystack.s_last && yygrowstack(&yystack))
{
goto yyoverflow;
}
yystate = yytable[yyn];
- *++yyssp = yytable[yyn];
- *++yyvsp = yylval;
+ *++yystack.s_mark = yytable[yyn];
+ *++yystack.l_mark = yylval;
goto yyloop;
}
else
@@ -787,11 +824,11 @@
#if YYDEBUG
Home |
Main Index |
Thread Index |
Old Index