Commit Graph

709 Commits

Author SHA1 Message Date
Akim Demaille
7215de245c * src/LR0.h (first_shift, first_reduction): Remove.
* src/lalr.c: Don't use first_shift: find shifts through the
states.
2001-12-10 09:08:28 +00:00
Akim Demaille
80e25d4d46 * src/LR0.c: Attach shifts to states as soon as they are
computed.
* src/lalr.c (set_state_table): Instead of assigning shifts to
state, just assert that the mapping was properly done.
2001-12-10 09:08:09 +00:00
Akim Demaille
0ab3728b12 * src/LR0.c (insert_start_shift): Rename as...
(insert_start_shifting_state): this.
(insert_eof_shifting_state, insert_accepting_state): New.
(augment_automaton): Adjust.
Better locality of the variables.
When looking if the start_symbol is shifted from the initial
state, using `while (... symbol != start_symbol ...)' sounds
better than `while (... symbol < start_symbol ...)': If fail
to see how the order between symbols could be relevant!
2001-12-10 09:07:55 +00:00
Akim Demaille
78af9bbcd3 * src/getargs.h: Don't declare `spec_name_prefix' and
`spec_file_prefix', declared by src/files.h.
* src/files.c, src/files.h: Default for spec_name_prefix is "yy".
* src/muscle_tab.c (muscle_init): Default prefix to NULL.
* src/output.c (prepare): Adjust.
* src/reader.c (symbols_output): Likewise.
* src/vmsgetargs.c: Vaguely adjust, but who cares?
2001-12-10 09:07:41 +00:00
Akim Demaille
bdef2a413a * src/muscle_tab.c (muscle_init): NULL is a better default than
`"0"'.
2001-12-10 09:07:17 +00:00
Akim Demaille
3735969c7d * src/reader.c (reader): Calling symbols_output once is enough. 2001-12-10 09:07:03 +00:00
Akim Demaille
49701457c2 Now that states have a complete set of members, the linked list of
reductions is useless: just fill directly the state's reductions
member.
* src/state.h (struct reductions): Remove member `number' and
`next'.
* src/LR0.c (first_reduction, last_reduction): Remove.
(save_reductions): Don't link the new reductions, store them in
this_state.
* src/lalr.c (set_state_table): No need to attach reductions to
states, it's already done.
* src/output.c (output_actions): No longer free the shifts, then
the reductions, then the states: free all the states and their
members.
2001-12-10 09:06:48 +00:00
Akim Demaille
0edad74997 * src/options.c (OPTN, DRTV, BOTH): New.
(option_table): Use them.
* src/muscle_tab.c: Don't include xalloc.h and string.h: that's
the job of system.h.
* src/options.c: Don't include stdio.h and xalloc.h for the same
reasons.
2001-12-10 09:06:27 +00:00
Akim Demaille
5449dd0f25 * src/output.c (output, prepare): Make sure the values of the
muscles `action' and `prologue' are 0-terminated.
2001-12-10 09:06:13 +00:00
Akim Demaille
a870c5670e Clean up GCC warnings.
* src/reader.c (copy_action): `buf' is not used.
(parse_skel_decl): Be static.
* src/muscle_tab.c (mhash1, mhash2, muscle_insert): Preserve `const'.
* src/options.h (create_long_option_table): Have a real prototype.
* lib/hash.c, lib/hash.h (hash_insert, hash_insert_at, hash_delete)
(hash_delete_at): Return const void *.
Adjust casts to preserve the const.
2001-12-10 09:05:47 +00:00
Akim Demaille
75addd5e5f Remove tests/Makefile.in and po/Makefile.in. 2001-12-10 09:02:16 +00:00
Akim Demaille
80df876864 * configure.in: Require 2.52g.
M4 is not needed, but AUTOM4TE is.
* m4/m4.m4: Remove.
* tests/Makefile.am: Adjust.
2001-12-10 09:00:36 +00:00
Akim Demaille
f693ad146e One structure for states is enough, even though theoretically
there are LR(0) states and LALR(1) states.
* src/lalr.h (state_t): Remove.
(state_table): Be state_t **, not state_t *.
* src/state.h (core, CORE_ALLOC): Rename as...
(state_t, STATE_ALLOC): this.
Add the LALR(1) members: shifts, reductions, errs.
* src/LR0.c (state_table): Rename as...
(state_hash): this, to avoid name clashes with the global
`state_table'.
* src/print_graph.c, src/LR0.c, src/LR0.h, src/conflicts.c
* src/lalr.c, src/lalr.h, src/output.c, src/print.c: Adjust.
2001-12-10 08:45:22 +00:00
Akim Demaille
74ffbcb6bf Bison dumps core on bash.y.
Reported by Pascal Bart.
* src/warshall.c (bitmatrix_print): New.
(TC): Use it.
When performing a transitive closure R(i, j) && R(j, k) => R(i,	k),
j must be the outer loop.
* tests/regression.at (Broken Closure): New.
2001-12-10 08:44:49 +00:00
Akim Demaille
07708e1946 * tests/atlocal.in (CPPFLAGS): Do not leave a space between -I and
its argument.
Reported by Peter Hmorsk.
2001-12-05 10:59:35 +00:00
Akim Demaille
448b17aa3c Regen. 2001-12-05 09:47:22 +00:00
Akim Demaille
92b16366dd * src/conflicts.c (err_table): Remove.
(resolve_sr_conflict): Adjust.
* src/lalr.h (state_t.reduction_table, state_t.shift_table):
Rename as...
(state_t.reductions, state_t.shifts): this.
2001-12-05 09:44:26 +00:00
Akim Demaille
076ab0334d * src/reduce.c (reduce_grammar_tables): No longer disable the
removal of useless rules via CPP but via `if (0)', so that the
compiler still check the code is valid.
For instance, it should have noticed `rline' no longer exists: use
the `line' member of rule_t.
* src/gram.c (dummy, rline): Remove, unused.
2001-12-05 09:43:53 +00:00
Akim Demaille
3843c413d0 * src/output.c (pack_vector): Use assert, not berror.
* src/main.c (berror): Remove, unused.
2001-12-05 09:43:21 +00:00
Akim Demaille
4316896018 New experimental feature: if --verbose --trace output all the
items of a state, not only its kernel.
* src/print.c (print_core): If `trace_flag', then invoke closure
before outputting the items of the state (print_core is no longer
a correct name them).
(print_results): Invoke new_closure/free_closure if needed.
2001-12-05 09:41:15 +00:00
Akim Demaille
b2872512f1 * src/LR0.c (new_itemsets): Use nshifts only, not shiftcount.
* src/closure.c, src/closure.h (itemsetsize): Rename as...
(nitemset): for consistency with the rest of the project.
2001-12-05 09:41:01 +00:00
Akim Demaille
23cbcc6c19 * src/closure.c (print_closure): Improve.
(closure): Use it for printing input and output.
2001-12-05 09:40:47 +00:00
Akim Demaille
03ec521cc5 * src/closure.c (FIRSTS, FDERIVES): Adjust to reality: they are
indexed by nonterminals.
2001-12-05 09:40:31 +00:00
Akim Demaille
3a7456dd96 * src/warshall.c (TC, RTC): De-obsfucate (source reduced to 22% of
what it was!).
* src/warshall.h: Remove accidental duplication of the content.
2001-12-05 09:40:16 +00:00
Akim Demaille
1cbcf2e795 * src/closure.c (set_fderives): De-obfuscate. 2001-12-05 09:40:00 +00:00
Akim Demaille
841822701a * src/closure.c (print_firsts, print_fderives): De-obfuscate. 2001-12-05 09:39:43 +00:00
Akim Demaille
3f6f053ce5 * src/closure.c (set_firsts): De-obfuscate. 2001-12-05 09:39:27 +00:00
Akim Demaille
7a5350baa0 * src/output.c (action_row): De-obfuscate
using the good o' techniques: arrays not pointers, variable
locality, BITISSET, RESETBIT etc.
2001-12-05 09:39:02 +00:00
Akim Demaille
5e893e1c88 Add src/state.c to the repo. 2001-12-05 09:38:44 +00:00
Akim Demaille
35687a9d8c Formatting changes. 2001-12-05 09:35:55 +00:00
Akim Demaille
d954473dee Pessimize the code to simplify it: from now on, all the states
have a valid SHIFTS, which NSHIFTS is possibly 0.
* src/LR0.c (shifts_new): Be global and move to..
* src/state.c, src/state.h: here.
* src/conflicts, src/lalr.c, src/output.c, src/print.c,
* src/print_graph: Adjust.
2001-12-05 09:34:55 +00:00
Akim Demaille
9839bbe557 * src/state.h (SHIFT_DISABLE, SHIFT_IS_DISABLED): New.
* src/conflicts.c: Use it.
Restore a few missing `if (!SHIFT_IS_DISABLED)' which were
incorrectly ``simplified''.
2001-12-05 09:32:23 +00:00
Akim Demaille
9f136c0720 * src/conflicts.c (flush_shift, resolve_sr_conflict): De-obfuscate
using the good o' techniques: arrays not pointers, variable
locality, BITISSET, RESETBIT etc.
2001-12-05 09:32:00 +00:00
Akim Demaille
b608206eca * src/state.h (SHIFT_SYMBOL): New.
* src/conflicts.c: Use it to deobfuscate.
2001-12-05 09:31:46 +00:00
Akim Demaille
52afa962d1 * src/conflicts.c (count_sr_conflicts, count_rr_conflicts)
(print_reductions): De-obfuscate using the good o' techniques:
arrays not pointers, variable locality, BITISSET.
2001-12-05 09:31:23 +00:00
Akim Demaille
e74dc3213f * src/conflicts.c (print_reductions): Arrays, not pointers.
Use BITISSET.
2001-12-05 09:31:09 +00:00
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