mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-13 14:23:04 +00:00
Merge maint into master
* upstream/maint: (48 commits) THANKS: update an address tests: adjust syncline tests to GCC 7 glr: fix improperly placed synclines bison: be git grep friendly Replace ftp with https maint: post-release administrivia version 3.0.5 bison: style: indentation fixes regen bison: please address sanitizer C++: style: fix indentation NEWS: update C++: style: prefer `unsigned` to `unsigned int` C++: style: space before paren C++: fix -Wdeprecated warnings tests: fix -Wdeprecated warning maint: update syntax-check exclusions autoconf: update regen Update copyright years ...
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
e# Executing Actions. -*- Autotest -*-
|
||||
|
||||
# Copyright (C) 2001-2015 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2001-2015, 2018 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -203,7 +203,7 @@ AT_DATA_GRAMMAR([[input.y]],
|
||||
]AT_YYLEX_DECLARE[
|
||||
}
|
||||
%%
|
||||
exp: { ]AT_SKEL_CC_IF([[std::cerr << @$ << std::endl]],
|
||||
exp: { ]AT_SKEL_CC_IF([[std::cerr << @$ << '\n']],
|
||||
[[LOCATION_PRINT(stderr, @$); fputc ('\n', stderr)]])[; }
|
||||
%%
|
||||
]AT_YYERROR_DEFINE[
|
||||
@@ -475,7 +475,7 @@ AT_DATA_GRAMMAR([[input.y]],
|
||||
|
||||
/* Display the symbol type Symbol. */
|
||||
#define V(Symbol, Value, Location, Sep) \
|
||||
fprintf (stderr, #Symbol " (%d@%d-%d)" Sep, Value, RANGE(Location))
|
||||
fprintf (stderr, #Symbol " (%d@%d-%d)%s", Value, RANGE(Location), Sep)
|
||||
}
|
||||
|
||||
$5
|
||||
@@ -490,15 +490,17 @@ AT_LALR1_CC_IF([typedef yy::location YYLTYPE;])[
|
||||
]AT_LALR1_CC_IF([], [AT_YYERROR_DECLARE])
|
||||
[}
|
||||
|
||||
]m4_ifval([$6], [%type <ival> '(' 'x' 'y' ')' ';' thing line input END])[
|
||||
]m4_ifval([$6],
|
||||
[%type <ival> '(' 'x' 'y' ')' ';' thing line input
|
||||
'!' raise check-spontaneous-errors END])[
|
||||
|
||||
/* FIXME: This %printer isn't actually tested. */
|
||||
%printer
|
||||
{
|
||||
]AT_LALR1_CC_IF([debug_stream () << $$;],
|
||||
[fprintf (yyoutput, "%d", $$)])[;
|
||||
]AT_LALR1_CC_IF([yyo << $$;],
|
||||
[fprintf (yyo, "%d", $$)])[;
|
||||
}
|
||||
input line thing 'x' 'y'
|
||||
'(' 'x' 'y' ')' ';' thing line input '!' raise check-spontaneous-errors END
|
||||
|
||||
%destructor
|
||||
{ fprintf (stderr, "Freeing nterm input (%d@%d-%d)\n", $$, RANGE (@$)); }
|
||||
@@ -512,6 +514,14 @@ AT_LALR1_CC_IF([typedef yy::location YYLTYPE;])[
|
||||
{ fprintf (stderr, "Freeing nterm thing (%d@%d-%d)\n", $$, RANGE (@$)); }
|
||||
thing
|
||||
|
||||
%destructor
|
||||
{ fprintf (stderr, "Freeing raise thing (%d@%d-%d)\n", $$, RANGE (@$)); }
|
||||
raise
|
||||
|
||||
%destructor
|
||||
{ fprintf (stderr, "Freeing check-spontaneous-errors thing (%d@%d-%d)\n", $$, RANGE (@$)); }
|
||||
check-spontaneous-errors
|
||||
|
||||
%destructor
|
||||
{ fprintf (stderr, "Freeing token 'x' (%d@%d-%d)\n", $$, RANGE (@$)); }
|
||||
'x'
|
||||
@@ -534,7 +544,7 @@ AT_LALR1_CC_IF([typedef yy::location YYLTYPE;])[
|
||||
*/
|
||||
|
||||
input:
|
||||
/* Nothing. */
|
||||
%empty
|
||||
{
|
||||
$$ = 0;
|
||||
V(input, $$, @$, ": /* Nothing */\n");
|
||||
@@ -547,6 +557,38 @@ input:
|
||||
V(line, $1, @1, " ");
|
||||
V(input, $2, @2, "\n");
|
||||
}
|
||||
| '!' check-spontaneous-errors
|
||||
{
|
||||
$$ = $2;
|
||||
}
|
||||
;
|
||||
|
||||
check-spontaneous-errors:
|
||||
raise { abort(); $$ = $1; }
|
||||
| '(' raise ')' { abort(); $$ = $2; }
|
||||
| error
|
||||
{
|
||||
$$ = 5;
|
||||
V(check-spontaneous-errors, $$, @$, ": ");
|
||||
fprintf (stderr, "error (@%d-%d)\n", RANGE(@1));
|
||||
}
|
||||
;
|
||||
|
||||
raise:
|
||||
%empty
|
||||
{
|
||||
$$ = 4;
|
||||
V(raise, $$, @$, ": %empty\n");
|
||||
YYERROR;
|
||||
}
|
||||
| '!' '!'
|
||||
{
|
||||
$$ = 5;
|
||||
V(raise, $$, @$, ": ");
|
||||
V(!, $1, @2, " ");
|
||||
V(!, $2, @2, "\n");
|
||||
YYERROR;
|
||||
}
|
||||
;
|
||||
|
||||
line:
|
||||
@@ -668,6 +710,38 @@ Freeing nterm input (2@0-29)
|
||||
Successful parse.
|
||||
]])
|
||||
|
||||
# Check the location of empty reductions raising an error
|
||||
# -------------------------------------------------------
|
||||
# Here, the error is after token "!@0-9", so the error is raised from
|
||||
# @9-9, and the error recovery detects that it starts from @9-9 and
|
||||
# ends where starts the next token: END@10-19.
|
||||
#
|
||||
# So error recovery reports error@9-19.
|
||||
AT_PARSER_CHECK([./input '!'], 0, [],
|
||||
[[sending: '!' (0@0-9)
|
||||
sending: END (1@10-19)
|
||||
raise (4@9-9): %empty
|
||||
check-spontaneous-errors (5@9-19): error (@9-19)
|
||||
Freeing token END (1@10-19)
|
||||
Freeing nterm input (5@0-19)
|
||||
Successful parse.
|
||||
]])
|
||||
|
||||
# Check the location of not empty reductions raising an error
|
||||
# -----------------------------------------------------------
|
||||
# This time the error is raised from a rule with 2 rhs symbols: @10-29.
|
||||
# It is recovered @10-29.
|
||||
AT_PARSER_CHECK([[./input '!!!']], 0, [],
|
||||
[[sending: '!' (0@0-9)
|
||||
sending: '!' (1@10-19)
|
||||
sending: '!' (2@20-29)
|
||||
raise (5@10-29): ! (1@20-29) ! (2@20-29)
|
||||
check-spontaneous-errors (5@10-29): error (@10-29)
|
||||
sending: END (3@30-39)
|
||||
Freeing token END (3@30-39)
|
||||
Freeing nterm input (5@0-29)
|
||||
Successful parse.
|
||||
]])
|
||||
|
||||
# Check locations in error recovery
|
||||
# ---------------------------------
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# @configure_input@ -*- shell-script -*-
|
||||
# Configurable variable values for Bison test suite.
|
||||
|
||||
# Copyright (C) 2000-2015 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2000-2015, 2018 Free Software Foundation, Inc.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -16,8 +16,8 @@
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# We need 'config.h'.
|
||||
CPPFLAGS="-I$abs_top_builddir/lib @CPPFLAGS@"
|
||||
# We need 'config.h' (builddir/lib), and the gnulib headers (srcdir/lib).
|
||||
CPPFLAGS="-I$abs_top_srcdir/lib -I$abs_top_builddir/lib @CPPFLAGS@"
|
||||
|
||||
# Don't just check if $POSIXLY_CORRECT is set, as Bash, when launched
|
||||
# as /bin/sh, sets the shell variable POSIXLY_CORRECT to y, but not
|
||||
@@ -69,7 +69,7 @@ if $BISON_CXX_WORKS; then
|
||||
|
||||
int main ()
|
||||
{
|
||||
std::cout << "Works" << std::endl;
|
||||
std::cout << "Works\n";
|
||||
}
|
||||
EOF
|
||||
$CXX $CXXFLAGS $CPPFLAGS $LDFLAGS $LIBS -o conftest conftest.cc
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
# @configure_input@
|
||||
# Wrapper around a non installed bison to make it work as an installed one.
|
||||
|
||||
# Copyright (C) 2001-2015 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2001-2015, 2018 Free Software Foundation, Inc.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
||||
119
tests/c++.at
119
tests/c++.at
@@ -1,6 +1,7 @@
|
||||
# Checking the C++ Features. -*- Autotest -*-
|
||||
|
||||
# Copyright (C) 2004-2005, 2007-2015 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2004-2005, 2007-2015, 2018 Free Software Foundation,
|
||||
# Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -49,7 +50,7 @@ check (const T& in, const std::string& s)
|
||||
os << in;
|
||||
if (os.str () != s)
|
||||
{
|
||||
std::cerr << "fail: " << os.str () << ", expected: " << s << std::endl;
|
||||
std::cerr << "fail: " << os.str () << ", expected: " << s << '\n';
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
@@ -96,7 +97,7 @@ AT_SETUP([C++ Variant-based Symbols])
|
||||
AT_KEYWORDS([variant])
|
||||
|
||||
AT_BISON_OPTION_PUSHDEFS([%skeleton "lalr1.cc" %debug $1])
|
||||
# Store strings and integers in a list of strings.
|
||||
# Store strings and integers in a vector of strings.
|
||||
AT_DATA_GRAMMAR([list.y],
|
||||
[[%skeleton "lalr1.cc"
|
||||
%define api.value.type variant
|
||||
@@ -114,20 +115,20 @@ AT_DATA_GRAMMAR([list.y],
|
||||
}
|
||||
|
||||
%token <int> INT "int"
|
||||
%type < std::list<int> > exp
|
||||
%type < std::vector<int> > exp
|
||||
|
||||
%printer { yyo << $$; } <int>
|
||||
%printer
|
||||
{
|
||||
for (std::list<int>::const_iterator i = $$.begin (); i != $$.end (); ++i)
|
||||
for (std::vector<int>::const_iterator i = $$.begin (); i != $$.end (); ++i)
|
||||
{
|
||||
if (i != $$.begin ())
|
||||
yyo << ", ";
|
||||
yyo << *i;
|
||||
}
|
||||
} < std::list<int> >
|
||||
} < std::vector<int> >
|
||||
|
||||
%code requires { #include <list> }
|
||||
%code requires { #include <vector> }
|
||||
%code { int yylex (yy::parser::semantic_type* yylval); }
|
||||
|
||||
%%
|
||||
@@ -140,13 +141,13 @@ int main()
|
||||
{
|
||||
{
|
||||
yy::parser::symbol_type s = yy::parser::make_INT(12);
|
||||
std::cerr << s.value.as<int>() << std::endl;
|
||||
std::cerr << s.value.as<int>() << '\n';
|
||||
}
|
||||
|
||||
{
|
||||
yy::parser::symbol_type s = yy::parser::make_INT(123);
|
||||
yy::parser::stack_symbol_type ss(1, s);
|
||||
std::cerr << ss.value.as<int>() << std::endl;
|
||||
std::cerr << ss.value.as<int>() << '\n';
|
||||
}
|
||||
|
||||
{
|
||||
@@ -185,7 +186,7 @@ m4_pushdef([AT_TEST],
|
||||
[AT_SETUP([Variants $1])
|
||||
|
||||
AT_BISON_OPTION_PUSHDEFS([%debug $1])
|
||||
# Store strings and integers in a list of strings.
|
||||
# Store strings and integers in a vector of strings.
|
||||
AT_DATA_GRAMMAR([list.y],
|
||||
[[%debug
|
||||
%define api.value.type variant
|
||||
@@ -194,29 +195,25 @@ AT_DATA_GRAMMAR([list.y],
|
||||
|
||||
%code requires // code for the .hh file
|
||||
{
|
||||
#include <list>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
typedef std::list<std::string> strings_type;
|
||||
typedef std::vector<std::string> strings_type;
|
||||
}
|
||||
|
||||
%code // code for the .cc file
|
||||
%code top // code for the .cc file.
|
||||
{
|
||||
#include <cstdlib> // abort, getenv
|
||||
#include <iostream>
|
||||
#include <vector>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
|
||||
typedef std::vector<std::string> strings_type;
|
||||
|
||||
namespace yy
|
||||
{
|
||||
static]AT_TOKEN_CTOR_IF([[
|
||||
parser::symbol_type yylex ()]], [[
|
||||
parser::token_type yylex (parser::semantic_type* yylval]AT_LOCATION_IF([,
|
||||
parser::location_type* yylloc])[)]])[;
|
||||
}
|
||||
|
||||
// Printing a list of strings (for %printer).
|
||||
// Koening look up will look into std, since that's an std::list.
|
||||
namespace std
|
||||
{
|
||||
// Must be available early, as is used in %destructor.
|
||||
std::ostream&
|
||||
operator<<(std::ostream& o, const strings_type& s)
|
||||
{
|
||||
@@ -230,16 +227,27 @@ typedef std::list<std::string> strings_type;
|
||||
return o << ')';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Conversion to string.
|
||||
template <typename T>
|
||||
inline
|
||||
std::string
|
||||
to_string (const T& t)
|
||||
%code // code for the .cc file.
|
||||
{
|
||||
namespace yy
|
||||
{
|
||||
std::ostringstream o;
|
||||
o << t;
|
||||
return o.str ();
|
||||
static]AT_TOKEN_CTOR_IF([[
|
||||
parser::symbol_type yylex ()]], [[
|
||||
parser::token_type yylex (parser::semantic_type* yylval]AT_LOCATION_IF([,
|
||||
parser::location_type* yylloc])[)]])[;
|
||||
|
||||
// Conversion to string.
|
||||
template <typename T>
|
||||
inline
|
||||
std::string
|
||||
to_string (const T& t)
|
||||
{
|
||||
std::ostringstream o;
|
||||
o << t;
|
||||
return o.str ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -252,16 +260,16 @@ typedef std::list<std::string> strings_type;
|
||||
// Using the template type to exercize its parsing.
|
||||
// Starting with :: to ensure we don't output "<::" which starts by the
|
||||
// digraph for the left square bracket.
|
||||
%type <::std::list<std::string>> list;
|
||||
%type <::std::vector<std::string>> list;
|
||||
|
||||
%printer { yyo << $$; }
|
||||
<int> <::std::string> <::std::list<std::string>>;
|
||||
<int> <::std::string> <::std::vector<std::string>>;
|
||||
%destructor { std::cerr << "Destroy: " << $$ << '\n'; } <*>;
|
||||
%destructor { std::cerr << "Destroy: \"" << $$ << "\"\n"; } <::std::string>;
|
||||
%%
|
||||
|
||||
result:
|
||||
list { std::cout << $][1 << std::endl; }
|
||||
list { std::cout << $][1 << '\n'; }
|
||||
;
|
||||
|
||||
list:
|
||||
@@ -497,7 +505,7 @@ void
|
||||
]$1[::parser::error (const ]$1[::parser::location_type &loc,
|
||||
const std::string &msg)
|
||||
{
|
||||
std::cerr << "At " << loc << ": " << msg << std::endl;
|
||||
std::cerr << "At " << loc << ": " << msg << '\n';
|
||||
}
|
||||
|
||||
]AT_MAIN_DEFINE[
|
||||
@@ -565,7 +573,7 @@ AT_DATA_GRAMMAR([[input.y]],
|
||||
%nonassoc 'a' ;
|
||||
|
||||
%destructor {
|
||||
std::cerr << "Discarding 'a'." << std::endl;
|
||||
std::cerr << "Discarding 'a'.\n";
|
||||
} 'a'
|
||||
|
||||
%%
|
||||
@@ -574,7 +582,7 @@ start: error-reduce consistent-error 'a' { USE ($3); };
|
||||
|
||||
error-reduce:
|
||||
'a' 'a' consistent-error 'a' { USE (($1, $2, $4)); }
|
||||
| 'a' error { std::cerr << "Reducing 'a'." << std::endl; USE ($1); }
|
||||
| 'a' error { std::cerr << "Reducing 'a'.\n"; USE ($1); }
|
||||
;
|
||||
|
||||
consistent-error:
|
||||
@@ -598,7 +606,7 @@ yylex (yy::parser::semantic_type *)
|
||||
void
|
||||
yy::parser::error (const std::string &m)
|
||||
{
|
||||
std::cerr << m << std::endl;
|
||||
std::cerr << m << '\n';
|
||||
}
|
||||
|
||||
]AT_MAIN_DEFINE[
|
||||
@@ -626,6 +634,7 @@ AT_BISON_OPTION_PUSHDEFS([%skeleton "lalr1.cc"])
|
||||
|
||||
AT_DATA_GRAMMAR([[input.y]],
|
||||
[[%skeleton "lalr1.cc"
|
||||
%defines
|
||||
|
||||
%code
|
||||
{
|
||||
@@ -644,7 +653,7 @@ start:
|
||||
;
|
||||
|
||||
thing:
|
||||
error { std::cerr << "caught error" << std::endl; }
|
||||
error { std::cerr << "caught error\n"; }
|
||||
| item
|
||||
;
|
||||
|
||||
@@ -657,6 +666,17 @@ item:
|
||||
|
||||
%%
|
||||
|
||||
void
|
||||
yy::parser::error (const std::string &m)
|
||||
{
|
||||
std::cerr << "error: " << m << '\n';
|
||||
}
|
||||
]AT_MAIN_DEFINE[
|
||||
]])
|
||||
|
||||
AT_DATA_SOURCE([input-scan.cc],
|
||||
[[#include "input.hh"
|
||||
|
||||
int
|
||||
yylex (yy::parser::semantic_type *)
|
||||
{
|
||||
@@ -670,16 +690,9 @@ yylex (yy::parser::semantic_type *)
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
yy::parser::error (const std::string &m)
|
||||
{
|
||||
std::cerr << "error: " << m << std::endl;
|
||||
}
|
||||
]AT_MAIN_DEFINE[
|
||||
]])
|
||||
|
||||
AT_FULL_COMPILE([[input]])
|
||||
AT_FULL_COMPILE([[input]], [[scan]])
|
||||
|
||||
AT_PARSER_CHECK([[./input]], [[0]], [[]],
|
||||
[[error: invalid expression
|
||||
@@ -757,6 +770,12 @@ $1
|
||||
Object::instances.erase (i);
|
||||
}
|
||||
|
||||
Object& operator= (const Object& that)
|
||||
{
|
||||
val = that.val;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Object& operator= (char v)
|
||||
{
|
||||
val = v;
|
||||
@@ -790,7 +809,7 @@ $1
|
||||
std::cerr << sep << *i;
|
||||
sep = ", ";
|
||||
}
|
||||
std::cerr << " }" << std::endl;
|
||||
std::cerr << " }\n";
|
||||
}
|
||||
}
|
||||
};
|
||||
@@ -922,11 +941,11 @@ main (int argc, const char *argv[])
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
std::cerr << "exception caught: " << e.what () << std::endl;
|
||||
std::cerr << "exception caught: " << e.what () << '\n';
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
std::cerr << "unknown exception caught" << std::endl;
|
||||
std::cerr << "unknown exception caught\n";
|
||||
}
|
||||
Object::log (YY_NULLPTR, "end");
|
||||
assert (Object::empty());
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Simple calculator. -*- Autotest -*-
|
||||
|
||||
# Copyright (C) 2000-2015 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2000-2015, 2018 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# Exercising Bison on conflicts. -*- Autotest -*-
|
||||
|
||||
# Copyright (C) 2002-2005, 2007-2015 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2002-2005, 2007-2015, 2018 Free Software Foundation,
|
||||
# Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Checking GLR Parsing. -*- Autotest -*-
|
||||
|
||||
# Copyright (C) 2002-2015 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2002-2015, 2018 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
# Exercising Bison on actual grammars. -*- Autotest -*-
|
||||
|
||||
# Copyright (C) 1989-1992, 2000-2005, 2007, 2009-2015 Free Software
|
||||
# Foundation, Inc.
|
||||
# Copyright (C) 1989-1992, 2000-2005, 2007, 2009-2015, 2018 Free
|
||||
# Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Checking GLR Parsing: Regression Tests -*- Autotest -*-
|
||||
|
||||
# Copyright (C) 2002-2003, 2005-2007, 2009-2015 Free Software
|
||||
# Copyright (C) 2002-2003, 2005-2007, 2009-2015, 2018 Free Software
|
||||
# Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
@@ -1755,27 +1755,60 @@ AT_CLEANUP
|
||||
## Predicates. ##
|
||||
## ##
|
||||
## http://lists.gnu.org/archive/html/bug-bison/2013-10/msg00004.html ##
|
||||
## http://lists.gnu.org/archive/html/bug-bison/2018-05/msg00033.html ##
|
||||
## ----------------------------------------------------------------- ##
|
||||
|
||||
AT_SETUP([Predicates])
|
||||
|
||||
# FIXME: We need genuine test cases with uses of %?.
|
||||
|
||||
AT_DATA_GRAMMAR([input.y],
|
||||
[[%glr-parser
|
||||
%error-verbose
|
||||
%expect-rr 1
|
||||
%code requires
|
||||
{
|
||||
#include <assert.h>
|
||||
#include <stdbool.h>
|
||||
bool new_syntax = false;
|
||||
const char *input = YY_NULLPTR;
|
||||
]AT_YYERROR_DECLARE[
|
||||
]AT_YYLEX_DECLARE[
|
||||
}
|
||||
%%
|
||||
// Exercise "%?{...}" and "%? {...}".
|
||||
widget:
|
||||
%? {new_syntax} "widget" id new_args { $$ = f($3, $4); }
|
||||
| %?{!new_syntax} "widget" id old_args { $$ = f($3, $4); }
|
||||
%? {new_syntax} 'w' id new_args { printf("new"); }
|
||||
| %?{!new_syntax} 'w' id old_args { printf("old"); }
|
||||
;
|
||||
id:;
|
||||
new_args:;
|
||||
old_args:;
|
||||
id: 'i';
|
||||
new_args: 'n';
|
||||
old_args: 'o';
|
||||
%%
|
||||
]AT_YYERROR_DEFINE[
|
||||
|
||||
int
|
||||
yylex (void)
|
||||
{
|
||||
return *input++;
|
||||
}
|
||||
|
||||
int
|
||||
main (int argc, const char* argv[])
|
||||
{
|
||||
assert (argc == 2); (void) argc;
|
||||
// First char decides whether new, or old syntax.
|
||||
// Then the input.
|
||||
new_syntax = argv[1][0] == 'N';
|
||||
input = argv[1] + 1;
|
||||
return yyparse ();
|
||||
}
|
||||
]])
|
||||
|
||||
AT_BISON_CHECK([[input.y]])
|
||||
AT_BISON_CHECK([[-o input.c input.y]])
|
||||
AT_COMPILE([input])
|
||||
AT_PARSER_CHECK([[./input Nwin]], [0], [new])
|
||||
AT_PARSER_CHECK([[./input Owin]], [1], [], [[syntax error, unexpected 'n', expecting 'o'
|
||||
]])
|
||||
AT_PARSER_CHECK([[./input Owio]], [0], [old])
|
||||
AT_PARSER_CHECK([[./input Nwio]], [1], [], [[syntax error, unexpected 'o', expecting 'n'
|
||||
]])
|
||||
|
||||
AT_CLEANUP
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Bison Parser Headers. -*- Autotest -*-
|
||||
|
||||
# Copyright (C) 2001-2002, 2006-2007, 2009-2015 Free Software
|
||||
# Copyright (C) 2001-2002, 2006-2007, 2009-2015, 2018 Free Software
|
||||
# Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
@@ -181,7 +181,7 @@ extern "C"
|
||||
do { \
|
||||
int res = S; \
|
||||
if (res) \
|
||||
std::cerr << #S": " << res << std::endl; \
|
||||
std::cerr << #S": " << res << '\n'; \
|
||||
} while (false)
|
||||
|
||||
int
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Checking the Bison scanner. -*- Autotest -*-
|
||||
|
||||
# Copyright (C) 2002-2015 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2002-2015, 2018 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Java tests for simple calculator. -*- Autotest -*-
|
||||
|
||||
# Copyright (C) 2007-2015 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2007-2015, 2018 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Checking Java Push Parsing. -*- Autotest -*-
|
||||
|
||||
# Copyright (C) 2013-2015 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2013-2015, 2018 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -241,10 +241,13 @@ m4_define([AT_CALC_BODY],[
|
||||
static StringReader
|
||||
getinput(String filename) throws IOException
|
||||
{
|
||||
StringBuilder buf = new StringBuilder();
|
||||
// Yes, there are better alternatives to StringBuffer. But we
|
||||
// don't really care about performances here, while portability
|
||||
// to older Java matters.
|
||||
StringBuffer buf = new StringBuffer();
|
||||
FileReader file = new FileReader(filename);
|
||||
int c;
|
||||
while ((c=file.read()) > 0)
|
||||
while (0 < (c = file.read()))
|
||||
buf.append((char)c);
|
||||
file.close();
|
||||
return new StringReader(buf.toString());
|
||||
@@ -302,6 +305,13 @@ exp:
|
||||
;
|
||||
])
|
||||
|
||||
|
||||
|
||||
## ------------------------------------- ##
|
||||
## Calc parser with api.push-pull both. ##
|
||||
## ------------------------------------- ##
|
||||
|
||||
|
||||
# Test that the states transitioned by the push parser are the
|
||||
# same as for the pull parser. This test is assumed to work
|
||||
# if it produces the same partial trace of stack states as is
|
||||
@@ -577,8 +587,9 @@ Stack now 0 7 15
|
||||
]])
|
||||
|
||||
AT_BISON_CHECK([PUSHPULLFLAG [-o Calc.java Calc.y]])
|
||||
|
||||
AT_JAVA_COMPILE([[Calc.java]])
|
||||
#Verify that this is a push parser.
|
||||
# Verify that this is a push parser.
|
||||
AT_CHECK_JAVA_GREP([[Calc.java]],
|
||||
[[.*public void push_parse_initialize().*]])
|
||||
# Capture stderr output for comparison purposes.
|
||||
@@ -593,6 +604,13 @@ AT_CHECK([[sed -e '/^Stack now.*$/p' -e d ./stderr]],
|
||||
AT_BISON_OPTION_POPDEFS
|
||||
AT_CLEANUP
|
||||
|
||||
|
||||
|
||||
## ---------------------------------------------------------------- ##
|
||||
## Calc parser with %locations %code lexer and api.push-pull both. ##
|
||||
## ---------------------------------------------------------------- ##
|
||||
|
||||
|
||||
# This test looks for location reporting by looking
|
||||
# at the lexer output with locations enabled.
|
||||
# It defines a lexer that reports location info.
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
# Macros for the GNU Bison Test suite.
|
||||
|
||||
# Copyright (C) 2003-2015 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2003-2015, 2018 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -539,7 +539,7 @@ m4_define([AT_YYERROR_DEFINE(c++)],
|
||||
void
|
||||
]AT_NAME_PREFIX[::parser::error (]AT_LOCATION_IF([[const location_type& l, ]])[const std::string& m)
|
||||
{
|
||||
std::cerr << ]AT_LOCATION_IF([l << ": " << ])[m << std::endl;
|
||||
std::cerr << ]AT_LOCATION_IF([l << ": " << ])[m << '\n';
|
||||
}]])
|
||||
|
||||
|
||||
@@ -892,7 +892,7 @@ void foo()
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
std::cerr << "Inner caught" << std::endl;
|
||||
std::cerr << "Inner caught\n";
|
||||
throw;
|
||||
}
|
||||
}
|
||||
@@ -905,7 +905,7 @@ int main()
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
std::cerr << "Outer caught" << std::endl;
|
||||
std::cerr << "Outer caught\n";
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
## Makefile for Bison testsuite.
|
||||
|
||||
# Copyright (C) 2000-2015 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2000-2015, 2018 Free Software Foundation, Inc.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -108,11 +108,13 @@ maintainer-check-posix: $(RUN_TESTSUITE_deps)
|
||||
$(RUN_TESTSUITE) POSIXLY_CORRECT=1 _POSIX2_VERSION=200112
|
||||
|
||||
.PHONY: maintainer-check-valgrind
|
||||
VALGRIND_OPTS = --leak-check=full --show-reachable=yes --gen-suppressions=all \
|
||||
$(VALGRIND_OPTS_SUPPRESSION)
|
||||
maintainer-check-valgrind: $(RUN_TESTSUITE_deps)
|
||||
test -z '$(VALGRIND)' || \
|
||||
test 'x$(VALGRIND)' != x || \
|
||||
$(RUN_TESTSUITE) \
|
||||
PREBISON='$(VALGRIND_PREBISON)' PREPARSER='$(VALGRIND) -q' \
|
||||
VALGRIND_OPTS='--leak-check=full --show-reachable=yes'
|
||||
PREBISON='$(VALGRIND) -q' PREPARSER='$(VALGRIND) -q' \
|
||||
VALGRIND_OPTS="$(VALGRIND_OPTS)"
|
||||
|
||||
.PHONY: maintainer-check
|
||||
maintainer-check: maintainer-check-posix maintainer-check-valgrind maintainer-check-g++
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Named references test. -*- Autotest -*-
|
||||
|
||||
# Copyright (C) 2009-2015 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2009-2015, 2018 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# Checking the output filenames. -*- Autotest -*-
|
||||
|
||||
# Copyright (C) 2000-2002, 2005-2015 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2000-2002, 2005-2015, 2018 Free Software Foundation,
|
||||
# Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Checking Push Parsing. -*- Autotest -*-
|
||||
|
||||
# Copyright (C) 2007, 2009-2015 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2007, 2009-2015, 2018 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# Exercising Bison Grammar Reduction. -*- Autotest -*-
|
||||
|
||||
# Copyright (C) 2001-2002, 2007-2015 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2001-2002, 2007-2015, 2018 Free Software Foundation,
|
||||
# Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Bison Regressions. -*- Autotest -*-
|
||||
|
||||
# Copyright (C) 2001-2015 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2001-2015, 2018 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Exercising Bison Grammar Sets. -*- Autotest -*-
|
||||
|
||||
# Copyright (C) 2001-2002, 2005, 2007, 2009-2015 Free Software
|
||||
# Copyright (C) 2001-2002, 2005, 2007, 2009-2015, 2018 Free Software
|
||||
# Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Checking skeleton support. -*- Autotest -*-
|
||||
|
||||
# Copyright (C) 2007, 2009-2015 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2007, 2009-2015, 2018 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Executing Actions. -*- Autotest -*-
|
||||
|
||||
# Copyright (C) 2002, 2004-2005, 2007, 2009-2015 Free Software
|
||||
# Copyright (C) 2002, 2004-2005, 2007, 2009-2015, 2018 Free Software
|
||||
# Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
@@ -81,7 +81,15 @@ m4_define([_AT_SYNCLINES_COMPILE],
|
||||
#
|
||||
# "input.yy", line 80.21: 1540-0218 (S) The call does not match any parameter list for "operator<<".
|
||||
# "/usr/vacpp/include/iosfwd", line 32.6: 1506-205 (S) #error This file to be used only with IBM VisualAge C++ v4 and later compilers
|
||||
|
||||
#
|
||||
# Newer GCCs go further and if the function is declared static, complain
|
||||
# that it's not used.
|
||||
#
|
||||
# GCC 7 also underlines the error.
|
||||
#
|
||||
# syncline.c:4:2: error: #error "4"
|
||||
# #error "4"
|
||||
# ^~~~~
|
||||
AT_CHECK([[$PERL -p -0777 - stderr <<\EOF
|
||||
# 1. Remove useless lines.
|
||||
|
||||
@@ -91,8 +99,8 @@ AT_CHECK([[$PERL -p -0777 - stderr <<\EOF
|
||||
s/^clang: warning: treating 'c' input as 'c\+\+'.*\n//gm;
|
||||
# Function context.
|
||||
s/^[^:]*: In function '[^']+':\n//gm;
|
||||
# Caret error.
|
||||
s/^ *#error.*\n *\^\n//gm;
|
||||
# Caret error (with possible '~' to underline).
|
||||
s/^ *#error.*\n *\^~*\n//gm;
|
||||
# Number of errors.
|
||||
s/^1 error generated\.\n//gm;
|
||||
|
||||
@@ -136,12 +144,15 @@ EOF
|
||||
m4_define([AT_SYNCLINES_COMPILE],
|
||||
[# Check if we can trust location translation.
|
||||
AT_DATA([syncline.c],
|
||||
[[#error "1"
|
||||
int i; /* avoids -pedantic warning about an empty translation unit. */
|
||||
[[void foo (void);
|
||||
void foo (void)
|
||||
{
|
||||
#error "4"
|
||||
}
|
||||
]])
|
||||
|
||||
_AT_SYNCLINES_COMPILE([syncline.c])
|
||||
AT_CHECK([[test "`cat stdout`" = 'syncline.c:1: @%:@error "1"' || exit 77]])
|
||||
AT_CHECK([[test "`cat stdout`" = 'syncline.c:4: @%:@error "4"' || exit 77]])
|
||||
|
||||
# Then work for real.
|
||||
_AT_SYNCLINES_COMPILE([$1])
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Test suite for GNU Bison. -*- Autotest -*-
|
||||
|
||||
# Copyright (C) 2000-2004, 2006-2007, 2009-2015 Free Software
|
||||
# Copyright (C) 2000-2004, 2006-2007, 2009-2015, 2018 Free Software
|
||||
# Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Torturing Bison. -*- Autotest -*-
|
||||
|
||||
# Copyright (C) 2001-2002, 2004-2007, 2009-2015 Free Software
|
||||
# Copyright (C) 2001-2002, 2004-2007, 2009-2015, 2018 Free Software
|
||||
# Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# Value type. -*- Autotest -*-
|
||||
|
||||
# Copyright (C) 2013-2015 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2013-2015, 2018 Free Software Foundation, Inc.
|
||||
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
@@ -243,7 +243,7 @@ m4_foreach([b4_skel], [[yacc.c], [glr.c], [lalr1.cc], [glr.cc]],
|
||||
%define api.value.type variant],
|
||||
[%token <int> '1';
|
||||
%token <std::string> '2';],
|
||||
['1' '2' { std::cout << $1 << ", " << $2 << std::endl; }],
|
||||
['1' '2' { std::cout << $1 << ", " << $2 << '\n'; }],
|
||||
["12"],
|
||||
[if (res == '1')
|
||||
AT_VAL.build(10);
|
||||
|
||||
Reference in New Issue
Block a user