]> git.saurik.com Git - bison.git/blobdiff - data/lalr1.cc
Regen.
[bison.git] / data / lalr1.cc
index 2244108178564751d91e3456b45527554ccc1161..39167f94c70a2e98da1f6197fbca8d3c7eff7325 100644 (file)
@@ -1,6 +1,6 @@
 # C++ skeleton for Bison
 
-# Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008
+# Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
 # Free Software Foundation, Inc.
 
 # This program is free software: you can redistribute it and/or modify
@@ -47,18 +47,6 @@ m4_define([b4_integral_parser_table_define],
 m4_copy([b4_symbol_value], [b4_symbol_value_template])
 
 
-# b4_lex_symbol_if([IF-YYLEX-RETURNS-A-COMPLETE-SYMBOL], [IF-NOT])
-# ----------------------------------------------------------------
-m4_define([b4_lex_symbol_if],
-[b4_percent_define_ifdef([[lex_symbol]], [$1], [$2])])
-
-
-# b4_assert_if([IF-ASSERTIONS-ARE-USED], [IF-NOT])
-# ------------------------------------------------
-m4_define([b4_assert_if],
-[b4_percent_define_ifdef([[assert]], [$1], [$2])])
-
-
 # b4_lhs_value([TYPE])
 # --------------------
 # Expansion of $<TYPE>$.
@@ -126,182 +114,9 @@ m4_popdef([b4_at_dollar])dnl
 m4_popdef([b4_dollar_dollar])dnl
 ])])
 
