Commit Graph

673 Commits

Author SHA1 Message Date
Akim Demaille
768fca8336 * src/conflicts.c (print_reductions): Pessimize, but clarify. 2001-12-05 09:30:56 +00:00
Akim Demaille
a17e599f81 * src/conflicts.c (print_reductions): Improve variable locality. 2001-12-05 09:30:42 +00:00
Akim Demaille
a04bc34180 * src/conflicts.c (print_reductions): Pessimize, but clarify. 2001-12-05 09:30:28 +00:00
Akim Demaille
c8ea038e69 * src/conflicts.c (print_reductions): Improve variable locality. 2001-12-05 09:30:13 +00:00
Akim Demaille
aa2aab3c16 * src/state.h (SHIFT_IS_ERROR, SHIFT_IS_GOTO, SHIFT_IS_SHIFT): New.
* src/lalr.c: Use them.
2001-12-05 09:30:00 +00:00
Akim Demaille
b178c8ccc4 * src/LR0.c (augment_automaton): Formatting changes.
Better variable locality.
2001-12-05 09:29:33 +00:00
Akim Demaille
f67d13aa6c * src/lalr.c (matrix_print): New.
(transpose): Use it.
Use arrays instead of pointers.
2001-12-05 09:29:17 +00:00
Akim Demaille
c2713865e3 * src/lalr.c (maxrhs): Move to...
* src/gram.c, src/gram.h (ritem_longest_rhs): here.
* src/lalr.c (build_relations): Adjust.
2001-12-05 09:29:02 +00:00
Akim Demaille
9887c18aca * src/lalr.c (transpose): Free the memory allocated to the
argument, as it is replaced by the results by the unique caller.
(build_relations): Merely invoke transpose: it handles the memory
deallocation.
Improve variable locality.
Avoid variables used as mere abbreviations.
(compute_lookaheads): Use arrays instead of pointers.
2001-12-05 09:28:27 +00:00
Akim Demaille
4d4f699ca4 * src/lalr.c (initialize_F): Improve variable locality.
Avoid variables used as mere abbreviations.
2001-12-05 09:28:13 +00:00
Akim Demaille
80a6975034 * src/derives.c (print_derives): Display the ruleno.
* src/lalr.c (initialize_F, transpose): Better variable locality
to improve readability.
Avoid variables used as mere abbreviations.
2001-12-05 09:28:00 +00:00
Akim Demaille
fe96109760 * src/lalr.c (traverse): Use arrays instead of pointers. 2001-12-05 09:27:47 +00:00
Akim Demaille
e3e4e81446 * src/nullable.c (set_nullable): Use a for loop to de-obfuscate
the handling of squeue.
`symbol >= 0' is wrong now, use `rule_table[ruleno].useful'.
2001-12-05 09:27:35 +00:00
Akim Demaille
630e182b7b Because useless nonterminals are now kept alive (instead of being
`destroyed'), we now sometimes examine them, and store information
related to them.  Hence we need to know their number, and adjust
memory allocations.
* src/reduce.c, src/reduce.h (nuseless_nonterminals): No longer
static.
* src/LR0.c (allocate_itemsets): The memory allocated to
`symbol_count' was used for two different purpose: once to count
the number of occurrences of each symbol, and later reassigned to
`shift_symbol', containing the symbol that can be shifted from a
given state.
Deobfuscate, i.e., allocate, use and free `symbol_count' here
only, and...
(new_itemsets): Allocate `shift_symbol' here.
(allocate_itemsets): symbol_count includes useless nonterminals.
Make room for them.
(free_storage): Use `free', not `XFREE', for pointers that cannot
be null.
2001-12-05 09:27:23 +00:00
Akim Demaille
81b51460c9 * src/nullable.c (set_nullable): Deobfuscate the handling of
ritem.
`symbol >= 0' is wrong now, use `rule_table[ruleno].useful'.
2001-12-05 09:27:08 +00:00
Akim Demaille
3067fbef53 * src/gram.c, src/gram.h (ritem_print): New.
* src/gram.c (dummy): Remove, now there is actual code in gram.c.
(This useless function was defined only to work around VMS linkers
that can't handle compilation units with variables only).
* src/reduce.c (dump_grammar): Use it to trace the construction of
ritem.
2001-12-05 09:26:05 +00:00
Paul Eggert
7d27c823de * src/bison.simple (union yyalloc): Change member names
to be the same as the stack names.
(yyparse): yyptr is now union yyalloc *, not char *.
(YYSTACK_RELOCATE): Likewise.  This avoids a GCC warning,
and may generate better code on some machines.
2001-12-04 14:10:51 +00:00
Paul Eggert
2729e106a7 (union yyalloc): Change member names to be the same as the stack names.
(YYPOINTER): Remove.
(yyparse): yyptr is now union yyalloc *, not char *.
(YYSTACK_RELOCATE): Likewise.  This avoids a GCC warning,
and may generate better code on some machines.
2001-12-04 14:10:07 +00:00
Paul Eggert
c2bea5f96f * src/bison.simple (YYPOINTER): New macro.
(YYSTACK_RELOCATE): Use it to avoid a GCC warning.
(yystpcpy): Use prototype if __STDC__ is defined, not just
if __cplusplus is defined.
2001-12-04 13:29:59 +00:00
Paul Eggert
f11966ffc5 (YYPOINTER): New macro.
(YYSTACK_RELOCATE): Use it to avoid a GCC warning.
(yystpcpy): Use prototype if __STDC__ is defined, not just
if __cplusplus is defined.
2001-12-04 13:29:27 +00:00
Akim Demaille
2c8a9dfa1d * configure.in (WARNING_CFLAGS): Add -Werror when possible.
(CFLAGS): Do not include the WARNING_CFLAGS here, since GNU
Gettext doesn't compile cleanly, and dies with -Werror.
* src/Makefile.am, lib/Makefile.am, tests/atlocal.in (CFLAGS):
Include WARNING_CFLAGS here.
* lib/xstrdup.c: Include xalloc.h, so that xstrdup be declared
before being defined.
2001-11-30 14:25:16 +00:00
Akim Demaille
f4e421e6e4 * lib/quotearg.h (quotearg_n, quotearg_n_style):
First arg is int, not unsigned.
* lib/quotearg.c (quotearg_n, quotearg_n_style): Likewise.
(SIZE_MAX, UINT_MAX): New macros.
(quotearg_n_options): Abort if N is negative.
Avoid overflow check on hosts where size_t is 64 bits and int
is 32 bits, as overflow is impossible there.
Fix off-by-one typo that caused unnecessary reallocation.
2001-11-30 14:04:24 +00:00
Akim Demaille
7093d0f541 Name space cleanup in generated parser.
* doc/bison.texinfo (Bison Parser): Discuss system headers
and their effect on the user name space.
* src/bison.simple:
(YYSTACK_ALLOC, YYSTACK_FREE, union yyalloc, YYSTACK_GAP_MAX,
YYSTACK_BYTES, YYSTACK_RELOCATE): Do not define unless necessary,
i.e. unless ! defined (yyoverflow) || defined (YYERROR_VERBOSE).
(YYSIZE_T): New macro.  Use it instead of size_t, to avoid infringing
on user names when possible.
(YYSTACK_USE_ALLOCA): Do not define; just use any existing defn.
Simplify test for whather <alloca.h> exists.
(<stdlib.h>): Include if we will use malloc, and if standard C or C++.
(<stdio.h>): Include if YYDEBUG.
(yymemcpy): Renamed from __yy_memcpy.  Do not define unless
! defined (yyoverflow) && ! defined (yymemcpy).
(yymemcpy, yyparse): Rename local variables as needed so that
they all begin with 'yy'.
(yystrlen, yystpcpy): New functions.
(YY_DECL_NON_LSP_VARIABLES): Renamed from _YY_DECL_VARIABLES.
All uses changed.
(yyparse): size_t -> YYSIZE_T.  Use yystrlen and yystpcpy
instead of relying on string.h functions.  Use YYSTACK_ALLOC
and YYSTACK_FREE instead of malloc and free.
2001-11-30 14:00:14 +00:00
Akim Demaille
fd51e5ffa2 * src/bison.simple (YYSTYPE, YYLTYPE): Move their definitions
before their first uses.
(YYBISON, YYPURE): Move to the top of the output.
2001-11-30 11:23:29 +00:00
Akim Demaille
7d13ff5f2f * tests/reduce.at (Useless Nonterminals): Fix. 2001-11-30 11:15:02 +00:00
Akim Demaille
892a39950d * src/bison.simple (YYSTACK_FREE): Use `do {;} while (0)' as empty
if body instead of `;' to pacify GCC's warnings.
2001-11-30 11:11:34 +00:00
Akim Demaille
68f1e3edc3 Instead of mapping the LHS of unused rules to -1, keep the LHS
valid, but flag the rules as invalid.
* src/gram.h (rule_t): `useful' is a new member.
* src/print.c (print_grammar): Adjust.
* src/derives.c (set_derives): Likewise.
* src/reader.c (packgram, reduce_output): Likewise.
* src/reduce.c (reduce_grammar_tables): Likewise.
* tests/reduce.at (Underivable Rules, Useless Rules): New.
2001-11-30 10:49:24 +00:00
Akim Demaille
d2d1b42b07 * src/reduce.c (reduce_output): Formatting changes.
* src/print.c (print_results, print_grammar): Likewise.
* tests/regression.at (Rule Line Numbers)
(Solved SR Conflicts, Unresolved SR Conflicts): Adjust.
2001-11-30 10:49:01 +00:00
Akim Demaille
760b53a84b * src/reduce.c (nonterminals_reduce): Instead of throwing away
useless nonterminals, move them at the end of the symbol arrays.
(reduce_output): Adjust.
* tests/reduce.at (Useless Nonterminals): Adjust.
2001-11-30 10:48:14 +00:00
Akim Demaille
002389585a * src/reduce.c: Various comment/formatting changes.
(nonterminals_reduce): New, extracted from...
(reduce_grammar_tables): here.
(reduce_grammar): Call nonterminals_reduce.
2001-11-30 10:47:56 +00:00
Paul Eggert
396452de26 * src/bison.simple (YYSTACK_REALLOC): Remove.
(YYSTACK_ALLOC): Resurrect this macro, with its old meaning.
(YYSTACK_FREE, YYSTACK_GAP_MAX, YYSTACK_BYTES, YYSTACK_RELOCATE):
New macros.
(union yyalloc): New type.
(__yy_memcpy): Last arg is size_t, not unsigned int, to remove
an arbitrary restriction on hosts where size_t is wider than int.

(yyparse): Don't dump core if alloca or malloc fails; instead, report
a parser stack overflow.  Allocate just one block of memory for all
three stacks, instead of allocating three blocks; this typically is
faster and reduces fragmentation.

Do not limit the number of items in the stack to a value that fits
in 'int', as this is an arbitrary limit on hosts with 64-bit
size_t and 32-bit int.
2001-11-30 02:56:45 +00:00
Paul Eggert
600f9b0ccc (YYSTACK_REALLOC): Remove.
(YYSTACK_ALLOC): Resurrect this macro, with its old meaning.
(YYSTACK_FREE, YYSTACK_GAP_MAX, YYSTACK_BYTES, YYSTACK_RELOCATE):
New macros.
(union yyalloc): New type.
(__yy_memcpy): Last arg is size_t, not unsigned int, to remove
an arbitrary restriction on hosts where size_t is wider than int.

(yyparse): Don't dump core if alloca or malloc fails; instead, report
a parser stack overflow.  Allocate just one block of memory for all
three stacks, instead of allocating three blocks; this typically is
faster and reduces fragmentation.

Do not limit the number of items in the stack to a value that fits
in 'int', as this is an arbitrary limit on hosts with 64-bit
size_t and 32-bit int.
2001-11-30 02:54:54 +00:00
Marc Autret
04a76783ab Update. 2001-11-29 20:52:44 +00:00
Marc Autret
147e184ccc * tests/calc.at [AT_DATA_CALC_Y]: Use %error-verbose instead
of defining YYERROR_VERBOSE.
[AT_DATA]: $4 is now out of C declarations in the prologue.
2001-11-29 20:48:45 +00:00
Marc Autret
84b113cd22 Update. 2001-11-28 22:31:51 +00:00
Marc Autret
426cf563bd * src/reader.c (parse_dquoted_param): New.
(parse_skel_decl): Use it.
* src/lex.h: Add its prototype.
* src/lex.c (literalchar): Become not static.
2001-11-28 22:28:01 +00:00
Marc Autret
ec93a21372 Update. 2001-11-28 21:31:49 +00:00
Marc Autret
c7925b99cb * src/output.h: And put its extern declaration here.
* src/output.c (error_verbose): Define here.
(prepare): Echo name modification.
* src/getargs.h: Clean its extern declaration.
* src/getargs.c (error_verbose_flag): Remove.
(getargs): Remove case 'e'.
* src/options.c (option_table): 'error-verbose' is now seen as simple
percent option.
Include output.h.
* src/reader.c (read_declarations): Remove case tok_include.
(parse_include_decl): Remove.
* src/lex.h (token_t): Remove tok_include.
* src/options.c (option_table): 'include' is now a simple command line
option.
2001-11-28 21:31:13 +00:00
Marc Autret
5b5d192929 * src/bison.simple: Adjust muscle names.
* src/muscle_tab.c (muscle_init): Also rename the muscles.
* src/output.c (prepare): s/_/-/ for the muscles names.
(output_parser): When scanning for a muscle, allow '-' instead of '_'.
2001-11-28 20:32:53 +00:00
Marc Autret
8850be4b1c * src/bison.simple: Fix debug.
[YYERROR_VERBOSE]: Re-integrate as an internal macro.
2001-11-28 19:54:36 +00:00
Akim Demaille
9113b58f6f Regen. 2001-11-28 14:59:53 +00:00
Akim Demaille
4a38e61393 * src/LR0.c (shifts_new): New.
(save_shifts, insert_start_shift, augment_automaton): Use it.
2001-11-28 14:53:29 +00:00
Akim Demaille
4b35e1c1dd * src/closure.c (closure): b' and ruleno' denote the same value:
keep ruleno only.
2001-11-28 14:53:16 +00:00
Akim Demaille
d2b04478d4 * src/closure.c (closure): Instead of looping over word in array
then bits in words, loop over bits in array.
2001-11-28 14:53:03 +00:00
Akim Demaille
2c4c30aa95 * src/closure.c (closure): No longer optimize the special case
where all the bits of `ruleset[r]' are set to 0, to make the code
clearer.
2001-11-28 14:52:50 +00:00
Akim Demaille
576890b7ee * src/closure.c (closure): r' and c' are new variables, used to
de-obfuscate accesses to RULESET and CORE.
2001-11-28 14:52:38 +00:00
Akim Demaille
cb487d7d0d * src/reduce.c (reduce_print): Use ngettext.
(dump_grammar): Improve the trace accuracy.
2001-11-28 13:38:53 +00:00
Akim Demaille
6013d43f59 * src/reduce.c (dump_grammar): Don't translate trace messages. 2001-11-28 11:58:28 +00:00
Akim Demaille
cb4956ee99 * tests/reduce.at (Useless Terminals, Useless Nonterminals): New.
* src/reduce.c (reduce_grammar_tables): Do not free useless tags,
as all tags are free'ed afterwards.
From Enrico Scholz.
2001-11-28 11:43:24 +00:00
Paul Eggert
648185ab4a * src/bison.simple (YYSTACK_REALLOC): Fix typo that caused us to
use alloca when we didn't want to, and vice versa.
2001-11-27 23:19:14 +00:00