]> git.saurik.com Git - bison.git/commitdiff
Merge remote-tracking branch 'origin/maint'
authorAkim Demaille <akim@lrde.epita.fr>
Mon, 3 Dec 2012 15:27:23 +0000 (16:27 +0100)
committerAkim Demaille <akim@lrde.epita.fr>
Mon, 3 Dec 2012 15:27:23 +0000 (16:27 +0100)
* origin/maint:
  parser: accept #line NUM
  m4: use a safer pattern to enable/disable output
  tests: beware of gnulib's need for config.h
  gnulib: update
  yacc.c, glr.c: check and fix the display of locations
  formatting changes
  glr.c: remove stray macro

Conflicts:
data/c.m4
data/glr.cc
data/lalr1.cc
data/lalr1.java
data/location.cc
data/stack.hh
data/yacc.c
src/scan-gram.l

16 files changed:
1  2 
THANKS
data/bison.m4
data/c.m4
data/glr.c
data/glr.cc
data/lalr1.cc
data/lalr1.java
data/location.cc
data/stack.hh
data/yacc.c
lib/.gitignore
m4/.gitignore
src/location.c
src/scan-gram.l
tests/actions.at
tests/skeletons.at

diff --cc THANKS
Simple merge
diff --cc data/bison.m4
Simple merge
diff --cc data/c.m4
index 91126a82b84ef325cb83ed406f5d4b0fdf33c2a1,dc3d303616d7e3c746756ccf7252de28e9b67fa6..6c2f552583ef3757f1c44996fd586c45c1039ea6
+++ b/data/c.m4
@@@ -610,14 -655,40 +610,40 @@@ m4_define([b4_yy_location_print_define]
  
  #ifndef YY_LOCATION_PRINT
  # if defined ]b4_api_PREFIX[LTYPE_IS_TRIVIAL && ]b4_api_PREFIX[LTYPE_IS_TRIVIAL
 -]b4_c_function_def([yy_location_print_],
+ /* Print *YYLOCP on YYO.  Private, do not rely on its existence. */
+ __attribute__((__unused__))
 -#  define YY_LOCATION_PRINT(File, Loc)          \
++]b4_function_define([yy_location_print_],
+     [static unsigned],
+                [[FILE *yyo],                    [yyo]],
+                [[YYLTYPE const * const yylocp], [yylocp]])[
+ {
+   unsigned res = 0;
+   int end_col = 0 != yylocp->last_column ? yylocp->last_column - 1 : 0;
+   if (0 <= yylocp->first_line)
+     {
+       res += fprintf (yyo, "%d", yylocp->first_line);
+       if (0 <= yylocp->first_column)
+         res += fprintf (yyo, ".%d", yylocp->first_column);
+     }
+   if (0 <= yylocp->last_line)
+     {
+       if (yylocp->first_line < yylocp->last_line)
+         {
+           res += fprintf (yyo, "-%d", yylocp->last_line);
+           if (0 <= end_col)
+             res += fprintf (yyo, ".%d", end_col);
+         }
+       else if (0 <= end_col && yylocp->first_column < end_col)
+         res += fprintf (yyo, "-%d", end_col);
+     }
+   return res;
+  }
-   do {                                                                   \
-     fprintf (File, "%d.%d", (Loc).first_line, (Loc).first_column);       \
-     if ((Loc).first_line < (Loc).last_line)                              \
-       fprintf (File, "-%d.%d", (Loc).last_line,  (Loc).last_column - 1); \
-     else if ((Loc).first_column < (Loc).last_column - 1)                 \
-       fprintf (File, "-%d", (Loc).last_column - 1);                      \
-   } while (0)
 +#  define YY_LOCATION_PRINT(File, Loc)                                   \
+   yy_location_print_ (File, &(Loc))
  # else
  #  define YY_LOCATION_PRINT(File, Loc) ((void) 0)
  # endif
diff --cc data/glr.c
Simple merge
diff --cc data/glr.cc
index 8841f10be51d31b646c7859cfb1b26289b6afae9,49b4fa1079a5b69b90e34d05d5a14ccf4cebfb3d..3cecfd8eb4ca406f4d44e71b99ce3446f0b9fc17
@@@ -304,32 -342,5 +304,31 @@@ b4_percent_define_flag_if([[global_toke
  
  ]b4_namespace_close[
  ]b4_percent_code_get([[provides]])[
 +]m4_popdef([b4_parse_param])dnl
 +])
 +
 +b4_defines_if(
 +[m4_changecom()dnl
 +m4_divert_push(0)dnl
 +@output(b4_spec_defines_file@)@
 +b4_copyright([Skeleton interface for Bison GLR parsers in C++],
 +             [2002-2012])[
 +
 +/* C++ GLR parser skeleton written by Akim Demaille.  */
 +
 +]b4_cpp_guard_open([b4_spec_defines_file])[
 +]b4_shared_declarations[
  ]b4_cpp_guard_close([b4_spec_defines_file])[
- ]m4_divert_pop(0)
- m4_changecom[#])])
 -]b4_output_end()
++]b4_output_end()])
 +
 +# Let glr.c (and b4_shared_declarations) believe that the user
 +# arguments include the parser itself.
 +m4_ifset([b4_parse_param],
 +[m4_pushdef([b4_parse_param],
 +            [[b4_namespace_ref::b4_parser_class_name[& yyparser], [[yyparser]]],]
 +m4_defn([b4_parse_param]))],
 +[m4_pushdef([b4_parse_param],
 +            [[b4_namespace_ref::b4_parser_class_name[& yyparser], [[yyparser]]]])
 +])
 +m4_include(b4_pkgdatadir/[glr.c])
 +m4_popdef([b4_parse_param])
