Locations are no longer required by lalr1.cc.

* data/lalr1.cc (_b4_args, b4_args): New.
	Adjust all uses of locations to make them optional.
	* tests/c++.at (AT_CHECK_VARIANTS): No longer use the locations.
	(AT_CHECK_NAMESPACE): Check the use of locations.
	* tests/calc.at (_AT_DATA_CALC_Y): Adjust to be usable with or
	without locations with lalr1.cc.
	Test these cases.
	* tests/output.at: Check lalr1.cc with and without location
	support.
	* tests/regression.at (_AT_DATA_EXPECT2_Y, _AT_DATA_DANCER_Y):
	Don't use locations.
This commit is contained in:
Akim Demaille
2008-08-25 13:52:51 +02:00
parent 7ca2266adc
commit 2ea7730c56
6 changed files with 160 additions and 87 deletions

View File

@@ -1,3 +1,18 @@
2008-11-11 Akim Demaille <demaille@gostai.com>
Locations are no longer required by lalr1.cc.
* data/lalr1.cc (_b4_args, b4_args): New.
Adjust all uses of locations to make them optional.
* tests/c++.at (AT_CHECK_VARIANTS): No longer use the locations.
(AT_CHECK_NAMESPACE): Check the use of locations.
* tests/calc.at (_AT_DATA_CALC_Y): Adjust to be usable with or
without locations with lalr1.cc.
Test these cases.
* tests/output.at: Check lalr1.cc with and without location
support.
* tests/regression.at (_AT_DATA_EXPECT2_Y, _AT_DATA_DANCER_Y):
Don't use locations.
2008-11-11 Akim Demaille <demaille@gostai.com> 2008-11-11 Akim Demaille <demaille@gostai.com>
AT_FULL_COMPILE. AT_FULL_COMPILE.

View File