-# b4_symbol_constructor_declaration_(SYMBOL-NUMBER)
-# -------------------------------------------------
-# Declare the overloaded version of make_symbol for the (common) type of
-# these SYMBOL-NUMBERS.  Use at class-level.
-m4_define([b4_symbol_constructor_declaration_],
-[b4_symbol_if([$1], [is_token], [b4_symbol_if([$1], [has_id],
-[    static inline
-    symbol_type
-    make_[]b4_symbol_([$1], [id]) (dnl
-b4_args(b4_symbol_if([$1], [has_type],
-                     [const b4_symbol([$1], [type])& v]),
-        b4_locations_if([const location_type& l])));
-
-])])])
-
-
-# b4_symbol_constructor_declarations
-# ----------------------------------
-# Declare symbol constructors for all the value types.
-# Use at class-level.
-m4_define([b4_symbol_constructor_declarations],
-[b4_variant_if([
-    // Symbol constructors declarations.
-b4_symbol_foreach([b4_symbol_constructor_declaration_])])])
-
-
-
-# b4_symbol_constructor_definition_(SYMBOL-NUMBER)
-# ------------------------------------------------
-# Define symbol constructor for this SYMBOL-NUMBER.
-m4_define([b4_symbol_constructor_definition_],
-[b4_symbol_if([$1], [is_token], [b4_symbol_if([$1], [has_id],
-[  b4_parser_class_name::symbol_type
-  b4_parser_class_name::make_[]b4_symbol_([$1], [id]) (dnl
-b4_args(b4_symbol_if([$1], [has_type],
-                     [const b4_symbol([$1], [type])& v]),
-        b4_locations_if([const location_type& l])))
-  {
-    return symbol_type (b4_args([yytranslate_ (token::b4_symbol([$1], [id]))],
-                                b4_symbol_if([$1], [has_type], [v]),
-                                b4_locations_if([l])));
-  }
-
-])])])
-
-
-# b4_symbol_constructor_definitions
-# ----------------------------------
-# Define the overloaded versions of make_symbol for all the value types.
-m4_define([b4_symbol_constructor_definitions],
-[[  // symbol_base_type.
-  template <typename Exact>
-  ]b4_parser_class_name[::symbol_base_type<Exact>::symbol_base_type ()
-    : value()]b4_locations_if([
-    , location()])[
-  {
-  }]b4_locations_if([[
-
-  template <typename Exact>
-  ]b4_parser_class_name[::symbol_base_type<Exact>::symbol_base_type (const location_type& l)
-    : value()
-    , location(l)
-  {
-  }]])[
-
-  template <typename Exact>
-  ]b4_parser_class_name[::symbol_base_type<Exact>::symbol_base_type (]b4_args(
-          [const semantic_type& v],
-          b4_locations_if([const location_type& l]))[)
-    : value(v)]b4_locations_if([
-    , location(l)])[
-  {
-  }
-
-  template <typename Exact>
-  const Exact&
-  ]b4_parser_class_name[::symbol_base_type<Exact>::self () const
-  {
-    return static_cast<const Exact&>(*this);
-  }
-
-  template <typename Exact>
-  Exact&
-  ]b4_parser_class_name[::symbol_base_type<Exact>::self ()
-  {
-    return static_cast<Exact&>(*this);
-  }
-
-  template <typename Exact>
-  int
-  ]b4_parser_class_name[::symbol_base_type<Exact>::type_get () const
-  {
-    return self ().type_get_ ();
-  }
-
-  // symbol_type.
-  ]b4_parser_class_name[::symbol_type::symbol_type ()
-    : super_type ()
-    , type ()
-  {
-  }
-
-  ]b4_parser_class_name[::symbol_type::symbol_type (]b4_args(
-                [int t],
-                b4_locations_if([const location_type& l]))[)
-    : super_type (]b4_locations_if([l])[)
-    , type (t)
-  {
-  }
-
-  ]b4_parser_class_name[::symbol_type::symbol_type (]b4_args(
-                 [int t],
-                 [const semantic_type& v],
-                 b4_locations_if([const location_type& l]))[)
-    : super_type (v]b4_locations_if([, l])[)
-    , type (t)
-  {
-  }
-
-  int
-  ]b4_parser_class_name[::symbol_type::type_get_ () const
-  {
-    return type;
-  }
-]b4_lex_symbol_if([[
-  ]b4_parser_class_name[::token_type
-  ]b4_parser_class_name[::symbol_type::token () const
-  {
-    // YYTOKNUM[NUM] -- (External) token number corresponding to the
-    // (internal) symbol number NUM (which must be that of a token).  */
-    static
-    const ]b4_int_type_for([b4_toknum])[
-    yytoken_number_[] =
-    {
-  ]b4_toknum[
-    };
-    return static_cast<token_type> (yytoken_number_[type]);
-  }
-]])[
-
-]b4_variant_if(
-[  // Implementation of make_symbol for each symbol type.
-b4_symbol_foreach([b4_symbol_constructor_definition_])])])
-
-
-# b4_yytranslate_definition
-# -------------------------
-# Define yytranslate_.  Sometimes we want it in the header file,
-# sometimes the cc file suffices.
-m4_define([b4_yytranslate_definition],
-[[  // Symbol number corresponding to token number t.
-  ]b4_parser_class_name[::token_number_type
-  ]b4_parser_class_name[::yytranslate_ (]b4_lex_symbol_if([token_type],
-                                                          [int])[ t)
-  {
-    static
-    const token_number_type
-    translate_table[] =
-    {
-]b4_translate[
-    };
-    const unsigned int user_token_number_max_ = ]b4_user_token_number_max[;
-    const token_number_type undef_token_ = ]b4_undef_token_number[;
-
-    if (static_cast<int>(t) <= yyeof_)
-      return yyeof_;
-    else if (static_cast<unsigned int> (t) <= user_token_number_max_)
-      return translate_table[t];
-    else
-      return undef_token_;
-  }
-]])
-
 
 m4_pushdef([b4_copyright_years],
-           [2002, 2003, 2004, 2005, 2006, 2007, 2008])
+           [2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009])
 
 m4_define([b4_parser_class_name],
           [b4_percent_define_get([[parser_class_name]])])
