[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: RFC: yacc.c: factor (was: yacc.c does not prototype yyparse in the h

From: Akim Demaille
Subject: Re: RFC: yacc.c: factor (was: yacc.c does not prototype yyparse in the header)
Date: Tue, 12 Jun 2012 18:24:59 +0200

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?

From 8fc5d55074347b52796ffe8e36f75245caf10485 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 we do in glr.c.

* data/yacc.c: here.
 NEWS        |   14 ++++++++++++++
 data/yacc.c |    3 ++-
 2 files changed, 16 insertions(+), 1 deletion(-)

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/yacc.c b/data/yacc.c
index 079e488..e88b4e0 100644
--- a/data/yacc.c
+++ b/data/yacc.c
@@ -319,7 +319,8 @@ m4_if(b4_prefix, [yy], [],
 # define YYTOKEN_TABLE ]b4_token_table[
+]b4_defines_if([[#include "]b4_spec_defines_file["]],
+               [b4_shared_declarations])[
 /* Copy the second part of user declarations.  */

reply via email to

[Prev in Thread] Current Thread [Next in Thread]