@@ -18,6 +18,29 @@
m4_include(b4_pkgdatadir/[c++.m4]) m4_include(b4_pkgdatadir/[c++.m4])
# b4_args(ARG1, ...)
# _b4_args(ARG1, ...)
# -------------------
# Join with comma, skipping empty arguments.
# b4_args calls itself recursively until it sees the first non-empty
# argument, then calls _b4_args which prepends each non-empty argument
# with a comma.
m4_define([b4_args],
[m4_if([$#$1],
[1], [],
[m4_ifval([$1],
[$1[]_$0(m4_shift($@))],
[$0(m4_shift($@))])])])
# _b4_args(ARGS1, ...)
# --------------------
m4_define([_b4_args],
[m4_if([$#$1],
[1], [],
[m4_ifval([$1], [, $1])[]$0(m4_shift($@))])])
# b4_table_define(TABLE-NAME, CONTENT) # b4_table_define(TABLE-NAME, CONTENT)
# ------------------------------------ # ------------------------------------
# Define "parser::yy<TABLE-NAME>_" which contents is CONTENT. # Define "parser::yy<TABLE-NAME>_" which contents is CONTENT.
@@ -179,9 +202,9 @@ m4_define([b4_type_action_],
m4_define([b4_symbol_constructor_declaration_], m4_define([b4_symbol_constructor_declaration_],
[ template <token_type> [ template <token_type>
static inline symbol_type static inline symbol_type
make_symbol (b4_symbol_if([$1], [has_type_name], make_symbol (b4_args(b4_symbol_if([$1], [has_type_name],
[const b4_symbol([$1], [type_name])& v, ])dnl [const b4_symbol([$1], [type_name])& v]),
const location_type& l); b4_locations_if([const location_type& l])));
]) ])
@@ -207,9 +230,9 @@ m4_define([b4_symbol_constructor_specialization_],
inline inline
b4_parser_class_name::symbol_type b4_parser_class_name::symbol_type
b4_parser_class_name::make_symbol <b4_parser_class_name::token::b4_symbol([$1], [tag])> (dnl b4_parser_class_name::make_symbol <b4_parser_class_name::token::b4_symbol([$1], [tag])> (dnl
b4_symbol_if([$1], [has_type_name], b4_args(b4_symbol_if([$1], [has_type_name],
[const b4_symbol([$1], [type_name])& v, ])dnl [const b4_symbol([$1], [type_name])& v]),
const b4_parser_class_name::location_type& l); b4_locations_if([const b4_parser_class_name::location_type& l])));
])])]) ])])])
# b4_symbol_constructor_specializations # b4_symbol_constructor_specializations
@@ -232,12 +255,13 @@ m4_define([b4_symbol_constructor_definition_],
[ template <> [ template <>
b4_parser_class_name::symbol_type b4_parser_class_name::symbol_type
b4_parser_class_name::make_symbol <b4_parser_class_name::token::b4_symbol([$1], [tag])> (dnl b4_parser_class_name::make_symbol <b4_parser_class_name::token::b4_symbol([$1], [tag])> (dnl
b4_symbol_if([$1], [has_type_name], b4_args(b4_symbol_if([$1], [has_type_name],
[const b4_symbol([$1], [type_name])& v, ])dnl [const b4_symbol([$1], [type_name])& v]),
const location_type& l) b4_locations_if([const location_type& l])))
{ {
return symbol_type (yytranslate_ (token::b4_symbol([$1], [tag])),dnl return symbol_type (b4_args([yytranslate_ (token::b4_symbol([$1], [tag]))],
b4_symbol_if([$1], [has_type_name], [v, ])l); b4_symbol_if([$1], [has_type_name], [v]),
b4_locations_if([l])));
} }
])])]) ])])])
@@ -309,9 +333,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_locations_if(
[# Backward compatibility.
m4_define([b4_location_constructors]) m4_define([b4_location_constructors])
m4_include(b4_pkgdatadir/[location.cc]) 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()
@@ -333,8 +358,8 @@ dnl FIXME: This is wrong, we want computed header guards.
#include "stack.hh" #include "stack.hh"
]b4_namespace_open[ ]b4_namespace_open[
class position; ]b4_locations_if([ class position;
class location; class location;])[
]b4_variant_if( ]b4_variant_if(
[[ [[
/// A char[S] buffer to store and retrieve objects. /// A char[S] buffer to store and retrieve objects.
@@ -435,7 +460,7 @@ dnl FIXME: This is wrong, we want computed header guards.
]])[ ]])[
]b4_namespace_close[ ]b4_namespace_close[
#include "location.hh" ]b4_locations_if([#include "location.hh"])[
/* Enabling traces. */ /* Enabling traces. */
#ifndef YYDEBUG #ifndef YYDEBUG
@@ -455,7 +480,8 @@ dnl FIXME: This is wrong, we want computed header guards.
# define YYTOKEN_TABLE ]b4_token_table[ # define YYTOKEN_TABLE ]b4_token_table[
#endif #endif
/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N]. ]b4_locations_if([dnl
[/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
If N is 0, then set CURRENT to the empty location which ends If N is 0, then set CURRENT to the empty location which ends
the previous symbol: RHS[0] (always defined). */ the previous symbol: RHS[0] (always defined). */
@@ -472,7 +498,7 @@ do { \
(Current).begin = (Current).end = (Rhs)[0].location.end; \ (Current).begin = (Current).end = (Rhs)[0].location.end; \
} \ } \
} while (false) } while (false)
#endif #endif]])[
]b4_namespace_open[ ]b4_namespace_open[
@@ -499,9 +525,9 @@ m4_ifdef([b4_stype],
[[ typedef YYSTYPE semantic_type;]])])])[ [[ typedef YYSTYPE semantic_type;]])])])[
#else #else
typedef YYSTYPE semantic_type; typedef YYSTYPE semantic_type;
#endif #endif]b4_locations_if([
/// Symbol locations. /// Symbol locations.
typedef ]b4_percent_define_get([[location_type]])[ location_type; typedef b4_percent_define_get([[location_type]]) location_type;])[
/// Tokens. /// Tokens.
struct token struct token
{ {
@@ -533,10 +559,10 @@ m4_ifdef([b4_stype],
#endif #endif
private: private:
/// Report a syntax error. /// Report a syntax error.]b4_locations_if([
/// \param loc where the syntax error is found. /// \param loc where the syntax error is found.])[
/// \param msg a description of the syntax error. /// \param msg a description of the syntax error.
virtual void error (const location_type& loc, const std::string& msg); virtual void error (]b4_locations_if([const location_type& loc, ])[const std::string& msg);
/// Generate an error message. /// Generate an error message.
/// \param state the state where the error occurred. /// \param state the state where the error occurred.
@@ -612,9 +638,11 @@ m4_ifdef([b4_stype],
/// Default constructor. /// Default constructor.
inline symbol_base_type (); inline symbol_base_type ();
/// Constructor. /// Constructor.]b4_locations_if([
inline symbol_base_type (const location_type& l); inline symbol_base_type (const location_type& l)])[;
inline symbol_base_type (const semantic_type& v, const location_type& l); inline symbol_base_type (]b4_args(
[const semantic_type& v],
b4_locations_if([const location_type& l]))[);
/// Return this with its exact type. /// Return this with its exact type.
const Exact& self () const; const Exact& self () const;
@@ -624,10 +652,10 @@ m4_ifdef([b4_stype],
int type_get () const; int type_get () const;
/// The semantic value. /// The semantic value.
semantic_type value; semantic_type value;]b4_locations_if([
/// The location. /// The location.
location_type location; location_type location;])[
}; };
#if YYDEBUG #if YYDEBUG
@@ -658,11 +686,12 @@ m4_ifdef([b4_stype],
inline symbol_type (); inline symbol_type ();
/// Constructor. /// Constructor.
inline symbol_type (int t, inline symbol_type (]b4_args([int t],
const semantic_type& v, const location_type& l); [const semantic_type& v],
b4_locations_if([const location_type& l]))[);
inline symbol_type (int t, inline symbol_type (]b4_args([int t],
const location_type& l); b4_locations_if([const location_type& l]))[);
/// The symbol type. /// The symbol type.
int type; int type;
@@ -684,8 +713,9 @@ m4_ifdef([b4_stype],
inline stack_symbol_type (); inline stack_symbol_type ();
/// Constructor. /// Constructor.
inline stack_symbol_type (state_type s, inline stack_symbol_type (]b4_args([state_type s],
const semantic_type& v, const location_type& l); [const semantic_type& v],
b4_locations_if([const location_type& l]))[);
/// The state. /// The state.
state_type state; state_type state;
@@ -886,22 +916,24 @@ b4_percent_code_get[]dnl
// symbol_base_type. // symbol_base_type.
template <typename Exact> template <typename Exact>
]b4_parser_class_name[::symbol_base_type<Exact>::symbol_base_type () ]b4_parser_class_name[::symbol_base_type<Exact>::symbol_base_type ()
: value() : value()]b4_locations_if([
, location() , location()])[
{ {
} }]b4_locations_if([[
template <typename Exact> template <typename Exact>
]b4_parser_class_name[::symbol_base_type<Exact>::symbol_base_type (const location_type& l) ]b4_parser_class_name[::symbol_base_type<Exact>::symbol_base_type (const location_type& l)
: value() : value()
, location(l) , location(l)
{ {
} }]])[
template <typename Exact> template <typename Exact>
]b4_parser_class_name[::symbol_base_type<Exact>::symbol_base_type (const semantic_type& v, const location_type& l) ]b4_parser_class_name[::symbol_base_type<Exact>::symbol_base_type (]b4_args(
: value(v) [const semantic_type& v],
, location(l) b4_locations_if([const location_type& l]))[)
: value(v)]b4_locations_if([
, location(l)])[
{ {
} }
@@ -933,16 +965,19 @@ b4_percent_code_get[]dnl
{ {
} }
]b4_parser_class_name[::symbol_type::symbol_type (int t, ]b4_parser_class_name[::symbol_type::symbol_type (]b4_args(
const location_type& l) [int t],
: super_type (l) b4_locations_if([const location_type& l]))[)
: super_type (]b4_locations_if([l])[)
, type (t) , type (t)
{ {
} }
]b4_parser_class_name[::symbol_type::symbol_type (int t, ]b4_parser_class_name[::symbol_type::symbol_type (]b4_args(
const semantic_type& v, const location_type& l) [int t],
: super_type (v, l) [const semantic_type& v],
b4_locations_if([const location_type& l]))[)
: super_type (v]b4_locations_if([, l])[)
, type (t) , type (t)
{ {
} }
@@ -962,9 +997,11 @@ b4_percent_code_get[]dnl
{ {
} }
]b4_parser_class_name[::stack_symbol_type::stack_symbol_type (state_type s, ]b4_parser_class_name[::stack_symbol_type::stack_symbol_type (]b4_args(
const semantic_type& v, const location_type& l) [state_type s],
: super_type (v, l) [const semantic_type& v],
b4_locations_if([const location_type& l]))[)
: super_type (v]b4_locations_if([, l])[)
, state (s) , state (s)
{ {
} }
@@ -1006,8 +1043,8 @@ b4_percent_code_get[]dnl
{ {
int yytype = yysym.type_get (); int yytype = yysym.type_get ();
yyo << (yytype < yyntokens_ ? "token" : "nterm") yyo << (yytype < yyntokens_ ? "token" : "nterm")
<< ' ' << yytname_[yytype] << " (" << ' ' << yytname_[yytype] << " ("]b4_locations_if([
<< yysym.location << ": "; << yysym.location << ": "])[;
switch (yytype) switch (yytype)
{ {
]m4_map([b4_symbol_actions], m4_defn([b4_symbol_printers]))[ ]m4_map([b4_symbol_actions], m4_defn([b4_symbol_printers]))[
@@ -1025,10 +1062,16 @@ b4_percent_code_get[]dnl
if (m) if (m)
YY_SYMBOL_PRINT (m, sym); YY_SYMBOL_PRINT (m, sym);
]b4_variant_if( ]b4_variant_if(
[[ yystack_.push (stack_symbol_type (s, semantic_type(), sym.location)); [[ yystack_.push (stack_symbol_type (]b4_args(
[s],
[semantic_type()],
b4_locations_if([sym.location]))[));
]b4_symbol_variant([[yystos_[s]]], [[yystack_[0].value]], ]b4_symbol_variant([[yystos_[s]]], [[yystack_[0].value]],
[build], [sym.value])], [build], [sym.value])],
[ yystack_.push (stack_symbol_type (s, sym.value, sym.location));])[ [[ yystack_.push (stack_symbol_type (]b4_args(
[s],
[sym.value],
b4_locations_if([sym.location]))[));]])[
} }
void void
@@ -1037,7 +1080,10 @@ b4_percent_code_get[]dnl
if (m) if (m)
YY_SYMBOL_PRINT (m, s); YY_SYMBOL_PRINT (m, s);
]b4_variant_if( ]b4_variant_if(
[[ yystack_.push (stack_symbol_type (s.state, semantic_type(), s.location)); [[ yystack_.push (stack_symbol_type (]b4_args(
[s.state],
[semantic_type()],
b4_locations_if([s.location]))[));
]b4_symbol_variant([[yystos_[s.state]]], [[yystack_[0].value]], ]b4_symbol_variant([[yystos_[s.state]]], [[yystack_[0].value]],
[build], [s.value])], [build], [s.value])],
[ yystack_.push (s);])[ [ yystack_.push (s);])[
@@ -1092,10 +1138,10 @@ b4_percent_code_get[]dnl
int yyerrstatus_ = 0; int yyerrstatus_ = 0;
/// The lookahead symbol. /// The lookahead symbol.
symbol_type yyla; symbol_type yyla;]b4_locations_if([[
/// The locations where the error started and ended. /// The locations where the error started and ended.
stack_symbol_type yyerror_range[2]; stack_symbol_type yyerror_range[2];]])[
/// $$ and @@$. /// $$ and @@$.
stack_symbol_type yylhs; stack_symbol_type yylhs;
@@ -1211,12 +1257,13 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param)));])[
yylhs.value = yystack_@{yylen - 1@}.value; yylhs.value = yystack_@{yylen - 1@}.value;
else else
yylhs.value = yystack_@{0@}.value;])[ yylhs.value = yystack_@{0@}.value;])[
]b4_locations_if([dnl
[
// Compute the default @@$. // Compute the default @@$.
{ {
slice<stack_symbol_type, stack_type> slice (yystack_, yylen); slice<stack_symbol_type, stack_type> slice (yystack_, yylen);
YYLLOC_DEFAULT (yylhs.location, slice, yylen); YYLLOC_DEFAULT (yylhs.location, slice, yylen);
} }]])[
// Perform the reduction. // Perform the reduction.
YY_REDUCE_PRINT (yyn); YY_REDUCE_PRINT (yyn);
@@ -1265,10 +1312,12 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param)));])[
if (!yyerrstatus_) if (!yyerrstatus_)
{ {
++yynerrs_; ++yynerrs_;
error (yyla.location, yysyntax_error_ (yystate, yyla.type)); error (]b4_args(b4_locations_if([yyla.location]),
[yysyntax_error_ (yystate, yyla.type)])[);
} }
yyerror_range[0].location = yyla.location; ]b4_locations_if([[
yyerror_range[0].location = yyla.location;]])[
if (yyerrstatus_ == 3) if (yyerrstatus_ == 3)
{ {
/* If just tried and failed to reuse lookahead token after an /* If just tried and failed to reuse lookahead token after an
@@ -1300,7 +1349,8 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param)));])[
if (false) if (false)
goto yyerrorlab; goto yyerrorlab;
yyerror_range[0].location = yystack_[yylen - 1].location; ]b4_locations_if([[
yyerror_range[0].location = yystack_[yylen - 1].location;]])[
/* Do not reclaim the symbols of the rule which action triggered /* Do not reclaim the symbols of the rule which action triggered
this YYERROR. */ this YYERROR. */
yypop_ (yylen); yypop_ (yylen);
@@ -1332,16 +1382,16 @@ m4_ifdef([b4_lex_param], [, ]b4_lex_param)));])[
// Pop the current state because it cannot handle the error token. // Pop the current state because it cannot handle the error token.
if (yystack_.size () == 1) if (yystack_.size () == 1)
YYABORT; YYABORT;
]b4_locations_if([[
yyerror_range[0].location = yystack_[0].location; yyerror_range[0].location = yystack_[0].location;]])[
yy_destroy_ ("Error: popping", yystack_[0]); yy_destroy_ ("Error: popping", yystack_[0]);
yypop_ (); yypop_ ();
yystate = yystack_[0].state; yystate = yystack_[0].state;
YY_STACK_PRINT (); YY_STACK_PRINT ();
} }
]b4_locations_if([[
yyerror_range[1].location = yyla.location; yyerror_range[1].location = yyla.location;
YYLLOC_DEFAULT (error_token.location, (yyerror_range - 1), 2); YYLLOC_DEFAULT (error_token.location, (yyerror_range - 1), 2);]])[
/* Shift the error token. */ /* Shift the error token. */
error_token.state = yystate = yyn; error_token.state = yystate = yyn;

View File

@@ -141,10 +141,9 @@ yylex(yy::parser::semantic_type* yylval)
} }
void void
yy::parser::error(const yy::parser::location_type& yylloc, yy::parser::error(const std::string& message)
const std::string& message)
{ {
std::cerr << yylloc << ": " << message << std::endl; std::cerr << message << std::endl;
} }
int int
@@ -278,10 +277,11 @@ AT_DATA_GRAMMAR([[input.y]],
%define namespace "]$1[" %define namespace "]$1["
%union { int i; } %union { int i; }
%define global_tokens_and_yystype %define global_tokens_and_yystype
%locations
%code { %code {
// YYSTYPE contains a namespace reference. // YYSTYPE contains a namespace reference.
int yylex (YYSTYPE *lval) { int yylex (YYSTYPE *lval, const ]$1[::parser::location_type* lloc) {
lval->i = 3; lval->i = 3;
return 0; return 0;
} }

View File

@@ -90,16 +90,16 @@ static int get_char (]AT_LEX_FORMALS[);
static void unget_char (]AT_LEX_PRE_FORMALS[ int c); static void unget_char (]AT_LEX_PRE_FORMALS[ int c);
%} %}
]AT_SKEL_CC_IF( ]AT_SKEL_CC_IF([AT_LOCATION_IF([
[/* The lalr1.cc skeleton, for backward compatibility, defines /* The lalr1.cc skeleton, for backward compatibility, defines
a constructor for position that initializes the filename. The a constructor for position that initializes the filename. The
glr.cc skeleton does not (and in fact cannot: location/position glr.cc skeleton does not (and in fact cannot: location/position
are stored in a union, from which objects with constructors are are stored in a union, from which objects with constructors are
excluded in C++. */ excluded in C++). */
%initial-action { %initial-action {
@$.initialize (0); @$.initialize (0);
} }
])[ ])])[
/* Bison Declarations */ /* Bison Declarations */
%token CALC_EOF 0 "end of input" %token CALC_EOF 0 "end of input"
@@ -150,9 +150,8 @@ static FILE *input;
]AT_SKEL_CC_IF( ]AT_SKEL_CC_IF(
[/* A C++ error reporting function. */ [/* A C++ error reporting function. */
void void
AT_NAME_PREFIX::parser::error (const location& l, const std::string& m) AT_NAME_PREFIX::parser::error (AT_LOCATION_IF([const location& l, ])const std::string& m)
{ {
(void) l;
std::cerr << AT_LOCATION_IF([l << ": " << ])m << std::endl; std::cerr << AT_LOCATION_IF([l << ": " << ])m << std::endl;
} }
@@ -627,16 +626,17 @@ AT_CHECK_CALC([%skeleton "lalr1.cc" %defines %locations])
# Start a testing chunk which compiles `calc' grammar with # Start a testing chunk which compiles `calc' grammar with
# the C++ skeleton, and performs several tests over the parser. # the C++ skeleton, and performs several tests over the parser.
m4_define([AT_CHECK_CALC_LALR1_CC], m4_define([AT_CHECK_CALC_LALR1_CC],
[AT_CHECK_CALC([%language "C++" %defines %locations] $@)]) [AT_CHECK_CALC([%language "C++" %defines] $@)])
AT_CHECK_CALC_LALR1_CC([]) AT_CHECK_CALC_LALR1_CC([])
AT_CHECK_CALC_LALR1_CC([%error-verbose %name-prefix "calc" %verbose %yacc]) AT_CHECK_CALC_LALR1_CC([%locations])
AT_CHECK_CALC_LALR1_CC([%locations %error-verbose %name-prefix "calc" %verbose %yacc])
AT_CHECK_CALC_LALR1_CC([%error-verbose %debug %name-prefix "calc" %verbose %yacc]) AT_CHECK_CALC_LALR1_CC([%locations %error-verbose %debug %name-prefix "calc" %verbose %yacc])
AT_CHECK_CALC_LALR1_CC([%pure-parser %error-verbose %debug %name-prefix "calc" %verbose %yacc]) AT_CHECK_CALC_LALR1_CC([%locations %pure-parser %error-verbose %debug %name-prefix "calc" %verbose %yacc])
AT_CHECK_CALC_LALR1_CC([%pure-parser %error-verbose %debug %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}]) AT_CHECK_CALC_LALR1_CC([%locations %pure-parser %error-verbose %debug %name-prefix "calc" %verbose %yacc %parse-param {semantic_value *result} %parse-param {int *count}])

View File

@@ -107,13 +107,16 @@ AT_CHECK([grep 'include .subdir/' $1.hh], 1, [])
]) ])
AT_CHECK_OUTPUT([foo.yy], [%skeleton "lalr1.cc" %defines %verbose], [], AT_CHECK_OUTPUT([foo.yy], [%skeleton "lalr1.cc" %defines %verbose], [],
[foo.tab.cc foo.tab.hh foo.output stack.hh])
AT_CHECK_OUTPUT([foo.yy], [%skeleton "lalr1.cc" %defines %verbose %locations], [],
[foo.tab.cc foo.tab.hh foo.output location.hh stack.hh position.hh]) [foo.tab.cc foo.tab.hh foo.output location.hh stack.hh position.hh])
AT_CHECK_OUTPUT([subdir/foo.yy], [%skeleton "lalr1.cc" %defines %verbose], [], AT_CHECK_OUTPUT([subdir/foo.yy], [%skeleton "lalr1.cc" %defines %verbose], [],
[foo.tab.cc foo.tab.hh foo.output location.hh stack.hh position.hh], [foo.tab.cc foo.tab.hh foo.output stack.hh],
[], [AT_CHECK_NO_SUBDIR_PART([foo.tab])]) [], [AT_CHECK_NO_SUBDIR_PART([foo.tab])])
AT_CHECK_OUTPUT([subdir/foo.yy], [%skeleton "lalr1.cc" %defines %verbose], AT_CHECK_OUTPUT([subdir/foo.yy], [%skeleton "lalr1.cc" %defines %verbose %locations],
[-o subdir/foo.cc], [-o subdir/foo.cc],
[subdir/foo.cc subdir/foo.hh subdir/foo.output subdir/location.hh subdir/stack.hh subdir/position.hh], [subdir/foo.cc subdir/foo.hh subdir/foo.output subdir/location.hh subdir/stack.hh subdir/position.hh],
[], [AT_CHECK_NO_SUBDIR_PART([subdir/foo])]) [], [AT_CHECK_NO_SUBDIR_PART([subdir/foo])])
@@ -121,6 +124,11 @@ AT_CHECK_OUTPUT([subdir/foo.yy], [%skeleton "lalr1.cc" %defines %verbose],
AT_CHECK_OUTPUT([gram_dir/foo.yy], AT_CHECK_OUTPUT([gram_dir/foo.yy],
[%skeleton "lalr1.cc" %defines %verbose %file-prefix "output_dir/foo"], [%skeleton "lalr1.cc" %defines %verbose %file-prefix "output_dir/foo"],
[], [],
[output_dir/foo.tab.cc output_dir/foo.tab.hh output_dir/foo.output output_dir/stack.hh])
AT_CHECK_OUTPUT([gram_dir/foo.yy],
[%skeleton "lalr1.cc" %defines %locations %verbose %file-prefix "output_dir/foo"],
[],
[output_dir/foo.tab.cc output_dir/foo.tab.hh output_dir/foo.output output_dir/location.hh output_dir/stack.hh output_dir/position.hh]) [output_dir/foo.tab.cc output_dir/foo.tab.hh output_dir/foo.output output_dir/location.hh output_dir/stack.hh output_dir/position.hh])
@@ -153,7 +161,7 @@ AT_CHECK_CONFLICTING_OUTPUT([foo.y],
]) ])
AT_CHECK_CONFLICTING_OUTPUT([foo.y], AT_CHECK_CONFLICTING_OUTPUT([foo.y],
[%skeleton "lalr1.cc" %defines], [--graph="location.hh"], [%skeleton "lalr1.cc" %defines %locations], [--graph="location.hh"],
[foo.y: warning: conflicting outputs to file `location.hh' [foo.y: warning: conflicting outputs to file `location.hh'
]) ])
@@ -163,7 +171,7 @@ AT_CHECK_CONFLICTING_OUTPUT([foo.y], [], [-o foo.y],
# AT_CHECK_OUTPUT_FILE_NAME(FILE-NAME-PREFIX, [ADDITIONAL-TESTS]) # AT_CHECK_OUTPUT_FILE_NAME(FILE-NAME-PREFIX, [ADDITIONAL-TESTS])
# ----------------------------------------------------------------------------- # ---------------------------------------------------------------
m4_define([AT_CHECK_OUTPUT_FILE_NAME], m4_define([AT_CHECK_OUTPUT_FILE_NAME],
[AT_SETUP([Output file name: $1]) [AT_SETUP([Output file name: $1])

View File

@@ -887,7 +887,7 @@ member: STRING
AT_LALR1_CC_IF( AT_LALR1_CC_IF(
[/* A C++ error reporting function. */ [/* A C++ error reporting function. */
void void
yy::parser::error (const location&, const std::string& m) yy::parser::error (const std::string& m)
{ {
std::cerr << m << std::endl; std::cerr << m << std::endl;
} }
@@ -986,7 +986,7 @@ t: A | B;
AT_LALR1_CC_IF( AT_LALR1_CC_IF(
[/* A C++ error reporting function. */ [/* A C++ error reporting function. */
void void
yy::parser::error (const location&, const std::string& m) yy::parser::error (const std::string& m)
{ {
std::cerr << m << std::endl; std::cerr << m << std::endl;
} }