diff --cc data/lalr1.cc
index 34eef13801a661d2db596f4d0da6612f7521d1fd,237b246f5be6490e7393028c86f425d1b57fc4c5..fa3a48d484af0e623b108a4ba504786c2d6e4ff9
@@@ -333,32 -261,14 +333,31 @@@ b4_public_types_define])
  #endif
  ])[
  ]b4_percent_code_get([[provides]])[
 +]])
 +
 +# We do want M4 expansion after # for CPP macros.
 +m4_changecom()
 +b4_defines_if(
 +[m4_divert_push(0)dnl
 +@output(b4_spec_defines_file@)@
 +b4_copyright([Skeleton interface for Bison LALR(1) parsers in C++])
 +[
 +/**
 + ** \file ]b4_spec_defines_file[
 + ** Define the ]b4_namespace_ref[::parser class.
 + */
 +
 +/* C++ LALR(1) parser skeleton written by Akim Demaille.  */
 +
 +]b4_cpp_guard_open([b4_spec_defines_file])[
 +]b4_shared_declarations[
  ]b4_cpp_guard_close([b4_spec_defines_file])
- m4_divert_pop(0)dnl
+ b4_output_end()
  ])
  
  
- m4_divert_push(0)dnl
- @output(b4_parser_file_name@)@
+ b4_output_begin([b4_parser_file_name])
 -b4_copyright([Skeleton implementation for Bison LALR(1) parsers in C++],
 -             [2002-2012])
 +b4_copyright([Skeleton implementation for Bison LALR(1) parsers in C++])
  b4_percent_code_get([[top]])[]dnl
  m4_if(b4_prefix, [yy], [],
  [
@@@ -1138,8 -1110,34 +1137,10 @@@ b4_error_verbose_if([state_type yystate
    }
  #endif // ]b4_api_PREFIX[DEBUG
  
 -  /* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
 -  ]b4_parser_class_name[::token_number_type
 -  ]b4_parser_class_name[::yytranslate_ (int t)
 -  {
 -    static
 -    const token_number_type
 -    translate_table[] =
 -    {
 -      ]b4_translate[
 -    };
 -    if ((unsigned int) t <= yyuser_token_number_max_)
 -      return translate_table[t];
 -    else
 -      return yyundef_token_;
 -  }
 -
 -  const int ]b4_parser_class_name[::yyeof_ = 0;
 -  const int ]b4_parser_class_name[::yylast_ = ]b4_last[;
 -  const int ]b4_parser_class_name[::yynnts_ = ]b4_nterms_number[;
 -  const int ]b4_parser_class_name[::yyempty_ = -2;
 -  const int ]b4_parser_class_name[::yyfinal_ = ]b4_final_state_number[;
 -  const int ]b4_parser_class_name[::yyterror_ = 1;
 -  const int ]b4_parser_class_name[::yyerrcode_ = 256;
 -  const int ]b4_parser_class_name[::yyntokens_ = ]b4_tokens_number[;
 -
 -  const unsigned int ]b4_parser_class_name[::yyuser_token_number_max_ = ]b4_user_token_number_max[;
 -  const ]b4_parser_class_name[::token_number_type ]b4_parser_class_name[::yyundef_token_ = ]b4_undef_token_number[;
 -
 +]b4_token_ctor_if([], [b4_yytranslate_define])[
  ]b4_namespace_close[
  ]b4_epilogue[]dnl
- m4_divert_pop(0)
+ b4_output_end()
++
++
 +m4_popdef([b4_copyright_years])dnl
diff --cc data/lalr1.java
index 1cfaef38caf15686beb2d9731ae46215d5af92b5,e961fc5b450f56a1d3a3ac31eede13b713b8205c..02079fd0a2f63efb1578f3bd2081fd6edc9fff71
  
  m4_include(b4_pkgdatadir/[java.m4])
  
 -b4_defines_if([b4_fatal([%s: %%defines does not make sense in Java], [b4_skeleton])])
 -m4_ifval(m4_defn([b4_symbol_destructors]),
 -        [b4_fatal([%s: %%destructor does not make sense in Java], [b4_skeleton])],
 -        [])
 +b4_defines_if([b4_fatal([%s: %%defines does not make sense in Java],
 +              [b4_skeleton])])
 +
 +# We don't depend on %debug in Java, but pacify warnings about non-used flags.
 +b4_parse_trace_if([0], [0])
 +
 +m4_define([b4_symbol_no_destructor_assert],
 +[b4_symbol_if([$1], [has_destructor],
 +              [b4_fatal([%s: %s: %%destructor does not make sense in Java],
 +                        [b4_skeleton],
 +                        [b4_symbol_action_location([$1], [destructor])])])])
 +b4_symbol_foreach([b4_symbol_no_destructor_assert])
  
- m4_divert_push(0)dnl
- @output(b4_parser_file_name@)@
+ b4_output_begin([b4_parser_file_name])
  b4_copyright([Skeleton implementation for Bison LALR(1) parsers in Java],
               [2007-2012])
  
@@@ -873,5 -923,5 +872,5 @@@ b4_percent_code_get[]dn
  
  }
  
 -b4_epilogue
 +b4_epilogue[]dnl
- m4_divert_pop(0)dnl
+ b4_output_end()
index 5879ea374e581bf331b67d30a67baa3c589cb5b1,58182a34acfe048966e8998eb29d1327ed9df45e..b49028f9559ac6ec0236486def75ea0fa92451c8
@@@ -262,50 -289,8 +262,53 @@@ m4_define([b4_location_define]
        ostr << '-' << last.column;
      return ostr;
    }
 +]])
 +
  
- m4_divert_push(0)dnl
- @output(b4_dir_prefix[]position.hh@)@
 +# We do want M4 expansion after # for CPP macros.
 +m4_changecom()
 +b4_defines_if([
++b4_output_begin([b4_dir_prefix[]position.hh])
 +b4_copyright([Positions for Bison parsers in C++])[
 +
 +/**
 + ** \file ]b4_dir_prefix[position.hh
 + ** Define the ]b4_namespace_ref[::position class.
 + */
 +
 +]b4_cpp_guard_open([b4_dir_prefix[]position.hh])[
 +
 +# include <algorithm> // std::max
 +# include <iostream>
 +# include <string>
 +
 +]b4_null_define[
 +
 +]b4_namespace_open[
 +]b4_position_define[
  ]b4_namespace_close[
- @output(b4_dir_prefix[]location.hh@)@
 +]b4_cpp_guard_close([b4_dir_prefix[]position.hh])
++b4_output_end()
++
++
++b4_output_begin([b4_dir_prefix[]location.hh])
 +b4_copyright([Locations for Bison parsers in C++])[
 +
 +/**
 + ** \file ]b4_dir_prefix[location.hh
 + ** Define the ]b4_namespace_ref[::location class.
 + */
  
 +]b4_cpp_guard_open([b4_dir_prefix[]location.hh])[
 +
 +# include "position.hh"
 +
 +]b4_namespace_open[
 +]b4_location_define[
 +]b4_namespace_close[
  ]b4_cpp_guard_close([b4_dir_prefix[]location.hh])
- m4_divert_pop(0)
- ])# b4_defines_if
- m4_popdef([b4_copyright_years])dnl
- m4_changecom([#])
+ b4_output_end()
++])
++
++
++m4_popdef([b4_copyright_years])
diff --cc data/stack.hh
index bd94eb2da5dded1256f7ed840257ae72d4adebf3,ab1049c184d4f111513e6bb33ecb00f8b888bab9..4fd136fd2d55f9203aed75b2728be67665aeae9e
@@@ -116,30 -113,9 +116,27 @@@ m4_define([b4_stack_define]
      const S& stack_;
      unsigned int range_;
    };
