mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-21 18:23:03 +00:00
Make it easier to move the definition of yytranslate_.
Forthcoming changes will make it possible to use yytranslate_ from outside the parser implementation file. * data/lalr1.cc (b4_yytranslate_definition): New. Use it.
This commit is contained in:
@@ -1,3 +1,12 @@
|
|||||||
|
2008-11-13 Akim Demaille <demaille@gostai.com>
|
||||||
|
|
||||||
|
Make it easier to move the definition of yytranslate_.
|
||||||
|
Forthcoming changes will make it possible to use yytranslate_
|
||||||
|
from outside the parser implementation file.
|
||||||
|
|
||||||
|
* data/lalr1.cc (b4_yytranslate_definition): New.
|
||||||
|
Use it.
|
||||||
|
|
||||||
2008-11-13 Akim Demaille <demaille@gostai.com>
|
2008-11-13 Akim Demaille <demaille@gostai.com>
|
||||||
|
|
||||||
Remove useless class specification.
|
Remove useless class specification.
|
||||||
|
|||||||
@@ -330,6 +330,35 @@ m4_map([b4_char_sizeof_], [$@])dnl
|
|||||||
])])
|
])])
|
||||||
|
|
||||||
|
|
||||||
|
# b4_yytranslate_definition
|
||||||
|
# -------------------------
|
||||||
|
# Define yytranslate_. Sometimes we want it in the header file,
|
||||||
|
# sometimes the cc file suffices.
|
||||||
|
m4_define([b4_yytranslate_definition],
|
||||||
|
[[ // YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.
|
||||||
|
]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],
|
m4_pushdef([b4_copyright_years],
|
||||||
[2002, 2003, 2004, 2005, 2006, 2007, 2008])
|
[2002, 2003, 2004, 2005, 2006, 2007, 2008])
|
||||||
|
|
||||||
@@ -635,8 +664,7 @@ m4_ifdef([b4_stype],
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
/// Convert a scanner token number \a t to a symbol number.
|
/// Convert a scanner token number \a t to a symbol number.
|
||||||
static inline token_number_type yytranslate_ (]b4_lex_symbol_if(
|
static token_number_type yytranslate_ (]b4_lex_symbol_if([token_type], [int])[ t);
|
||||||
[token_type], [int])[ t);
|
|
||||||
|
|
||||||
/// A complete symbol, with its type.
|
/// A complete symbol, with its type.
|
||||||
template <typename Exact>
|
template <typename Exact>
|
||||||
@@ -1586,28 +1614,7 @@ b4_error_verbose_if([int yystate, int yytoken],
|
|||||||
}
|
}
|
||||||
#endif // YYDEBUG
|
#endif // YYDEBUG
|
||||||
|
|
||||||
/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
|
]b4_yytranslate_definition[
|
||||||
]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_;
|
|
||||||
}
|
|
||||||
|
|
||||||
]b4_namespace_close[
|
]b4_namespace_close[
|
||||||
|
|
||||||
]b4_epilogue[]dnl
|
]b4_epilogue[]dnl
|
||||||
|
|||||||
Reference in New Issue
Block a user