Paul Eggert [Sun, 26 Dec 2004 06:13:31 +0000 (06:13 +0000)]
* tests/torture.at (Exploding the Stack Size with Alloca): Set
YYSTACK_USE_ALLOCA to 1 if __GNUC__ or alloca are defined;
otherwise, we're not testing alloca. Unfortunately there's no
simple way to consult HAVE_ALLOCA here.
Paul Eggert [Sun, 26 Dec 2004 06:12:18 +0000 (06:12 +0000)]
(Exploding the Stack Size with Alloca): Set
YYSTACK_USE_ALLOCA to 1 if __GNUC__ or alloca are defined;
otherwise, we're not testing alloca. Unfortunately there's no
simple way to consult HAVE_ALLOCA here.
Paul Eggert [Wed, 22 Dec 2004 21:19:47 +0000 (21:19 +0000)]
* NEWS: Bison-generated parsers no longer default to using the
alloca function (when available) to extend the parser stack, due
to widespread problems in unchecked stack-overflow detection.
* data/glr.c (YYMAXDEPTH): Remove undef when zero. It's the user's
responsibility to set it to a positive value. This lets the user
specify a value that is not a preprocessor constant.
* data/yacc.c (YYMAXDEPTH): Likewise.
(YYSTACK_ALLOC): Define only if YYSTACK_USE_ALLOCA is nonzero.
* doc/bison.texinfo (Stack Overflow): YYMAXDEPTH no longer needs
to be a compile-time constant. However, explain the constraints on it.
Also, explain the constraints on YYINITDEPTH.
(Table of Symbols): Explain that alloca is no longer the default.
Explain the user's responsibility if they define YYSTACK_USE_ALLOCA
to 1.
Akim Demaille [Wed, 22 Dec 2004 10:06:15 +0000 (10:06 +0000)]
* data/lalr1.cc (parser::token_number_type, parser::rhs_number_type)
(parser::state_type, parser::semantic_type, parser::location_type):
Private, not public.
(parser::parse): Return ints, not bool.
Returning a bool introduces a problem: 0 corresponds to false, and
it seems weird to return false on success. Returning true changes
the conventions for yyparse.
Alternatively we could return void and send an exception.
There is no clear consensus (yet?).
(state_stack, semantic_stack, location_stack): Rename as...
(state_stack_type, semantic_stack_type, location_stack_type): these.
Private, not public.
* tests/c++.at: New.
* tests/testsuite.at, tests/Makefile.am: Adjust.
Akim Demaille [Tue, 21 Dec 2004 12:26:56 +0000 (12:26 +0000)]
Don't impose std::string for filenames.
* data/lalr1.cc (b4_filename_type): New.
(position::filename): Use it.
(parser.hh): Move the inclusion of stack.hh and location.hh below
the user code, so that needed headers for the filename type can be
included first.
Forward declare them before the user code.
* tests/Makefile.am (check-local, installcheck-local): Pass
TESTSUITEFLAGS to the TESTSUITE.
Akim Demaille [Tue, 21 Dec 2004 12:03:47 +0000 (12:03 +0000)]
Don't impose std::string for filenames.
* data/lalr1.cc (b4_filename_type): New.
(position::filename): Use it.
(parser.hh): Move the inclusion of stack.hh and location.hh below
the user code, so that needed headers for the filename type can be
included first.
Akim Demaille [Fri, 17 Dec 2004 15:24:32 +0000 (15:24 +0000)]
* data/lalr1.cc: Extensive Doxygenation.
(error_): Rename as...
(error): this, since it is visible to the user.
Adjust callers.
(Parser::message): Now an automatic variable from...
(Parser::yyreport_syntax_error_): here.
* tests/actions.at, tests/calc.at, tests/regression.at: Adjust to
Parser::error.
* tests/input.at: Escape $.
Akim Demaille [Thu, 16 Dec 2004 09:06:08 +0000 (09:06 +0000)]
Use #define to handle the %name-prefix.
* data/glr.c, data/yacc.c: Comment changes.
* data/lalr1.cc (yylex): Use #define to select the name of yylex,
so that one can refer to yylex in the parser file, and have it
renamed, as is the case with other skeletons.
Paul Eggert [Thu, 16 Dec 2004 00:09:08 +0000 (00:09 +0000)]
* src/vcg.h (enum layoutalgorithm): Remove. All uses removed.
(struct node, struct graph):
Rename member expand to stretch. All uses changed.
(struct graph): Remove member layoutalgorithm. All uses removed.
* src/vcg.c (get_layoutalgorithm_str): Remove. All uses removed.
* src/vcg_defaults.h (G_STRETCH): Renamed from G_EXPAND.
All uses changed.
(N_STRETCH): Rename from N_EXPAND. All uses changed.
Akim Demaille [Wed, 15 Dec 2004 16:18:12 +0000 (16:18 +0000)]
Simplify the C++ parser constructor.
* data/lalr1.cc (debug_): Rename as...
(yydebug_): so that the parser's internals are always in the yy*
pseudo namespace.
Adjust uses.
(b4_parse_param_decl): Remove the leading comma as it is now only
called as unique argument list.
(Parser::Parser): Remove the constructor accepting a location and
an initial debugging level.
Remove from the other ctor the argument for the debugging level.
(debug_level_type, debug_level, set_debug_level): New.
* tests/actions.at, tests/calc.at, tests/regression.at: Adjust
constructor calls.
Akim Demaille [Wed, 15 Dec 2004 15:35:17 +0000 (15:35 +0000)]
Remove b4_root related material: failure experiment
(which goal was to allow to derive from an class).
* data/lalr1.cc (b4_root, b4_param, b4_constructor): Remove
definitions and uses.
Paul Eggert [Tue, 14 Dec 2004 18:48:42 +0000 (18:48 +0000)]
(struct yyGLRStack): yyerror_range now has 3 items,
not 2, since it's not portable to subtract 1 from the start of an
array. The new item 0 is never set or used. All uses changed.
(yyrecoverSyntaxError): Use YYLLOC_DEFAULT instead of assuming
the default definition of YYLLOC_DEFAULT. Problem reported
by Frank Heckenbach.
Paul Eggert [Sun, 12 Dec 2004 09:25:45 +0000 (09:25 +0000)]
(YYRHSLOC): Don't have two definitions, one for
the normal case and one for the error case. Just use the
first one uniformly. Problem reported by Frank Heckenbach.
(YYLLOC_DEFAULT): Use the conventions of yacc.c, so we can
use exactly the same macro in both places.
(yyerror_range): Now of type yyGLRStackItem, not YYLTYPE,
so that the normal-case YYRHSLOC works for the error case too.
All uses changed.
Paul Eggert [Sun, 12 Dec 2004 09:24:56 +0000 (09:24 +0000)]
(Location Default Action): Don't claim that
we have an array of locations. Use the same macro for both glr
and lalr parsers. Mention YYRHSLOC. Mention what happens when
the index is 0.
Paul Eggert [Sat, 11 Dec 2004 07:07:48 +0000 (07:07 +0000)]
(_AT_CHECK_PRINTER_AND_DESTRUCTOR): New arg
specifying whether the test should be skipped. Use it tp
specify that the [%defines %skeleton "lalr1.cc"] tests currently
fail on some hosts, and should be skipped.
Paul Eggert [Sat, 11 Dec 2004 06:13:07 +0000 (06:13 +0000)]
(relation_print, relation_digraph):
Relation sizes are of type relation_node, not size_t (this is
merely a doc fix, since the two types are equivalent).
(relation_transpose): Relation sizes are of type relation_node,
not int.
(top, infinity): Now of type relation_node, not int.
(traverse, relation_transpose): Use relation_node, not int.
Paul Eggert [Sat, 11 Dec 2004 06:12:41 +0000 (06:12 +0000)]
(relation_print, relation_digraph):
Relation sizes are of type relation_node, not size_t (this is
merely a doc fix, since the two types are equivalent).
(relation_transpose): Relation sizes are of type relation_node,
not int.
Paul Eggert [Sat, 11 Dec 2004 06:07:11 +0000 (06:07 +0000)]
(yyuserAction, yyrecoverSyntaxError): Mark args
with ATTRIBUTE_UNUSED if they're not used, to avoid GCC warning.
(yyparse): Remove unused local introduced in 2004-10-25 patch.
Paul Eggert [Sat, 11 Dec 2004 05:38:19 +0000 (05:38 +0000)]
(_AT_CHECK_PRINTER_AND_DESTRUCTOR): New arg
specifying whether the test is expected to fail. Use it tp
specify that the [%defines %skeleton "lalr1.cc"] tests currently
fail.
Paul Eggert [Fri, 10 Dec 2004 07:50:44 +0000 (07:50 +0000)]
* src/system.h (CALLOC, MALLOC, REALLOC): Remove. All callers
changed to use xcalloc, xnmalloc, xnrealloc, respectively,
unless otherwise specified below.
* src/LR0.c (allocate_itemsets): Use xnmalloc, not xcalloc,
to allocate kernel_base, kernel_items, kernel_size, since
they needn't be initialized to 0.
(allocate_storgae): Likewise, for shiftset, redset, shift_symbol.
* src/closure.c (new_closure): Likewise, for itemset.
* src/derives.c (derives_compute): Likewise, for delts, derives, q.
* src/lalr.c (set_goto_map): Likewise, for temp_map.
(initialize_F): Likewise, for reads, edge, reads[i], includes[i].
(build_relations): Likewise for edge, states1, includes.
* src/nullable.c (nullable_compute): Likewise, for squeue, relts.
* src/reader.c (packgram): Likewise, for ritem, rules.
* src/reduce.c (nonterminals_reduce): Likewise for nontermmap.
* src/relation.c (relation_digraph): Likewise for VERTICES.
(relation_transpose): Likewise for new_R, end_R.
* src/symtab.c (symbols_token_translations_init): Likewise for
token_translations.
* src/tables.c (save_row): Likewise for froms, tos, conflict_tos.
(token_actions): Likewise for yydefact, actrow, conflrow,
conflict_list.
(save_column): Likewise for froms[symno], tos[symno].
(goto_actions): Likewise for state_count.
(pack_table): Likewise for base, pos, check.
(tables_generate): Likewise for width.
* src/LR0.c (set_states): Don't reuse kernel_size and kernel_base
for initial core. Just have a separate core, so we needn't worry
about whether kernel_size and kernel_base are initialized.
* src/closure.c (new_closure): Arg is of type unsigned int, not int.
This is because all callers pass unsigned int.
* src/closure.h (new_closure): Likewise.
* src/lalr.c (initialize_F): Initialize reads[i] in all cases.
(build_relations): Initialize includes[i] in all cases.
* src/reader.c (packgram): Always initialize rules[ruleno].prec
and rules[ruleno].precsym. Initialize members in order.
* src/relation.c (relation_transpose): Always initialize new_R[i]
and end_R[i].
* src/table.c (conflict_row): Initialize 0 at end of conflict_list.
* src/output.c (prepare_actions): Pass 0 instead of conflict_list[0];
conflict_list[0] was always 0, but now it isn't initialized.
* src/table.c (table_grow): When conflict_table grew, the grown
area wasn't cleared. Fix this.
Paul Eggert [Fri, 10 Dec 2004 07:48:43 +0000 (07:48 +0000)]
(allocate_itemsets): Use xnmalloc, not xcalloc,
to allocate kernel_base, kernel_items, kernel_size, since
they needn't be initialized to 0.
(set_states): Don't reuse kernel_size and kernel_base
for initial core. Just have a separate core, so we needn't worry
about whether kernel_size and kernel_base are initialized.
(shift_symbol, redset, shiftset, kernel_base,
kernel_size, kernel_items): Remove unnecessary initialization.
Paul Eggert [Wed, 8 Dec 2004 05:54:20 +0000 (05:54 +0000)]
(set_goto_map): Don't allow ngotos to equal
GOTO_NUMBER_MAXIMUM, since we occasionally compute
ngotos + 1 without checking for overflow.
(build_relations): Use END_NODE, not -1, to denote end of edges.
(set_goto_map, map_goto, initialize_F, add_loopback_edge,
build_relations): Use goto_number, not int, for goto numbers.
Akim Demaille [Tue, 23 Nov 2004 19:56:12 +0000 (19:56 +0000)]
2004-11-23 Akim Demaille <akim@epita.fr>
* data/lalr1.cc (YYSTYPE): Define it as is done for C, instead
of #defining from yystype.
Don't typedef yystype, C++ does not need it.
This lets it possible to forward declare it as union.
Akim Demaille [Wed, 17 Nov 2004 16:17:50 +0000 (16:17 +0000)]
Alexandre Duret-Lutz <adl@gnu.org>
* data/lalr1.cc (Parser::yycdebug_): New, a pointer, to allow
changes.
(YYCDEBUG): Adjust.
Use it instead of cdebug_.
(Parser::debug_stream, Parser::set_debug_stream): New.
(Parser::symprint_): Define cdebug_ for temporary backward
compatibility.
* tests/actions.at (_AT_CHECK_PRINTER_AND_DESTRUCTOR): Use
debug_stream ().
Akim Demaille [Mon, 25 Oct 2004 10:37:35 +0000 (10:37 +0000)]
* data/glr.c (YYRHSLOC): Move its definition next to its uses.
Introduce another definition to address simple location arrays.
(yyGLRStack): New member: yyerror_range.
(yyrecoverSyntaxError, yyparse): Update it.
(yyrecoverSyntaxError): Use it when shifting the error token to
have an accurate range, equivalent to the one computed by both
yacc.c and lalr1.cc.
* tests/cxx-type.at (_AT_TEST_GLR_CXXTYPES): Change its yylex so
that column numbers start at column 0, as per GNU Coding
Standards, the others tests, and the doc.
(_AT_RESOLVED_GLR_OUTPUT_WITH_LOC, _AT_AMBIG_GLR_OUTPUT_WITH_LOC):
Adjust to the above change (first column is 0).
And adjust the location of the "<error>", now covering the whole
line.
Akim Demaille [Mon, 11 Oct 2004 09:03:55 +0000 (09:03 +0000)]
* src/symtab.c (symbol_check_alias_consistency): Also check
type names, destructors, and printers.
Reported by Alexandre Duret-Lutz.
Recode the handling of associativity and precedence in terms
of symbol_precedence_set.
Accept no redeclaration at all, not even equal to the previous
value.
(redeclaration): New.
Use it to factor redeclaration complaints.
(symbol_make_alias): Don't set the type of the alias, let
symbol_check_alias_consistency do it as for other features.
* src/symtab.h (symbol): Add new member prec_location, and
type_location.
* src/symtab.c (symbol_precedence_set, symbol_type_set): Set them.
* tests/input.at (Incompatible Aliases): New.