From: Akim Demaille Date: Mon, 25 Jun 2012 07:26:48 +0000 (+0200) Subject: Merge remote-tracking branch 'origin/maint' X-Git-Tag: v2.7.90~423 X-Git-Url: https://git.saurik.com/bison.git/commitdiff_plain/6cf3716c3166d6d41cdbeea45d018b1760184421 Merge remote-tracking branch 'origin/maint' * origin/maint: tests: more uniformity. tests: handle locations in a more generic way. tests: handle locations in the generic yyerror functions. tests: fix AT_CHECK_CALC. tests: improve infrastructure tests: factor. skeletons: minor style changes tests: AT_LANG. c skeletons: factor the declaration of yylloc and yylval. news: condemn YYPARSE_PARAM and YYLEX_PARAM. maint: regen. Conflicts: tests/calc.at tests/local.at tests/regression.at --- 6cf3716c3166d6d41cdbeea45d018b1760184421 diff --cc doc/bison.texinfo index 3f24b9ac,4f2e1c62..d1223bdc --- a/doc/bison.texinfo +++ b/doc/bison.texinfo @@@ -6265,18 -6011,18 +6265,18 @@@ For instance @end example @noindent - results in the following signature: + results in the following signatures: @example -int yylex (int *nastiness); -int yyparse (int *nastiness, int *randomness); +int yylex (scanner_mode *mode, environment_type *env); +int yyparse (parser_mode *mode, environment_type *env); @end example -If @code{%define api.pure} is added: +If @samp{%define api.pure} is added: @example -int yylex (YYSTYPE *lvalp, int *nastiness); -int yyparse (int *nastiness, int *randomness); +int yylex (YYSTYPE *lvalp, scanner_mode *mode, environment_type *env); +int yyparse (parser_mode *mode, environment_type *env); @end example @noindent diff --cc src/output.c index e8cff20e,e0d6ed3a..6ff6a9b8 --- a/src/output.c +++ b/src/output.c @@@ -581,13 -496,32 +581,13 @@@ output_skeleton (void pid_t pid; /* Compute the names of the package data dir and skeleton files. */ - char const m4sugar[] = "m4sugar/m4sugar.m4"; - char const m4bison[] = "bison.m4"; - char *full_m4sugar; - char *full_m4bison; - char *full_skeleton; - char const *p; - char const *m4 = (p = getenv ("M4")) ? p : M4; - char const *pkgdatadir = compute_pkgdatadir (); - size_t skeleton_size = strlen (skeleton) + 1; - size_t pkgdatadirlen = strlen (pkgdatadir); - while (pkgdatadirlen && pkgdatadir[pkgdatadirlen - 1] == '/') - pkgdatadirlen--; - full_skeleton = xmalloc (pkgdatadirlen + 1 - + (skeleton_size < sizeof m4sugar - ? sizeof m4sugar : skeleton_size)); - memcpy (full_skeleton, pkgdatadir, pkgdatadirlen); - full_skeleton[pkgdatadirlen] = '/'; - strcpy (full_skeleton + pkgdatadirlen + 1, m4sugar); - full_m4sugar = xstrdup (full_skeleton); - strcpy (full_skeleton + pkgdatadirlen + 1, m4bison); - full_m4bison = xstrdup (full_skeleton); - if (mbschr (skeleton, '/')) - strcpy (full_skeleton, skeleton); - else - strcpy (full_skeleton + pkgdatadirlen + 1, skeleton); + char const *m4 = (m4 = getenv ("M4")) ? m4 : M4; + char const *datadir = pkgdatadir (); + char *m4sugar = xconcatenated_filename (datadir, "m4sugar/m4sugar.m4", NULL); + char *m4bison = xconcatenated_filename (datadir, "bison.m4", NULL); + char *skel = (IS_PATH_WITH_DIR (skeleton) - ? xstrdup (skeleton) - : xconcatenated_filename (datadir, skeleton, NULL)); ++ ? xstrdup (skeleton) ++ : xconcatenated_filename (datadir, skeleton, NULL)); /* Test whether m4sugar.m4 is readable, to check for proper installation. A faulty installation can cause deadlock, so a diff --cc tests/calc.at index 5c6c4cc1,836c3a33..0a9f9e11 --- a/tests/calc.at +++ b/tests/calc.at @@@ -206,9 -205,9 +205,9 @@@ read_signed_integer (]AT_YYLEX_FORMALS[ /* process numbers */ if (c == '.' || isdigit (c)) { - unget_char (]AT_LEX_PRE_ARGS[ c); - ]AT_VAL[.ival = read_signed_integer (]AT_LEX_ARGS[); + unget_char (]AT_YYLEX_PRE_ARGS[ c); + ]AT_VAL[.ival = read_signed_integer (]AT_YYLEX_ARGS[); - return NUM; + return ]AT_TOKEN_PREFIX[NUM; } /* Return end-of-file. */ @@@ -295,10 -291,10 +291,10 @@@ static int power (int base, int exponen AT_PARAM_IF([semantic_value *result, int *count, ]) const char *s );])[ - int yylex (]AT_LEX_FORMALS[); + ]AT_YYLEX_DECLARE_EXTERN[ } -]AT_SKEL_CC_IF([AT_LOCATION_TYPE_IF([], [ +]AT_SKEL_CC_IF([AT_LOCATION_IF([AT_LOCATION_TYPE_IF([], [ /* The lalr1.cc skeleton, for backward compatibility, defines a constructor for position that initializes the filename. The glr.cc skeleton does not (and in fact cannot: location/position diff --cc tests/local.at index f43ffde8,b0e4ee1a..649e9943 --- a/tests/local.at +++ b/tests/local.at @@@ -135,15 -138,12 +138,15 @@@ m4_pushdef([AT_GLR_OR_PARAM_IF] [m4_bmatch([$3], [%glr-parser\|%parse-param], [$1], [$2])]) m4_pushdef([AT_NAME_PREFIX], [m4_bmatch([$3], [%name-prefix ".*"], - [m4_bregexp([$3], [name-prefix "\([^""]*\)"], [\1])], + [m4_bregexp([$3], [%name-prefix "\([^""]*\)"], [\1])], [yy])]) m4_pushdef([AT_API_PREFIX], - [m4_bmatch([$3], [%define api\.prefix ".*"], - [m4_bregexp([$3], [%define api\.prefix "\([^""]*\)"], [\1])], + [m4_bmatch([$3], [\(%define api\.prefix\|%name-prefix\) ".*"], + [m4_bregexp([$3], [\(%define api\.prefix\|%name-prefix\) "\([^""]*\)"], [\2])], [yy])]) +m4_pushdef([AT_TOKEN_PREFIX], +[m4_bmatch([$3], [%define api.tokens.prefix ".*"], + [m4_bregexp([$3], [%define api.tokens.prefix "\(.*\)"], [\1])])]) # yyerror receives the location if %location & %pure & (%glr or %parse-param). m4_pushdef([AT_YYERROR_ARG_LOC_IF], [AT_GLR_OR_PARAM_IF([AT_PURE_AND_LOC_IF([$1], [$2])], @@@ -165,16 -165,16 +168,16 @@@ m4_pushdef([AT_PURE_LEX_IF] AT_PURE_LEX_IF( [m4_pushdef([AT_LOC], [(*llocp)]) m4_pushdef([AT_VAL], [(*lvalp)]) - m4_pushdef([AT_LEX_FORMALS], + m4_pushdef([AT_YYLEX_FORMALS], - [YYSTYPE *lvalp[]AT_LOCATION_IF([, YYLTYPE *llocp])]) + [YYSTYPE *lvalp[]AT_LOCATION_IF([, YYLTYPE *llocp])]) - m4_pushdef([AT_LEX_ARGS], + m4_pushdef([AT_YYLEX_ARGS], - [lvalp[]AT_LOCATION_IF([, llocp])]) + [lvalp[]AT_LOCATION_IF([, llocp])]) m4_pushdef([AT_USE_LEX_ARGS], - [(void) lvalp;AT_LOCATION_IF([(void) llocp])]) + [(void) lvalp;AT_LOCATION_IF([(void) llocp])]) - m4_pushdef([AT_LEX_PRE_FORMALS], - [AT_LEX_FORMALS, ]) - m4_pushdef([AT_LEX_PRE_ARGS], - [AT_LEX_ARGS, ]) + m4_pushdef([AT_YYLEX_PRE_FORMALS], + [AT_YYLEX_FORMALS, ]) + m4_pushdef([AT_YYLEX_PRE_ARGS], + [AT_YYLEX_ARGS, ]) ], [m4_pushdef([AT_LOC], [[(]AT_NAME_PREFIX[lloc)]]) m4_pushdef([AT_VAL], [[(]AT_NAME_PREFIX[lval)]]) @@@ -322,21 -338,46 +343,44 @@@ m4_define([AT_YYERROR_DECLARE] ]) m4_define([AT_YYERROR_DEFINE], - [AT_SKEL_JAVA_IF([[public void yyerror (String msg) - { - System.err.println (msg); - }]], [AT_SKEL_CC_IF([[void - yy::parser::error (]AT_LOCATION_IF([[const yy::location &, ]])[std::string const &msg) - { - std::cerr << msg << std::endl; - }]], [[#include - static void - ]AT_API_PREFIX[error (char const *msg) + [m4_case(AT_LANG, + [c], [[#include + /* A C error reporting function. */ + static + ]AT_YYERROR_PROTOTYPE[ { + ]AT_YYERROR_SEES_LOC_IF([[ + fprintf (stderr, "%d.%d", + ]AT_LOC_FIRST_LINE[, ]AT_LOC_FIRST_COLUMN[); + if (]AT_LOC_FIRST_LINE[ != ]AT_LOC_LAST_LINE[) + fprintf (stderr, "-%d.%d", + ]AT_LOC_LAST_LINE[, ]AT_LOC_LAST_COLUMN[ - 1); + else if (]AT_LOC_FIRST_COLUMN[ != ]AT_LOC_LAST_COLUMN[ - 1) + fprintf (stderr, "-%d", + ]AT_LOC_LAST_COLUMN[ - 1); + fprintf (stderr, ": ");]])[ fprintf (stderr, "%s\n", msg); + }]], + [c++], [[/* A C++ error reporting function. */ + void -]AT_NAME_PREFIX[::parser::error (const location_type& l, const std::string& m) -{ - (void) l; - std::cerr << ]AT_LOCATION_IF([l << ": " << ])[m << std::endl; ++]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; + }]], + [java], [AT_LOCATION_IF([[public void yyerror (Calc.Location l, String s) - { ++{ + if (l == null) + System.err.println (s); + else + System.err.println (l + ": " + s); + } + ]], [[ + public void yyerror (String s) + { + System.err.println (s); - }]])])dnl +}]])])dnl ]) + ## --------------- ## ## Running Bison. ## ## --------------- ## @@@ -531,31 -581,29 +584,29 @@@ m4_define([AT_LANG_COMPILE] # OUTPUT-OTHER.c, OUTPUT-OTHER.cc, or OUTPUT-OTHER.java to OUTPUT or # OUTPUT.java along with it. Relies on AT_SKEL_CC_IF and # AT_SKEL_JAVA_IF. - m4_define([AT_FULL_COMPILE], [ - AT_SKEL_JAVA_IF([ - AT_BISON_CHECK([-o $1.java $1.y]) - AT_JAVA_COMPILE([$1.java], + m4_define([AT_FULL_COMPILE], + [m4_case(AT_LANG, + [java], + [AT_BISON_CHECK([-o $1.java $1.y]) + AT_LANG_COMPILE([$1], - m4_join([ ], - [$1.java], - m4_ifval($2, [[$1-$2.java]]), + m4_join([ ], + [$1.java], + m4_ifval($2, [[$1-$2.java]]), - m4_ifval($3, [[$1-$3.java]]))) - ], [ - AT_SKEL_CC_IF([ - AT_BISON_CHECK([-o $1.cc $1.y]) - AT_COMPILE_CXX([$1], + m4_ifval($3, [[$1-$3.java]])))], + [c++], + [AT_BISON_CHECK([-o $1.cc $1.y]) + AT_LANG_COMPILE([$1], - m4_join([ ], - [$1.cc], - m4_ifval($2, [[$1-$2.cc]]), + m4_join([ ], + [$1.cc], + m4_ifval($2, [[$1-$2.cc]]), - m4_ifval($3, [[$1-$3.cc]]))) - ], [ - AT_BISON_CHECK([-o $1.c $1.y]) - AT_COMPILE([$1], + m4_ifval($3, [[$1-$3.cc]])))], + [c], + [AT_BISON_CHECK([-o $1.c $1.y]) + AT_LANG_COMPILE([$1], - m4_join([ ], - [$1.c], - m4_ifval($2, [[$1-$2.c]]), + m4_join([ ], + [$1.c], + m4_ifval($2, [[$1-$2.c]]), - m4_ifval($3, [[$1-$3.c]]))) - ]) - ]) + m4_ifval($3, [[$1-$3.c]])))]) ])