- [# We do want M4 expansion after # for CPP macros.
- m4_changecom()
- m4_divert_push(0)dnl
- @output(b4_dir_prefix[]stack.hh@)@
 +]])
 +
 +b4_defines_if(
++[b4_output_begin([b4_dir_prefix[]stack.hh])
 +b4_copyright([Stack handling for Bison parsers in C++])[
 +
 +/**
 + ** \file ]b4_dir_prefix[stack.hh
 + ** Define the ]b4_namespace_ref[::stack class.
 + */
 +
 +]b4_cpp_guard_open([b4_dir_prefix[]stack.hh])[
 +
 +# include <deque>
 +
 +]b4_namespace_open[
 +]b4_stack_define[
  ]b4_namespace_close[
  
  ]b4_cpp_guard_close([b4_dir_prefix[]stack.hh])
- m4_divert_pop(0)
- m4_popdef([b4_copyright_years])dnl
- m4_changecom([#])
+ b4_output_end()
 +])
+ m4_popdef([b4_copyright_years])
diff --cc data/yacc.c
index 2b6d10acbb3b7e5c67bf9d881a4d2951a42b6bf3,810e2b21a0726c8544433e37a1160c6adf477c93..9bd80280bd7d26cdbe06c46b56d706b10f76b456
@@@ -326,11 -331,9 +326,8 @@@ m4_define([b4_shared_declarations]
  ## Output files.  ##
  ## -------------- ##
  
- # We do want M4 expansion after # for CPP macros.
- m4_changecom()
- m4_divert_push(0)dnl
- @output(b4_parser_file_name@)@
+ b4_output_begin([b4_parser_file_name])
 -b4_copyright([Bison implementation for Yacc-like parsers in C],
 -             [1984, 1989-1990, 2000-2012])[
 +b4_copyright([Bison implementation for Yacc-like parsers in C])[
  
  /* C LALR(1) parser skeleton written by Richard Stallman, by
     simplifying the original so-called "semantic" parser.  */
@@@ -1938,14 -2044,19 +1935,15 @@@ yypushreturn:]])
    if (yymsg != yymsgbuf)
      YYSTACK_FREE (yymsg);
  #endif
 -  /* Make sure YYID is used.  */
 -  return YYID (yyresult);
 +  return yyresult;
  }
 -
 -
  ]b4_epilogue[]dnl
