Akim Demaille [Thu, 27 Dec 2001 18:04:28 +0000 (18:04 +0000)]
* src/output.c (prepare): Drop the muscle `ntbase' which
duplicates ntokens.
* src/bison.simple: Formatting/comment changes.
Use YYNTOKENS only, which is documented, but not YYNTBASE, which
is an undocumented synonym.
Akim Demaille [Sat, 22 Dec 2001 15:16:41 +0000 (15:16 +0000)]
* src/output.c (output_table_data): Change the prototype to use
`int' for array ranges: some invocations do pass an int, not a
short.
Reported by Wayne Green.
Akim Demaille [Sat, 22 Dec 2001 14:58:53 +0000 (14:58 +0000)]
Some actions of web2c.y are improperly triggered.
Reported by Mike Castle.
* src/lalr.c (traverse): s/F (i)[k] = F (j)[k]/F (j)[k] = F (i)[k]/.
* tests/regression.at (Web2c): Rename as...
(Web2c Report): this.
(Web2c Actions): New.
Akim Demaille [Tue, 18 Dec 2001 09:33:44 +0000 (09:33 +0000)]
Some host fail on `assert (!"foo")', which expands to
((!"foo") ? (void)0 : __assert("!"foo."", __FILE__, __LINE__))
Reported by Nelson Beebee.
* src/output.c, src/vcg.c: Replace `assert (!"it succeeded")' with
`#define it_succeeded 0' and `assert (it_succeeded)'.
Marc Autret [Mon, 17 Dec 2001 20:28:51 +0000 (20:28 +0000)]
* src/bison.simple: Don't hard code the skeleton line and filename.
* src/output.c (output_parser): Rename 'line' as 'output_line'.
New line counter 'skeleton_line' (skeleton-line muscle).
Akim Demaille [Mon, 17 Dec 2001 17:32:59 +0000 (17:32 +0000)]
* src/state.h (state_t): Rename lookaheads as lookaheadsp.
nlookaheads is a new member.
Adjust all users.
* src/lalr.h (nlookaheads): Remove this orphan declaration.
* src/lalr.c (initialize_lookaheads): Set nlookaheads for each
state.
Akim Demaille [Mon, 17 Dec 2001 17:31:56 +0000 (17:31 +0000)]
* src/output.c (output_obstack): Be static and rename as...
(format_obstack): this, to avoid any confusion with files.c's
output_obstack.
* src/reader.h (muscle_obstack): Move to...
* src/output.h: here, since it's defined in output.c.
Marc Autret [Sun, 16 Dec 2001 01:26:25 +0000 (01:26 +0000)]
* src/bison.simple: Remove a useless #line directive.
s/#line %%line %%skeleton/#line %%line "%%parser-file-name"/'.
* src/output.c (get_lines_number): New.
(output_parser): Adjust, now takes care about the lines of a
output muscles.
Fix line numbering.
(actions_output): Computes the number of lines taken by actions.
(output_master_parser): Insert new skeleton which is the name of
the output parser file name.
Akim Demaille [Sat, 15 Dec 2001 16:21:44 +0000 (16:21 +0000)]
* src/nullable.c (set_nullable): Useless rules must be skipped,
otherwise, since we range over their symbols, we might look at a
nonterminal which no longer ``exists'', i.e., it is not counted in
`nvars', hence we overflow our arrays.
Akim Demaille [Sat, 15 Dec 2001 16:06:50 +0000 (16:06 +0000)]
The header can also be produced directly, without any obstack!
Yahoo!
* src/files.c, src/files.h (defines_obstack): Remove.
(compute_header_macro): Global.
(defines_obstack_save): Remove.
* src/reader.c (parse_union_decl): No longer output to
defines_obstack: its content can be found in the `stype' muscle
anyway.
(output_token_translations): Merge into...
(symbols_output): this.
Rename as...
(symbols_save): this.
(reader): Adjust.
* src/output.c (header_output): New.
(output): Call it.
Akim Demaille [Sat, 15 Dec 2001 15:25:15 +0000 (15:25 +0000)]
* src/reader.c (parse_union_decl): Instead of handling two obstack
simultaneously, use one to define the `stype' muscle, and use the
value of the latter to fill defines_obstack.
(copy_comment): Remove.
(copy_comment2): Work for a single obstack.
Rename as...
(copy_comment): this.
Akim Demaille [Sat, 15 Dec 2001 14:35:57 +0000 (14:35 +0000)]
Still making progress in separating Bison into (i) input, (ii)
process, (iii) output: now we can directly output the parser file
without using table_obstack at all.
* src/files.c, src/files.h (table_obstack): Bye bye.
(parser_file_name): New.
* src/files.c (compute_output_file_names): Compute it.
* src/output.c (actions_output, output_parser)
(output_master_parser): To a file instead of an obstack.
Akim Demaille [Sat, 15 Dec 2001 14:14:30 +0000 (14:14 +0000)]
Attach actions to rules, instead of pre-outputting them to
actions_obstack.
* src/gram.h (rule_t): action and action_line are new members.
* src/reader.c (symbol_list): Likewise.
(copy_action): Save the actions within the rule.
(packgram): Save them in rule_table.
* src/output.c (actions_output): New.
(output_parser): Use it on `%%actions'.
(output_rule_data): Don't free rule_table.
(output): Do it.
(prepare): Don't save the `action' muscle.
* src/bison.simple: s/%%action/%%actions/.
Akim Demaille [Fri, 14 Dec 2001 15:39:05 +0000 (15:39 +0000)]
* src/lex.c (literalchar): Don't escape the special characters,
just decode them, and keep them as char (before, eol was output as
the 2 char string `n' etc.).
* src/output.c (output_rule_data): Use quotearg to output the
token strings.
Paul Eggert [Fri, 14 Dec 2001 01:54:30 +0000 (01:54 +0000)]
* src/bison.simple (YYSIZE_T, YYSTACK_ALLOC, YYSTACK_FREE):
Do not infringe on the global user namespace when using C++.
(YYFPRINTF, YYSTDERR): New macros, needed for the above.
All uses of `fprintf' and `stderr' changed.
Paul Eggert [Fri, 14 Dec 2001 01:52:50 +0000 (01:52 +0000)]
(const): Do not define; that is now config.h's job.
(YYSIZE_T, YYSTACK_ALLOC, YYSTACK_FREE):
Do not infringe on the global user namespace when using C++.
(YYFPRINTF, YYSTDERR): New macros, needed for the above.
All uses of `fprintf' and `stderr' changed.
Akim Demaille [Thu, 13 Dec 2001 11:02:21 +0000 (11:02 +0000)]
The computation of nullable is broken: it doesn't handle empty
RHS's properly.
* tests/torture.at (GNU AWK Grammar): New.
* tests/sets.at (Nullable): New.
* src/nullable.c (set_nullable): Instead of blindly looping over
`ritems', loop over the rules, and then over their rhs's.
Work around Autotest bugs.
* src/warshall.c (bitmatrix_print): Don't use `+--+' as table
frame, because Autotest understand lines starting with a `+' as
traces from the shell. Then, they are not processed properly.
Admittedly an Autotest bug, but we don't have time to wait for
Autotest to catch up.
* tests/regression.at (Broken Closure): Adjust to the new table
frames.
Move to...
* tests/sets.at: here.
Akim Demaille [Thu, 13 Dec 2001 11:01:51 +0000 (11:01 +0000)]
* src/print.c (print_actions): Output the handling of `$' as the
traces do: shifting the token EOF. Before EOF was treated as a
nonterminal.
* tests/regression.at: Adjust some tests.
* src/print_graph.c (print_core): Complete the set of items via
closure. The next-to-final and final states are still unsatisfying,
but that's to be addressed elsewhere.
No longer output the rule numbers, but do output the state number.
A single loop for the shifts + gotos is enough, but picked a
distinct color for each.
(print_graph): Initialize and finalize closure.
Akim Demaille [Wed, 12 Dec 2001 11:58:19 +0000 (11:58 +0000)]
Some hosts don't like `/' in includes.
* src/system.h: Include libgettext.h without qualifying the path.
* src/Makefile.am (INCLUDES): Add $(top_srcdir)/intl, remove
$(top_srcdir).
Marc Autret [Tue, 11 Dec 2001 20:10:22 +0000 (20:10 +0000)]
* src/bison.simple: Remove #line just before %%epilogue. It
is now handled in ...
* src/reader.c (read_additionnal_code): Add the output of a
#line for the epilogue.
Marc Autret [Mon, 10 Dec 2001 23:19:09 +0000 (23:19 +0000)]
* src/reader.c (copy_definition): Re-use CPP-outed code which
replace precedent remove.
* src/bison.simple: Remove #line before %%prologue because
%%input-line is wrong at this time.
Akim Demaille [Mon, 10 Dec 2001 09:09:49 +0000 (09:09 +0000)]
Now that states have a complete set of members, the linked list of
shifts is useless: just fill directly the state's shifts member.
* src/state.h (shifts): Remove the `next' member.
* src/LR0.c (first_state, last_state): Remove.
Adjust the callers.
(augment_automaton): Don't look for the shifts that must be added
a shift on EOF: it is those of the state we looked for! But now,
since shifts are attached, it is no longer needed to looking
merely by its id: its number.
Akim Demaille [Mon, 10 Dec 2001 09:09:28 +0000 (09:09 +0000)]
* src/LR0.c (augment_automaton): Better variable locality.
Remove an impossible branch: if there is a state corresponding to
the start symbol being shifted, then there is shift for the start
symbol from the initial state.
Akim Demaille [Mon, 10 Dec 2001 09:09:14 +0000 (09:09 +0000)]
* src/LR0.c (augment_automaton): Call `insert_eof_shifting_state'
only when appropriate: when insert_start_shifting_state' is not
invoked.
* tests/regression.at (Rule Line Numbers): Adjust.
Akim Demaille [Mon, 10 Dec 2001 09:08:09 +0000 (09:08 +0000)]
* 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.
Akim Demaille [Mon, 10 Dec 2001 09:07:55 +0000 (09:07 +0000)]
* 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!
Akim Demaille [Mon, 10 Dec 2001 09:06:48 +0000 (09:06 +0000)]
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.
Akim Demaille [Mon, 10 Dec 2001 09:06:27 +0000 (09:06 +0000)]
* 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.
Akim Demaille [Mon, 10 Dec 2001 09:05:47 +0000 (09:05 +0000)]
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.
Akim Demaille [Mon, 10 Dec 2001 08:45:22 +0000 (08:45 +0000)]
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.
Akim Demaille [Mon, 10 Dec 2001 08:44:49 +0000 (08:44 +0000)]
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.
Akim Demaille [Wed, 5 Dec 2001 09:43:53 +0000 (09:43 +0000)]
* 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.
Akim Demaille [Wed, 5 Dec 2001 09:41:15 +0000 (09:41 +0000)]
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.
Akim Demaille [Wed, 5 Dec 2001 09:41:01 +0000 (09:41 +0000)]
* 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.
Akim Demaille [Wed, 5 Dec 2001 09:34:55 +0000 (09:34 +0000)]
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.
Akim Demaille [Wed, 5 Dec 2001 09:32:23 +0000 (09:32 +0000)]
* 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''.
Akim Demaille [Wed, 5 Dec 2001 09:32:00 +0000 (09:32 +0000)]
* src/conflicts.c (flush_shift, resolve_sr_conflict): De-obfuscate
using the good o' techniques: arrays not pointers, variable
locality, BITISSET, RESETBIT etc.
Akim Demaille [Wed, 5 Dec 2001 09:31:23 +0000 (09:31 +0000)]
* src/conflicts.c (count_sr_conflicts, count_rr_conflicts)
(print_reductions): De-obfuscate using the good o' techniques:
arrays not pointers, variable locality, BITISSET.