* src/muscle_tab.h (MUSCLE_INSERT_LONG_INT): New.

* src/output.c (output_table_data): Return the longest number.
(prepare_tokens): Output `token_number_max').
* data/bison.simple, data/bison.c++ (b4_sint_type, b4_uint_type):
New.
Use them to define yy_token_number_type/TokenNumberType.
Use this type for yytranslate.
* tests/torture.at (Big triangle): Push the limit from 124 to
253.
* tests/regression.at (Web2c Actions): Adjust.
This commit is contained in:
Akim Demaille
2002-04-07 17:44:59 +00:00
parent 817e9f41d1
commit 680e8701b5
11 changed files with 95 additions and 26 deletions

View File

@@ -1,5 +1,25 @@
m4_divert(-1)
# b4_sint_type(MAX)
# -----------------
# Return the smallest signed int type able to handle the number MAX.
m4_define([b4_sint_type],
[m4_if(m4_eval([$1 <= 127]), [1], [signed char],
m4_eval([$1 <= 32767]), [1], [signed short],
m4_eval([$1 <= 2147483647]), [1], [signed int],
[m4_fatal([no signed int type for $1])])])
# b4_uint_type(MAX)
# -----------------
# Return the smallest unsigned int type able to handle the number MAX.
m4_define([b4_uint_type],
[m4_if(m4_eval([$1 <= 255]), [1], [unsigned char],
m4_eval([$1 <= 65535]), [1], [unsigned short],
m4_eval([$1 <= 4294967295]), [1], [unsigned int],
[m4_fatal([no unsigned int type for $1])])])
# b4_token_defines(TOKEN-NAME, TOKEN-NUMBER)
# ------------------------------------------
# Output the definition of this token as #define.
@@ -147,6 +167,7 @@ namespace yy
template < >
struct Traits< b4_name >
{
typedef typedef b4_uint_type(b4_token_number_max) TokenNumberType;
typedef int StateType;
typedef yystype SemanticType;
typedef b4_ltype LocationType;
@@ -159,9 +180,10 @@ namespace yy
{
public:
typedef Traits< b4_name >::StateType StateType;
typedef Traits< b4_name >::SemanticType SemanticType;
typedef Traits< b4_name >::LocationType LocationType;
typedef Traits< b4_name >::TokenNumberType TokenNumberType;
typedef Traits< b4_name >::StateType StateType;
typedef Traits< b4_name >::SemanticType SemanticType;
typedef Traits< b4_name >::LocationType LocationType;
typedef Stack< StateType > StateStack;
typedef Stack< SemanticType > SemanticStack;
@@ -218,7 +240,7 @@ namespace yy
#endif
/* Even more tables. */
static inline char translate_ (int token);
static inline TokenNumberType translate_ (int token);
/* Constants. */
static const int eof_;
@@ -685,16 +707,16 @@ yy::b4_name::rline_[[]] =
#endif
/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
char
TokenNumberType
yy::b4_name::translate_ (int token)
{
static
const char
const TokenNumberType
translate_[[]] =
{
b4_translate
};
return ((unsigned)(token) <= maxtok_ ? translate_[[token]] : nsym_);
return (unsigned)(token) <= maxtok_ ? translate_[[token]] : nsym_;
}
const int yy::b4_name::eof_ = 0;

View File

@@ -1,5 +1,25 @@
m4_divert(-1)
# b4_sint_type(MAX)
# -----------------
# Return the smallest signed int type able to handle the number MAX.
m4_define([b4_sint_type],
[m4_if(m4_eval([$1 <= 127]), [1], [signed char],
m4_eval([$1 <= 32767]), [1], [signed short],
m4_eval([$1 <= 2147483647]), [1], [signed int],
[m4_fatal([no signed int type for $1])])])
# b4_uint_type(MAX)
# -----------------
# Return the smallest unsigned int type able to handle the number MAX.
m4_define([b4_uint_type],
[m4_if(m4_eval([$1 <= 255]), [1], [unsigned char],
m4_eval([$1 <= 65535]), [1], [unsigned short],
m4_eval([$1 <= 4294967295]), [1], [unsigned int],
[m4_fatal([no unsigned int type for $1])])])
m4_define_default([b4_input_suffix], [.y])
m4_define_default([b4_output_parser_suffix],
@@ -248,10 +268,11 @@ b4_token_defines(b4_tokens)
#define YYMAXUTOK b4_maxtok
/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
typedef b4_uint_type(b4_token_number_max) yy_token_number_type;
#define YYTRANSLATE(x) ((unsigned)(x) <= b4_maxtok ? yytranslate[[x]] : b4_nsym)
/* YYTRANSLATE[[YYLEX]] -- Bison symbol number corresponding to YYLEX. */
static const char yytranslate[[]] =
static const yy_token_number_type yytranslate[[]] =
{
b4_translate
};