+ b4_output_end()
  b4_defines_if(
- [@output(b4_spec_defines_file@)@
- b4_copyright([Bison interface for Yacc-like parsers in C])[
+ [b4_output_begin([b4_spec_defines_file])[
 -]b4_copyright([Bison interface for Yacc-like parsers in C],
 -              [1984, 1989-1990, 2000-2012])[
++]b4_copyright([Bison interface for Yacc-like parsers in C])[
  
  ]b4_shared_declarations[
- ]])dnl b4_defines_if
- m4_divert_pop(0)
- m4_popdef([b4_copyright_years])
+ ]b4_output_end()
 -])
++])# b4_defines_if
diff --cc lib/.gitignore
index e62b99c31b56485a4780d3754d55da6eab5fe10a,15354476e5f604ff5861116b24c9143ba3bf718c..ba37d129a39e3ddcdcb50559cb030dadf013fa77
  /xsize.h
  /xstrndup.c
  /xstrndup.h
 -/xmemdup0.c
 -/xmemdup0.h
 -/sys_types.in.h
 -/obstack_printf.c
  /binary-io.c
 -/mbuiter.c
  /xsize.c
+ /bitrotate.c
+ /math.c
+ /sig-handler.c
+ /stdio.c
+ /unistd.c
+ /wctype-h.c
diff --cc m4/.gitignore
index 3dfdf6adc8f4e963c4c89dd9b3207710f8f21cc5,7d1124906728546d8b7446d71fe723cc9242e0d4..80193dbb1778cd0db3a88e4f1188ea0eb0aa5201
  /hash.m4
  /iconv.m4
  /include_next.m4
- /inline.m4
  /intdiv0.m4
  /intl.m4
 +/intl.m4~
  /intldir.m4
  /intlmacosx.m4
  /intmax.m4
diff --cc src/location.c
Simple merge
diff --cc src/scan-gram.l
index f5c9b88f013463dac4f9931c55531333e86aca3c,5e78cb9b7ade7994980e04af7fd687fc34e05844..e6f42ea934c57a539f659d869100855821032739
@@@ -981,16 -852,20 +981,20 @@@ convert_ucn_to_byte (char const *ucn
  static void
  handle_syncline (char *args, location loc)
  {
-   char *after_num;
-   unsigned long int lineno = strtoul (args, &after_num, 10);
-   char *file = strchr (after_num, '"') + 1;
-   *strchr (file, '"') = '\0';
+   char *file;
+   unsigned long int lineno = strtoul (args, &file, 10);
    if (INT_MAX <= lineno)
      {
 -      warn_at (loc, _("line number overflow"));
 +      complain (&loc, Wother, _("line number overflow"));
        lineno = INT_MAX;
      }
-   current_file = uniqstr_new (file);
 -  file = mbschr (file, '"');
++  file = strchr (file, '"');
+   if (file)
+     {
 -      *mbschr (file + 1, '"') = '\0';
++      *strchr (file + 1, '"') = '\0';
+       current_file = uniqstr_new (file + 1);
+     }
    boundary_set (&scanner_cursor, current_file, lineno, 1);
  }
  
Simple merge
Simple merge