[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: YYSTYPE_IS_TRIVIAL
From: |
Paul Eggert |
Subject: |
Re: YYSTYPE_IS_TRIVIAL |
Date: |
Mon, 22 Apr 2002 15:27:29 -0700 (PDT) |
> From: Akim Demaille <address@hidden>
> Date: 22 Apr 2002 15:42:12 +0200
>
> I think the patch should be applied to the head too, but of course we
> can debate about it. If you too think we should apply it, would you
> do it? I'm fine with tweaking it a bit afterwards if needed, and I'm
> fine with helping you too.
OK, here's my first cut at trying to adapt the patches in:
http://mail.gnu.org/pipermail/bison-patches/2002-March/000760.html
The main problem is that I haven't a clue as to what to do about those
patches to reader.c. I gather that I need to add a muscle, but I need
something that will define YYSTYPE_IS_TRIVIAL only if the user does
not define YYSTYPE. In 1_29-branch I did this:
const char *prologue = "\
#ifndef YYSTYPE\n\
typedef union";
const char *epilogue = "\
yystype;\n\
# define YYSTYPE yystype\n\
# define YYSTYPE_IS_TRIVIAL 1\n\
#endif\n";
...
obstack_sgrow (&attrs_obstack, prologue);
[copy some stuff to attrs_obstack]
obstack_sgrow (&attrs_obstack, epilogue);
but I don't see how to get the same effect using muscles.
I can merge the bison.simple part of the patch, as follows, and I
think the following patch is an improvement (though I can't test this
easily as the head has problems on my host as I discussed in an
earlier message today). However, by itself the patch below won't fix
the C++-compiler-masquerading-as-C-compiler problem on the head.
2002-04-22 Paul Eggert <address@hidden>
* data/bison.simple: Remove unnecessary commentary and white
space differences from 1_29-branch.
(union yyalloc, YYSTACK_GAP_MAX, YYSTACK_BYTES, YYCOPY,
YYSTACK_RELOCATE): Do not define if yyoverflow is defined, or
if this is a C++ parser and YYSTYPE or YYLTYPE has nontrivial
constructors or destructors.
(yyparse) [! defined YYSTACK_RELOCATE]: Do not relocate the stack.
--- bison.simple.~1.12.~ 2002-04-22 01:22:22.000000000 -0700
+++ bison.simple 2002-04-22 12:09:36.627402000 -0700
@@ -89,6 +89,13 @@ m4_divert(0)dnl
It was written by Richard Stallman by simplifying the hairy parser
used when %semantic_parser is specified. */
+/* All symbols defined below should begin with yy or YY, to avoid
+ infringing on user name space. This should be done even for local
+ variables, as they might otherwise be expanded by user macros.
+ There are some unavoidable exceptions within include files to
+ define necessary library symbols; they are noted "INFRINGES ON
+ USER NAME SPACE" below. */
+
/* Identify Bison output. */
#define YYBISON 1
@@ -151,14 +158,7 @@ typedef struct yyltype
/* Line __line__ of __file__. */
#line __oline__ "__ofile__"
-/* All symbols defined below should begin with yy or YY, to avoid
- infringing on user name space. This should be done even for local
- variables, as they might otherwise be expanded by user macros.
- There are some unavoidable exceptions within include files to
- define necessary library symbols; they are noted "INFRINGES ON
- USER NAME SPACE" below. */
-
-#if ! defined (yyoverflow) || defined (YYERROR_VERBOSE)
+#if ! defined (yyoverflow) || YYERROR_VERBOSE
/* The parser invokes alloca or malloc; define the necessary symbols. */
@@ -187,6 +187,12 @@ typedef struct yyltype
# define YYSTACK_ALLOC malloc
# define YYSTACK_FREE free
# endif
+#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
+
+
+#if (! defined (yyoverflow) \
+ && (! defined (__cplusplus) \
+ || (YYLTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
/* A type that is properly aligned for any stack member. */
union yyalloc
@@ -205,12 +211,12 @@ union yyalloc
N elements. */
# if YYLSP_NEEDED
# define YYSTACK_BYTES(N) \
- ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
- + 2 * YYSTACK_GAP_MAX)
+ ((N) * (sizeof (short) + sizeof (YYSTYPE) + sizeof (YYLTYPE)) \
+ + 2 * YYSTACK_GAP_MAX)
# else
# define YYSTACK_BYTES(N) \
- ((N) * (sizeof (short) + sizeof (YYSTYPE)) \
- + YYSTACK_GAP_MAX)
+ ((N) * (sizeof (short) + sizeof (YYSTYPE))
\
+ + YYSTACK_GAP_MAX)
# endif
/* Copy COUNT objects from FROM to TO. The source and destination do
@@ -247,7 +253,7 @@ union yyalloc
}
\
while (0)
-#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
+#endif
/* Tokens. */
b4_token_defines(b4_tokens)
@@ -469,8 +475,8 @@ do { \
if (yydebug) \
YYFPRINTF Args; \
} while (0)
-/* Nonzero means print parse trace. Since this is uninitialized, it
- does not stop multiple parsers from coexisting. */
+/* Nonzero means print parse trace. It is left uninitialized so that
+ multiple parsers can coexist. */
int yydebug;
#else /* !YYDEBUG */
# define YYDPRINTF(Args)
@@ -738,6 +744,9 @@ yyparse (YYPARSE_PARAM_ARG)
yyvs = yyvs1;
}
#else /* no yyoverflow */
+# ifndef YYSTACK_RELOCATE
+ goto yyoverflowlab;
+# else
/* Extend the stack our own way. */
if (yystacksize >= YYMAXDEPTH)
goto yyoverflowlab;
@@ -753,13 +762,14 @@ yyparse (YYPARSE_PARAM_ARG)
goto yyoverflowlab;
YYSTACK_RELOCATE (yyss);
YYSTACK_RELOCATE (yyvs);
-# if YYLSP_NEEDED
+# if YYLSP_NEEDED
YYSTACK_RELOCATE (yyls);
-# endif
-# undef YYSTACK_RELOCATE
+# endif
+# undef YYSTACK_RELOCATE
if (yyss1 != yyssa)
YYSTACK_FREE (yyss1);
}
+# endif
#endif /* no yyoverflow */
yyssp = yyss + yysize - 1;
@@ -1058,7 +1068,7 @@ yyerrlab1:
/* Else will try to reuse lookahead token after shifting the error
token. */
- yyerrstatus = 3; /* Each real token shifted decrements this. */
+ yyerrstatus = 3; /* Each real token shifted decrements this. */
goto yyerrhandle;
- YYSTYPE_IS_TRIVIAL, Akim Demaille, 2002/04/22
- Re: YYSTYPE_IS_TRIVIAL,
Paul Eggert <=
- Re: YYSTYPE_IS_TRIVIAL, Akim Demaille, 2002/04/23
- Re: YYSTYPE_IS_TRIVIAL, Paul Eggert, 2002/04/24
- FYI: autoreconf (Was: YYSTYPE_IS_TRIVIAL), Akim Demaille, 2002/04/24
- Re: YYSTYPE_IS_TRIVIAL, Akim Demaille, 2002/04/24
- Re: YYSTYPE_IS_TRIVIAL, Paul Eggert, 2002/04/24
- Re: YYSTYPE_IS_TRIVIAL, Akim Demaille, 2002/04/24
- Re: YYSTYPE_IS_TRIVIAL, Paul Eggert, 2002/04/24
- Re: YYSTYPE_IS_TRIVIAL, Akim Demaille, 2002/04/25
- Re: YYSTYPE_IS_TRIVIAL, Akim Demaille, 2002/04/24
- Re: YYSTYPE_IS_TRIVIAL, Paul Eggert, 2002/04/24