mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 20:33:03 +00:00
Prefer signed to unsigned integers
This patch contains more fixes to prefer signed to unsigned integer types, as modern tools like 'gcc -fsanitize=undefined' can check for signed integer overflow but not unsigned overflow. * NEWS: Document the API change. * boostrap.conf (gnulib_modules): Add intprops. * data/skeletons/glr.c: Include stddef.h and stdint.h, since this skeleton can assume C99 or later. (YYSIZEMAX): Now signed, and the minimum of SIZE_MAX and PTRDIFF_MAX. (yybool) [!__cplusplus]: Now signed (which is how bool behaves). (YYTRANSLATE): Avoid use of unsigned, and make the macro safe even for values greater than UINT_MAX. (yytnamerr, struct yyGLRState, struct yyGLRStateSet, struct yyGLRStack) (yyaddDeferredAction, yyinitStateSet, yyinitGLRStack) (yyexpandGLRStack, yymarkStackDeleted, yyremoveDeletes) (yyglrShift, yyglrShiftDefer, yy_reduce_print, yydoAction) (yyglrReduce, yysplitStack, yyreportTree, yycompressStack) (yyprocessOneStack, yyreportSyntaxError, yyrecoverSyntaxError) (yyparse, yy_yypstack, yypstack, yypdumpstack): * tests/input.at (Torturing the Scanner): Prefer ptrdiff_t to size_t. * data/skeletons/c++.m4 (b4_yytranslate_define): * src/AnnotationList.c (AnnotationList__computePredecessorAnnotations): * src/AnnotationList.h (AnnotationIndex): * src/InadequacyList.h (InadequacyListNodeCount): * src/closure.c (closure_new): * src/complain.c (error_message, complains, complain_indent) (complain_args, duplicate_directive, duplicate_rule_directive): * src/gram.c (nritems, ritem_print, grammar_dump): * src/ielr.c (ielr_compute_ritem_sees_lookahead_set) (ielr_item_has_lookahead, ielr_compute_annotation_lists) (ielr_compute_lookaheads): * src/location.c (columns, boundary_print, location_print): * src/muscle-tab.c (muscle_percent_define_insert) (muscle_percent_define_check_values): * src/output.c (prepare_rules, prepare_actions): * src/parse-gram.y (id, handle_require): * src/reader.c (record_merge_function_type, packgram): * src/reduce.c (nuseless_productions, nuseless_nonterminals) (inaccessable_symbols): * src/relation.c (relation_print): * src/scan-code.l (variant, variant_table_size, variant_count) (variant_add, get_at_spec, show_sub_message, show_sub_messages) (parse_ref): * src/scan-gram.l (<SC_ESCAPED_STRING,SC_ESCAPED_CHARACTER>) (scan_integer, convert_ucn_to_byte, handle_syncline): * src/scan-skel.l (at_complain): * src/symtab.c (complain_symbol_redeclared) (complain_semantic_type_redeclared, complain_class_redeclared) (symbol_class_set, complain_user_token_number_redeclared): * src/tables.c (conflict_tos, conflrow, conflict_table) (conflict_list, save_row, pack_vector): * tests/local.at (AT_YYLEX_DEFINE(c)): Prefer signed to unsigned integer. * data/skeletons/lalr1.cc (yy_lac_check_): * tests/actions.at (_AT_CHECK_PRINTER_AND_DESTRUCTOR): * tests/local.at (AT_YYLEX_DEFINE(c)): Omit now-unnecessary casts. * data/skeletons/location.cc (b4_location_define): * doc/bison.texi (Mfcalc Lexer, C++ position, C++ location): Prefer int to unsigned for line and column numbers. Change example to abort explicitly on memory exhaustion, and fix an off-by-one bug that led to undefined behavior. * data/skeletons/stack.hh (stack::operator[]): Also allow ptrdiff_t indexes. (stack::pop, slice::slice, slice::operator[]): Index arg is now ptrdiff_t, not int. (stack::ssize): New method. (slice::range_): Now ptrdiff_t, not int. * data/skeletons/yacc.c (b4_state_num_type): Remove. All uses replaced by b4_int_type. (YY_CONVERT_INT_BEGIN, YY_CONVERT_INT_END): New macros. (yylac, yyparse): Use them around conversions that -Wconversion would give false alarms about. Omit unnecessary casts. (yy_stack_print): Use int rather than unsigned, and omit a cast that doesn’t seem to be needed here any more. * examples/c++/variant.yy (yylex): * examples/c++/variant-11.yy (yylex): Omit no-longer-needed conversions to unsigned. * src/InadequacyList.c (InadequacyList__new_conflict): Don’t assume *node_count is unsigned. * src/output.c (muscle_insert_unsigned_table): Remove; no longer used.
This commit is contained in:
4
NEWS
4
NEWS
@@ -8,6 +8,10 @@ GNU Bison NEWS
|
||||
longer treated as end-of-lines. This changes the diagnostics, and in
|
||||
particular their locations.
|
||||
|
||||
Line numbers and columns are now represented as 'int' not 'unsigned',
|
||||
so that integer overflow on positions is easily checkable via 'gcc
|
||||
-fsanitize=undefined' and the like. This affects the API for positions.
|
||||
|
||||
** Bug fixes
|
||||
|
||||
In Java, %define api.prefix was ignored. It now behaves as expected.
|
||||
|
||||
@@ -25,7 +25,7 @@ gnulib_modules='
|
||||
error extensions fdl fopen-safer
|
||||
getopt-gnu
|
||||
gettext-h git-version-gen gitlog-to-changelog
|
||||
gpl-3.0 inttypes isnan javacomp-script
|
||||
gpl-3.0 intprops inttypes isnan javacomp-script
|
||||
javaexec-script
|
||||
ldexpl
|
||||
libtextstyle-optional
|
||||
|
||||
@@ -542,12 +542,12 @@ m4_define([b4_yytranslate_define],
|
||||
{
|
||||
]b4_translate[
|
||||
};
|
||||
const unsigned user_token_number_max_ = ]b4_user_token_number_max[;
|
||||
const 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> (t) <= user_token_number_max_)
|
||||
else if (static_cast<int> (t) <= user_token_number_max_)
|
||||
return translate_table[t];
|
||||
else
|
||||
return undef_token_;]])[
|
||||
|
||||
@@ -183,7 +183,7 @@ m4_define([b4_int_type],
|
||||
|
||||
# b4_int_type_for(NAME)
|
||||
# ---------------------
|
||||
# Return the smallest int type able to handle numbers ranging from
|
||||
# Return a narrow int type able to handle numbers ranging from
|
||||
# 'NAME_min' to 'NAME_max' (included).
|
||||
m4_define([b4_int_type_for],
|
||||
[b4_int_type($1_min, $1_max)])
|
||||
|
||||
@@ -259,7 +259,9 @@ static YYLTYPE yyloc_default][]b4_yyloc_default;])[
|
||||
]b4_user_post_prologue[
|
||||
]b4_percent_code_get[]dnl
|
||||
|
||||
[#include <stdio.h>
|
||||
[#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
@@ -285,7 +287,7 @@ static YYLTYPE yyloc_default][]b4_yyloc_default;])[
|
||||
# define YYREALLOC realloc
|
||||
#endif
|
||||
|
||||
#define YYSIZEMAX ((size_t) -1)
|
||||
#define YYSIZEMAX (PTRDIFF_MAX < SIZE_MAX ? PTRDIFF_MAX : (ptrdiff_t) SIZE_MAX)
|
||||
|
||||
#ifdef __cplusplus
|
||||
typedef bool yybool;
|
||||
@@ -293,7 +295,7 @@ static YYLTYPE yyloc_default][]b4_yyloc_default;])[
|
||||
# define yyfalse false
|
||||
#else
|
||||
/* When we move to stdbool, get rid of the various casts to yybool. */
|
||||
typedef unsigned char yybool;
|
||||
typedef signed char yybool;
|
||||
# define yytrue 1
|
||||
# define yyfalse 0
|
||||
#endif
|
||||
@@ -349,7 +351,7 @@ static YYLTYPE yyloc_default][]b4_yyloc_default;])[
|
||||
]b4_api_token_raw_if(dnl
|
||||
[[#define YYTRANSLATE(YYX) (YYX)]],
|
||||
[[#define YYTRANSLATE(YYX) \
|
||||
((unsigned) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
|
||||
(0 <= (YYX) && (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
|
||||
|
||||
/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
|
||||
as returned by yylex. */
|
||||
@@ -490,7 +492,7 @@ typedef enum { yyok, yyaccept, yyabort, yyerr } YYRESULTTAG;
|
||||
int yydebug;
|
||||
|
||||
struct yyGLRStack;
|
||||
static void yypstack (struct yyGLRStack* yystackp, size_t yyk)
|
||||
static void yypstack (struct yyGLRStack* yystackp, ptrdiff_t yyk)
|
||||
YY_ATTRIBUTE_UNUSED;
|
||||
static void yypdumpstack (struct yyGLRStack* yystackp)
|
||||
YY_ATTRIBUTE_UNUSED;
|
||||
@@ -574,12 +576,12 @@ yystpcpy (char *yydest, const char *yysrc)
|
||||
backslash-backslash). YYSTR is taken from yytname. If YYRES is
|
||||
null, do not copy; instead, return the length of what the result
|
||||
would have been. */
|
||||
static size_t
|
||||
static ptrdiff_t
|
||||
yytnamerr (char *yyres, const char *yystr)
|
||||
{
|
||||
if (*yystr == '"')
|
||||
{
|
||||
size_t yyn = 0;
|
||||
ptrdiff_t yyn = 0;
|
||||
char const *yyp = yystr;
|
||||
|
||||
for (;;)
|
||||
@@ -611,9 +613,9 @@ yytnamerr (char *yyres, const char *yystr)
|
||||
}
|
||||
|
||||
if (! yyres)
|
||||
return strlen (yystr);
|
||||
return (ptrdiff_t) strlen (yystr);
|
||||
|
||||
return (size_t) (yystpcpy (yyres, yystr) - yyres);
|
||||
return yystpcpy (yyres, yystr) - yyres;
|
||||
}
|
||||
# endif
|
||||
|
||||
@@ -648,7 +650,7 @@ struct yyGLRState {
|
||||
/** Preceding state in this stack */
|
||||
yyGLRState* yypred;
|
||||
/** Source position of the last token produced by my symbol */
|
||||
size_t yyposn;
|
||||
ptrdiff_t yyposn;
|
||||
union {
|
||||
/** First in a chain of alternative reductions producing the
|
||||
* nonterminal corresponding to this state, threaded through
|
||||
@@ -668,7 +670,7 @@ struct yyGLRStateSet {
|
||||
* operation, yylookaheadNeeds[0] is not maintained since it would merely
|
||||
* duplicate yychar != YYEMPTY. */
|
||||
yybool* yylookaheadNeeds;
|
||||
size_t yysize, yycapacity;
|
||||
ptrdiff_t yysize, yycapacity;
|
||||
};
|
||||
|
||||
struct yySemanticOption {
|
||||
@@ -708,7 +710,7 @@ struct yyGLRStack {
|
||||
YYJMP_BUF yyexception_buffer;
|
||||
yyGLRStackItem* yyitems;
|
||||
yyGLRStackItem* yynextFree;
|
||||
size_t yyspaceLeft;
|
||||
ptrdiff_t yyspaceLeft;
|
||||
yyGLRState* yysplitPoint;
|
||||
yyGLRState* yylastDeleted;
|
||||
yyGLRStateSet yytops;
|
||||
@@ -1066,7 +1068,7 @@ yynewGLRStackItem (yyGLRStack* yystackp, yybool yyisState)
|
||||
* alternative actions for YYSTATE. Assumes that YYRHS comes from
|
||||
* stack #YYK of *YYSTACKP. */
|
||||
static void
|
||||
yyaddDeferredAction (yyGLRStack* yystackp, size_t yyk, yyGLRState* yystate,
|
||||
yyaddDeferredAction (yyGLRStack* yystackp, ptrdiff_t yyk, yyGLRState* yystate,
|
||||
yyGLRState* yyrhs, yyRuleNum yyrule)
|
||||
{
|
||||
yySemanticOption* yynewOption =
|
||||
@@ -1097,19 +1099,21 @@ yyinitStateSet (yyGLRStateSet* yyset)
|
||||
yyset->yysize = 1;
|
||||
yyset->yycapacity = 16;
|
||||
yyset->yystates
|
||||
= (yyGLRState**) YYMALLOC (yyset->yycapacity * sizeof yyset->yystates[0]);
|
||||
= (yyGLRState**) YYMALLOC ((size_t) yyset->yycapacity
|
||||
* sizeof yyset->yystates[0]);
|
||||
if (! yyset->yystates)
|
||||
return yyfalse;
|
||||
yyset->yystates[0] = YY_NULLPTR;
|
||||
yyset->yylookaheadNeeds
|
||||
= (yybool*) YYMALLOC (yyset->yycapacity * sizeof yyset->yylookaheadNeeds[0]);
|
||||
= (yybool*) YYMALLOC ((size_t) yyset->yycapacity
|
||||
* sizeof yyset->yylookaheadNeeds[0]);
|
||||
if (! yyset->yylookaheadNeeds)
|
||||
{
|
||||
YYFREE (yyset->yystates);
|
||||
return yyfalse;
|
||||
}
|
||||
memset (yyset->yylookaheadNeeds,
|
||||
0, yyset->yycapacity * sizeof yyset->yylookaheadNeeds[0]);
|
||||
0, (size_t) yyset->yycapacity * sizeof yyset->yylookaheadNeeds[0]);
|
||||
return yytrue;
|
||||
}
|
||||
|
||||
@@ -1122,13 +1126,14 @@ static void yyfreeStateSet (yyGLRStateSet* yyset)
|
||||
/** Initialize *YYSTACKP to a single empty stack, with total maximum
|
||||
* capacity for all stacks of YYSIZE. */
|
||||
static yybool
|
||||
yyinitGLRStack (yyGLRStack* yystackp, size_t yysize)
|
||||
yyinitGLRStack (yyGLRStack* yystackp, ptrdiff_t yysize)
|
||||
{
|
||||
yystackp->yyerrState = 0;
|
||||
yynerrs = 0;
|
||||
yystackp->yyspaceLeft = yysize;
|
||||
yystackp->yyitems =
|
||||
(yyGLRStackItem*) YYMALLOC (yysize * sizeof yystackp->yynextFree[0]);
|
||||
(yyGLRStackItem*) YYMALLOC ((size_t) yysize
|
||||
* sizeof yystackp->yynextFree[0]);
|
||||
if (!yystackp->yyitems)
|
||||
return yyfalse;
|
||||
yystackp->yynextFree = yystackp->yyitems;
|
||||
@@ -1152,15 +1157,16 @@ yyexpandGLRStack (yyGLRStack* yystackp)
|
||||
{
|
||||
yyGLRStackItem* yynewItems;
|
||||
yyGLRStackItem* yyp0, *yyp1;
|
||||
size_t yynewSize;
|
||||
size_t yyn;
|
||||
size_t yysize = (size_t) (yystackp->yynextFree - yystackp->yyitems);
|
||||
ptrdiff_t yynewSize;
|
||||
ptrdiff_t yyn;
|
||||
ptrdiff_t yysize = yystackp->yynextFree - yystackp->yyitems;
|
||||
if (YYMAXDEPTH - YYHEADROOM < yysize)
|
||||
yyMemoryExhausted (yystackp);
|
||||
yynewSize = 2*yysize;
|
||||
if (YYMAXDEPTH < yynewSize)
|
||||
yynewSize = YYMAXDEPTH;
|
||||
yynewItems = (yyGLRStackItem*) YYMALLOC (yynewSize * sizeof yynewItems[0]);
|
||||
yynewItems = (yyGLRStackItem*) YYMALLOC ((size_t) yynewSize
|
||||
* sizeof yynewItems[0]);
|
||||
if (! yynewItems)
|
||||
yyMemoryExhausted (yystackp);
|
||||
for (yyp0 = yystackp->yyitems, yyp1 = yynewItems, yyn = yysize;
|
||||
@@ -1224,7 +1230,7 @@ yyupdateSplit (yyGLRStack* yystackp, yyGLRState* yys)
|
||||
|
||||
/** Invalidate stack #YYK in *YYSTACKP. */
|
||||
static inline void
|
||||
yymarkStackDeleted (yyGLRStack* yystackp, size_t yyk)
|
||||
yymarkStackDeleted (yyGLRStack* yystackp, ptrdiff_t yyk)
|
||||
{
|
||||
if (yystackp->yytops.yystates[yyk] != YY_NULLPTR)
|
||||
yystackp->yylastDeleted = yystackp->yytops.yystates[yyk];
|
||||
@@ -1248,7 +1254,7 @@ yyundeleteLastStack (yyGLRStack* yystackp)
|
||||
static inline void
|
||||
yyremoveDeletes (yyGLRStack* yystackp)
|
||||
{
|
||||
size_t yyi, yyj;
|
||||
ptrdiff_t yyi, yyj;
|
||||
yyi = yyj = 0;
|
||||
while (yyj < yystackp->yytops.yysize)
|
||||
{
|
||||
@@ -1272,8 +1278,8 @@ yyremoveDeletes (yyGLRStack* yystackp)
|
||||
yystackp->yytops.yylookaheadNeeds[yyi];
|
||||
if (yyj != yyi)
|
||||
{
|
||||
YYDPRINTF ((stderr, "Rename stack %lu -> %lu.\n",
|
||||
(unsigned long) yyi, (unsigned long) yyj));
|
||||
YYDPRINTF ((stderr, "Rename stack %ld -> %ld.\n",
|
||||
(long) yyi, (long) yyj));
|
||||
}
|
||||
yyj += 1;
|
||||
}
|
||||
@@ -1285,8 +1291,8 @@ yyremoveDeletes (yyGLRStack* yystackp)
|
||||
* state YYLRSTATE, at input position YYPOSN, with (resolved) semantic
|
||||
* value *YYVALP and source location *YYLOCP. */
|
||||
static inline void
|
||||
yyglrShift (yyGLRStack* yystackp, size_t yyk, yyStateNum yylrState,
|
||||
size_t yyposn,
|
||||
yyglrShift (yyGLRStack* yystackp, ptrdiff_t yyk, yyStateNum yylrState,
|
||||
ptrdiff_t yyposn,
|
||||
YYSTYPE* yyvalp]b4_locations_if([, YYLTYPE* yylocp])[)
|
||||
{
|
||||
yyGLRState* yynewState = &yynewGLRStackItem (yystackp, yytrue)->yystate;
|
||||
@@ -1306,8 +1312,8 @@ yyglrShift (yyGLRStack* yystackp, size_t yyk, yyStateNum yylrState,
|
||||
* state YYLRSTATE, at input position YYPOSN, with the (unresolved)
|
||||
* semantic value of YYRHS under the action for YYRULE. */
|
||||
static inline void
|
||||
yyglrShiftDefer (yyGLRStack* yystackp, size_t yyk, yyStateNum yylrState,
|
||||
size_t yyposn, yyGLRState* yyrhs, yyRuleNum yyrule)
|
||||
yyglrShiftDefer (yyGLRStack* yystackp, ptrdiff_t yyk, yyStateNum yylrState,
|
||||
ptrdiff_t yyposn, yyGLRState* yyrhs, yyRuleNum yyrule)
|
||||
{
|
||||
yyGLRState* yynewState = &yynewGLRStackItem (yystackp, yytrue)->yystate;
|
||||
YYASSERT (yynewState->yyisState);
|
||||
@@ -1337,15 +1343,14 @@ yyglrShiftDefer (yyGLRStack* yystackp, size_t yyk, yyStateNum yylrState,
|
||||
`----------------------------------------------------------------------*/
|
||||
|
||||
static inline void
|
||||
yy_reduce_print (yybool yynormal, yyGLRStackItem* yyvsp, size_t yyk,
|
||||
yy_reduce_print (yybool yynormal, yyGLRStackItem* yyvsp, ptrdiff_t yyk,
|
||||
yyRuleNum yyrule]b4_user_formals[)
|
||||
{
|
||||
int yynrhs = yyrhsLength (yyrule);]b4_locations_if([
|
||||
int yylow = 1;])[
|
||||
int yyi;
|
||||
YYFPRINTF (stderr, "Reducing stack %lu by rule %d (line %d):\n",
|
||||
(unsigned long) yyk, yyrule - 1,
|
||||
yyrline[yyrule]);
|
||||
YYFPRINTF (stderr, "Reducing stack %ld by rule %d (line %d):\n",
|
||||
(long) yyk, yyrule - 1, yyrline[yyrule]);
|
||||
if (! yynormal)
|
||||
yyfillin (yyvsp, 1, -yynrhs);
|
||||
/* The symbols being reduced. */
|
||||
@@ -1371,7 +1376,7 @@ yy_reduce_print (yybool yynormal, yyGLRStackItem* yyvsp, size_t yyk,
|
||||
* and *YYLOCP to the computed location (if any). Return value is as
|
||||
* for userAction. */
|
||||
static inline YYRESULTTAG
|
||||
yydoAction (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
|
||||
yydoAction (yyGLRStack* yystackp, ptrdiff_t yyk, yyRuleNum yyrule,
|
||||
YYSTYPE* yyvalp]b4_locuser_formals[)
|
||||
{
|
||||
int yynrhs = yyrhsLength (yyrule);
|
||||
@@ -1382,7 +1387,7 @@ yydoAction (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
|
||||
yyGLRStackItem* yyrhs = (yyGLRStackItem*) yystackp->yytops.yystates[yyk];
|
||||
YYASSERT (yyk == 0);
|
||||
yystackp->yynextFree -= yynrhs;
|
||||
yystackp->yyspaceLeft += (size_t) yynrhs;
|
||||
yystackp->yyspaceLeft += yynrhs;
|
||||
yystackp->yytops.yystates[0] = & yystackp->yynextFree[-1].yystate;
|
||||
YY_REDUCE_PRINT ((yytrue, yyrhs, yyk, yyrule]b4_user_args[));
|
||||
return yyuserAction (yyrule, yynrhs, yyrhs, yystackp,
|
||||
@@ -1422,10 +1427,10 @@ yydoAction (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
|
||||
* added to the options for the existing state's semantic value.
|
||||
*/
|
||||
static inline YYRESULTTAG
|
||||
yyglrReduce (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
|
||||
yyglrReduce (yyGLRStack* yystackp, ptrdiff_t yyk, yyRuleNum yyrule,
|
||||
yybool yyforceEval]b4_user_formals[)
|
||||
{
|
||||
size_t yyposn = yystackp->yytops.yystates[yyk]->yyposn;
|
||||
ptrdiff_t yyposn = yystackp->yytops.yystates[yyk]->yyposn;
|
||||
|
||||
if (yyforceEval || yystackp->yysplitPoint == YY_NULLPTR)
|
||||
{
|
||||
@@ -1435,8 +1440,8 @@ yyglrReduce (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
|
||||
YYRESULTTAG yyflag = yydoAction (yystackp, yyk, yyrule, &yysval]b4_locuser_args([&yyloc])[);
|
||||
if (yyflag == yyerr && yystackp->yysplitPoint != YY_NULLPTR)
|
||||
{
|
||||
YYDPRINTF ((stderr, "Parse on stack %lu rejected by rule #%d.\n",
|
||||
(unsigned long) yyk, yyrule - 1));
|
||||
YYDPRINTF ((stderr, "Parse on stack %ld rejected by rule #%d.\n",
|
||||
(long) yyk, yyrule - 1));
|
||||
}
|
||||
if (yyflag != yyok)
|
||||
return yyflag;
|
||||
@@ -1448,7 +1453,7 @@ yyglrReduce (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
|
||||
}
|
||||
else
|
||||
{
|
||||
size_t yyi;
|
||||
ptrdiff_t yyi;
|
||||
int yyn;
|
||||
yyGLRState* yys, *yys0 = yystackp->yytops.yystates[yyk];
|
||||
yyStateNum yynewLRState;
|
||||
@@ -1462,9 +1467,9 @@ yyglrReduce (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
|
||||
yyupdateSplit (yystackp, yys);
|
||||
yynewLRState = yyLRgotoState (yys->yylrState, yylhsNonterm (yyrule));
|
||||
YYDPRINTF ((stderr,
|
||||
"Reduced stack %lu by rule #%d; action deferred. "
|
||||
"Reduced stack %ld by rule #%d; action deferred. "
|
||||
"Now in state %d.\n",
|
||||
(unsigned long) yyk, yyrule - 1, yynewLRState));
|
||||
(long) yyk, yyrule - 1, yynewLRState));
|
||||
for (yyi = 0; yyi < yystackp->yytops.yysize; yyi += 1)
|
||||
if (yyi != yyk && yystackp->yytops.yystates[yyi] != YY_NULLPTR)
|
||||
{
|
||||
@@ -1476,9 +1481,8 @@ yyglrReduce (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
|
||||
{
|
||||
yyaddDeferredAction (yystackp, yyk, yyp, yys0, yyrule);
|
||||
yymarkStackDeleted (yystackp, yyk);
|
||||
YYDPRINTF ((stderr, "Merging stack %lu into stack %lu.\n",
|
||||
(unsigned long) yyk,
|
||||
(unsigned long) yyi));
|
||||
YYDPRINTF ((stderr, "Merging stack %ld into stack %ld.\n",
|
||||
(long) yyk, (long) yyi));
|
||||
return yyok;
|
||||
}
|
||||
yyp = yyp->yypred;
|
||||
@@ -1490,8 +1494,8 @@ yyglrReduce (yyGLRStack* yystackp, size_t yyk, yyRuleNum yyrule,
|
||||
return yyok;
|
||||
}
|
||||
|
||||
static size_t
|
||||
yysplitStack (yyGLRStack* yystackp, size_t yyk)
|
||||
static ptrdiff_t
|
||||
yysplitStack (yyGLRStack* yystackp, ptrdiff_t yyk)
|
||||
{
|
||||
if (yystackp->yysplitPoint == YY_NULLPTR)
|
||||
{
|
||||
@@ -1502,15 +1506,15 @@ yysplitStack (yyGLRStack* yystackp, size_t yyk)
|
||||
{
|
||||
yyGLRState** yynewStates = YY_NULLPTR;
|
||||
yybool* yynewLookaheadNeeds;
|
||||
ptrdiff_t half_max_capacity = YYSIZEMAX / (2 * sizeof yynewStates[0]);
|
||||
|
||||
if (yystackp->yytops.yycapacity
|
||||
> (YYSIZEMAX / (2 * sizeof yynewStates[0])))
|
||||
if (half_max_capacity < yystackp->yytops.yycapacity)
|
||||
yyMemoryExhausted (yystackp);
|
||||
yystackp->yytops.yycapacity *= 2;
|
||||
|
||||
yynewStates =
|
||||
(yyGLRState**) YYREALLOC (yystackp->yytops.yystates,
|
||||
(yystackp->yytops.yycapacity
|
||||
((size_t) yystackp->yytops.yycapacity
|
||||
* sizeof yynewStates[0]));
|
||||
if (yynewStates == YY_NULLPTR)
|
||||
yyMemoryExhausted (yystackp);
|
||||
@@ -1518,7 +1522,7 @@ yysplitStack (yyGLRStack* yystackp, size_t yyk)
|
||||
|
||||
yynewLookaheadNeeds =
|
||||
(yybool*) YYREALLOC (yystackp->yytops.yylookaheadNeeds,
|
||||
(yystackp->yytops.yycapacity
|
||||
((size_t) yystackp->yytops.yycapacity
|
||||
* sizeof yynewLookaheadNeeds[0]));
|
||||
if (yynewLookaheadNeeds == YY_NULLPTR)
|
||||
yyMemoryExhausted (yystackp);
|
||||
@@ -1720,10 +1724,10 @@ yyreportTree (yySemanticOption* yyx, int yyindent)
|
||||
yyindent, "", yytokenName (yylhsNonterm (yyx->yyrule)),
|
||||
yyx->yyrule - 1);
|
||||
else
|
||||
YYFPRINTF (stderr, "%*s%s -> <Rule %d, tokens %lu .. %lu>\n",
|
||||
YYFPRINTF (stderr, "%*s%s -> <Rule %d, tokens %ld .. %ld>\n",
|
||||
yyindent, "", yytokenName (yylhsNonterm (yyx->yyrule)),
|
||||
yyx->yyrule - 1, (unsigned long) (yys->yyposn + 1),
|
||||
(unsigned long) yyx->yystate->yyposn);
|
||||
yyx->yyrule - 1, (long) (yys->yyposn + 1),
|
||||
(long) yyx->yystate->yyposn);
|
||||
for (yyi = 1; yyi <= yynrhs; yyi += 1)
|
||||
{
|
||||
if (yystates[yyi]->yyresolved)
|
||||
@@ -1732,10 +1736,10 @@ yyreportTree (yySemanticOption* yyx, int yyindent)
|
||||
YYFPRINTF (stderr, "%*s%s <empty>\n", yyindent+2, "",
|
||||
yytokenName (yystos[yystates[yyi]->yylrState]));
|
||||
else
|
||||
YYFPRINTF (stderr, "%*s%s <tokens %lu .. %lu>\n", yyindent+2, "",
|
||||
YYFPRINTF (stderr, "%*s%s <tokens %ld .. %ld>\n", yyindent+2, "",
|
||||
yytokenName (yystos[yystates[yyi]->yylrState]),
|
||||
(unsigned long) (yystates[yyi-1]->yyposn + 1),
|
||||
(unsigned long) yystates[yyi]->yyposn);
|
||||
(long) (yystates[yyi-1]->yyposn + 1),
|
||||
(long) yystates[yyi]->yyposn);
|
||||
}
|
||||
else
|
||||
yyreportTree (yystates[yyi]->yysemantics.yyfirstVal, yyindent+2);
|
||||
@@ -1930,9 +1934,9 @@ yycompressStack (yyGLRStack* yystackp)
|
||||
yyr = yyp, yyp = yyq, yyq = yyp->yypred)
|
||||
yyp->yypred = yyr;
|
||||
|
||||
yystackp->yyspaceLeft += (size_t) (yystackp->yynextFree - yystackp->yyitems);
|
||||
yystackp->yyspaceLeft += yystackp->yynextFree - yystackp->yyitems;
|
||||
yystackp->yynextFree = ((yyGLRStackItem*) yystackp->yysplitPoint) + 1;
|
||||
yystackp->yyspaceLeft -= (size_t) (yystackp->yynextFree - yystackp->yyitems);
|
||||
yystackp->yyspaceLeft -= yystackp->yynextFree - yystackp->yyitems;
|
||||
yystackp->yysplitPoint = YY_NULLPTR;
|
||||
yystackp->yylastDeleted = YY_NULLPTR;
|
||||
|
||||
@@ -1948,14 +1952,13 @@ yycompressStack (yyGLRStack* yystackp)
|
||||
}
|
||||
|
||||
static YYRESULTTAG
|
||||
yyprocessOneStack (yyGLRStack* yystackp, size_t yyk,
|
||||
size_t yyposn]b4_pure_formals[)
|
||||
yyprocessOneStack (yyGLRStack* yystackp, ptrdiff_t yyk,
|
||||
ptrdiff_t yyposn]b4_pure_formals[)
|
||||
{
|
||||
while (yystackp->yytops.yystates[yyk] != YY_NULLPTR)
|
||||
{
|
||||
yyStateNum yystate = yystackp->yytops.yystates[yyk]->yylrState;
|
||||
YYDPRINTF ((stderr, "Stack %lu Entering state %d\n",
|
||||
(unsigned long) yyk, yystate));
|
||||
YYDPRINTF ((stderr, "Stack %ld Entering state %d\n", yyk, yystate));
|
||||
|
||||
YYASSERT (yystate != YYFINAL);
|
||||
|
||||
@@ -1965,8 +1968,7 @@ yyprocessOneStack (yyGLRStack* yystackp, size_t yyk,
|
||||
yyRuleNum yyrule = yydefaultAction (yystate);
|
||||
if (yyrule == 0)
|
||||
{
|
||||
YYDPRINTF ((stderr, "Stack %lu dies.\n",
|
||||
(unsigned long) yyk));
|
||||
YYDPRINTF ((stderr, "Stack %ld dies.\n", (long) yyk));
|
||||
yymarkStackDeleted (yystackp, yyk);
|
||||
return yyok;
|
||||
}
|
||||
@@ -1974,9 +1976,9 @@ yyprocessOneStack (yyGLRStack* yystackp, size_t yyk,
|
||||
if (yyflag == yyerr)
|
||||
{
|
||||
YYDPRINTF ((stderr,
|
||||
"Stack %lu dies "
|
||||
"Stack %ld dies "
|
||||
"(predicate failure or explicit user error).\n",
|
||||
(unsigned long) yyk));
|
||||
(long) yyk));
|
||||
yymarkStackDeleted (yystackp, yyk);
|
||||
return yyok;
|
||||
}
|
||||
@@ -1996,10 +1998,9 @@ yyprocessOneStack (yyGLRStack* yystackp, size_t yyk,
|
||||
while (*yyconflicts != 0)
|
||||
{
|
||||
YYRESULTTAG yyflag;
|
||||
size_t yynewStack = yysplitStack (yystackp, yyk);
|
||||
YYDPRINTF ((stderr, "Splitting off stack %lu from %lu.\n",
|
||||
(unsigned long) yynewStack,
|
||||
(unsigned long) yyk));
|
||||
ptrdiff_t yynewStack = yysplitStack (yystackp, yyk);
|
||||
YYDPRINTF ((stderr, "Splitting off stack %ld from %ld.\n",
|
||||
(long) yynewStack, (long) yyk));
|
||||
yyflag = yyglrReduce (yystackp, yynewStack,
|
||||
*yyconflicts,
|
||||
yyimmediate[*yyconflicts]]b4_user_args[);
|
||||
@@ -2008,8 +2009,7 @@ yyprocessOneStack (yyGLRStack* yystackp, size_t yyk,
|
||||
yyposn]b4_pure_args[));
|
||||
else if (yyflag == yyerr)
|
||||
{
|
||||
YYDPRINTF ((stderr, "Stack %lu dies.\n",
|
||||
(unsigned long) yynewStack));
|
||||
YYDPRINTF ((stderr, "Stack %ld dies.\n", (long) yynewStack));
|
||||
yymarkStackDeleted (yystackp, yynewStack);
|
||||
}
|
||||
else
|
||||
@@ -2021,8 +2021,7 @@ yyprocessOneStack (yyGLRStack* yystackp, size_t yyk,
|
||||
break;
|
||||
else if (yyisErrorAction (yyaction))
|
||||
{
|
||||
YYDPRINTF ((stderr, "Stack %lu dies.\n",
|
||||
(unsigned long) yyk));
|
||||
YYDPRINTF ((stderr, "Stack %ld dies.\n", (long) yyk));
|
||||
yymarkStackDeleted (yystackp, yyk);
|
||||
break;
|
||||
}
|
||||
@@ -2033,9 +2032,9 @@ yyprocessOneStack (yyGLRStack* yystackp, size_t yyk,
|
||||
if (yyflag == yyerr)
|
||||
{
|
||||
YYDPRINTF ((stderr,
|
||||
"Stack %lu dies "
|
||||
"Stack %ld dies "
|
||||
"(predicate failure or explicit user error).\n",
|
||||
(unsigned long) yyk));
|
||||
(long) yyk));
|
||||
yymarkStackDeleted (yystackp, yyk);
|
||||
break;
|
||||
}
|
||||
@@ -2057,8 +2056,8 @@ yyreportSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
|
||||
#else
|
||||
{
|
||||
yySymbol yytoken = yychar == YYEMPTY ? YYEMPTY : YYTRANSLATE (yychar);
|
||||
size_t yysize0 = yytnamerr (YY_NULLPTR, yytokenName (yytoken));
|
||||
size_t yysize = yysize0;
|
||||
ptrdiff_t yysize0 = yytnamerr (YY_NULLPTR, yytokenName (yytoken));
|
||||
ptrdiff_t yysize = yysize0;
|
||||
yybool yysize_overflow = yyfalse;
|
||||
char* yymsg = YY_NULLPTR;
|
||||
enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
|
||||
@@ -2119,10 +2118,11 @@ yyreportSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
|
||||
}
|
||||
yyarg[yycount++] = yytokenName (yyx);
|
||||
{
|
||||
size_t yysz = yysize + yytnamerr (YY_NULLPTR, yytokenName (yyx));
|
||||
if (yysz < yysize)
|
||||
ptrdiff_t yysz = yytnamerr (YY_NULLPTR, yytokenName (yyx));
|
||||
if (YYSIZEMAX - yysize < yysz)
|
||||
yysize_overflow = yytrue;
|
||||
yysize = yysz;
|
||||
else
|
||||
yysize += yysz;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2145,14 +2145,15 @@ yyreportSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
|
||||
}
|
||||
|
||||
{
|
||||
size_t yysz = yysize + strlen (yyformat);
|
||||
if (yysz < yysize)
|
||||
ptrdiff_t yysz = (ptrdiff_t) strlen (yyformat);
|
||||
if (YYSIZEMAX - yysize < yysz)
|
||||
yysize_overflow = yytrue;
|
||||
yysize = yysz;
|
||||
else
|
||||
yysize += yysz;
|
||||
}
|
||||
|
||||
if (!yysize_overflow)
|
||||
yymsg = (char *) YYMALLOC (yysize);
|
||||
yymsg = (char *) YYMALLOC ((size_t) yysize);
|
||||
|
||||
if (yymsg)
|
||||
{
|
||||
@@ -2229,7 +2230,7 @@ yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
|
||||
|
||||
/* Reduce to one stack. */
|
||||
{
|
||||
size_t yyk;
|
||||
ptrdiff_t yyk;
|
||||
for (yyk = 0; yyk < yystackp->yytops.yysize; yyk += 1)
|
||||
if (yystackp->yytops.yystates[yyk] != YY_NULLPTR)
|
||||
break;
|
||||
@@ -2303,7 +2304,7 @@ yyrecoverSyntaxError (yyGLRStack* yystackp]b4_user_formals[)
|
||||
int yyresult;
|
||||
yyGLRStack yystack;
|
||||
yyGLRStack* const yystackp = &yystack;
|
||||
size_t yyposn;
|
||||
ptrdiff_t yyposn;
|
||||
|
||||
YYDPRINTF ((stderr, "Starting parse\n"));
|
||||
|
||||
@@ -2383,7 +2384,7 @@ b4_dollar_popdef])[]dnl
|
||||
while (yytrue)
|
||||
{
|
||||
yySymbol yytoken_to_shift;
|
||||
size_t yys;
|
||||
ptrdiff_t yys;
|
||||
|
||||
for (yys = 0; yys < yystack.yytops.yysize; yys += 1)
|
||||
yystackp->yytops.yylookaheadNeeds[yys] = (yybool) (yychar != YYEMPTY);
|
||||
@@ -2437,12 +2438,12 @@ b4_dollar_popdef])[]dnl
|
||||
int yyaction = yygetLRActions (yystate, yytoken_to_shift,
|
||||
&yyconflicts);
|
||||
/* Note that yyconflicts were handled by yyprocessOneStack. */
|
||||
YYDPRINTF ((stderr, "On stack %lu, ", (unsigned long) yys));
|
||||
YYDPRINTF ((stderr, "On stack %ld, ", (long) yys));
|
||||
YY_SYMBOL_PRINT ("shifting", yytoken_to_shift, &yylval, &yylloc);
|
||||
yyglrShift (&yystack, yys, yyaction, yyposn,
|
||||
&yylval]b4_locations_if([, &yylloc])[);
|
||||
YYDPRINTF ((stderr, "Stack %lu now in state #%d\n",
|
||||
(unsigned long) yys,
|
||||
YYDPRINTF ((stderr, "Stack %ld now in state #%d\n",
|
||||
(long) yys,
|
||||
yystack.yytops.yystates[yys]->yylrState));
|
||||
}
|
||||
|
||||
@@ -2490,8 +2491,8 @@ b4_dollar_popdef])[]dnl
|
||||
yyGLRState** yystates = yystack.yytops.yystates;
|
||||
if (yystates)
|
||||
{
|
||||
size_t yysize = yystack.yytops.yysize;
|
||||
size_t yyk;
|
||||
ptrdiff_t yysize = yystack.yytops.yysize;
|
||||
ptrdiff_t yyk;
|
||||
for (yyk = 0; yyk < yysize; yyk += 1)
|
||||
if (yystates[yyk])
|
||||
{
|
||||
@@ -2524,8 +2525,7 @@ yy_yypstack (yyGLRState* yys)
|
||||
yy_yypstack (yys->yypred);
|
||||
YYFPRINTF (stderr, " -> ");
|
||||
}
|
||||
YYFPRINTF (stderr, "%d@@%lu", yys->yylrState,
|
||||
(unsigned long) yys->yyposn);
|
||||
YYFPRINTF (stderr, "%d@@%ld", yys->yylrState, (long) yys->yyposn);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -2539,7 +2539,7 @@ yypstates (yyGLRState* yyst)
|
||||
}
|
||||
|
||||
static void
|
||||
yypstack (yyGLRStack* yystackp, size_t yyk)
|
||||
yypstack (yyGLRStack* yystackp, ptrdiff_t yyk)
|
||||
{
|
||||
yypstates (yystackp->yytops.yystates[yyk]);
|
||||
}
|
||||
@@ -2552,18 +2552,18 @@ static void
|
||||
yypdumpstack (yyGLRStack* yystackp)
|
||||
{
|
||||
yyGLRStackItem* yyp;
|
||||
size_t yyi;
|
||||
ptrdiff_t yyi;
|
||||
for (yyp = yystackp->yyitems; yyp < yystackp->yynextFree; yyp += 1)
|
||||
{
|
||||
YYFPRINTF (stderr, "%3lu. ",
|
||||
(unsigned long) (yyp - yystackp->yyitems));
|
||||
YYFPRINTF (stderr, "%3ld. ",
|
||||
(long) (yyp - yystackp->yyitems));
|
||||
if (*(yybool *) yyp)
|
||||
{
|
||||
YYASSERT (yyp->yystate.yyisState);
|
||||
YYASSERT (yyp->yyoption.yyisState);
|
||||
YYFPRINTF (stderr, "Res: %d, LR State: %d, posn: %lu, pred: %ld",
|
||||
YYFPRINTF (stderr, "Res: %d, LR State: %d, posn: %ld, pred: %ld",
|
||||
yyp->yystate.yyresolved, yyp->yystate.yylrState,
|
||||
(unsigned long) yyp->yystate.yyposn,
|
||||
(long) yyp->yystate.yyposn,
|
||||
(long) YYINDEX (yyp->yystate.yypred));
|
||||
if (! yyp->yystate.yyresolved)
|
||||
YYFPRINTF (stderr, ", firstVal: %ld",
|
||||
@@ -2583,7 +2583,7 @@ yypdumpstack (yyGLRStack* yystackp)
|
||||
}
|
||||
YYFPRINTF (stderr, "Tops:");
|
||||
for (yyi = 0; yyi < yystackp->yytops.yysize; yyi += 1)
|
||||
YYFPRINTF (stderr, "%lu: %ld; ", (unsigned long) yyi,
|
||||
YYFPRINTF (stderr, "%ld: %ld; ", (long) yyi,
|
||||
(long) YYINDEX (yystackp->yytops.yystates[yyi]));
|
||||
YYFPRINTF (stderr, "\n");
|
||||
}
|
||||
|
||||
@@ -1159,7 +1159,7 @@ b4_dollar_popdef])[]dnl
|
||||
while (true)
|
||||
{
|
||||
state_type top_state = (yylac_stack_.empty ()
|
||||
? yystack_[(size_t) lac_top].state
|
||||
? yystack_[lac_top].state
|
||||
: yylac_stack_.back ());
|
||||
int yyrule = yypact_[top_state];
|
||||
if (yy_pact_value_is_default_ (yyrule)
|
||||
@@ -1213,7 +1213,7 @@ b4_dollar_popdef])[]dnl
|
||||
}
|
||||
// Keep top_state in sync with the updated stack.
|
||||
top_state = (yylac_stack_.empty ()
|
||||
? yystack_[(size_t) lac_top].state
|
||||
? yystack_[lac_top].state
|
||||
: yylac_stack_.back ());
|
||||
// Push the resulting state of the reduction.
|
||||
state_type state = yy_lr_goto_state_ (top_state, yyr1_[yyrule]);
|
||||
|
||||
@@ -65,8 +65,8 @@ m4_define([b4_location_define],
|
||||
public:]m4_ifdef([b4_location_constructors], [[
|
||||
/// Construct a position.
|
||||
explicit position (]b4_percent_define_get([[filename_type]])[* f = YY_NULLPTR,
|
||||
unsigned l = ]b4_location_initial_line[u,
|
||||
unsigned c = ]b4_location_initial_column[u)
|
||||
int l = ]b4_location_initial_line[u,
|
||||
int c = ]b4_location_initial_column[u)
|
||||
: filename (f)
|
||||
, line (l)
|
||||
, column (c)
|
||||
@@ -75,8 +75,8 @@ m4_define([b4_location_define],
|
||||
]])[
|
||||
/// Initialization.
|
||||
void initialize (]b4_percent_define_get([[filename_type]])[* fn = YY_NULLPTR,
|
||||
unsigned l = ]b4_location_initial_line[u,
|
||||
unsigned c = ]b4_location_initial_column[u)
|
||||
int l = ]b4_location_initial_line[u,
|
||||
int c = ]b4_location_initial_column[u)
|
||||
{
|
||||
filename = fn;
|
||||
line = l;
|
||||
@@ -105,16 +105,15 @@ m4_define([b4_location_define],
|
||||
/// File name to which this position refers.
|
||||
]b4_percent_define_get([[filename_type]])[* filename;
|
||||
/// Current line number.
|
||||
unsigned line;
|
||||
int line;
|
||||
/// Current column number.
|
||||
unsigned column;
|
||||
int column;
|
||||
|
||||
private:
|
||||
/// Compute max (min, lhs+rhs).
|
||||
static unsigned add_ (unsigned lhs, int rhs, int min)
|
||||
static int add_ (int lhs, int rhs, int min)
|
||||
{
|
||||
return static_cast<unsigned> (std::max (min,
|
||||
static_cast<int> (lhs) + rhs));
|
||||
return std::max (min, lhs + rhs);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -197,8 +196,8 @@ m4_define([b4_location_define],
|
||||
|
||||
/// Construct a 0-width location in \a f, \a l, \a c.
|
||||
explicit location (]b4_percent_define_get([[filename_type]])[* f,
|
||||
unsigned l = ]b4_location_initial_line[u,
|
||||
unsigned c = ]b4_location_initial_column[u)
|
||||
int l = ]b4_location_initial_line[u,
|
||||
int c = ]b4_location_initial_column[u)
|
||||
: begin (f, l, c)
|
||||
, end (f, l, c)
|
||||
{}
|
||||
@@ -206,8 +205,8 @@ m4_define([b4_location_define],
|
||||
])[
|
||||
/// Initialization.
|
||||
void initialize (]b4_percent_define_get([[filename_type]])[* f = YY_NULLPTR,
|
||||
unsigned l = ]b4_location_initial_line[u,
|
||||
unsigned c = ]b4_location_initial_column[u)
|
||||
int l = ]b4_location_initial_line[u,
|
||||
int c = ]b4_location_initial_column[u)
|
||||
{
|
||||
begin.initialize (f, l, c);
|
||||
end = begin;
|
||||
@@ -305,7 +304,7 @@ m4_define([b4_location_define],
|
||||
std::basic_ostream<YYChar>&
|
||||
operator<< (std::basic_ostream<YYChar>& ostr, const location& loc)
|
||||
{
|
||||
unsigned end_col = 0 < loc.end.column ? loc.end.column - 1 : 0;
|
||||
int end_col = 0 < loc.end.column ? loc.end.column - 1 : 0;
|
||||
ostr << loc.begin;
|
||||
if (loc.end.filename
|
||||
&& (!loc.begin.filename
|
||||
|
||||
@@ -48,10 +48,11 @@ m4_define([b4_stack_define],
|
||||
{
|
||||
return seq_[size () - 1 - i];
|
||||
}
|
||||
|
||||
/// Random access.
|
||||
///
|
||||
/// Index 0 returns the topmost element.
|
||||
T&
|
||||
operator[] (ptrdiff_t i)
|
||||
{
|
||||
return operator[] (size_type (i));
|
||||
}
|
||||
T&
|
||||
operator[] (int i)
|
||||
{
|
||||
@@ -66,10 +67,11 @@ m4_define([b4_stack_define],
|
||||
{
|
||||
return seq_[size () - 1 - i];
|
||||
}
|
||||
|
||||
/// Random access.
|
||||
///
|
||||
/// Index 0 returns the topmost element.
|
||||
const T&
|
||||
operator[] (ptrdiff_t i) const
|
||||
{
|
||||
return operator[] (size_type (i));
|
||||
}
|
||||
const T&
|
||||
operator[] (int i) const
|
||||
{
|
||||
@@ -88,7 +90,7 @@ m4_define([b4_stack_define],
|
||||
|
||||
/// Pop elements from the stack.
|
||||
void
|
||||
pop (int n = 1) YY_NOEXCEPT
|
||||
pop (ptrdiff_t n = 1) YY_NOEXCEPT
|
||||
{
|
||||
for (; 0 < n; --n)
|
||||
seq_.pop_back ();
|
||||
@@ -107,6 +109,11 @@ m4_define([b4_stack_define],
|
||||
{
|
||||
return seq_.size ();
|
||||
}
|
||||
ptrdiff_t
|
||||
ssize () const YY_NOEXCEPT
|
||||
{
|
||||
return (ptrdiff_t) size ();
|
||||
}
|
||||
|
||||
/// Iterator on top of the stack (going downwards).
|
||||
const_iterator
|
||||
@@ -126,20 +133,20 @@ m4_define([b4_stack_define],
|
||||
class slice
|
||||
{
|
||||
public:
|
||||
slice (const stack& stack, int range)
|
||||
slice (const stack& stack, ptrdiff_t range)
|
||||
: stack_ (stack)
|
||||
, range_ (range)
|
||||
{}
|
||||
|
||||
const T&
|
||||
operator[] (int i) const
|
||||
operator[] (ptrdiff_t i) const
|
||||
{
|
||||
return stack_[range_ - i];
|
||||
}
|
||||
|
||||
private:
|
||||
const stack& stack_;
|
||||
int range_;
|
||||
ptrdiff_t range_;
|
||||
};
|
||||
|
||||
private:
|
||||
|
||||
@@ -113,9 +113,8 @@ m4_ifset([b4_parse_param], [b4_args(b4_parse_param), ])])
|
||||
# b4_int_type(MIN, MAX)
|
||||
# ---------------------
|
||||
# Return a narrow int type able to handle numbers ranging from
|
||||
# MIN to MAX (included). Overwrite the version from c.m4, which
|
||||
# uses only C89 types, so that the user can override the shorter
|
||||
# types, and so that pre-C89 compilers are handled correctly.
|
||||
# MIN to MAX (included). Overwrite the version from c.m4,
|
||||
# so that the user can override the shorter types.
|
||||
m4_define([b4_int_type],
|
||||
[m4_if(b4_ints_in($@, [-127], [127]), [1], [yytype_int8],
|
||||
b4_ints_in($@, [0], [255]), [1], [yytype_uint8],
|
||||
@@ -125,18 +124,6 @@ m4_define([b4_int_type],
|
||||
|
||||
[int])])
|
||||
|
||||
# b4_state_num_type(MIN, MAX)
|
||||
# ---------------------------
|
||||
# Likewise, but prefer 'int' to 'unsigned' for large integers.
|
||||
m4_define([b4_state_num_type],
|
||||
[m4_if(b4_ints_in($@, [0], [255]), [1], [yytype_uint8],
|
||||
b4_ints_in($@, [-128], [127]), [1], [yytype_int8],
|
||||
|
||||
b4_ints_in($@, [0], [65535]), [1], [yytype_uint16],
|
||||
b4_ints_in($@, [-32768], [32767]), [1], [yytype_int16],
|
||||
|
||||
[int])])
|
||||
|
||||
|
||||
## ----------------- ##
|
||||
## Semantic Values. ##
|
||||
@@ -464,7 +451,7 @@ typedef short yytype_int16;
|
||||
|
||||
|
||||
/* State numbers. */
|
||||
typedef ]b4_state_num_type(0, m4_eval(b4_states_number - 1))[ yy_state_num;
|
||||
typedef ]b4_int_type(0, m4_eval(b4_states_number - 1))[ yy_state_num;
|
||||
|
||||
|
||||
#ifndef YY_
|
||||
@@ -481,6 +468,18 @@ typedef ]b4_state_num_type(0, m4_eval(b4_states_number - 1))[ yy_state_num;
|
||||
|
||||
]b4_attribute_define[
|
||||
|
||||
/* Suppress bogus -Wconversion warnings from GCC. */
|
||||
#if 4 < __GNUC__ + (7 <= __GNUC_MINOR__)
|
||||
# define YY_CONVERT_INT_BEGIN \
|
||||
_Pragma ("GCC diagnostic push") \
|
||||
_Pragma ("GCC diagnostic ignored \"-Wconversion\"")
|
||||
# define YY_CONVERT_INT_END \
|
||||
_Pragma ("GCC diagnostic pop")
|
||||
#else
|
||||
# define YY_CONVERT_INT_BEGIN
|
||||
# define YY_CONVERT_INT_END
|
||||
#endif
|
||||
|
||||
]b4_parse_assert_if([[#ifdef NDEBUG
|
||||
# define YY_ASSERT(E) ((void) (0 && (E)))
|
||||
#else
|
||||
@@ -650,7 +649,7 @@ union yyalloc
|
||||
]b4_api_token_raw_if(dnl
|
||||
[[#define YYTRANSLATE(YYX) (YYX)]],
|
||||
[[#define YYTRANSLATE(YYX) \
|
||||
((unsigned) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
|
||||
(0 <= (YYX) && (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
|
||||
|
||||
/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
|
||||
as returned by yylex. */
|
||||
@@ -773,7 +772,10 @@ do { \
|
||||
{
|
||||
YYFPRINTF (stderr, "Stack now");
|
||||
for (; yybottom <= yytop; yybottom++)
|
||||
YYFPRINTF (stderr, " %u", (unsigned) *yybottom);
|
||||
{
|
||||
int yybot = *yybottom;
|
||||
YYFPRINTF (stderr, " %d", yybot);
|
||||
}
|
||||
YYFPRINTF (stderr, "\n");
|
||||
}
|
||||
|
||||
@@ -1015,7 +1017,7 @@ yy_lac (yy_state_num *yyesa, yy_state_num **yyes,
|
||||
}
|
||||
else
|
||||
{
|
||||
yyrule = (int) yytable[yyrule];
|
||||
yyrule = yytable[yyrule];
|
||||
if (yytable_value_is_error (yyrule))
|
||||
{
|
||||
YYDPRINTF ((stderr, " Err\n"));
|
||||
@@ -1052,15 +1054,17 @@ yy_lac (yy_state_num *yyesa, yy_state_num **yyes,
|
||||
int yystate;
|
||||
{
|
||||
const int yylhs = yyr1[yyrule] - YYNTOKENS;
|
||||
const int yyi = yypgoto[yylhs] + (int) *yyesp;
|
||||
const int yyi = yypgoto[yylhs] + *yyesp;
|
||||
yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyesp
|
||||
? (int) yytable[yyi]
|
||||
? yytable[yyi]
|
||||
: yydefgoto[yylhs]);
|
||||
}
|
||||
if (yyesp == yyes_prev)
|
||||
{
|
||||
yyesp = *yyes;
|
||||
*yyesp = (yy_state_num) yystate;
|
||||
YY_CONVERT_INT_BEGIN
|
||||
*yyesp = yystate;
|
||||
YY_CONVERT_INT_END
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1073,7 +1077,9 @@ yy_lac (yy_state_num *yyesa, yy_state_num **yyes,
|
||||
YYDPRINTF ((stderr, "\n"));
|
||||
return 2;
|
||||
}
|
||||
*++yyesp = (yy_state_num) yystate;
|
||||
YY_CONVERT_INT_BEGIN
|
||||
*++yyesp = yystate;
|
||||
YY_CONVERT_INT_END
|
||||
}
|
||||
YYDPRINTF ((stderr, " G%d", yystate));
|
||||
}
|
||||
@@ -1536,7 +1542,9 @@ yynewstate:
|
||||
yysetstate:
|
||||
YYDPRINTF ((stderr, "Entering state %d\n", yystate));
|
||||
YY_ASSERT (0 <= yystate && yystate < YYNSTATES);
|
||||
*yyssp = (yy_state_num) yystate;
|
||||
YY_CONVERT_INT_BEGIN
|
||||
*yyssp = yystate;
|
||||
YY_CONVERT_INT_END
|
||||
|
||||
if (yyss + yystacksize - 1 <= yyssp)
|
||||
#if !defined yyoverflow && !defined YYSTACK_RELOCATE
|
||||
@@ -1670,7 +1678,7 @@ yyread_pushed_token:]])[
|
||||
goto yydefault;
|
||||
}]], [[
|
||||
goto yydefault;]])[
|
||||
yyn = (int) yytable[yyn];
|
||||
yyn = yytable[yyn];
|
||||
if (yyn <= 0)
|
||||
{
|
||||
if (yytable_value_is_error (yyn))
|
||||
@@ -1772,9 +1780,9 @@ yyreduce:
|
||||
number reduced by. */
|
||||
{
|
||||
const int yylhs = yyr1[yyn] - YYNTOKENS;
|
||||
const int yyi = yypgoto[yylhs] + (int) *yyssp;
|
||||
const int yyi = yypgoto[yylhs] + *yyssp;
|
||||
yystate = (0 <= yyi && yyi <= YYLAST && yycheck[yyi] == *yyssp
|
||||
? (int) yytable[yyi]
|
||||
? yytable[yyi]
|
||||
: yydefgoto[yylhs]);
|
||||
}
|
||||
|
||||
@@ -1890,7 +1898,7 @@ yyerrlab1:
|
||||
yyn += YYTERROR;
|
||||
if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
|
||||
{
|
||||
yyn = (int) yytable[yyn];
|
||||
yyn = yytable[yyn];
|
||||
if (0 < yyn)
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -2662,7 +2662,7 @@ found, a pointer to that symbol is returned; otherwise zero is returned.
|
||||
|
||||
@comment file: mfcalc.y: 3
|
||||
@example
|
||||
#include <stdlib.h> /* malloc. */
|
||||
#include <stdlib.h> /* malloc, abort. */
|
||||
#include <string.h> /* strlen. */
|
||||
|
||||
@group
|
||||
@@ -2670,7 +2670,11 @@ symrec *
|
||||
putsym (char const *name, int sym_type)
|
||||
@{
|
||||
symrec *res = (symrec *) malloc (sizeof (symrec));
|
||||
if (!res)
|
||||
abort ();
|
||||
res->name = strdup (name);
|
||||
if (!res->name)
|
||||
abort ();
|
||||
res->type = sym_type;
|
||||
res->value.var = 0; /* Set value to 0 even if fun. */
|
||||
res->next = sym_table;
|
||||
@@ -2712,6 +2716,8 @@ operators in @code{yylex}.
|
||||
@comment file: mfcalc.y: 3
|
||||
@example
|
||||
#include <ctype.h>
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
@group
|
||||
int
|
||||
@@ -2748,23 +2754,25 @@ Bison generated a definition of @code{YYSTYPE} with a member named
|
||||
/* Char starts an identifier => read the name. */
|
||||
if (isalpha (c))
|
||||
@{
|
||||
/* Initially make the buffer long enough
|
||||
for a 40-character symbol name. */
|
||||
static size_t length = 40;
|
||||
static ptrdiff_t bufsize = 0;
|
||||
static char *symbuf = 0;
|
||||
@end group
|
||||
if (!symbuf)
|
||||
symbuf = malloc (length + 1);
|
||||
|
||||
int i = 0;
|
||||
ptrdiff_t i = 0;
|
||||
do
|
||||
@group
|
||||
@{
|
||||
/* If buffer is full, make it bigger. */
|
||||
if (i == length)
|
||||
if (bufsize <= i)
|
||||
@{
|
||||
length *= 2;
|
||||
symbuf = realloc (symbuf, length + 1);
|
||||
ptrdiff_t maxsize
|
||||
= (PTRDIFF_MAX < SIZE_MAX
|
||||
? PTRDIFF_MAX : SIZE_MAX);
|
||||
if ((maxsize - 40) / 2 < bufsize)
|
||||
abort ();
|
||||
bufsize = 2 * bufsize + 40;
|
||||
symbuf = realloc (symbuf, bufsize);
|
||||
if (!symbuf)
|
||||
abort ();
|
||||
@}
|
||||
/* Add this character to the buffer. */
|
||||
symbuf[i++] = c;
|
||||
@@ -11476,13 +11484,13 @@ classes will not be generated, and the user defined type will be used.
|
||||
@node C++ position
|
||||
@subsubsection C++ @code{position}
|
||||
|
||||
@deftypeop {Constructor} {position} {} position (std::string* @var{file} = nullptr, unsigned @var{line} = 1, unsigned @var{col} = 1)
|
||||
@deftypeop {Constructor} {position} {} position (std::string* @var{file} = nullptr, int @var{line} = 1, int @var{col} = 1)
|
||||
Create a @code{position} denoting a given point. Note that @code{file} is
|
||||
not reclaimed when the @code{position} is destroyed: memory managed must be
|
||||
handled elsewhere.
|
||||
@end deftypeop
|
||||
|
||||
@deftypemethod {position} {void} initialize (std::string* @var{file} = nullptr, unsigned @var{line} = 1, unsigned @var{col} = 1)
|
||||
@deftypemethod {position} {void} initialize (std::string* @var{file} = nullptr, int @var{line} = 1, int @var{col} = 1)
|
||||
Reset the position to the given values.
|
||||
@end deftypemethod
|
||||
|
||||
@@ -11493,7 +11501,7 @@ change it to @samp{@var{type}*} using @samp{%define filename_type
|
||||
"@var{type}"}.
|
||||
@end deftypeivar
|
||||
|
||||
@deftypeivar {position} {unsigned} line
|
||||
@deftypeivar {position} {int} line
|
||||
The line, starting at 1.
|
||||
@end deftypeivar
|
||||
|
||||
@@ -11502,7 +11510,7 @@ If @var{height} is not null, advance by @var{height} lines, resetting the
|
||||
column number. The resulting line number cannot be less than 1.
|
||||
@end deftypemethod
|
||||
|
||||
@deftypeivar {position} {unsigned} column
|
||||
@deftypeivar {position} {int} column
|
||||
The column, starting at 1.
|
||||
@end deftypeivar
|
||||
|
||||
@@ -11537,11 +11545,11 @@ Create a @code{Location} from the endpoints of the range.
|
||||
@end deftypeop
|
||||
|
||||
@deftypeop {Constructor} {location} {} location (const position& @var{pos} = position())
|
||||
@deftypeopx {Constructor} {location} {} location (std::string* @var{file}, unsigned @var{line}, unsigned @var{col})
|
||||
@deftypeopx {Constructor} {location} {} location (std::string* @var{file}, int @var{line}, int @var{col})
|
||||
Create a @code{Location} denoting an empty range located at a given point.
|
||||
@end deftypeop
|
||||
|
||||
@deftypemethod {location} {void} initialize (std::string* @var{file} = nullptr, unsigned @var{line} = 1, unsigned @var{col} = 1)
|
||||
@deftypemethod {location} {void} initialize (std::string* @var{file} = nullptr, int @var{line} = 1, int @var{col} = 1)
|
||||
Reset the location to an empty range at the given values.
|
||||
@end deftypemethod
|
||||
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace yy
|
||||
static int count = 0;
|
||||
const int stage = count;
|
||||
++count;
|
||||
auto loc = parser::location_type{nullptr, unsigned (stage + 1), unsigned (stage + 1)};
|
||||
auto loc = parser::location_type{nullptr, stage + 1, stage + 1};
|
||||
if (stage == 0)
|
||||
return parser::make_TEXT (make_string_uptr ("I have numbers for you."), std::move (loc));
|
||||
else if (stage < max)
|
||||
|
||||
@@ -117,7 +117,7 @@ namespace yy
|
||||
static int count = 0;
|
||||
const int stage = count;
|
||||
++count;
|
||||
parser::location_type loc (NULLPTR, unsigned (stage + 1), unsigned (stage + 1));
|
||||
parser::location_type loc (NULLPTR, stage + 1, stage + 1);
|
||||
switch (stage)
|
||||
{
|
||||
case 0:
|
||||
|
||||
@@ -269,7 +269,7 @@ AnnotationList__computePredecessorAnnotations (
|
||||
if (item_number_is_rule_number (ritem[s->items[self_item]
|
||||
- 2]))
|
||||
{
|
||||
unsigned rulei;
|
||||
int rulei;
|
||||
for (rulei = s->items[self_item];
|
||||
!item_number_is_rule_number (ritem[rulei]);
|
||||
++rulei)
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
# include "InadequacyList.h"
|
||||
# include "state.h"
|
||||
|
||||
typedef unsigned AnnotationIndex;
|
||||
typedef int AnnotationIndex;
|
||||
|
||||
/**
|
||||
* A node in a list of annotations on a particular LR(0) state. Each
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
|
||||
#include "InadequacyList.h"
|
||||
|
||||
#include <intprops.h>
|
||||
|
||||
ContributionIndex const ContributionIndex__none = -1;
|
||||
ContributionIndex const ContributionIndex__error_action = -2;
|
||||
|
||||
@@ -31,8 +33,9 @@ InadequacyList__new_conflict (state *manifesting_state, symbol *token,
|
||||
InadequacyListNodeCount *node_count)
|
||||
{
|
||||
InadequacyList *result = xmalloc (sizeof *result);
|
||||
result->id = (*node_count)++;
|
||||
aver (*node_count != 0);
|
||||
result->id = *node_count;
|
||||
if (INT_ADD_WRAPV (*node_count, 1, node_count))
|
||||
aver (false);
|
||||
result->next = NULL;
|
||||
result->manifestingState = manifesting_state;
|
||||
result->contributionCount = bitset_count (actions);
|
||||
|
||||
@@ -27,11 +27,8 @@
|
||||
|
||||
/**
|
||||
* A unique ID assigned to every \c InadequacyList node.
|
||||
*
|
||||
* This must remain unsigned so that the overflow check in
|
||||
* \c InadequacyList__new_conflict works properly.
|
||||
*/
|
||||
typedef unsigned long long InadequacyListNodeCount;
|
||||
typedef long long InadequacyListNodeCount;
|
||||
|
||||
/**
|
||||
* For a conflict, each rule in the grammar can have at most one contributing
|
||||
|
||||
@@ -170,7 +170,7 @@ set_fderives (void)
|
||||
|
||||
|
||||
void
|
||||
closure_new (unsigned n)
|
||||
closure_new (int n)
|
||||
{
|
||||
itemset = xnmalloc (n, sizeof *itemset);
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
data so that closure can be called. n is the number of elements to
|
||||
allocate for itemset. */
|
||||
|
||||
void closure_new (unsigned n);
|
||||
void closure_new (int n);
|
||||
|
||||
|
||||
/* Given the kernel (aka core) of a state (a sorted vector of item numbers
|
||||
|
||||
@@ -417,10 +417,10 @@ warnings_print_categories (warnings warn_flags, FILE *out)
|
||||
*/
|
||||
static
|
||||
void
|
||||
error_message (const location *loc, unsigned *indent, warnings flags,
|
||||
error_message (const location *loc, int *indent, warnings flags,
|
||||
severity sever, const char *message, va_list args)
|
||||
{
|
||||
unsigned pos = 0;
|
||||
int pos = 0;
|
||||
|
||||
if (loc)
|
||||
pos += location_print (*loc, stderr);
|
||||
@@ -470,7 +470,7 @@ error_message (const location *loc, unsigned *indent, warnings flags,
|
||||
/** Raise a complaint (fatal error, error or just warning). */
|
||||
|
||||
static void
|
||||
complains (const location *loc, unsigned *indent, warnings flags,
|
||||
complains (const location *loc, int *indent, warnings flags,
|
||||
const char *message, va_list args)
|
||||
{
|
||||
severity s = warning_severity (flags);
|
||||
@@ -498,7 +498,7 @@ complain (location const *loc, warnings flags, const char *message, ...)
|
||||
}
|
||||
|
||||
void
|
||||
complain_indent (location const *loc, warnings flags, unsigned *indent,
|
||||
complain_indent (location const *loc, warnings flags, int *indent,
|
||||
const char *message, ...)
|
||||
{
|
||||
va_list args;
|
||||
@@ -508,7 +508,7 @@ complain_indent (location const *loc, warnings flags, unsigned *indent,
|
||||
}
|
||||
|
||||
void
|
||||
complain_args (location const *loc, warnings w, unsigned *indent,
|
||||
complain_args (location const *loc, warnings w, int *indent,
|
||||
int argc, char *argv[])
|
||||
{
|
||||
switch (argc)
|
||||
@@ -563,7 +563,7 @@ void
|
||||
duplicate_directive (char const *directive,
|
||||
location first, location second)
|
||||
{
|
||||
unsigned i = 0;
|
||||
int i = 0;
|
||||
if (feature_flag & feature_caret)
|
||||
complain_indent (&second, Wother, &i, _("duplicate directive"));
|
||||
else
|
||||
@@ -577,7 +577,7 @@ void
|
||||
duplicate_rule_directive (char const *directive,
|
||||
location first, location second)
|
||||
{
|
||||
unsigned i = 0;
|
||||
int i = 0;
|
||||
complain_indent (&second, complaint, &i,
|
||||
_("only one %s allowed per rule"), directive);
|
||||
i += SUB_INDENT;
|
||||
|
||||
@@ -133,11 +133,11 @@ void complain (location const *loc, warnings flags, char const *message, ...)
|
||||
__attribute__ ((__format__ (__printf__, 3, 4)));
|
||||
|
||||
/** Likewise, but with an \a argc/argv interface. */
|
||||
void complain_args (location const *loc, warnings w, unsigned *indent,
|
||||
void complain_args (location const *loc, warnings w, int *indent,
|
||||
int argc, char *arg[]);
|
||||
|
||||
/** Make a complaint with location and some indentation. */
|
||||
void complain_indent (location const *loc, warnings flags, unsigned *indent,
|
||||
void complain_indent (location const *loc, warnings flags, int *indent,
|
||||
char const *message, ...)
|
||||
__attribute__ ((__format__ (__printf__, 4, 5)));
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
/* Comments for these variables are in gram.h. */
|
||||
|
||||
item_number *ritem = NULL;
|
||||
unsigned nritems = 0;
|
||||
int nritems = 0;
|
||||
|
||||
rule *rules = NULL;
|
||||
rule_number nrules = 0;
|
||||
@@ -165,7 +165,7 @@ void
|
||||
ritem_print (FILE *out)
|
||||
{
|
||||
fputs ("RITEM\n", out);
|
||||
for (unsigned i = 0; i < nritems; ++i)
|
||||
for (int i = 0; i < nritems; ++i)
|
||||
if (ritem[i] >= 0)
|
||||
fprintf (out, " %s", symbols[ritem[i]]->tag);
|
||||
else
|
||||
@@ -280,8 +280,8 @@ grammar_dump (FILE *out, const char *title)
|
||||
for (rule_number i = 0; i < nrules + nuseless_productions; ++i)
|
||||
{
|
||||
rule const *rule_i = &rules[i];
|
||||
unsigned const rhs_itemno = rule_i->rhs - ritem;
|
||||
unsigned length = rule_rhs_length (rule_i);
|
||||
int const rhs_itemno = rule_i->rhs - ritem;
|
||||
int length = rule_rhs_length (rule_i);
|
||||
aver (item_number_as_rule_number (rule_i->rhs[length] == i));
|
||||
fprintf (out, "%3d (%2d, %2d, %2s, %2s) %2d -> (%2u-%2u)",
|
||||
i,
|
||||
|
||||
@@ -115,7 +115,7 @@ extern int nvars;
|
||||
typedef int item_number;
|
||||
# define ITEM_NUMBER_MAX INT_MAX
|
||||
extern item_number *ritem;
|
||||
extern unsigned nritems;
|
||||
extern int nritems;
|
||||
|
||||
/* There is weird relationship between OT1H item_number and OTOH
|
||||
symbol_number and rule_number: we store the latter in
|
||||
|
||||
@@ -78,7 +78,7 @@ static bitset
|
||||
ielr_compute_ritem_sees_lookahead_set (void)
|
||||
{
|
||||
bitset result = bitset_create (nritems, BITSET_FIXED);
|
||||
unsigned i = nritems-1;
|
||||
int i = nritems-1;
|
||||
while (0 < i)
|
||||
{
|
||||
--i;
|
||||
@@ -418,7 +418,7 @@ ielr_item_has_lookahead (state *s, symbol_number lhs, size_t item,
|
||||
top-level invocation), go get it. */
|
||||
if (!lhs)
|
||||
{
|
||||
unsigned i;
|
||||
int i;
|
||||
for (i = s->items[item];
|
||||
!item_number_is_rule_number (ritem[i]);
|
||||
++i)
|
||||
@@ -496,7 +496,7 @@ ielr_compute_annotation_lists (bitsetv follow_kernel_items,
|
||||
AnnotationIndex *annotation_counts =
|
||||
xnmalloc (nstates, sizeof *annotation_counts);
|
||||
ContributionIndex max_contributions = 0;
|
||||
unsigned total_annotations = 0;
|
||||
int total_annotations = 0;
|
||||
|
||||
*inadequacy_listsp = xnmalloc (nstates, sizeof **inadequacy_listsp);
|
||||
*annotation_listsp = xnmalloc (nstates, sizeof **annotation_listsp);
|
||||
@@ -633,7 +633,7 @@ ielr_compute_lookaheads (bitsetv follow_kernel_items, bitsetv always_follows,
|
||||
{
|
||||
if (item_number_is_rule_number (ritem[t->items[t_item] - 2]))
|
||||
{
|
||||
unsigned rule_item;
|
||||
int rule_item;
|
||||
for (rule_item = t->items[t_item];
|
||||
!item_number_is_rule_number (ritem[rule_item]);
|
||||
++rule_item)
|
||||
|
||||
@@ -60,8 +60,8 @@ columns (void)
|
||||
int res = 80;
|
||||
if (cp && *cp)
|
||||
{
|
||||
unsigned long ul = strtoul (cp, NULL, 10);
|
||||
res = ul < INT_MAX ? ul : INT_MAX;
|
||||
long l = strtol (cp, NULL, 10);
|
||||
res = 0 <= l && l <= INT_MAX ? l : INT_MAX;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -149,7 +149,7 @@ location_compute (location *loc, boundary *cur, char const *token, size_t size)
|
||||
complain (loc, Wother, _("byte number overflow"));
|
||||
}
|
||||
|
||||
static unsigned
|
||||
static int
|
||||
boundary_print (boundary const *b, FILE *out)
|
||||
{
|
||||
return fprintf (out, "%s:%d.%d@%d",
|
||||
@@ -157,10 +157,10 @@ boundary_print (boundary const *b, FILE *out)
|
||||
b->line, b->column, b->byte);
|
||||
}
|
||||
|
||||
unsigned
|
||||
int
|
||||
location_print (location loc, FILE *out)
|
||||
{
|
||||
unsigned res = 0;
|
||||
int res = 0;
|
||||
if (trace_flag & trace_locations)
|
||||
{
|
||||
res += boundary_print (&loc.start, out);
|
||||
|
||||
@@ -112,7 +112,7 @@ void location_compute (location *loc,
|
||||
/* Print location to file.
|
||||
Return number of actually printed characters.
|
||||
Warning: uses quotearg's slot 3. */
|
||||
unsigned location_print (location loc, FILE *out);
|
||||
int location_print (location loc, FILE *out);
|
||||
|
||||
/* Prepare the use of location_caret. */
|
||||
void caret_init (void);
|
||||
|
||||
@@ -525,7 +525,7 @@ muscle_percent_define_insert (char const *var, location variable_loc,
|
||||
= atoi (muscle_find_const (how_name));
|
||||
if (how_old == MUSCLE_PERCENT_DEFINE_F)
|
||||
goto end;
|
||||
unsigned i = 0;
|
||||
int i = 0;
|
||||
/* If assigning the same value, make it a warning. */
|
||||
warnings warn = STREQ (value, current_value) ? Wother : complaint;
|
||||
complain_indent (&variable_loc, warn, &i,
|
||||
@@ -739,7 +739,7 @@ muscle_percent_define_check_values (char const * const *values)
|
||||
if (!*values)
|
||||
{
|
||||
location loc = muscle_percent_define_get_loc (*variablep);
|
||||
unsigned i = 0;
|
||||
int i = 0;
|
||||
complain_indent (&loc, complaint, &i,
|
||||
_("invalid value for %%define variable %s: %s"),
|
||||
quote (*variablep), quote_n (1, value));
|
||||
|
||||
23
src/output.c
23
src/output.c
@@ -91,7 +91,6 @@ Name (char const *name, Type *table_data, Type first, \
|
||||
MUSCLE_INSERT_LONG_INT (obstack_finish0 (&format_obstack), lmax); \
|
||||
}
|
||||
|
||||
GENERATE_MUSCLE_INSERT_TABLE (muscle_insert_unsigned_table, unsigned)
|
||||
GENERATE_MUSCLE_INSERT_TABLE (muscle_insert_int_table, int)
|
||||
GENERATE_MUSCLE_INSERT_TABLE (muscle_insert_base_table, base_number)
|
||||
GENERATE_MUSCLE_INSERT_TABLE (muscle_insert_rule_number_table, rule_number)
|
||||
@@ -214,17 +213,17 @@ prepare_symbols (void)
|
||||
static void
|
||||
prepare_rules (void)
|
||||
{
|
||||
unsigned *prhs = xnmalloc (nrules, sizeof *prhs);
|
||||
int *prhs = xnmalloc (nrules, sizeof *prhs);
|
||||
item_number *rhs = xnmalloc (nritems, sizeof *rhs);
|
||||
unsigned *rline = xnmalloc (nrules, sizeof *rline);
|
||||
int *rline = xnmalloc (nrules, sizeof *rline);
|
||||
symbol_number *r1 = xnmalloc (nrules, sizeof *r1);
|
||||
unsigned *r2 = xnmalloc (nrules, sizeof *r2);
|
||||
int *r2 = xnmalloc (nrules, sizeof *r2);
|
||||
int *dprec = xnmalloc (nrules, sizeof *dprec);
|
||||
int *merger = xnmalloc (nrules, sizeof *merger);
|
||||
int *immediate = xnmalloc (nrules, sizeof *immediate);
|
||||
|
||||
/* Index in RHS. */
|
||||
unsigned i = 0;
|
||||
int i = 0;
|
||||
for (rule_number r = 0; r < nrules; ++r)
|
||||
{
|
||||
/* Index of rule R in RHS. */
|
||||
@@ -251,10 +250,10 @@ prepare_rules (void)
|
||||
aver (i == nritems);
|
||||
|
||||
muscle_insert_item_number_table ("rhs", rhs, ritem[0], 1, nritems);
|
||||
muscle_insert_unsigned_table ("prhs", prhs, 0, 0, nrules);
|
||||
muscle_insert_unsigned_table ("rline", rline, 0, 0, nrules);
|
||||
muscle_insert_int_table ("prhs", prhs, 0, 0, nrules);
|
||||
muscle_insert_int_table ("rline", rline, 0, 0, nrules);
|
||||
muscle_insert_symbol_number_table ("r1", r1, 0, 0, nrules);
|
||||
muscle_insert_unsigned_table ("r2", r2, 0, 0, nrules);
|
||||
muscle_insert_int_table ("r2", r2, 0, 0, nrules);
|
||||
muscle_insert_int_table ("dprec", dprec, 0, 0, nrules);
|
||||
muscle_insert_int_table ("merger", merger, 0, 0, nrules);
|
||||
muscle_insert_int_table ("immediate", immediate, 0, 0, nrules);
|
||||
@@ -542,10 +541,10 @@ prepare_actions (void)
|
||||
parser, so we could avoid accidents by not writing them out in
|
||||
that case. Nevertheless, it seems even better to be able to use
|
||||
the GLR skeletons even without the non-deterministic tables. */
|
||||
muscle_insert_unsigned_table ("conflict_list_heads", conflict_table,
|
||||
conflict_table[0], 1, high + 1);
|
||||
muscle_insert_unsigned_table ("conflicting_rules", conflict_list,
|
||||
0, 1, conflict_list_cnt);
|
||||
muscle_insert_int_table ("conflict_list_heads", conflict_table,
|
||||
conflict_table[0], 1, high + 1);
|
||||
muscle_insert_int_table ("conflicting_rules", conflict_list,
|
||||
0, 1, conflict_list_cnt);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -743,7 +743,7 @@ id:
|
||||
}
|
||||
if (muscle_percent_define_ifdef (var))
|
||||
{
|
||||
unsigned indent = 0;
|
||||
int indent = 0;
|
||||
complain_indent (&@1, complaint, &indent,
|
||||
_("character literals cannot be used together"
|
||||
" with %s"), var);
|
||||
@@ -981,7 +981,7 @@ handle_require (location const *loc, char const *version)
|
||||
is the same as "3.0". */
|
||||
errno = 0;
|
||||
char* cp = NULL;
|
||||
unsigned long major = strtoul (version, &cp, 10);
|
||||
long major = strtol (version, &cp, 10);
|
||||
if (errno || *cp != '.')
|
||||
{
|
||||
complain (loc, complaint, _("invalid version requirement: %s"),
|
||||
@@ -989,7 +989,7 @@ handle_require (location const *loc, char const *version)
|
||||
return;
|
||||
}
|
||||
++cp;
|
||||
unsigned long minor = strtoul (cp, NULL, 10);
|
||||
long minor = strtol (cp, NULL, 10);
|
||||
if (errno)
|
||||
{
|
||||
complain (loc, complaint, _("invalid version requirement: %s"),
|
||||
|
||||
@@ -124,7 +124,7 @@ record_merge_function_type (int merger, uniqstr type, location declaration_loc)
|
||||
aver (merge_function != NULL && merger_find == merger);
|
||||
if (merge_function->type != NULL && !UNIQSTR_EQ (merge_function->type, type))
|
||||
{
|
||||
unsigned indent = 0;
|
||||
int indent = 0;
|
||||
complain_indent (&declaration_loc, complaint, &indent,
|
||||
_("result type clash on merge function %s: "
|
||||
"<%s> != <%s>"),
|
||||
@@ -611,7 +611,7 @@ grammar_current_rule_expect_rr (int count, location loc)
|
||||
static void
|
||||
packgram (void)
|
||||
{
|
||||
unsigned itemno = 0;
|
||||
int itemno = 0;
|
||||
ritem = xnmalloc (nritems + 1, sizeof *ritem);
|
||||
/* This sentinel is used by build_relations in gram.c. */
|
||||
*ritem++ = 0;
|
||||
|
||||
@@ -52,8 +52,8 @@ static bitset V;
|
||||
'useless', but no warning should be issued). */
|
||||
static bitset V1;
|
||||
|
||||
unsigned nuseless_productions;
|
||||
unsigned nuseless_nonterminals;
|
||||
int nuseless_productions;
|
||||
int nuseless_nonterminals;
|
||||
|
||||
#define bitset_swap(Lhs, Rhs) \
|
||||
do { \
|
||||
@@ -195,10 +195,10 @@ inaccessable_symbols (void)
|
||||
bitset_free (P);
|
||||
P = Pp;
|
||||
|
||||
unsigned nuseful_productions = bitset_count (P);
|
||||
int nuseful_productions = bitset_count (P);
|
||||
nuseless_productions = nrules - nuseful_productions;
|
||||
|
||||
unsigned nuseful_nonterminals = 0;
|
||||
int nuseful_nonterminals = 0;
|
||||
for (symbol_number i = ntokens; i < nsyms; ++i)
|
||||
nuseful_nonterminals += bitset_test (V, i);
|
||||
nuseless_nonterminals = nvars - nuseful_nonterminals;
|
||||
|
||||
@@ -36,7 +36,7 @@ void reduce_free (void);
|
||||
* reduce_grammar. Size nvars + nuseless_nonterminals. */
|
||||
extern symbol_number *nterm_map;
|
||||
|
||||
extern unsigned nuseless_nonterminals;
|
||||
extern unsigned nuseless_productions;
|
||||
extern int nuseless_nonterminals;
|
||||
extern int nuseless_productions;
|
||||
|
||||
#endif /* !REDUCE_H_ */
|
||||
|
||||
@@ -33,14 +33,14 @@ relation_print (const char *title,
|
||||
{
|
||||
if (title)
|
||||
fprintf (out, "%s:\n", title);
|
||||
for (size_t i = 0; i < size; ++i)
|
||||
for (relation_node i = 0; i < size; ++i)
|
||||
if (r[i])
|
||||
{
|
||||
fputs (" ", out);
|
||||
if (print)
|
||||
print (i, out);
|
||||
else
|
||||
fprintf (out, "%3lu", (unsigned long) i);
|
||||
fprintf (out, "%3ld", (long) i);
|
||||
fputc (':', out);
|
||||
for (relation_node j = 0; r[i][j] != END_NODE; ++j)
|
||||
{
|
||||
@@ -48,7 +48,7 @@ relation_print (const char *title,
|
||||
if (print)
|
||||
print (r[i][j], out);
|
||||
else
|
||||
fprintf (out, "%3lu", (unsigned long) r[i][j]);
|
||||
fprintf (out, "%3ld", (long) r[i][j]);
|
||||
}
|
||||
fputc ('\n', out);
|
||||
}
|
||||
|
||||
@@ -223,7 +223,7 @@ contains_dot_or_dash (const char* p)
|
||||
typedef struct
|
||||
{
|
||||
/* Index in symbol list. */
|
||||
unsigned symbol_index;
|
||||
int symbol_index;
|
||||
|
||||
/* Matched symbol id and loc. */
|
||||
uniqstr id;
|
||||
@@ -250,8 +250,8 @@ typedef struct
|
||||
#define VARIANT_NOT_VISIBLE_FROM_MIDRULE (1 << 2)
|
||||
|
||||
static variant *variant_table = NULL;
|
||||
static unsigned variant_table_size = 0;
|
||||
static unsigned variant_count = 0;
|
||||
static int variant_table_size = 0;
|
||||
static int variant_count = 0;
|
||||
|
||||
static variant *
|
||||
variant_table_grow (void)
|
||||
@@ -286,7 +286,7 @@ find_prefix_end (char const *prefix, char const *cp, char const *end)
|
||||
}
|
||||
|
||||
static variant *
|
||||
variant_add (uniqstr id, location id_loc, unsigned symbol_index,
|
||||
variant_add (uniqstr id, location id_loc, int symbol_index,
|
||||
char const *cp, char const *cp_end, bool explicit_bracketing)
|
||||
{
|
||||
char const *prefix_end = find_prefix_end (id, cp, cp_end);
|
||||
@@ -307,7 +307,7 @@ variant_add (uniqstr id, location id_loc, unsigned symbol_index,
|
||||
}
|
||||
|
||||
static const char *
|
||||
get_at_spec(unsigned symbol_index)
|
||||
get_at_spec(int symbol_index)
|
||||
{
|
||||
static char at_buf[20];
|
||||
if (symbol_index == 0)
|
||||
@@ -321,7 +321,7 @@ static void
|
||||
show_sub_message (warnings warning,
|
||||
const char* cp, bool explicit_bracketing,
|
||||
int midrule_rhs_index, char dollar_or_at,
|
||||
unsigned indent, const variant *var)
|
||||
int indent, const variant *var)
|
||||
{
|
||||
const char *at_spec = get_at_spec (var->symbol_index);
|
||||
|
||||
@@ -385,9 +385,9 @@ static void
|
||||
show_sub_messages (warnings warning,
|
||||
const char* cp, bool explicit_bracketing,
|
||||
int midrule_rhs_index, char dollar_or_at,
|
||||
unsigned indent)
|
||||
int indent)
|
||||
{
|
||||
for (unsigned i = 0; i < variant_count; ++i)
|
||||
for (int i = 0; i < variant_count; ++i)
|
||||
show_sub_message (warning | silent,
|
||||
cp, explicit_bracketing,
|
||||
midrule_rhs_index, dollar_or_at,
|
||||
@@ -437,7 +437,7 @@ parse_ref (char *cp, symbol_list *rule, int rule_length,
|
||||
|
||||
/* Add all relevant variants. */
|
||||
{
|
||||
unsigned symbol_index;
|
||||
int symbol_index;
|
||||
symbol_list *l;
|
||||
variant_count = 0;
|
||||
for (symbol_index = 0, l = rule; !symbol_list_null (l);
|
||||
@@ -459,12 +459,12 @@ parse_ref (char *cp, symbol_list *rule, int rule_length,
|
||||
}
|
||||
|
||||
/* Check errors. */
|
||||
unsigned valid_variants = 0;
|
||||
unsigned valid_variant_index = 0;
|
||||
for (unsigned i = 0; i < variant_count; ++i)
|
||||
int valid_variants = 0;
|
||||
int valid_variant_index = 0;
|
||||
for (int i = 0; i < variant_count; ++i)
|
||||
{
|
||||
variant *var = &variant_table[i];
|
||||
unsigned symbol_index = var->symbol_index;
|
||||
int symbol_index = var->symbol_index;
|
||||
|
||||
/* Check visibility from midrule actions. */
|
||||
if (midrule_rhs_index != 0
|
||||
@@ -490,9 +490,9 @@ parse_ref (char *cp, symbol_list *rule, int rule_length,
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
unsigned len = (explicit_bracketing || !ref_tail_fields) ?
|
||||
int len = (explicit_bracketing || !ref_tail_fields) ?
|
||||
cp_end - cp : ref_tail_fields - cp;
|
||||
unsigned indent = 0;
|
||||
int indent = 0;
|
||||
|
||||
complain_indent (text_loc, complaint, &indent,
|
||||
_("invalid reference: %s"), quote (text));
|
||||
@@ -525,7 +525,7 @@ parse_ref (char *cp, symbol_list *rule, int rule_length,
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
unsigned indent = 0;
|
||||
int indent = 0;
|
||||
if (variant_count > 1)
|
||||
{
|
||||
complain_indent (text_loc, Wother, &indent,
|
||||
@@ -535,7 +535,7 @@ parse_ref (char *cp, symbol_list *rule, int rule_length,
|
||||
dollar_or_at, indent + SUB_INDENT);
|
||||
}
|
||||
{
|
||||
unsigned symbol_index =
|
||||
int symbol_index =
|
||||
variant_table[valid_variant_index].symbol_index;
|
||||
return (symbol_index == midrule_rhs_index) ? LHS_REF : symbol_index;
|
||||
}
|
||||
@@ -543,7 +543,7 @@ parse_ref (char *cp, symbol_list *rule, int rule_length,
|
||||
case 2:
|
||||
default:
|
||||
{
|
||||
unsigned indent = 0;
|
||||
int indent = 0;
|
||||
complain_indent (text_loc, complaint, &indent,
|
||||
_("ambiguous reference: %s"), quote (text));
|
||||
show_sub_messages (complaint,
|
||||
|
||||
@@ -97,7 +97,7 @@ gram_scanner_last_string_free (void)
|
||||
}
|
||||
|
||||
static void handle_syncline (char *, location);
|
||||
static unsigned long scan_integer (char const *p, int base, location loc);
|
||||
static int scan_integer (char const *p, int base, location loc);
|
||||
static int convert_ucn_to_byte (char const *hex_text);
|
||||
static void unexpected_eof (boundary, char const *);
|
||||
static void unexpected_newline (boundary, char const *);
|
||||
@@ -600,22 +600,22 @@ eqopt ({sp}=)?
|
||||
{
|
||||
\\[0-7]{1,3} {
|
||||
verify (UCHAR_MAX < ULONG_MAX);
|
||||
unsigned long c = strtoul (yytext + 1, NULL, 8);
|
||||
if (!c || UCHAR_MAX < c)
|
||||
long c = strtol (yytext + 1, NULL, 8);
|
||||
if (0 < c && c <= UCHAR_MAX)
|
||||
obstack_1grow (&obstack_for_string, c);
|
||||
else
|
||||
complain (loc, complaint, _("invalid number after \\-escape: %s"),
|
||||
yytext+1);
|
||||
else
|
||||
obstack_1grow (&obstack_for_string, c);
|
||||
}
|
||||
|
||||
\\x[0-9abcdefABCDEF]+ {
|
||||
verify (UCHAR_MAX < ULONG_MAX);
|
||||
unsigned long c = strtoul (yytext + 2, NULL, 16);
|
||||
if (!c || UCHAR_MAX < c)
|
||||
long c = strtol (yytext + 2, NULL, 16);
|
||||
if (0 < c && c <= UCHAR_MAX)
|
||||
obstack_1grow (&obstack_for_string, c);
|
||||
else
|
||||
complain (loc, complaint, _("invalid number after \\-escape: %s"),
|
||||
yytext+1);
|
||||
else
|
||||
obstack_1grow (&obstack_for_string, c);
|
||||
}
|
||||
|
||||
\\a obstack_1grow (&obstack_for_string, '\a');
|
||||
@@ -810,7 +810,7 @@ eqopt ({sp}=)?
|
||||
| Scan NUMBER for a base-BASE integer at location LOC. |
|
||||
`------------------------------------------------------*/
|
||||
|
||||
static unsigned long
|
||||
static int
|
||||
scan_integer (char const *number, int base, location loc)
|
||||
{
|
||||
verify (INT_MAX < ULONG_MAX);
|
||||
@@ -818,9 +818,9 @@ scan_integer (char const *number, int base, location loc)
|
||||
complain (&loc, Wyacc,
|
||||
_("POSIX Yacc does not support hexadecimal literals"));
|
||||
|
||||
unsigned long num = strtoul (number, NULL, base);
|
||||
long num = strtol (number, NULL, base);
|
||||
|
||||
if (INT_MAX < num)
|
||||
if (! (0 <= num && num <= INT_MAX))
|
||||
{
|
||||
complain (&loc, complaint, _("integer out of range: %s"),
|
||||
quote (number));
|
||||
@@ -841,7 +841,7 @@ static int
|
||||
convert_ucn_to_byte (char const *ucn)
|
||||
{
|
||||
verify (UCHAR_MAX <= INT_MAX);
|
||||
unsigned long code = strtoul (ucn + 2, NULL, 16);
|
||||
long code = strtol (ucn + 2, NULL, 16);
|
||||
|
||||
/* FIXME: Currently we assume Unicode-compatible unibyte characters
|
||||
on ASCII hosts (i.e., Latin-1 on hosts with 8-bit bytes). On
|
||||
@@ -849,7 +849,7 @@ convert_ucn_to_byte (char const *ucn)
|
||||
These limitations should be removed once we add support for
|
||||
multibyte characters. */
|
||||
|
||||
if (UCHAR_MAX < code)
|
||||
if (! (0 <= code && code <= UCHAR_MAX))
|
||||
return -1;
|
||||
|
||||
#if ! ('$' == 0x24 && '@' == 0x40 && '`' == 0x60 && '~' == 0x7e)
|
||||
@@ -896,8 +896,8 @@ static void
|
||||
handle_syncline (char *args, location loc)
|
||||
{
|
||||
char *file;
|
||||
unsigned long lineno = strtoul (args, &file, 10);
|
||||
if (INT_MAX <= lineno)
|
||||
long lineno = strtol (args, &file, 10);
|
||||
if (! (0 <= lineno && lineno <= INT_MAX))
|
||||
{
|
||||
complain (&loc, Wother, _("line number overflow"));
|
||||
lineno = INT_MAX;
|
||||
|
||||
@@ -209,7 +209,7 @@ at_basename (int argc, char *argv[], char **out_namep, int *out_linenop)
|
||||
static void
|
||||
at_complain (int argc, char *argv[], char **out_namep, int *out_linenop)
|
||||
{
|
||||
static unsigned indent;
|
||||
static int indent;
|
||||
warnings w = flag (argv[1]);
|
||||
location loc;
|
||||
location *locp = NULL;
|
||||
|
||||
10
src/symtab.c
10
src/symtab.c
@@ -279,7 +279,7 @@ static void
|
||||
complain_symbol_redeclared (symbol *s, const char *what, location first,
|
||||
location second)
|
||||
{
|
||||
unsigned i = 0;
|
||||
int i = 0;
|
||||
locations_sort (&first, &second);
|
||||
complain_indent (&second, complaint, &i,
|
||||
_("%s redeclaration for %s"), what, s->tag);
|
||||
@@ -292,7 +292,7 @@ static void
|
||||
complain_semantic_type_redeclared (semantic_type *s, const char *what, location first,
|
||||
location second)
|
||||
{
|
||||
unsigned i = 0;
|
||||
int i = 0;
|
||||
locations_sort (&first, &second);
|
||||
complain_indent (&second, complaint, &i,
|
||||
_("%s redeclaration for <%s>"), what, s->tag);
|
||||
@@ -304,7 +304,7 @@ complain_semantic_type_redeclared (semantic_type *s, const char *what, location
|
||||
static void
|
||||
complain_class_redeclared (symbol *sym, symbol_class class, location second)
|
||||
{
|
||||
unsigned i = 0;
|
||||
int i = 0;
|
||||
complain_indent (&second, complaint, &i,
|
||||
class == token_sym
|
||||
? _("symbol %s redeclared as a token")
|
||||
@@ -463,7 +463,7 @@ symbol_class_set (symbol *sym, symbol_class class, location loc, bool declaring)
|
||||
{
|
||||
if (s->status == declared)
|
||||
{
|
||||
unsigned i = 0;
|
||||
int i = 0;
|
||||
complain_indent (&loc, Wother, &i,
|
||||
_("symbol %s redeclared"), sym->tag);
|
||||
i += SUB_INDENT;
|
||||
@@ -668,7 +668,7 @@ symbol_pack_processor (void *this, void *null ATTRIBUTE_UNUSED)
|
||||
static void
|
||||
complain_user_token_number_redeclared (int num, symbol *first, symbol *second)
|
||||
{
|
||||
unsigned i = 0;
|
||||
int i = 0;
|
||||
symbols_sort (&first, &second);
|
||||
complain_indent (&second->location, complaint, &i,
|
||||
_("user token number %d redeclaration for %s"),
|
||||
|
||||
12
src/tables.c
12
src/tables.c
@@ -84,7 +84,7 @@ int nvectors;
|
||||
|
||||
static base_number **froms;
|
||||
static base_number **tos;
|
||||
static unsigned **conflict_tos;
|
||||
static int **conflict_tos;
|
||||
static size_t *tally;
|
||||
static base_number *width;
|
||||
|
||||
@@ -115,9 +115,9 @@ base_number base_ninf = 0;
|
||||
-nstates..table_size (as an upper bound) */
|
||||
static bitset pos_set = NULL;
|
||||
|
||||
static unsigned *conflrow;
|
||||
unsigned *conflict_table;
|
||||
unsigned *conflict_list;
|
||||
static int *conflrow;
|
||||
int *conflict_table;
|
||||
int *conflict_list;
|
||||
int conflict_list_cnt;
|
||||
static int conflict_list_free;
|
||||
|
||||
@@ -391,7 +391,7 @@ save_row (state_number s)
|
||||
/* Allocate non defaulted actions. */
|
||||
base_number *sp1 = froms[s] = xnmalloc (count, sizeof *sp1);
|
||||
base_number *sp2 = tos[s] = xnmalloc (count, sizeof *sp2);
|
||||
unsigned *sp3 = conflict_tos[s] =
|
||||
int *sp3 = conflict_tos[s] =
|
||||
nondeterministic_parser ? xnmalloc (count, sizeof *sp3) : NULL;
|
||||
|
||||
/* Store non defaulted actions. */
|
||||
@@ -646,7 +646,7 @@ pack_vector (vector_number vector)
|
||||
size_t t = tally[i];
|
||||
base_number *from = froms[i];
|
||||
base_number *to = tos[i];
|
||||
unsigned *conflict_to = conflict_tos[i];
|
||||
int *conflict_to = conflict_tos[i];
|
||||
|
||||
aver (t != 0);
|
||||
|
||||
|
||||
@@ -122,8 +122,8 @@ extern base_number *base;
|
||||
keep parser tables small. */
|
||||
extern base_number base_ninf;
|
||||
|
||||
extern unsigned *conflict_table;
|
||||
extern unsigned *conflict_list;
|
||||
extern int *conflict_table;
|
||||
extern int *conflict_list;
|
||||
extern int conflict_list_cnt;
|
||||
|
||||
extern base_number *table;
|
||||
|
||||
@@ -769,7 +769,7 @@ static
|
||||
|
||||
int c = ]AT_VAL[]m4_ifval([$6], [.ival])[ = counter++;
|
||||
/* As in BASIC, line numbers go from 10 to 10. */
|
||||
]AT_LOC_FIRST_LINE[ = ]AT_LOC_FIRST_COLUMN[ = ]AT_CXX_IF([(unsigned)], [(int)])[(10 * c);
|
||||
]AT_LOC_FIRST_LINE[ = ]AT_LOC_FIRST_COLUMN[ = (10 * c);
|
||||
]AT_LOC_LAST_LINE[ = ]AT_LOC_LAST_COLUMN[ = ]AT_LOC_FIRST_LINE[ + 9;
|
||||
assert (c <= (int) strlen (source));
|
||||
if (source[c])
|
||||
|
||||
@@ -1320,8 +1320,9 @@ yylex (void)
|
||||
static char const input[] = "@<:@\1\2$@{@oline@__@&t@oline__\
|
||||
#output "; /* "
|
||||
*/
|
||||
static size_t toknum;
|
||||
assert (toknum < sizeof input);
|
||||
enum { input_elts = sizeof input };
|
||||
static ptrdiff_t toknum;
|
||||
assert (0 <= toknum && toknum < input_elts);
|
||||
yylval = value_as_yystype (input[toknum]);
|
||||
return input[toknum++];
|
||||
}
|
||||
|
||||
@@ -555,15 +555,16 @@ static
|
||||
]m4_bmatch([$1], [^\(".*"\)?$],
|
||||
[[static char const input[] = ]m4_default([$1], [""])],
|
||||
[[static int const input[] = ]$1])[;
|
||||
static size_t toknum = 0;
|
||||
static int toknum = 0;
|
||||
int res;
|
||||
]AT_USE_LEX_ARGS[
|
||||
assert (toknum < sizeof input / sizeof input[0]);
|
||||
int input_elts = sizeof input / sizeof input[0];
|
||||
assert (0 <= toknum && toknum < input_elts);
|
||||
res = input[toknum++];
|
||||
]$2[;]AT_TOKEN_CTOR_IF([], [[
|
||||
]AT_LOCATION_IF([[
|
||||
]AT_LOC_FIRST_LINE[ = ]AT_LOC_LAST_LINE[ = 1;
|
||||
]AT_LOC_FIRST_COLUMN[ = ]AT_LOC_LAST_COLUMN[ = ]AT_CXX_IF([(unsigned )], [(int)])[toknum;]])[
|
||||
]AT_LOC_FIRST_COLUMN[ = ]AT_LOC_LAST_COLUMN[ = toknum;]])[
|
||||
return res;]])[
|
||||
}]])
|
||||
|
||||
|
||||
Reference in New Issue
Block a user