* data/c++.m4 (b4_public_types_declare): Declare token_number_type soon.
Introduce symbol_number_type (wider than token_number_type).
Clarify the requirement that kind_type from by_state and by_type
denote the _input_ type (required by the constructor), not the stored type.
Use symbol_number_type and token_number_type where appropriate, instead
of int.
* data/lalr1.cc: Adjust to these changes.
Propagate "symbol_number_type".
Invoke "type_get ()" instead of read "type" directly.
+ /// (External) token type, as returned by yylex.
typedef token::yytokentype token_type;
typedef token::yytokentype token_type;
+ /// Internal symbol number.
+ typedef int symbol_number_type;
+
+ /// Internal symbol number for tokens (subsumed by symbol_number_type).
+ typedef ]b4_int_type_for([b4_translate])[ token_number_type;
+
/// A complete symbol.
///
/// Expects its Base type to provide access to the symbol type
/// A complete symbol.
///
/// Expects its Base type to provide access to the symbol type
/// Copy constructor.
by_type (const by_type& other);
/// Copy constructor.
by_type (const by_type& other);
- /// Constructor.
- ///
- by_type (token_type t);
+ /// The symbol type as needed by the constructor.
+ typedef token_type kind_type;
- /// Steal the type of \a that.
- void move (by_type& that);
+ /// Constructor from (external) token numbers.
+ by_type (kind_type t);
- /// The symbol type.
- ///
- /// -1 when this symbol is empty.
- int type;
+ /// Steal the symbol type from \a that.
+ void move (by_type& that);
- /// The type (corresponding to \a type).
+ /// The (internal) type number (corresponding to \a type).
/// -1 when this symbol is empty.
/// -1 when this symbol is empty.
+ symbol_number_type type_get () const;
/// The token.
token_type token () const;
/// The token.
token_type token () const;
- /// The type used to store the symbol type.
- typedef token_type kind_type;
+ /// The symbol type.
+ ///
+ /// -1 when this symbol is empty.
+ token_number_type type;
};
/// "External" symbols: returned by the scanner.
};
/// "External" symbols: returned by the scanner.
]b4_parser_class_name[::basic_symbol<Base>::~basic_symbol ()
{]b4_variant_if([[
// User destructor.
]b4_parser_class_name[::basic_symbol<Base>::~basic_symbol ()
{]b4_variant_if([[
// User destructor.
- int yytype = this->type_get ();
+ symbol_number_type yytype = this->type_get ();
switch (yytype)
{
]b4_symbol_foreach([b4_symbol_destructor])dnl
switch (yytype)
{
]b4_symbol_foreach([b4_symbol_destructor])dnl
/// \param yyvalue the value to check
static bool yy_table_value_is_error_ (int yyvalue);
/// \param yyvalue the value to check
static bool yy_table_value_is_error_ (int yyvalue);
- /// Internal symbol numbers.
- typedef ]b4_int_type_for([b4_translate])[ token_number_type;
static const ]b4_int_type(b4_pact_ninf, b4_pact_ninf)[ yypact_ninf_;
static const ]b4_int_type(b4_table_ninf, b4_table_ninf)[ yytable_ninf_;
static const ]b4_int_type(b4_pact_ninf, b4_pact_ninf)[ yypact_ninf_;
static const ]b4_int_type(b4_table_ninf, b4_table_ninf)[ yytable_ninf_;
/// Default constructor.
by_state ();
/// Default constructor.
by_state ();
+ /// The symbol type as needed by the constructor.
+ typedef state_type kind_type;
+
- by_state (state_type s);
+ by_state (kind_type s);
/// Copy constructor.
by_state (const by_state& other);
/// Copy constructor.
by_state (const by_state& other);
+ /// Steal the symbol type from \a that.
void move (by_state& that);
void move (by_state& that);
- /// The state.
- state_type state;
-
- /// The type (corresponding to \a state).
+ /// The (internal) type number (corresponding to \a state).
+ symbol_number_type type_get () const;
- /// The type used to store the symbol type.
- typedef state_type kind_type;
+ /// The state.
+ state_type state;
};
/// "Internal" symbol: element of the stack.
};
/// "Internal" symbol: element of the stack.
+ ]b4_parser_class_name[::symbol_number_type
]b4_parser_class_name[::by_state::type_get () const
{
return state == -1 ? -1 : yystos_[state];
]b4_parser_class_name[::by_state::type_get () const
{
return state == -1 ? -1 : yystos_[state];
YY_SYMBOL_PRINT (yymsg, yysym);]b4_variant_if([], [
// User destructor.
YY_SYMBOL_PRINT (yymsg, yysym);]b4_variant_if([], [
// User destructor.
- int yytype = yysym.type_get ();
+ symbol_number_type yytype = yysym.type_get ();
switch (yytype)
{
]b4_symbol_foreach([b4_symbol_destructor])dnl
switch (yytype)
{
]b4_symbol_foreach([b4_symbol_destructor])dnl
{
std::ostream& yyoutput = yyo;
YYUSE (yyoutput);
{
std::ostream& yyoutput = yyo;
YYUSE (yyoutput);
- int yytype = yysym.type_get ();
+ symbol_number_type yytype = yysym.type_get ();
yyo << (yytype < yyntokens_ ? "token" : "nterm")
<< ' ' << yytname_[yytype] << " ("]b4_locations_if([
<< yysym.location << ": "])[;
yyo << (yytype < yyntokens_ ? "token" : "nterm")
<< ' ' << yytname_[yytype] << " ("]b4_locations_if([
<< yysym.location << ": "])[;
/* If the proper action on seeing token YYLA.TYPE is to reduce or
to detect an error, take that action. */
/* If the proper action on seeing token YYLA.TYPE is to reduce or
to detect an error, take that action. */
- yyn += yyla.type;
- if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yyla.type)
+ yyn += yyla.type_get ();
+ if (yyn < 0 || yylast_ < yyn || yycheck_[yyn] != yyla.type_get ())
goto yydefault;
// Reduce or error.
goto yydefault;
// Reduce or error.
++yynerrs_;
error (]b4_join(b4_locations_if([yyla.location]),
[[yysyntax_error_ (yystack_[0].state,
++yynerrs_;
error (]b4_join(b4_locations_if([yyla.location]),
[[yysyntax_error_ (yystack_[0].state,
- yyempty ? yyempty_ : yyla.type)]])[);
+ yyempty ? yyempty_ : yyla.type_get ())]])[);
error, discard it. */
// Return failure if at end of input.
error, discard it. */
// Return failure if at end of input.
- if (yyla.type == yyeof_)
+ if (yyla.type_get () == yyeof_)
YYABORT;
else if (!yyempty)
{
YYABORT;
else if (!yyempty)
{