mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
lalr1.cc: don't generate location.hh when location_type is defined
* data/bison.m4 (b4_percent_define_use): New.
(b4_percent_define_get): Use it.
Accept a default value.
* data/c++.m4: Do not provide a default value for the %define
variable location_type, rather, use b4_percent_define_get with a
default argument where its value is needed.
* data/lalr1.cc: Do not load location.cc (which outputs both
location.hh and position.hh) if the user defined location_type.
Do not include location.hh either.
* data/glr.cc: Likewise.
(cherry picked from commit 7789b6e3e7)
Conflicts:
ChangeLog
data/bison.m4
data/c++.m4
data/lalr1.cc
This commit is contained in:
14
ChangeLog
14
ChangeLog
@@ -1,3 +1,17 @@
|
|||||||
|
2010-05-04 Akim Demaille <demaille@gostai.com>
|
||||||
|
|
||||||
|
lalr1.cc: don't generate location.hh when location_type is defined
|
||||||
|
* data/bison.m4 (b4_percent_define_use): New.
|
||||||
|
(b4_percent_define_get): Use it.
|
||||||
|
Accept a default value.
|
||||||
|
* data/c++.m4: Do not provide a default value for the %define
|
||||||
|
variable location_type, rather, use b4_percent_define_get with a
|
||||||
|
default argument where its value is needed.
|
||||||
|
* data/lalr1.cc: Do not load location.cc (which outputs both
|
||||||
|
location.hh and position.hh) if the user defined location_type.
|
||||||
|
Do not include location.hh either.
|
||||||
|
* data/glr.cc: Likewise.
|
||||||
|
|
||||||
2010-05-04 Akim Demaille <demaille@gostai.com>
|
2010-05-04 Akim Demaille <demaille@gostai.com>
|
||||||
|
|
||||||
lalr1.cc: location_type: make sure we don't depend on loc.(begin|end).
|
lalr1.cc: location_type: make sure we don't depend on loc.(begin|end).
|
||||||
|
|||||||
@@ -361,10 +361,26 @@ m4_popdef([b4_start])dnl
|
|||||||
m4_popdef([b4_end])dnl
|
m4_popdef([b4_end])dnl
|
||||||
])])
|
])])
|
||||||
|
|
||||||
# b4_percent_define_get(VARIABLE)
|
|
||||||
|
|
||||||
|
|
||||||
|
## --------------------- ##
|
||||||
|
## b4_percent_define_*. ##
|
||||||
|
## --------------------- ##
|
||||||
|
|
||||||
|
|
||||||
|
# b4_percent_define_use(VARIABLE)
|
||||||
# -------------------------------
|
# -------------------------------
|
||||||
# Mimic muscle_percent_define_get in ../src/muscle-tab.h exactly. That is, if
|
# Declare that VARIABLE was used.
|
||||||
# the %define variable VARIABLE is defined, emit its value. Also, record
|
m4_define([b4_percent_define_use],
|
||||||
|
[m4_define([b4_percent_define_bison_variables(]$1[)])dnl
|
||||||
|
])
|
||||||
|
|
||||||
|
# b4_percent_define_get(VARIABLE, [DEFAULT])
|
||||||
|
# ------------------------------------------
|
||||||
|
# Mimic muscle_percent_define_get in ../src/muscle-tab.h. That is, if
|
||||||
|
# the %define variable VARIABLE is defined, emit its value. Contrary
|
||||||
|
# to its C counterpart, return DEFAULT otherwise. Also, record
|
||||||
# Bison's usage of VARIABLE by defining
|
# Bison's usage of VARIABLE by defining
|
||||||
# b4_percent_define_bison_variables(VARIABLE).
|
# b4_percent_define_bison_variables(VARIABLE).
|
||||||
#
|
#
|
||||||
@@ -372,8 +388,11 @@ m4_popdef([b4_end])dnl
|
|||||||
#
|
#
|
||||||
# b4_percent_define_get([[foo]])
|
# b4_percent_define_get([[foo]])
|
||||||
m4_define([b4_percent_define_get],
|
m4_define([b4_percent_define_get],
|
||||||
[m4_define([b4_percent_define_bison_variables(]$1[)])dnl
|
[b4_percent_define_use([$1])dnl
|
||||||
m4_ifdef([b4_percent_define(]$1[)], [m4_indir([b4_percent_define(]$1[)])])])
|
m4_ifdef([b4_percent_define(]$1[)],
|
||||||
|
[m4_indir([b4_percent_define(]$1[)])],
|
||||||
|
[$2])])
|
||||||
|
|
||||||
|
|
||||||
# b4_percent_define_get_loc(VARIABLE)
|
# b4_percent_define_get_loc(VARIABLE)
|
||||||
# -----------------------------------
|
# -----------------------------------
|
||||||
|
|||||||
@@ -25,7 +25,12 @@ m4_include(b4_pkgdatadir/[c.m4])
|
|||||||
|
|
||||||
# Default parser class name.
|
# Default parser class name.
|
||||||
b4_percent_define_default([[parser_class_name]], [[parser]])
|
b4_percent_define_default([[parser_class_name]], [[parser]])
|
||||||
b4_percent_define_default([[location_type]], [[location]])
|
|
||||||
|
# Don't do that so that we remember whether we're using a user
|
||||||
|
# request, or the default value.
|
||||||
|
#
|
||||||
|
# b4_percent_define_default([[location_type]], [[location]])
|
||||||
|
|
||||||
b4_percent_define_default([[filename_type]], [[std::string]])
|
b4_percent_define_default([[filename_type]], [[std::string]])
|
||||||
b4_percent_define_default([[namespace]], m4_defn([b4_prefix]))
|
b4_percent_define_default([[namespace]], m4_defn([b4_prefix]))
|
||||||
b4_percent_define_default([[global_tokens_and_yystype]], [[false]])
|
b4_percent_define_default([[global_tokens_and_yystype]], [[false]])
|
||||||
|
|||||||
@@ -229,7 +229,8 @@ b4_copyright([Skeleton interface for Bison GLR parsers in C++],
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "location.hh"
|
]b4_percent_define_ifdef([[location_type]], [],
|
||||||
|
[[#include "location.hh"]])[
|
||||||
|
|
||||||
/* Using locations. */
|
/* Using locations. */
|
||||||
#define YYLSP_NEEDED ]b4_locations_flag[
|
#define YYLSP_NEEDED ]b4_locations_flag[
|
||||||
@@ -277,7 +278,8 @@ b4_user_stype
|
|||||||
typedef YYSTYPE semantic_type;
|
typedef YYSTYPE semantic_type;
|
||||||
#endif
|
#endif
|
||||||
/// Symbol locations.
|
/// Symbol locations.
|
||||||
typedef ]b4_percent_define_get([[location_type]])[ location_type;
|
typedef ]b4_percent_define_get([[location_type]],
|
||||||
|
[[location]])[ location_type;
|
||||||
/// Tokens.
|
/// Tokens.
|
||||||
struct token
|
struct token
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -24,9 +24,10 @@ m4_define([b4_parser_class_name],
|
|||||||
b4_defines_if([],
|
b4_defines_if([],
|
||||||
[b4_fatal([b4_skeleton[: using %%defines is mandatory]])])
|
[b4_fatal([b4_skeleton[: using %%defines is mandatory]])])
|
||||||
|
|
||||||
# Backward compatibility.
|
b4_percent_define_ifdef([[location_type]], [],
|
||||||
m4_define([b4_location_constructors])
|
[# Backward compatibility.
|
||||||
m4_include(b4_pkgdatadir/[location.cc])
|
m4_define([b4_location_constructors])
|
||||||
|
m4_include(b4_pkgdatadir/[location.cc])])
|
||||||
|
|
||||||
# We do want M4 expansion after # for CPP macros.
|
# We do want M4 expansion after # for CPP macros.
|
||||||
m4_changecom()
|
m4_changecom()
|
||||||
@@ -46,8 +47,9 @@ dnl FIXME: This is wrong, we want computed header guards.
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "location.hh"
|
|
||||||
#include "stack.hh"
|
#include "stack.hh"
|
||||||
|
]b4_percent_define_ifdef([[location_type]], [],
|
||||||
|
[[#include "location.hh"]])[
|
||||||
|
|
||||||
/* Enabling traces. */
|
/* Enabling traces. */
|
||||||
#ifndef YYDEBUG
|
#ifndef YYDEBUG
|
||||||
@@ -106,7 +108,8 @@ b4_user_stype
|
|||||||
typedef YYSTYPE semantic_type;
|
typedef YYSTYPE semantic_type;
|
||||||
#endif
|
#endif
|
||||||
/// Symbol locations.
|
/// Symbol locations.
|
||||||
typedef ]b4_percent_define_get([[location_type]])[ location_type;
|
typedef ]b4_percent_define_get([[location_type]],
|
||||||
|
[[location]])[ location_type;
|
||||||
/// Tokens.
|
/// Tokens.
|
||||||
struct token
|
struct token
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user