[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: yacc.c: instead of duplicating y.tab.h inside y.tac.c, include it (w
From: |
Akim Demaille |
Subject: |
Re: yacc.c: instead of duplicating y.tab.h inside y.tac.c, include it (was: RFC: yacc.c: factor) |
Date: |
Fri, 15 Jun 2012 13:34:21 +0200 |
Le 12 juin 2012 à 18:24, Akim Demaille a écrit :
> Le 12 juin 2012 à 16:07, Akim Demaille a écrit :
>
>> Third act of refactoring. This time it is not installed
>> yet, as I would appreciate some opinion, as the generated
>> code is somewhat different:
>
> Fourth step. This introduces a weakness in Bison: when
> given arguments such as
>
> --output=sub1/foo.c --defines=sub2/foo.h
>
> then sub1/foo.c features '#include "sub2/foo.h"'. But we actually
> already have this problem in glr.c which already prefers to include
> the header instead of duplicating its content.
>
> So we really need to be able to compute "relative" paths here, to
> be addressed in the near future.
>
> Ok to install?
I installed it, and some more tests, in maint, as follows.
From 0f11eec272453d5646e5aeda135650b4fb8ac33d Mon Sep 17 00:00:00 2001
From: Akim Demaille <address@hidden>
Date: Tue, 12 Jun 2012 16:15:14 +0200
Subject: [PATCH 1/2] yacc.c: instead of duplicating y.tab.h inside y.tac.c,
include it.
This is already what glr.c and lalr1.cc do.
* data/yacc.c: here.
---
NEWS | 14 ++++++++++++++
data/glr.c | 2 +-
data/yacc.c | 3 ++-
3 files changed, 17 insertions(+), 2 deletions(-)
diff --git a/NEWS b/NEWS
index 393538c..fd51b61 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,20 @@ GNU Bison NEWS
* Noteworthy changes in release ?.? (????-??-??) [?]
+** Future changes:
+
+ The next major release will drop support for generating parsers in K&R C,
+ and remove the definition of yystype (removal announced since Bison
+ 1.875).
+
+** Changes in regular C parsers (yacc.c):
+
+*** The generated header is included
+
+ Instead of duplicating the content of the generated header (definition of
+ YYSTYPE, yyltype etc.), the generated parser now includes it, as was
+ already the case for GLR or C++ parsers.
+
* Noteworthy changes in release 2.5.1 (2012-06-05) [stable]
** Future changes:
diff --git a/data/glr.c b/data/glr.c
index 7ebc65c..223aa1e 100644
--- a/data/glr.c
+++ b/data/glr.c
@@ -203,7 +203,7 @@ m4_if(b4_prefix, [yy], [],
]b4_null_define[
]b4_defines_if([[#include "@basename(]b4_spec_defines_file[@)"]],
- [b4_shared_declarations])[
+ [b4_shared_declarations])[
/* Enabling traces. */
#ifndef YYDEBUG
diff --git a/data/yacc.c b/data/yacc.c
index 079e488..d5000da 100644
--- a/data/yacc.c
+++ b/data/yacc.c
@@ -319,7 +319,8 @@ m4_if(b4_prefix, [yy], [],
# define YYTOKEN_TABLE ]b4_token_table[
#endif
-]b4_shared_declarations[
+]b4_defines_if([[#include "@basename(]b4_spec_defines_file[@)"]],
+ [b4_shared_declarations])[
/* Copy the second part of user declarations. */
]b4_user_post_prologue
--
1.7.10.4
From 9d67a52ad6f9aa1241d64b9766525362715b16e8 Mon Sep 17 00:00:00 2001
From: Akim Demaille <address@hidden>
Date: Tue, 12 Jun 2012 18:14:49 +0200
Subject: [PATCH 2/2] tests: strengthen the test on generated headers
inclusion
* tests/headers.at (AT_TEST_CPP_GUARD_H): Accept Bison directives.
(Invalid CPP headers): Check glr.
---
tests/headers.at | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 deletions(-)
diff --git a/tests/headers.at b/tests/headers.at
index 9d4946d..9710e0c 100644
--- a/tests/headers.at
+++ b/tests/headers.at
@@ -46,17 +46,19 @@ AT_CLEANUP
## Invalid CPP headers. ##
## --------------------- ##
-# AT_TEST_CPP_GUARD_H([INPUT-FILE-BASE)
-# -------------------------------------
+# AT_TEST_CPP_GUARD_H(BASE-NAME, [DIRECTIVES])
+# --------------------------------------------
+# FIXME: Much of this can be covered by calc.at.
m4_define([AT_TEST_CPP_GUARD_H],
-[AT_SETUP([Invalid CPP guards: $1])
+[AT_SETUP([Invalid CPP guards: $2 --defines=$1.h])
# Possibly create inner directories.
dirname=`AS_DIRNAME([$1])`
AS_MKDIR_P([$dirname])
AT_DATA_GRAMMAR([$1.y],
-[%{
+[$2
+%{
#include <$1.h>
void yyerror (const char *);
int yylex (void);
@@ -67,15 +69,17 @@ dummy:;
#include <$1.h>
])
-AT_BISON_CHECK([--defines=$1.h --output=y.tab.c $1.y])
+AT_BISON_CHECK([--defines=$1.h --output=$1.c $1.y])
-AT_COMPILE([y.tab.o], [-I. -c y.tab.c])
+AT_COMPILE([$1.o], [-I. -c $1.c])
AT_CLEANUP
])
AT_TEST_CPP_GUARD_H([input/input])
AT_TEST_CPP_GUARD_H([9foo])
+AT_TEST_CPP_GUARD_H([input/input], [%glr-parser])
+AT_TEST_CPP_GUARD_H([9foo], [%glr-parser])
--
1.7.10.4
- Re: yacc.c does not prototype yyparse in the header, (continued)
- Re: yacc.c does not prototype yyparse in the header, Paul Eggert, 2012/06/12
- Re: yacc.c does not prototype yyparse in the header, Akim Demaille, 2012/06/13
- Re: yacc.c does not prototype yyparse in the header, Paul Eggert, 2012/06/13
- Re: yacc.c does not prototype yyparse in the header, Akim Demaille, 2012/06/28
- Re: yacc.c does not prototype yyparse in the header, Akim Demaille, 2012/06/29
- FYI: glr.c: minor refactoring (was: yacc.c does not prototype yyparse in the header), Akim Demaille, 2012/06/12
- FYI: skeletons: factor yacc.c and glr.c (was: yacc.c does not prototype yyparse in the header), Akim Demaille, 2012/06/12
- RFC: yacc.c: factor (was: yacc.c does not prototype yyparse in the header), Akim Demaille, 2012/06/12
- Re: RFC: yacc.c: factor (was: yacc.c does not prototype yyparse in the header), Akim Demaille, 2012/06/12
- Re: RFC: yacc.c: factor (was: yacc.c does not prototype yyparse in the header), Akim Demaille, 2012/06/13
- Re: yacc.c: instead of duplicating y.tab.h inside y.tac.c, include it (was: RFC: yacc.c: factor),
Akim Demaille <=
- ylwrap does not rename y.tab.h in y.tab.c (was: yacc.c: instead of duplicating y.tab.h inside y.tac.c, include it), Akim Demaille, 2012/06/20
- Re: ylwrap does not rename y.tab.h in y.tab.c (was: yacc.c: instead of duplicating y.tab.h inside y.tac.c, include it), Akim Demaille, 2012/06/25
- Re: ylwrap does not rename y.tab.h in y.tab.c, Stefano Lattarini, 2012/06/25
- [PATCH] yacc, lex: new 'no-ylwrap' option to prevent use of the 'ylwrap' script, Stefano Lattarini, 2012/06/25
- Re: [PATCH] yacc, lex: new 'no-ylwrap' option to prevent use of the 'ylwrap' script, Akim Demaille, 2012/06/26
- Re: [PATCH] yacc, lex: new 'no-ylwrap' option to prevent use of the 'ylwrap' script, Stefano Lattarini, 2012/06/26
- Re: [PATCH] yacc, lex: new 'no-ylwrap' option to prevent use of the 'ylwrap' script, Akim Demaille, 2012/06/26
- Re: [PATCH] yacc, lex: new 'no-ylwrap' option to prevent use of the 'ylwrap' script, Eric Blake, 2012/06/26
- Re: [PATCH] yacc, lex: new 'no-ylwrap' option to prevent use of the 'ylwrap' script, Akim Demaille, 2012/06/26
- Re: [PATCH] yacc, lex: new 'no-ylwrap' option to prevent use of the 'ylwrap' script, Stefano Lattarini, 2012/06/26