@@ -331,7 +146,7 @@ dnl FIXME: This is wrong, we want computed header guards.
 
 ]b4_percent_code_get([[requires]])[
 
-]b4_assert_if([#include <cassert>])[
+]b4_parse_assert_if([#include <cassert>])[
 #include <string>
 #include <iostream>
 #include "stack.hh"
@@ -339,14 +154,14 @@ dnl FIXME: This is wrong, we want computed header guards.
 ]b4_namespace_open[
 ]b4_locations_if([  class position;
   class location;])[
-]b4_variant_if([b4_variant_definition])[
+]b4_variant_if([b4_variant_define])[
 ]b4_namespace_close[
 
 ]b4_locations_if([#include "location.hh"])[
 
 /* Enabling traces.  */
 #ifndef YYDEBUG
-# define YYDEBUG ]b4_debug_flag[
+# define YYDEBUG ]b4_parse_trace_if([1], [0])[
 #endif
 
 /* Enabling verbose error messages.  */
@@ -354,7 +169,7 @@ dnl FIXME: This is wrong, we want computed header guards.
 # undef YYERROR_VERBOSE
 # define YYERROR_VERBOSE 1
 #else
-# define YYERROR_VERBOSE ]b4_error_verbose_flag[
+# define YYERROR_VERBOSE ]b4_error_verbose_if([1], [0])[
 #endif
 
 /* Enabling the token table.  */
@@ -388,21 +203,7 @@ do {                                                            \
   class ]b4_parser_class_name[
   {
   public:
-#ifndef YYSTYPE
-]b4_semantic_type_declare[
-#else
-    typedef YYSTYPE semantic_type;
-#endif]b4_locations_if([
-    /// Symbol locations.
-    typedef b4_percent_define_get([[location_type]]) location_type;])[
-    /// Tokens.
-    struct token
-    {
-      ]b4_token_enums(b4_tokens)[
-    };
-    /// Token type.
-    typedef token::yytokentype token_type;
-
+]b4_public_types_declare[
     /// Build a parser object.
     ]b4_parser_class_name[ (]b4_parse_param_decl[);
     virtual ~]b4_parser_class_name[ ();
@@ -471,33 +272,6 @@ do {                                                            \
     /// Convert a scanner token number \a t to a symbol number.
     static inline token_number_type yytranslate_ (]b4_lex_symbol_if([token_type], [int])[ t);
 
-    /// A complete symbol, with its type.
-    template <typename Exact>
-    struct symbol_base_type
-    {
-      /// Default constructor.
-      inline symbol_base_type ();
-
-      /// Constructor.]b4_locations_if([
-      inline symbol_base_type (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.
-      const Exact& self () const;
-      Exact& self ();
-
-      /// Return the type of this symbol.
-      int type_get () const;
-
-      /// The semantic value.
-      semantic_type value;]b4_locations_if([
-
-      /// The location.
-      location_type location;])[
-    };
-
 #if YYDEBUG
     /// \brief Display a symbol type, value and location.
     /// \param yyo    The output stream.
@@ -515,36 +289,6 @@ do {                                                            \
     inline void yy_destroy_ (const char* yymsg,
                              symbol_base_type<Exact>& yysym) const;
 
-  public:
-    /// External form of a symbol: its type and attributes.
-    struct symbol_type : symbol_base_type<symbol_type>
-    {
-      /// The parent class.
-      typedef symbol_base_type<symbol_type> super_type;
-
-      /// Default constructor.
-      inline symbol_type ();
-
-      /// Constructor.
-      inline symbol_type (]b4_args([int t],
-                                   [const semantic_type& v],
-                                   b4_locations_if([const location_type& l]))[);
-
-      inline symbol_type (]b4_args([int t],
-                                   b4_locations_if([const location_type& l]))[);
-
-      /// The symbol type.
-      int type;
-
-      /// Return the type corresponding to this state.
-      inline int type_get_ () const;
-
-      /// Its token.
-      inline token_type token () const;
-    };
-
-]b4_symbol_constructor_declarations[
-
   private:
     /// Element of the stack: a state and its attributes.
     struct stack_symbol_type : symbol_base_type<stack_symbol_type>
@@ -607,8 +351,8 @@ do {                                                            \
 ]b4_parse_param_vars[
   };
 
-]b4_lex_symbol_if([b4_yytranslate_definition])[
-]b4_lex_symbol_if([b4_symbol_constructor_definitions])[
+]b4_lex_symbol_if([b4_yytranslate_define
+b4_public_types_define])[
 ]b4_namespace_close[
 
 ]b4_percent_define_flag_if([[global_tokens_and_yystype]],
@@ -758,7 +502,7 @@ b4_percent_code_get[]dnl
   | Symbol types.  |
   `---------------*/
 
-]b4_lex_symbol_if([], [b4_symbol_constructor_definitions])[
+]b4_lex_symbol_if([], [b4_public_types_define])[
 
   // stack_symbol_type.
   ]b4_parser_class_name[::stack_symbol_type::stack_symbol_type ()
@@ -1316,7 +1060,7 @@ b4_error_verbose_if([int yystate, int yytoken],
   }
 #endif // YYDEBUG
 
-]b4_lex_symbol_if([], [b4_yytranslate_definition])[
+]b4_lex_symbol_if([], [b4_yytranslate_define])[
 ]b4_namespace_close[
 ]b4_epilogue[]dnl
 m4_divert_pop(0)