mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-19 17:23:02 +00:00
symbol::token.
This is allows the user to get the type of a token return by yylex. * data/lalr1.cc (symbol::token): New. (yytoknum_): Define when %define lex_symbol, independently of %debug. (yytoken_number_): Move into... (symbol::token): here, since that's the only use. The other one is YYPRINT which was not officially supported by lalr1.cc, and anyway it did not work since YYPRINT uses this array under a different name (yytoknum).
This commit is contained in:
15
ChangeLog
15
ChangeLog
@@ -1,3 +1,18 @@
|
|||||||
|
2008-11-13 Akim Demaille <demaille@gostai.com>
|
||||||
|
|
||||||
|
symbol::token.
|
||||||
|
This is allows the user to get the type of a token return by
|
||||||
|
yylex.
|
||||||
|
|
||||||
|
* data/lalr1.cc (symbol::token): New.
|
||||||
|
(yytoknum_): Define when %define lex_symbol, independently of
|
||||||
|
%debug.
|
||||||
|
(yytoken_number_): Move into...
|
||||||
|
(symbol::token): here, since that's the only use.
|
||||||
|
The other one is YYPRINT which was not officially supported
|
||||||
|
by lalr1.cc, and anyway it did not work since YYPRINT uses this
|
||||||
|
array under a different name (yytoknum).
|
||||||
|
|
||||||
2008-11-13 Akim Demaille <demaille@gostai.com>
|
2008-11-13 Akim Demaille <demaille@gostai.com>
|
||||||
|
|
||||||
YYERRCODE.
|
YYERRCODE.
|
||||||
|
|||||||
@@ -346,6 +346,21 @@ m4_define([b4_symbol_constructor_definitions],
|
|||||||
{
|
{
|
||||||
return type;
|
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(
|
]b4_variant_if(
|
||||||
[ // Implementation of make_symbol for each symbol type.
|
[ // Implementation of make_symbol for each symbol type.
|
||||||
@@ -727,9 +742,6 @@ m4_ifdef([b4_stype],
|
|||||||
#if YYDEBUG
|
#if YYDEBUG
|
||||||
/// For each rule, its source line number.
|
/// For each rule, its source line number.
|
||||||
static const ]b4_int_type_for([b4_rline])[ yyrline_[];
|
static const ]b4_int_type_for([b4_rline])[ yyrline_[];
|
||||||
/// (External) token number corresponding to the (internal) symbol
|
|
||||||
/// number (which must be that of a token).
|
|
||||||
static const ]b4_int_type_for([b4_toknum])[ yytoken_number_[];
|
|
||||||
/// Report on the debug stream that the rule \a r is going to be reduced.
|
/// Report on the debug stream that the rule \a r is going to be reduced.
|
||||||
virtual void yy_reduce_print_ (int r);
|
virtual void yy_reduce_print_ (int r);
|
||||||
/// Print the state stack on the debug stream.
|
/// Print the state stack on the debug stream.
|
||||||
@@ -810,6 +822,9 @@ m4_ifdef([b4_stype],
|
|||||||
|
|
||||||
/// Return the type corresponding to this state.
|
/// Return the type corresponding to this state.
|
||||||
inline int type_get_ () const;
|
inline int type_get_ () const;
|
||||||
|
|
||||||
|
/// Its token.
|
||||||
|
inline token_type token () const;
|
||||||
};
|
};
|
||||||
|
|
||||||
]b4_symbol_constructor_declarations[
|
]b4_symbol_constructor_declarations[
|
||||||
@@ -1564,12 +1579,6 @@ b4_error_verbose_if([int yystate, int yytoken],
|
|||||||
symbol of state STATE-NUM. */
|
symbol of state STATE-NUM. */
|
||||||
]b4_table_define([stos], [b4_stos])[;
|
]b4_table_define([stos], [b4_stos])[;
|
||||||
|
|
||||||
#if YYDEBUG
|
|
||||||
/* YYTOKNUM[NUM] -- (External) token number corresponding to the
|
|
||||||
(internal) symbol number NUM (which must be that of a token). */
|
|
||||||
]b4_table_define([token_number], [b4_toknum])[;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
|
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
|
||||||
]b4_table_define([r1], [b4_r1])[;
|
]b4_table_define([r1], [b4_r1])[;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user