Merge in branch-1_29.

This commit is contained in:
Akim Demaille
2001-10-04 14:55:21 +00:00
parent 0150aabe35
commit 342b8b6e21
59 changed files with 2212 additions and 1586 deletions

View File

@@ -3,10 +3,11 @@ config.cache
config.h config.h
config.log config.log
config.status config.status
stamp-h stamp-h*
bison-* bison-*
patches patches
*.patch *.log log patches applied *.patch *.log log patches applied
*.prj *.prj
releases releases
*.flc *.flc
autom4te.cache

478
ChangeLog
View File

@@ -1,3 +1,451 @@
2001-10-04 Akim Demaille <akim@epita.fr>
Merge in the branch 1.29.
* src/reader.c (packsymbols): Use a temporary obstack for
`%%tokendef', since output_stack is already used elsewhere.
2001-10-02 Akim Demaille <akim@epita.fr>
Bump 1.29d.
2001-10-02 Akim Demaille <akim@epita.fr>
Version 1.29c.
2001-10-02 Akim Demaille <akim@epita.fr>
* tests/regression.at (Invalid CPP headers): New.
From Alexander Belopolsky.
* src/files.c (compute_header_macro): Map non alnum chars to `_'.
2001-10-02 Akim Demaille <akim@epita.fr>
* tests/regression.at (Invalid input): New.
* src/lex.c (lex): Be sure to set `token_buffer' in any case.
Reported by Shura.
2001-10-02 Akim Demaille <akim@epita.fr>
* tests/calc.at: Now that --debug works, the tests must be adjusted.
2001-10-02 Akim Demaille <akim@epita.fr>
* src/output.c (output_parser): Assert `skeleton'.
* src/files.c (skeleton_find): Look harder for skeletons on DOSish
systems.
From Shura.
2001-10-01 Marc Autret <autret_m@epita.fr>
* src/lex.h: Echo modifications.
* src/lex.c (unlex): Parameter is now token_t.
From Hans Aberg.
2001-10-01 Marc Autret <autret_m@epita.fr>
* src/main.c: Include lex.h.
From Hans Aberg.
2001-09-29 Akim Demaille <akim@epita.fr>
* src/getargs.c (longopts): `--debug' is `-t', not `-d'.
2001-09-28 Akim Demaille <akim@epita.fr>
* tests/testsuite.at: Update to newer Autotest.
* tests/Makefile.am (EXTRA_DIST): bison is not to be shipped.
2001-09-27 Akim Demaille <akim@epita.fr>
Position independent wrapper.
* tests/bison: Remove.
* tests/bison.in: New.
* configure.in: Adjust.
2001-09-27 Paul Eggert <eggert@twinsun.com>
Port quotearg fixes from tar 1.13.24.
* lib/quotearg.c: BSD/OS 4.1 wchar.h requires FILE and struct
tm to be declared.
(HAVE_MBSINIT): Undef if !HAVE_MBRTOWC.
(mbsinit): Define to 1 if !defined mbsinit && !HAVE_MBSINIT.
* m4/Makefile.am (EXTRA_DIST): Add mbrtowc.m4.
* m4/mbrtowc.m4: New file.
* m4/prereq.m4 (jm_PREREQ_QUOTEARG): Check for mbsinit and stddef.h.
Use jm_FUNC_MBRTOWC instead of AC_CHECK_FUNCS(mbrtowc).
2001-09-27 Akim Demaille <akim@epita.fr>
Bump to 1.29c.
2001-09-27 Akim Demaille <akim@epita.fr>
Version 1.29b.
2001-09-25 Akim Demaille <akim@epita.fr>
* src/system.h: Include `xalloc.h'.
Remove it from the C files.
* src/files.c (output_files): Free the obstacks.
* src/lex.c (init_lex): Rename as...
(lex_init): this.
(lex_free): New.
* src/main.c (main): Use it.
2001-09-24 Marc Autret <autret_m@epita.fr>
* src/vcg.c (open_edge, close_edge, open_node, close_node): Change
to output informations in fout (FILE*).
(open_graph, close_graph): Likewise.
(output_graph, output_edge, output_node): Likewise.
* src/vcg.h: Update function prototypes.
* src/print_graph.c (print_graph): Open output graph file.
(print_actions): Adjust.
* src/files.h: Remove extern declaration.
* src/files.c: Remove graph_obstack declaration.
(open_files): Remove graph_obstack initialization.
(output_files): Remove graph_obstack saving.
2001-09-24 Marc Autret <autret_m@epita.fr>
* src/files.c (compute_output_file_names): Fix.
2001-09-24 Marc Autret <autret_m@epita.fr>,
Akim Demaille <akim@epita.fr>
* src/reader.c (reader): Remove call to free_symtab ().
* src/main.c (main): Call it here.
Include symtab.h.
* src/conflicts.c (initialize_conflicts): Rename as...
(solve_conflicts): this.
* src/print.c (print_core, print_actions, print_state)
(print_grammar): Dump to a file instead a `output_obstack'.
(print_results): Dump `output_obstack', and then proceed with the
FILE *.
* src/files.c (compute_output_file_names, close_files): New.
(output_files): Adjust.
* src/main.c (main): Adjust.
2001-09-23 Marc Autret <autret_m@epita.fr>
* src/files.c (compute_header_macro): Computes header macro name
from spec_defines_file when given.
2001-09-23 Marc Autret <autret_m@epita.fr>
* src/files.c (output_files): Add default extensions.
2001-09-22 Akim Demaille <akim@epita.fr>
* src/conflicts.c (finalize_conflicts): Rename as...
(free_conflicts): this.
2001-09-22 Akim Demaille <akim@epita.fr>
* src/gram.c (gram_free): Rename back as...
(dummy): this.
(output_token_translations): Free `token_translations'.
* src/symtab.c (free_symtab): Free the tag field.
2001-09-22 Akim Demaille <akim@epita.fr>
Remove `translations' as it is always set to true.
* src/gram.h: Adjust.
* src/reader.c (packsymbols, parse_token_decl): Adjust
* src/print.c (print_grammar): Adjust.
* src/output.c (output_token_translations): Adjust.
* src/lex.c (lex): Adjust.
* src/gram.c: Be sure the set pointers to NULL.
(dummy): Rename as...
(gram_free): this.
2001-09-22 Akim Demaille <akim@epita.fr>
* configure.in: Invoke AM_LIB_DMALLOC.
* src/system.h: Use dmalloc.
* src/LR0.c: Be sure to have pointers initialized to NULL.
(allocate_itemsets): Allocate kernel_items only if needed.
2001-09-22 Akim Demaille <akim@epita.fr>
* configure.in: Bump to 1.29b.
* tests/Makefile.am (DISTCLEANFILES): Add package.m4.
* tests/calc.at (_AT_DATA_CALC_Y): #undef malloc so that we don't
need xmalloc.c in calc.y.
From Pascal Bart.
2001-09-21 Akim Demaille <akim@epita.fr>
Version 1.29a.
* Makefile.maint, config/config.guess, config/config.sub,
* config/missing: Update from masters.
* tests/Makefile.am ($(srcdir)/$(TESTSUITE)): No longer depend
upon package.m4.
* configure.in (ALL_LINGUAS): Add `tr'.
2001-09-21 Akim Demaille <akim@epita.fr>
* tests/Makefile.am (package.m4): Move to...
($(srcdir)/$(TESTSUITE)): here.
2001-09-20 Akim Demaille <akim@epita.fr>
* src/complain.c: No longer try to be standalone: use system.h.
Don't assume __STDC__ is defined to 1. Just test if it is defined.
* src/complain.h: Likewise.
* src/reduce.c (useless_nonterminals, inaccessable_symbols):
Remove the unused variable `n'.
From Albert Chin-A-Young.
2001-09-18 Marc Autret <autret_m@epita.fr>
* doc/bison.1: Update.
* doc/bison.texinfo (Bison Options): Update --defines and --graph
descriptions.
(Option Cross Key): Update.
Add --graph.
2001-09-18 Marc Autret <autret_m@epita.fr>
* tests/regression.at: New test (comment in %union).
2001-09-18 Marc Autret <autret_m@epita.fr>
* src/reader.c (parse_union_decl): Do not output '/'. Let copy_comment
do that.
Reported by Keith Browne.
2001-09-18 Marc Autret <autret_m@epita.fr>
* tests/output.at: Add tests for --defines and --graph.
2001-09-18 Marc Autret <autret_m@epita.fr>
* tests/output.at: Removes tests of %{header,src}_extension features.
2001-09-18 Akim Demaille <akim@epita.fr>
* tests/Makefile.am (package.m4): New.
* tests/calc.at (_AT_CHECK_CALC): Just run `calc input'.
(_AT_CHECK_CALC_ERROR): Likewise.
Factor the `, ' part of verbose error messages.
2001-09-18 Marc Autret <autret_m@epita.fr>
* src/getargs.c (longopts): Declare --defines and --graph as options
with optional arguments.
* src/files.h: Add extern declarations.
* src/files.c (spec_graph_file, spec_defines_file): New.
(output_files): Update.
Remove CPP-outed code.
2001-09-18 Marc Autret <autret_m@epita.fr>
Turn off %{source,header}_extension feature.
* src/files.c (compute_exts_from_gf): Update.
(compute_exts_from_src): Update.
(output_files): CPP-out useless code.
* src/files.h: Remove {header,source}_extension extern declarations.
* src/reader.c (parse_dquoted_param): CPP-out.
(parse_header_extension_decl): Remove.
(parse_source_extension_decl): Remove.
(read_declarations): Remove cases tok_{hdrext,srcext}.
* src/lex.c (percent_table): Remove {header,source}_extension entries.
* src/lex.h (token_t): Remove tok_hdrext and tok_srcext.
2001-09-10 Akim Demaille <akim@epita.fr>
* tests/output.at (AT_CHECK_BISON_FLAGS, AT_CHECK_BISON_PERCENT):
(AT_CHECK_BISON_PERCENT_FLAGS): Merge into...
(AT_CHECK_OUTPUT): this.
Merely check ls' exit status, its output is useless.
2001-09-10 Akim Demaille <akim@epita.fr>
* tests/calc.at: Use m4_match.
(_AT_DATA_CALC_Y): Check `yyin != NULL', not `stdin != NULL'.
2001-09-10 Marc Autret <autret_m@epita.fr>,
Akim Demaille <akim@epita.fr>
* src/vcg.h (graph_s): color, textcolor, bordercolor are now
enum color_e.
* src/print_graph.c (print_graph): Initalize graph.layoutalgorithm
to `normal'.
* src/reader.c (parse_token_decl): Initialize token with tok_eof.
* src/lex.h: Adjust prototype.
(token_t): Add `tok_undef'.
* src/lex.c (struct percent_table_struct): Retval is now a token_t.
(parse_percent_token): Now returns token_t.
Add default statement in switch.
(lex): Separate `c' as an input variable, from the token_t result
part.
(unlexed): Is a token_t.
2001-09-10 Akim Demaille <akim@epita.fr>
* configure.in: Bump to 1.29a.
2001-09-07 Akim Demaille <akim@epita.fr>
Version 1.29.
2001-08-30 Akim Demaille <akim@epita.fr>
* tests/atgeneral.m4, tests/atconfig.in, tests/suite.at: Remove.
* m4/atconfig.m4: Remove.
* tests/testsuite.at, tests/atlocal.in, tests/output.at,
* tests/bison: New.
* tests/regression.at, tests/calc.at: Use m4_define, AT_BANNER,
m4_if, m4_patsubst, and m4_regexp.
* tests/calc.at (_AT_CHECK_CALC, _AT_CHECK_CALC_ERROR): Use an
`input' file instead of echo.
2001-08-29 Akim Demaille <akim@epita.fr>
Bump to 1.28e.
2001-08-29 Akim Demaille <akim@epita.fr>
Version 1.28d.
2001-08-29 Paul Eggert <eggert@twinsun.com>
* src/bison.simple (yyparse): Don't take the address of an
item before the start of an array, as that doesn't conform to
the C Standard.
2001-08-29 Robert Anisko <anisko_r@epita.fr>
* doc/bison.texinfo (Location Tracking Calc): New node.
2001-08-29 Paul Eggert <eggert@twinsun.com>
* src/output.c (output): Do not define const, as this now
causes more problems than it cures.
2001-08-29 Akim Demaille <akim@epita.fr>
* doc/bison.texinfo: Modernize `@node' and `@top' use: just name
the nodes.
Be sure to tag the `detailmenu'.
2001-08-29 Akim Demaille <akim@epita.fr>
* Makefile.maint (do-po-update): Wget refuses to overwrite files:
download in a tmp dir.
2001-08-28 Marc Autret <autret_m@epita.fr>
* config/depcomp: New file.
2001-08-28 Marc Autret <autret_m@epita.fr>
* doc/bison.1 (mandoc): Adjust.
From Juan Manuel Guerrero.
2001-08-28 Marc Autret <autret_m@epita.fr>
* src/print_graph.c (print_state): Fix.
2001-08-27 Marc Autret <autret_m@epita.fr>
* src/vcg.h (classname_s, infoname_s, node_s): Constify the
char * members.
Echo modifications to the functions prototypes.
* src/vcg.c (add_classname, add_infoname): Adjust arguments.
2001-08-27 Marc Autret <autret_m@epita.fr>
* src/vcg.c: Include `xalloc.h'.
(add_colorentry): New.
(add_classname): New.
(add_infoname): New.
* src/vcg.h: Add new prototypes.
2001-08-27 Akim Demaille <akim@epita.fr>
* Makefile.maint: Sync. again with CVS Autoconf.
2001-08-27 Akim Demaille <akim@epita.fr>
* Makefile.maint: Formatting changes.
(po-update, cvs-update, update): New targets.
(AMTAR): Remove.
2001-08-27 Akim Demaille <akim@epita.fr>
* Makefile.am (AUTOMAKE_OPTIONS): 1.5.
* Makefile.maint: Sync. with CVS Autoconf.
2001-08-27 Marc Autret <autret_m@epita.fr>
* src/vcg.h (struct infoname_s): New.
(struct colorentry_s): New.
(graph_s): New fields {vertical,horizontal}_order in structure.
Add `infoname' field.
Add `colorentry' field;
* src/vcg_defaults.h (G_VERTICAL_ORDER): New.
(G_HORIZONTAL_ORDER): New.
(G_INFONAME): New.
(G_COLORENTRY): New.
* src/vcg.c (output_graph): Add output of {vertical,horizontal}_order.
Add output of `infoname'.
Add output of `colorentry'.
2001-08-27 Marc Autret <autret_m@epita.fr>
* src/reader.c (parse_dquoted_param): Rename variable `index' to `i'.
This one shadowed a global parameter.
2001-08-24 Marc Autret <autret_m@epita.fr>
* src/print_graph.c (node_output_size): Declared POSIX `size_t' type,
instead of `unsigned'.
(print_state): Do not call obstack_object_size () in obstack_grow ()
to avoid macro variables shadowing.
2001-08-23 Marc Autret <autret_m@epita.fr>
* src/lex.c (percent_table): Typo: s/naem/name/.
Add graph option.
Normalize new options declarations.
2001-08-20 Pascal Bart <pascal.bart@epita.fr>
* tests/suite.at: Exercise %header_extension and %source_extension.
2001-08-16 Marc Autret <autret_m@epita.fr>
* src/reader.c (parse_dquoted_param): New.
(parse_header_extension_decl): Use it.
(parse_source_extension_decl): Likewise.
2001-08-16 Marc Autret <autret_m@epita.fr>
* src/vcg.c: Remove includes of `complain.h' and `xalloc.h'.
(get_xxxx_str): Use assert () instead of complain ().
Remove return invokations in default cases.
(get_decision_str): Modify default behaviour. Remove second argument.
Echo modifications on calls.
(output_graph): Fix.
2001-08-16 Marc Autret <autret_m@epita.fr>
* src/getargs.c (usage): Update with ``-g, --graph''.
2001-08-16 Marc Autret <autret_m@epita.fr>
* doc/bison.texinfo (Bison Options): Add items `-g', `--graph'.
(Option Cross Key): Likewise.
* doc/bison.1: Update.
2001-09-25 Pascal Bart <pascal.bart@epita.fr> 2001-09-25 Pascal Bart <pascal.bart@epita.fr>
* src/output.c (output_master_parser): Don't finish action_obstack. * src/output.c (output_master_parser): Don't finish action_obstack.
@@ -46,7 +494,7 @@
2001-09-20 Pascal Bart <pascal.bart@epita.fr> 2001-09-20 Pascal Bart <pascal.bart@epita.fr>
* src/options.c (symtab.h): Include it, need by lex.h. * src/options.c (symtab.h): Include it, need by lex.h.
2001-09-20 Pascal Bart <pascal.bart@epita.fr> 2001-09-20 Pascal Bart <pascal.bart@epita.fr>
* src/lex.c (parse_percent_token): Change type of variable `tx', which * src/lex.c (parse_percent_token): Change type of variable `tx', which
@@ -92,7 +540,7 @@
* src/output.c (output): Delete call to reader_output_yylsp. * src/output.c (output): Delete call to reader_output_yylsp.
* src/reader.c (reader): Likewise. * src/reader.c (reader): Likewise.
* src/reader.h: Delete declaration of reader_output_yylsp. * src/reader.h: Delete declaration of reader_output_yylsp.
2001-09-02 Marc Autret <autret_m@epita.fr> 2001-09-02 Marc Autret <autret_m@epita.fr>
* src/reader.c: Include muscle_tab.h. * src/reader.c: Include muscle_tab.h.
@@ -102,9 +550,9 @@
(read_declarations, copy_action, read_additionnal_code, : Updated (read_declarations, copy_action, read_additionnal_code, : Updated
with correct variables and functions names. with correct variables and functions names.
(packsymbols, reader): Likewise. (packsymbols, reader): Likewise.
* src/reader.h (muscle_obstack): Extern declaration update. * src/reader.h (muscle_obstack): Extern declaration update.
* src/output.c: Include muscle_tab.h * src/output.c: Include muscle_tab.h
In all functions using macro_insert, change by using muscle_insert (). In all functions using macro_insert, change by using muscle_insert ().
(macro_obstack): Rename muscle_obstack. (macro_obstack): Rename muscle_obstack.
@@ -116,7 +564,7 @@
* src/muscle_tab.h: Update double inclusion macros. * src/muscle_tab.h: Update double inclusion macros.
(macro_entry_s): Rename muscle_entry_s. (macro_entry_s): Rename muscle_entry_s.
Update prototypes. Update prototypes.
* src/muscle_tab.c: Include muscle_tab.h. * src/muscle_tab.c: Include muscle_tab.h.
Rename macro_tabble to muscle_table. Rename macro_tabble to muscle_table.
(mhash1, mhash2, mcmp): Use muscle_entry. (mhash1, mhash2, mcmp): Use muscle_entry.
@@ -131,7 +579,7 @@
2001-09-02 Marc Autret <autret_m@epita.fr> 2001-09-02 Marc Autret <autret_m@epita.fr>
Now the files macro_tab.[ch] are named muscle_tab.[ch]. Now the files macro_tab.[ch] are named muscle_tab.[ch].
* src/muscle_tab.c, src/muscle_tab.h: Add files. * src/muscle_tab.c, src/muscle_tab.h: Add files.
2001-09-02 Marc Autret <autret_m@epita.fr> 2001-09-02 Marc Autret <autret_m@epita.fr>
@@ -140,7 +588,7 @@
2001-09-01 Pascal Bart <pascal.bart@epita.fr> 2001-09-01 Pascal Bart <pascal.bart@epita.fr>
* src/reader.c (copy_guard): Use muscle to specify the `#line' * src/reader.c (copy_guard): Use muscle to specify the `#line'
filename. filename.
2001-09-01 Marc Autret <autret_m@epita.fr> 2001-09-01 Marc Autret <autret_m@epita.fr>
@@ -166,10 +614,10 @@
and insert the `prefix' muscles. and insert the `prefix' muscles.
* src/macrotab.c (macro_init): Likewise. * src/macrotab.c (macro_init): Likewise.
(macro_init): Initialization prefix directive by `yy'. (macro_init): Initialization prefix directive by `yy'.
* src/bison.simple: Substitute all %%yylex, %%yychar, %%yylval, * src/bison.simple: Substitute all %%yylex, %%yychar, %%yylval,
%%yydebug, %%yyerror, %%yynerrs and %%yyparse by yylex, yychar, %%yydebug, %%yyerror, %%yynerrs and %%yyparse by yylex, yychar,
yylval, yydebug, yyerror, yynerrs and yyparse. yylval, yydebug, yyerror, yynerrs and yyparse.
New directive `#define' to substitute yydebug, ... with option New directive `#define' to substitute yydebug, ... with option
name_prefix. name_prefix.
2001-08-31 Pascal Bart <pascal.bart@epita.fr> 2001-08-31 Pascal Bart <pascal.bart@epita.fr>
@@ -180,11 +628,11 @@
2001-08-31 Pascal Bart <pascal.bart@epita.fr>, Marc Autret <autret_m@epita.fr> 2001-08-31 Pascal Bart <pascal.bart@epita.fr>, Marc Autret <autret_m@epita.fr>
* src/reader.c (read_additionnal_code): Rename %%user_code to * src/reader.c (read_additionnal_code): Rename %%user_code to
%%epilogue. %%epilogue.
* src/output.c (output): Rename %%declarations to %%prologue. * src/output.c (output): Rename %%declarations to %%prologue.
* src/bison.simple: Echo modifications. * src/bison.simple: Echo modifications.
2001-08-31 Marc Autret <autret_m@epita.fr> 2001-08-31 Marc Autret <autret_m@epita.fr>
* src/reader.c (readgram): CleanUp. * src/reader.c (readgram): CleanUp.
@@ -195,7 +643,7 @@
2001-08-31 Pascal Bart <pascal.bart@epita.fr> 2001-08-31 Pascal Bart <pascal.bart@epita.fr>
* src/reader.c (reader): Delete obsolete call to function * src/reader.c (reader): Delete obsolete call to function
output_trailers and output_headers. output_trailers and output_headers.
* src/output.h: Remove obsolete functions prototypes of output_headers * src/output.h: Remove obsolete functions prototypes of output_headers
and output_trailers. and output_trailers.
@@ -203,7 +651,7 @@
2001-08-30 Pascal Bart <pascal.bart@epita.fr> 2001-08-30 Pascal Bart <pascal.bart@epita.fr>
* src/main.c: Include macrotab.h. * src/main.c: Include macrotab.h.
* src/macrotab.h (macro_entry_s): Constify fields. * src/macrotab.h (macro_entry_s): Constify fields.
Adjust functions prototypes. Adjust functions prototypes.
* src/macrotab.c (macro_insert): Constify key and value. * src/macrotab.c (macro_insert): Constify key and value.
(macro_find): Constify key. (macro_find): Constify key.
@@ -216,7 +664,7 @@
2001-08-30 Marc Autret <autret_m@epita.fr> 2001-08-30 Marc Autret <autret_m@epita.fr>
* src/reader.c (parse_skel_decl): New. * src/reader.c (parse_skel_decl): New.
(read_declarations): Add case `tok_skel', call parse_skel_decl (). (read_declarations): Add case `tok_skel', call parse_skel_decl ().
* src/lex.h (token_t): New token `tok_skel'. * src/lex.h (token_t): New token `tok_skel'.
* src/lex.c (percent_table): Add skeleton option entry. * src/lex.c (percent_table): Add skeleton option entry.
Standardize. Standardize.
@@ -237,7 +685,7 @@
2001-08-28 Pascal Bart <pascal.bart@epita.fr> 2001-08-28 Pascal Bart <pascal.bart@epita.fr>
* src/output.c (output): Copy attrs_obstack in the '%%definitions' * src/output.c (output): Copy attrs_obstack in the '%%definitions'
directive. directive.
* src/bison.simple: Add `%%definitions'. * src/bison.simple: Add `%%definitions'.

View File

@@ -1,5 +1,5 @@
## Process this file with automake to produce Makefile.in -*-Makefile-*- ## Process this file with automake to produce Makefile.in -*-Makefile-*-
AUTOMAKE_OPTIONS = 1.5 check-news readme-alpha AUTOMAKE_OPTIONS = 1.5 check-news readme-alpha dist-bzip2
ACLOCAL_AMFLAGS = -I m4 ACLOCAL_AMFLAGS = -I m4
@@ -26,3 +26,5 @@ alpha_url_dir = gnu/bison
# Files to update automatically. # Files to update automatically.
wget_files = $(srcdir)/config/config.guess $(srcdir)/config/config.sub \ wget_files = $(srcdir)/config/config.guess $(srcdir)/config/config.sub \
$(srcdir)/config/texinfo.tex $(srcdir)/config/texinfo.tex
cvs_files = $(srcdir)/config/missing

View File

@@ -22,9 +22,6 @@
# Do not save the original name or timestamp in the .tar.gz file. # Do not save the original name or timestamp in the .tar.gz file.
GZIP_ENV = '--no-name --best' GZIP_ENV = '--no-name --best'
# Automake 1.4 does not define AMTAR.
AMTAR ?= $(TAR)
CVS = cvs CVS = cvs
prev_version_file ?= .prev-version prev_version_file ?= .prev-version
@@ -46,12 +43,101 @@ release_archive_dir ?= ../release
## ---------------- ##
## Updating files. ##
## ---------------- ##
WGET = wget
ftp-gnu = ftp://ftp.gnu.org/gnu
# Use mv, if you don't have/want move-if-change.
move_if_change ?= move-if-change
# ------------------- #
# Updating PO files. #
# ------------------- #
po_repo = http://www.iro.umontreal.ca/contrib/po/maint/$(PACKAGE)
.PHONY: do-po-update po-update
do-po-update:
tmppo=/tmp/$(PACKAGE)-$(VERSION)-po &&\
rm -rf $$tmppo && \
mkdir $$tmppo && \
(cd $$tmppo && $(WGET) -r -l1 -nd --no-parent -A '*.po' $(po_repo)) &&\
cp $$tmppo/*.po po
cd po && $(MAKE) update-po
$(MAKE) po-check
po-update:
if test -d "po"; then \
$(MAKE) do-po-update; \
fi
# -------------------------- #
# Updating GNU build tools. #
# -------------------------- #
# The following pseudo table associates a local directory and a URL
# with each of the files that belongs to some other package and is
# regularly updated from the specified URL.
wget_files ?= $(srcdir)/config.guess $(srcdir)/config.sub \
$(srcdir)/src/ansi2knr.c \
$(srcdir)/doc/texinfo.tex
wget-targets = $(patsubst %, get-%, $(wget_files))
config.guess-url_prefix = $(ftp-gnu)/config/
config.sub-url_prefix = $(ftp-gnu)/config/
ansi2knr.c-url_prefix = ftp://ftp.cs.wisc.edu/ghost/
texinfo.tex-url_prefix = $(ftp-gnu)/texinfo/
standards.texi-url_prefix = $(ftp-gnu)/GNUinfo/
make-stds.texi-url_prefix = $(ftp-gnu)/GNUinfo/
target = $(patsubst get-%, %, $@)
url = $($(notdir $(target))-url_prefix)$(notdir $(target))
.PHONY: $(wget-targets)
$(wget-targets):
$(WGET) $(url) -O $(target).t \
&& $(move_if_change) $(target).t $(target)
.PHONY: wget-update
wget-update: $(wget-targets)
# Updating tools via CVS.
cvs_files ?= depcomp missing
cvs-targets = $(patsubst %, get-%, $(cvs_files))
automake_repo = :pserver:anoncvs@anoncvs.cygnus.com:/cvs/automake
.PHONY: $(cvs-targets)
$(cvs-targets):
$(CVS) -d $(automake_repo) co -p automake/lib/$(notdir $(target)) \
>$(target).t \
&& $(move_if_change) $(target).t $(target);
.PHONY: cvs-update
cvs-update: $(cvs-targets)
# --------------------- #
# Updating everything. #
# --------------------- #
.PHONY: update
update: wget-update cvs-update po-update
## --------------- ## ## --------------- ##
## Sanity checks. ## ## Sanity checks. ##
## --------------- ## ## --------------- ##
# Checks that don't require cvs. # Checks that don't require cvs. Run `changelog-check' last as
local-check: changelog-check po-check writable-files copyright-check # previous test may reveal problems requiring new ChangeLog entries.
local-check: po-check copyright-check writable-files changelog-check
changelog-check: changelog-check:
if head ChangeLog | grep 'Version $(VERSION)' >/dev/null; then \ if head ChangeLog | grep 'Version $(VERSION)' >/dev/null; then \
@@ -117,10 +203,16 @@ maintainer-distcheck: changelog-check
$(MAKE) my-distcheck $(MAKE) my-distcheck
## -------------- ##
## Making dists. ##
## -------------- ##
# Tag before making distribution. Also, don't make a distribution if # Tag before making distribution. Also, don't make a distribution if
# checks fail. Also, make sure the NEWS file is up-to-date. # checks fail. Also, make sure the NEWS file is up-to-date.
# FIXME: use dist-hook/my-dist like distcheck-hook/my-distcheck. # FIXME: use dist-hook/my-dist like distcheck-hook/my-distcheck.
cvs-dist: cvs-check maintainer-distcheck cvs-dist: local-check cvs-check maintainer-distcheck
$(CVS) update po $(CVS) update po
$(CVS) tag -c $(this-cvs-tag) $(CVS) tag -c $(this-cvs-tag)
$(MAKE) dist $(MAKE) dist
@@ -130,6 +222,7 @@ cvs-dist: cvs-check maintainer-distcheck
null_AM_MAKEFLAGS = \ null_AM_MAKEFLAGS = \
ACLOCAL=false \ ACLOCAL=false \
AUTOCONF=false \ AUTOCONF=false \
AUTOM4TE=false \
AUTOMAKE=false \ AUTOMAKE=false \
AUTOHEADER=false \ AUTOHEADER=false \
MAKEINFO=false MAKEINFO=false
@@ -177,7 +270,7 @@ rel-check:
md5_tmp=/tmp/rel-check-md5-$$$$; \ md5_tmp=/tmp/rel-check-md5-$$$$; \
set -e; \ set -e; \
trap 'status=$$?; rm -f $$tarz $$md5_tmp; exit $$status' 0 1 2 3 15; \ trap 'status=$$?; rm -f $$tarz $$md5_tmp; exit $$status' 0 1 2 3 15; \
wget -q --output-document=$$tarz $(url); \ $(WGET) -q --output-document=$$tarz $(url); \
echo "$(md5) -" > $$md5_tmp; \ echo "$(md5) -" > $$md5_tmp; \
md5sum -c $$md5_tmp < $$tarz md5sum -c $$md5_tmp < $$tarz
@@ -228,48 +321,6 @@ announcement: NEWS ChangeLog $(rel-files)
-e 'print "\n"."*"x70 ."\n"; s///; print; print "*"x70 ."\n"'; \ -e 'print "\n"."*"x70 ."\n"; s///; print; print "*"x70 ."\n"'; \
) )
WGET = wget
ftp-gnu = ftp://ftp.gnu.org/gnu
# Use mv, if you don't have/want move-if-change.
move_if_change ?= move-if-change
# The following pseudo table associates a local directory and a URL
# with each of the files that belongs to some other package and is
# regularly updated from the specified URL.
wget_files ?= $(srcdir)/config.guess $(srcdir)/config.sub \
$(srcdir)/src/ansi2knr.c \
$(srcdir)/doc/texinfo.tex
get-targets = $(patsubst %, get-%, $(wget_files))
config.guess-url_prefix = $(ftp-gnu)/config/
config.sub-url_prefix = $(ftp-gnu)/config/
ansi2knr.c-url_prefix = ftp://ftp.cs.wisc.edu/ghost/
texinfo.tex-url_prefix = $(ftp-gnu)/texinfo/
standards.texi-url_prefix = $(ftp-gnu)/GNUinfo/
make-stds.texi-url_prefix = $(ftp-gnu)/GNUinfo/
target = $(patsubst get-%, %, $@)
url = $($(notdir $(target))-url_prefix)$(notdir $(target))
.PHONY: $(get-targets)
$(get-targets):
$(WGET) $(url) -O $(target).t \
&& $(move_if_change) $(target).t $(target)
automake_repo=:pserver:anoncvs@anoncvs.cygnus.com:/cvs/automake
.PHONY: wget-update
wget-update: $(get-targets)
for f in depcomp missing; do \
test -f $$f || continue; \
echo checking out $$f...; \
$(CVS) -d $(automake_repo) co -p automake/lib/$$f > $$f.t \
&& $(move_if_change) $$f.t $$f; \
done
define emit-rsync-commands define emit-rsync-commands
echo ===================================== echo =====================================
echo ===================================== echo =====================================
@@ -284,7 +335,7 @@ endef
$(xd-delta): $(release_archive_dir)/$(prev-tgz) $(distdir).tar.gz $(xd-delta): $(release_archive_dir)/$(prev-tgz) $(distdir).tar.gz
xdelta delta -9 $^ $@ || : xdelta delta -9 $^ $@ || :
alpha: local-check alpha:
$(MAKE) cvs-dist $(MAKE) cvs-dist
$(MAKE) $(xd-delta) $(MAKE) $(xd-delta)
$(MAKE) -s announcement > /tmp/announce-$(my_distdir) $(MAKE) -s announcement > /tmp/announce-$(my_distdir)

22
NEWS
View File

@@ -1,7 +1,27 @@
Bison News Bison News
---------- ----------
Changes in version 1.28c: Changes in version 1.29d:
* `--defines' and `--graph' have now an optionnal argument which is the
output file name. `-d' and `-g' do not change, they do not take any
argument.
* `%source_extension' and `%header_extension' are removed, failed
experiment.
* The test suite is more portable.
* Better portability.
Changes in version 1.29:
* The output file does not define const, as this caused problems when used
with common autoconfiguration schemes. If you still use ancient compilers
that lack const, compile with the equivalent of the C compiler option
`-Dconst='. autoconf's AC_C_CONST macro provides one way to do this.
* Added `-g' and `--graph'.
* The Bison manual is now distributed under the terms of the GNU FDL. * The Bison manual is now distributed under the terms of the GNU FDL.

31
THANKS
View File

@@ -1,22 +1,27 @@
Bison was originally written by Robert Corbett. It would not be what Bison was originally written by Robert Corbett. It would not be what
it is today without the invaluable help of these people: it is today without the invaluable help of these people:
Akim Demaille akim@epita.fr Akim Demaille akim@epita.fr
Daniel Hagerty hag@gnu.org Albert Chin-A-Young china@thewrittenword.com
David J. MacKenzie djm@gnu.org Alexander Belopolsky alexb@rentec.com
Fabrice Bauzac noon@cote-dazur.com Daniel Hagerty hag@gnu.org
Hans Aberg haberg@matematik.su.se David J. MacKenzie djm@gnu.org
Jesse Thilo jthilo@gnu.org Fabrice Bauzac noon@cote-dazur.com
Jim Meyering meyering@gnu.org Hans Aberg haberg@matematik.su.se
Laurent Mascherpa laurent.mascherpa@epita.fr Jesse Thilo jthilo@gnu.org
Jim Meyering meyering@gnu.org
Juan Manuel Guerrero ST001906@HRZ1.HRZ.TU-Darmstadt.De
Keith Browne kbrowne@legato.com
Laurent Mascherpa laurent.mascherpa@epita.fr
Marc Autret autret_m@epita.fr Marc Autret autret_m@epita.fr
Neil Booth NeilB@earthling.net Neil Booth NeilB@earthling.net
Noah Friedman friedman@gnu.org Noah Friedman friedman@gnu.org
Pascal Bart pascal.bart@epita.fr Pascal Bart pascal.bart@epita.fr
Paul Eggert eggert@twinsun.com Paul Eggert eggert@twinsun.com
Piotr Gackiewicz gacek@intertel.com.pl Piotr Gackiewicz gacek@intertel.com.pl
Richard Stallman rms@gnu.org Richard Stallman rms@gnu.org
Robert Anisko anisko_r@epita.fr Robert Anisko anisko_r@epita.fr
Shura debil_urod@ngs.ru
Many people are not named here because we lost track of them. We Many people are not named here because we lost track of them. We
thank them! Please, help us keeping this list up to date. thank them! Please, help us keeping this list up to date.

View File

@@ -1 +1 @@
1.28c 1.29c

View File

@@ -1,12 +1,32 @@
# Process this file with autoconf to produce a configure script. # Configure template for GNU Bison. -*-Autoconf-*-
AC_PREREQ(2.52) #
AC_INIT(bison, 1.28c, bug-bison@gnu.org) # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
# 02111-1307 USA
# We need a recent Autoconf to run a recent Autotest.
AC_PREREQ(2.52e)
AC_INIT([GNU Bison], [1.29d], [bug-bison@gnu.org])
AC_CONFIG_AUX_DIR(config) AC_CONFIG_AUX_DIR(config)
AM_INIT_AUTOMAKE(bison, 1.28c)
AM_INIT_AUTOMAKE([bison], [1.29d])
AM_CONFIG_HEADER(config.h:config.hin) AM_CONFIG_HEADER(config.h:config.hin)
# Initialize the test suite. # Initialize the test suite.
AT_CONFIG(../src) AC_CONFIG_TESTDIR(tests)
AC_CONFIG_FILES([tests/bison], [chmod +x tests/bison])
# Checks for programs. # Checks for programs.
AC_PROG_CC AC_PROG_CC
@@ -69,8 +89,9 @@ jm_FUNC_MALLOC
jm_FUNC_REALLOC jm_FUNC_REALLOC
jm_PREREQ_QUOTEARG jm_PREREQ_QUOTEARG
jm_PREREQ_ERROR jm_PREREQ_ERROR
AM_WITH_DMALLOC
ALL_LINGUAS="de es et fr ja nl ru" ALL_LINGUAS="de es et fr ja nl tr ru"
AM_GNU_GETTEXT AM_GNU_GETTEXT
# This is necessary so that .o files in LIBOBJS are also built via # This is necessary so that .o files in LIBOBJS are also built via
@@ -83,4 +104,4 @@ AC_OUTPUT([Makefile
intl/Makefile po/Makefile.in intl/Makefile po/Makefile.in
lib/Makefile src/Makefile doc/Makefile lib/Makefile src/Makefile doc/Makefile
m4/Makefile m4/Makefile
tests/Makefile tests/atconfig]) tests/Makefile])

View File

@@ -10,7 +10,11 @@ bison \- GNU Project parser generator (yacc replacement)
] [ ] [
.B \-d .B \-d
] [ ] [
.B \-\-defines .BI \-\-defines= defines-file
] [
.B \-g
] [
.BI \-\-graph= graph-file
] [ ] [
.B \-k .B \-k
] [ ] [
@@ -123,8 +127,6 @@ chosen as if the input file were named
.B \-d .B \-d
.br .br
.ns .ns
.TP
.B \-\-defines
Write an extra output file containing macro definitions for the token Write an extra output file containing macro definitions for the token
type names defined in the grammar and the semantic value type type names defined in the grammar and the semantic value type
.BR YYSTYPE , .BR YYSTYPE ,
@@ -145,6 +147,32 @@ in a separate source file, because
needs to be able to refer to token type codes and the variable needs to be able to refer to token type codes and the variable
.BR yylval . .BR yylval .
.TP .TP
.BI \-\-defines= defines-file
The behaviour of
.BI \-\-defines
is the same than
.BI \-d
option.
The only difference is that it has an optionnal argument which is
the name of the output filename.
.TP
.BI \-g
.br
.ns
Output a VCG definition of the LALR(1) grammar automaton computed by
Bison. If the grammar file is
.BR foo.y
, the VCG output file will be
.BR foo.vcg .
.TP
.BI \-\-graph= graph-file
The behaviour of
.BI \-\-graph
is the same than
.BI \-g
option. The only difference is that it has an optionnal argument which
is the name of the output graph filename.
.TP
.B \-k .B \-k
.br .br
.ns .ns
@@ -315,9 +343,9 @@ bison \-y $*
.sp .sp
.RE .RE
.SH FILES .SH FILES
/usr/local/lib/bison.simple simple parser /usr/local/share/bison/bison.simple simple parser
.br .br
/usr/local/lib/bison.hairy complicated parser /usr/local/share/bison/bison.hairy complicated parser
.SH "ENVIRONMENT VARIABLES" .SH "ENVIRONMENT VARIABLES"
.TP .TP
.SM BISON_SIMPLE .SM BISON_SIMPLE

File diff suppressed because it is too large Load Diff

View File

@@ -63,6 +63,11 @@
#endif #endif
#if HAVE_WCHAR_H #if HAVE_WCHAR_H
/* BSD/OS 4.1 wchar.h requires FILE and struct tm to be declared. */
# include <stdio.h>
# include <time.h>
# include <wchar.h> # include <wchar.h>
#endif #endif
@@ -73,8 +78,12 @@
# undef MB_CUR_MAX # undef MB_CUR_MAX
# define MB_CUR_MAX 1 # define MB_CUR_MAX 1
# define mbrtowc(pwc, s, n, ps) ((*(pwc) = *(s)) != 0) # define mbrtowc(pwc, s, n, ps) ((*(pwc) = *(s)) != 0)
# define mbsinit(ps) 1
# define iswprint(wc) ISPRINT ((unsigned char) (wc)) # define iswprint(wc) ISPRINT ((unsigned char) (wc))
# undef HAVE_MBSINIT
#endif
#if !defined mbsinit && !HAVE_MBSINIT
# define mbsinit(ps) 1
#endif #endif
#ifndef iswprint #ifndef iswprint

View File

@@ -1,8 +1,8 @@
## Process this file with automake to produce Makefile.in -*-Makefile-*- ## Process this file with automake to produce Makefile.in -*-Makefile-*-
EXTRA_DIST = \ EXTRA_DIST = \
atconfig.m4 \
c-bs-a.m4 \ c-bs-a.m4 \
codeset.m4 \ codeset.m4 \
dmalloc.m4 \
error.m4 \ error.m4 \
gettext.m4 \ gettext.m4 \
glibc21.m4 \ glibc21.m4 \
@@ -11,6 +11,7 @@ isc-posix.m4 \
lcmessage.m4 \ lcmessage.m4 \
m4.m4 \ m4.m4 \
malloc.m4 \ malloc.m4 \
mbrtowc.m4 \
mbstate_t.m4 \ mbstate_t.m4 \
prereq.m4 \ prereq.m4 \
progtest.m4 \ progtest.m4 \

View File

@@ -1,22 +0,0 @@
## ----------------------##
## Prepare for testing. ##
## ----------------------##
# serial 2
# Single argument says where are built sources to test, relative to the
# built test directory. Maybe omitted if the same (flat distribution).
AC_DEFUN([AT_CONFIG],
[AT_TESTPATH=ifelse([$1], [], [.], [$1])
AC_SUBST([AT_TESTPATH])
# Try to be compatible with both Autoconf 2.13 and 2.50.
if test -z "$ECHO_C$ECHO_N$ECHO_T"; then
ECHO_C="$ac_c"
ECHO_N="$ac_n"
ECHO_T="$ac_t"
AC_SUBST([ECHO_C])
AC_SUBST([ECHO_N])
AC_SUBST([ECHO_T])
fi
])

22
m4/dmalloc.m4 Normal file
View File

@@ -0,0 +1,22 @@
## ----------------------------------- ##
## Check if --with-dmalloc was given. ##
## From Franc,ois Pinard ##
## ----------------------------------- ##
# serial 1
AC_DEFUN([AM_WITH_DMALLOC],
[AC_MSG_CHECKING([if malloc debugging is wanted])
AC_ARG_WITH(dmalloc,
[ --with-dmalloc use dmalloc, as in
http://www.dmalloc.com/dmalloc.tar.gz],
[if test "$withval" = yes; then
AC_MSG_RESULT(yes)
AC_DEFINE(WITH_DMALLOC,1,
[Define if using the dmalloc debugging malloc package])
LIBS="$LIBS -ldmalloc"
LDFLAGS="$LDFLAGS -g"
else
AC_MSG_RESULT(no)
fi], [AC_MSG_RESULT(no)])
])

18
m4/mbrtowc.m4 Normal file
View File

@@ -0,0 +1,18 @@
#serial 4
dnl From Paul Eggert
AC_DEFUN([jm_FUNC_MBRTOWC],
[
AC_CACHE_CHECK([whether mbrtowc and mbstate_t are properly declared],
jm_cv_func_mbrtowc,
[AC_TRY_LINK(
[#include <wchar.h>],
[mbstate_t state; return ! (sizeof state && mbrtowc);],
jm_cv_func_mbrtowc=yes,
jm_cv_func_mbrtowc=no)])
if test $jm_cv_func_mbrtowc = yes; then
AC_DEFINE(HAVE_MBRTOWC, 1,
[Define to 1 if mbrtowc and mbstate_t are properly declared.])
fi
])

View File

@@ -1,12 +1,13 @@
#serial 1 #serial 2
dnl These are the prerequisite macros for files in the lib/ dnl These are the prerequisite macros for files in the lib/
dnl directories of Bison. dnl directories of Bison.
AC_DEFUN([jm_PREREQ_QUOTEARG], AC_DEFUN([jm_PREREQ_QUOTEARG],
[ [
AC_CHECK_FUNCS(isascii iswprint mbrtowc) AC_CHECK_FUNCS(isascii iswprint mbsinit)
AC_CHECK_HEADERS(limits.h stdlib.h string.h wchar.h wctype.h) jm_FUNC_MBRTOWC
AC_CHECK_HEADERS(limits.h stddef.h stdlib.h string.h wchar.h wctype.h)
AC_HEADER_STDC AC_HEADER_STDC
AC_C_BACKSLASH_A AC_C_BACKSLASH_A
AC_MBSTATE_T AC_MBSTATE_T

View File

@@ -4,3 +4,4 @@ Makefile.in
POTFILES POTFILES
bison.pot bison.pot
stamp-cat-id stamp-cat-id
*.gmo

View File

@@ -1,3 +1,13 @@
2001-10-04 gettextize <bug-gnu-utils@gnu.org>
* Makefile.in.in: Upgrade to gettext-0.10.40.
* cat-id-tbl.c: Remove file.
2001-09-27 gettextize <bug-gnu-utils@gnu.org>
* Makefile.in.in: Upgrade to gettext-0.10.40.
* cat-id-tbl.c: Remove file.
2001-08-03 gettextize <bug-gnu-utils@gnu.org> 2001-08-03 gettextize <bug-gnu-utils@gnu.org>
* Makefile.in.in: Upgrade to gettext-0.10.39. * Makefile.in.in: Upgrade to gettext-0.10.39.

View File

@@ -13,7 +13,6 @@ src/print.c
src/print_graph.c src/print_graph.c
src/reader.c src/reader.c
src/reduce.c src/reduce.c
src/vcg.c
lib/error.c lib/error.c
lib/getopt.c lib/getopt.c

View File

@@ -23,7 +23,6 @@
The entry point is generate_states. */ The entry point is generate_states. */
#include "system.h" #include "system.h"
#include "xalloc.h"
#include "gram.h" #include "gram.h"
#include "state.h" #include "state.h"
#include "complain.h" #include "complain.h"
@@ -33,39 +32,39 @@
int nstates; int nstates;
int final_state; int final_state;
core *first_state; core *first_state = NULL;
shifts *first_shift; shifts *first_shift = NULL;
reductions *first_reduction; reductions *first_reduction = NULL;
static core *this_state; static core *this_state = NULL;
static core *last_state; static core *last_state = NULL;
static shifts *last_shift; static shifts *last_shift = NULL;
static reductions *last_reduction; static reductions *last_reduction = NULL;
static int nshifts; static int nshifts;
static short *shift_symbol; static short *shift_symbol = NULL;
static short *redset; static short *redset = NULL;
static short *shiftset; static short *shiftset = NULL;
static short **kernel_base; static short **kernel_base = NULL;
static short **kernel_end; static short **kernel_end = NULL;
static short *kernel_items; static short *kernel_items = NULL;
/* hash table for states, to recognize equivalent ones. */ /* hash table for states, to recognize equivalent ones. */
#define STATE_TABLE_SIZE 1009 #define STATE_TABLE_SIZE 1009
static core **state_table; static core **state_table = NULL;
static void static void
allocate_itemsets (void) allocate_itemsets (void)
{ {
short *itemp; short *itemp = NULL;
int symbol; int symbol;
int i; int i;
int count; int count;
short *symbol_count; short *symbol_count = NULL;
count = 0; count = 0;
symbol_count = XCALLOC (short, nsyms); symbol_count = XCALLOC (short, nsyms);
@@ -89,7 +88,8 @@ allocate_itemsets (void)
We allocate that much space for each symbol. */ We allocate that much space for each symbol. */
kernel_base = XCALLOC (short *, nsyms); kernel_base = XCALLOC (short *, nsyms);
kernel_items = XCALLOC (short, count); if (count)
kernel_items = XCALLOC (short, count);
count = 0; count = 0;
for (i = 0; i < nsyms; i++) for (i = 0; i < nsyms; i++)

View File

@@ -512,13 +512,13 @@ yyparse (YYPARSE_PARAM_ARG)
/*------------------------------------------------------------. /*------------------------------------------------------------.
| yynewstate -- Push a new state, which is found in yystate. | | yynewstate -- Push a new state, which is found in yystate. |
`------------------------------------------------------------*/ `------------------------------------------------------------*/
yynewstate: yynewstate:
/* In all cases, when you get here, the value and location stacks /* In all cases, when you get here, the value and location stacks
have just been pushed. so pushing a state here evens the stacks. have just been pushed. so pushing a state here evens the stacks.
*/ */
yyssp++; yyssp++;
yysetstate: yysetstate:
*yyssp = yystate; *yyssp = yystate;
if (yyssp >= yyss + yystacksize - 1) if (yyssp >= yyss + yystacksize - 1)
@@ -995,4 +995,3 @@ yyabortlab:
#line %%input_line "%%filename" #line %%input_line "%%filename"
%%epilogue %%epilogue

View File

@@ -19,7 +19,6 @@
02111-1307, USA. */ 02111-1307, USA. */
#include "system.h" #include "system.h"
#include "xalloc.h"
#include "gram.h" #include "gram.h"
#include "closure.h" #include "closure.h"
#include "derives.h" #include "derives.h"

View File

@@ -19,14 +19,10 @@
/* Based on error.c and error.h, /* Based on error.c and error.h,
written by David MacKenzie <djm@gnu.ai.mit.edu>. */ written by David MacKenzie <djm@gnu.ai.mit.edu>. */
#ifdef HAVE_CONFIG_H #include "system.h"
# include <config.h>
#endif
#include <stdio.h>
#if HAVE_VPRINTF || HAVE_DOPRNT || _LIBC #if HAVE_VPRINTF || HAVE_DOPRNT || _LIBC
# if __STDC__ # ifdef __STDC__
# include <stdarg.h> # include <stdarg.h>
# define VA_START(args, lastarg) va_start(args, lastarg) # define VA_START(args, lastarg) va_start(args, lastarg)
# else # else
@@ -119,7 +115,7 @@ int error_one_per_line;
`--------------------------------*/ `--------------------------------*/
void void
#if defined VA_START && __STDC__ #if defined VA_START && defined __STDC__
warn (const char *message, ...) warn (const char *message, ...)
#else #else
warn (message, va_alist) warn (message, va_alist)
@@ -171,7 +167,7 @@ warn (message, va_alist)
`-----------------------------------------------------------*/ `-----------------------------------------------------------*/
void void
#if defined VA_START && __STDC__ #if defined VA_START && defined __STDC__
complain (const char *message, ...) complain (const char *message, ...)
#else #else
complain (message, va_alist) complain (message, va_alist)
@@ -221,7 +217,7 @@ complain (message, va_alist)
`-------------------------------------------------*/ `-------------------------------------------------*/
void void
#if defined VA_START && __STDC__ #if defined VA_START && defined __STDC__
fatal (const char *message, ...) fatal (const char *message, ...)
#else #else
fatal (message, va_alist) fatal (message, va_alist)
@@ -259,7 +255,7 @@ fatal (message, va_alist)
`------------------------------------------------------------------*/ `------------------------------------------------------------------*/
void void
#if defined VA_START && __STDC__ #if defined VA_START && defined __STDC__
error (int status, int errnum, error (int status, int errnum,
const char *message, ...) const char *message, ...)
#else #else

View File

@@ -23,7 +23,7 @@
extern "C" { extern "C" {
#endif #endif
#if defined (__STDC__) && __STDC__ #ifdef __STDC__
/* Informative messages, but we proceed. */ /* Informative messages, but we proceed. */

View File

@@ -20,7 +20,6 @@
#include "system.h" #include "system.h"
#include "getargs.h" #include "getargs.h"
#include "xalloc.h"
#include "files.h" #include "files.h"
#include "gram.h" #include "gram.h"
#include "state.h" #include "state.h"
@@ -30,12 +29,12 @@
#include "LR0.h" #include "LR0.h"
int any_conflicts = 0; int any_conflicts = 0;
errs **err_table; errs **err_table = NULL;
int expected_conflicts; int expected_conflicts;
static char *conflicts; static char *conflicts = NULL;
static unsigned *shiftset; static unsigned *shiftset = NULL;
static unsigned *lookaheadset; static unsigned *lookaheadset = NULL;
static int src_total; static int src_total;
static int rrc_total; static int rrc_total;
static int src_count; static int src_count;
@@ -264,7 +263,7 @@ set_conflicts (int state)
} }
void void
initialize_conflicts (void) solve_conflicts (void)
{ {
int i; int i;
@@ -458,7 +457,7 @@ conflict_report (int src_num, int rrc_num)
`---------------------------------------------*/ `---------------------------------------------*/
void void
print_conflicts (void) print_conflicts (FILE *out)
{ {
int i; int i;
@@ -478,9 +477,8 @@ print_conflicts (void)
if (verbose_flag) if (verbose_flag)
{ {
obstack_fgrow1 (&output_obstack, _("State %d contains"), i); fprintf (out, _("State %d contains"), i);
obstack_sgrow (&output_obstack, fputs (conflict_report (src_count, rrc_count), out);
conflict_report (src_count, rrc_count));
} }
} }
} }
@@ -738,7 +736,7 @@ print_reductions (int state)
void void
finalize_conflicts (void) free_conflicts (void)
{ {
XFREE (conflicts); XFREE (conflicts);
XFREE (shiftset); XFREE (shiftset);

View File

@@ -22,10 +22,10 @@
# define CONFLICTS_H_ # define CONFLICTS_H_
# include "state.h" # include "state.h"
void initialize_conflicts PARAMS ((void)); void solve_conflicts PARAMS ((void));
void print_conflicts PARAMS ((void)); void print_conflicts PARAMS ((FILE *out));
void print_reductions PARAMS ((int)); void print_reductions PARAMS ((int));
void finalize_conflicts PARAMS ((void)); void free_conflicts PARAMS ((void));
/* Were there conflicts? */ /* Were there conflicts? */
extern int any_conflicts; extern int any_conflicts;

View File

@@ -25,7 +25,6 @@
*/ */
#include "system.h" #include "system.h"
#include "xalloc.h"
#include "types.h" #include "types.h"
#include "gram.h" #include "gram.h"
#include "derives.h" #include "derives.h"

View File

@@ -22,7 +22,6 @@
#include "system.h" #include "system.h"
#include "getargs.h" #include "getargs.h"
#include "files.h" #include "files.h"
#include "xalloc.h"
#include "gram.h" #include "gram.h"
#include "complain.h" #include "complain.h"
@@ -34,11 +33,13 @@ struct obstack table_obstack;
struct obstack defines_obstack; struct obstack defines_obstack;
struct obstack guard_obstack; struct obstack guard_obstack;
struct obstack output_obstack; struct obstack output_obstack;
struct obstack graph_obstack;
char *spec_outfile = NULL; /* for -o. */ char *spec_outfile = NULL; /* for -o. */
char *spec_file_prefix = NULL; /* for -b. */ char *spec_file_prefix = NULL; /* for -b. */
char *spec_name_prefix = NULL; /* for -p. */ char *spec_name_prefix = NULL; /* for -p. */
char *spec_verbose_file = NULL; /* for --verbose. */
char *spec_graph_file = NULL; /* for -g. */
char *spec_defines_file = NULL; /* for --defines. */
char *infile = NULL; char *infile = NULL;
char *attrsfile = NULL; char *attrsfile = NULL;
@@ -93,24 +94,26 @@ stringappend (const char *string1, const char *string2)
static char * static char *
compute_header_macro (void) compute_header_macro (void)
{ {
int ite; char *macro_name, *cp;
char *macro_name;
macro_name = XMALLOC (char, if (spec_defines_file)
strlen (base_name) + macro_name = xstrdup (spec_defines_file);
strlen (header_extension) + 1); else
{
macro_name = XMALLOC (char,
strlen (base_name) +
strlen (header_extension) + 1);
stpcpy (macro_name, base_name); stpcpy (macro_name, base_name);
strcat (macro_name, header_extension); strcat (macro_name, header_extension);
}
for (cp = macro_name; *cp; ++cp)
if (islower (*cp))
*cp = toupper (*cp);
else if (!isalnum (*cp))
*cp = '_';
for (ite = 0; macro_name[ite]; ite++)
if (macro_name[ite] == '.')
macro_name[ite] = '_';
else
{
if (islower (macro_name[ite]))
macro_name[ite] -= ('a' - 'A');
}
return macro_name; return macro_name;
} }
@@ -194,17 +197,42 @@ skeleton_find (const char *envvar, const char *skeleton_name)
{ {
const char *res = getenv (envvar); const char *res = getenv (envvar);
#ifdef MSDOS #if defined (MSDOS) || defined (_WIN32)
const char *cp; if (!res)
/* File doesn't exist in current directory; try in INIT directory. */
if (!res && (cp = getenv ("INIT")))
{ {
res = XMALLOC (char, strlen (cp) + strlen (skeleton_name) + 2); /* Skeleton file name without path */
sprintf (res, "%s%c%s", cp, '/', skeleton_name); const char *skel_name = strrchr(skeleton_name, '/');
} if (!skel_name)
#endif /* !MSDOS */ skel_name = strrchr(skeleton_name, '\\');
if (!skel_name)
skel_name = skeleton_name;
else
++skel_name;
/* File doesn't exist in current directory; try in INIT directory. */
const char *cp = getenv ("INIT");
if (cp)
{
res = XMALLOC (char, strlen (cp) + strlen (skel_name) + 2);
sprintf (res, "%s%c%s", cp, '\\', skel_name);
}
else if (access (skel_name, 4) == 0) /* Look in current dir. */
res = skel_name;
else
{
/* Look in program locations dir. */
extern char *program_name;
cp = strrchr(program_name, '\\');
if (!cp)
return skeleton_name;
else
++cp;
res = XMALLOC (char, cp - program_name + strlen (skel_name) + 1);
strncpy (res, program_name, cp - program_name);
strcpy (res + (cp - program_name), skel_name);
}
}
#endif /* defined (MSDOS) || defined (_WIN32) */
if (!res) if (!res)
res = skeleton_name; res = skeleton_name;
@@ -260,20 +288,10 @@ get_extension_index (const char *filename)
static void static void
compute_exts_from_gf (const char *ext) compute_exts_from_gf (const char *ext)
{ {
/* Checks if SRC_EXTENSION is NULL. In the other case, %source_extension src_extension = tr (ext, 'y', 'c');
was specified in the grammar file. */ src_extension = tr (src_extension, 'Y', 'C');
if (src_extension == NULL) header_extension = tr (ext, 'y', 'h');
{ header_extension = tr (header_extension, 'Y', 'H');
src_extension = tr (ext, 'y', 'c');
src_extension = tr (src_extension, 'Y', 'C');
}
/* Checks if HEADER_EXTENSION is NULL. In the other case,
%header_extension was specified in the grammar file. */
if (header_extension == NULL)
{
header_extension = tr (ext, 'y', 'h');
header_extension = tr (header_extension, 'Y', 'H');
}
} }
/* Computes extensions from the given c source file extension. */ /* Computes extensions from the given c source file extension. */
@@ -395,6 +413,38 @@ compute_base_names (void)
} }
} }
/*-------------------------------------------------------.
| Close the open files, compute the output files names. |
`-------------------------------------------------------*/
void
compute_output_file_names (void)
{
compute_base_names ();
/* If not yet done. */
if (!src_extension)
src_extension = ".c";
if (!header_extension)
header_extension = ".h";
/* It the defines filename if not given, we create it. */
if (!spec_defines_file)
spec_defines_file = stringappend (base_name, header_extension);
/* It the graph filename if not given, we create it. */
if (!spec_graph_file)
spec_graph_file = stringappend (short_base_name, ".vcg");
spec_verbose_file = stringappend (short_base_name, EXT_OUTPUT);
attrsfile = stringappend (short_base_name, EXT_STYPE_H);
#ifndef MSDOS
attrsfile = stringappend (attrsfile, header_extension);
#endif /* MSDOS */
}
/*-----------------------------------------------------------------. /*-----------------------------------------------------------------.
| Open the input file. Look for the skeletons. Find the names of | | Open the input file. Look for the skeletons. Find the names of |
| the output files. Prepare the obstacks. | | the output files. Prepare the obstacks. |
@@ -412,46 +462,47 @@ open_files (void)
obstack_init (&defines_obstack); obstack_init (&defines_obstack);
obstack_init (&guard_obstack); obstack_init (&guard_obstack);
obstack_init (&output_obstack); obstack_init (&output_obstack);
obstack_init (&graph_obstack);
} }
/*-----------------------------------------------------. /*-----------------------.
| Close the open files, produce all the output files. | | Close the open file.. |
`-----------------------------------------------------*/ `-----------------------*/
void
close_files (void)
{
xfclose (finput);
}
/*---------------------------.
| Produce the output files. |
`---------------------------*/
void void
output_files (void) output_files (void)
{ {
xfclose (finput);
compute_base_names ();
/* Set default extensions */
if (!src_extension)
src_extension = ".c";
if (!header_extension)
header_extension = ".h";
attrsfile = stringappend (short_base_name, EXT_STYPE_H);
#ifndef MSDOS
stringappend (attrsfile, header_extension);
#endif /* MSDOS */
/* Output the main file. */ /* Output the main file. */
if (spec_outfile) if (spec_outfile)
obstack_save (&table_obstack, spec_outfile); obstack_save (&table_obstack, spec_outfile);
else else
obstack_save (&table_obstack, stringappend (base_name, src_extension)); obstack_save (&table_obstack, stringappend (base_name, src_extension));
obstack_free (&table_obstack, NULL);
/* Output the header file if wanted. */ /* Output the header file if wanted. */
if (defines_flag) if (defines_flag)
defines_obstack_save (stringappend (base_name, header_extension)); defines_obstack_save (spec_defines_file);
obstack_free (&defines_obstack, NULL);
#if 0
/* Seems to be invalid now --akim. */
/* If we output only the table, dump the actions in ACTFILE. */ /* If we output only the table, dump the actions in ACTFILE. */
if (no_parser_flag) if (no_parser_flag)
obstack_save (&action_obstack, stringappend (short_base_name, ".act")); obstack_save (&action_obstack, stringappend (short_base_name, ".act"));
obstack_free (&action_obstack, NULL);
#endif
/* If we produced a semantic parser ATTRS_OBSTACK must be dumped /* If we produced a semantic parser ATTRS_OBSTACK must be dumped
into its own file, ATTTRSFILE. */ into its own file, ATTTRSFILE. */
@@ -460,19 +511,12 @@ output_files (void)
char *temp_name; char *temp_name;
obstack_save (&attrs_obstack, attrsfile); obstack_save (&attrs_obstack, attrsfile);
obstack_free (&attrs_obstack, NULL);
temp_name = stringappend (short_base_name, EXT_GUARD_C); temp_name = stringappend (short_base_name, EXT_GUARD_C);
#ifndef MSDOS #ifndef MSDOS
temp_name = stringappend (temp_name, src_extension); temp_name = stringappend (temp_name, src_extension);
#endif /* MSDOS */ #endif /* MSDOS */
obstack_save (&guard_obstack, temp_name); obstack_save (&guard_obstack, temp_name);
obstack_free (&guard_obstack, NULL);
} }
if (verbose_flag)
/* We used to use just .out if spec_name_prefix (-p) was used, but
that conflicts with Posix. */
obstack_save (&output_obstack,
stringappend (short_base_name, EXT_OUTPUT));
if (graph_flag)
obstack_save (&graph_obstack, stringappend (short_base_name, ".vcg"));
} }

View File

@@ -33,10 +33,19 @@ extern char *spec_name_prefix;
/* File name pfx specified with -b, or 0 if no -b. */ /* File name pfx specified with -b, or 0 if no -b. */
extern char *spec_file_prefix; extern char *spec_file_prefix;
/* --verbose. */
extern char *spec_verbose_file;
/* File name specified for the output VCG graph. */
extern char *spec_graph_file;
/* File name specified with --defines. */
extern char *spec_defines_file;
/* Read grammar specifications. */ /* Read grammar specifications. */
extern FILE *finput; extern FILE *finput;
/* Output all the action code; precise form depends on which parser. */ /* Output all the action code; precise form depends on which parser. */
extern struct obstack action_obstack; extern struct obstack action_obstack;
@@ -56,17 +65,13 @@ extern struct obstack guard_obstack;
/* The verbose output. */ /* The verbose output. */
extern struct obstack output_obstack; extern struct obstack output_obstack;
/* The VCG graph output. */
extern struct obstack graph_obstack;
extern char *infile; extern char *infile;
extern char *attrsfile; extern char *attrsfile;
extern const char *src_extension;
extern const char *header_extension;
void open_files PARAMS((void)); void open_files PARAMS((void));
void close_files PARAMS((void));
void compute_output_file_names PARAMS((void));
void output_files PARAMS((void)); void output_files PARAMS((void));
FILE *xfopen PARAMS ((const char *name, const char *mode)); FILE *xfopen PARAMS ((const char *name, const char *mode));

View File

@@ -89,7 +89,9 @@ Output:\n\
-d, --defines also produce a header file\n\ -d, --defines also produce a header file\n\
-v, --verbose also produce an explanation of the automaton\n\ -v, --verbose also produce an explanation of the automaton\n\
-b, --file-prefix=PREFIX specify a PREFIX for output files\n\ -b, --file-prefix=PREFIX specify a PREFIX for output files\n\
-o, --output-file=FILE leave output to FILE\n"), stream); -o, --output-file=FILE leave output to FILE\n\
-g, --graph also produce a VCG graph description of the \
automaton\n"), stream);
putc ('\n', stream); putc ('\n', stream);
fputs (_("\ fputs (_("\
@@ -153,7 +155,9 @@ getargs (int argc, char *argv[])
exit (0); exit (0);
case 'g': case 'g':
/* Here, the -g and --graph=FILE options are differentiated. */
graph_flag = 1; graph_flag = 1;
spec_graph_file = optarg;
break; break;
case 'v': case 'v':
@@ -165,7 +169,9 @@ getargs (int argc, char *argv[])
break; break;
case 'd': case 'd':
/* Here, the -d and --defines options are differentiated. */
defines_flag = 1; defines_flag = 1;
spec_defines_file = optarg;
break; break;
case 'l': case 'l':

View File

@@ -31,21 +31,19 @@ int nsyms;
int ntokens; int ntokens;
int nvars; int nvars;
short *ritem; short *ritem = NULL;
short *rlhs; short *rlhs = NULL;
short *rrhs; short *rrhs = NULL;
short *rprec; short *rprec = NULL;
short *rprecsym; short *rprecsym = NULL;
short *sprec; short *sprec = NULL;
short *rassoc; short *rassoc = NULL;
short *sassoc; short *sassoc = NULL;
short *token_translations; short *token_translations = NULL;
short *rline; short *rline = NULL;
int start_symbol; int start_symbol;
int translations;
int max_user_token_number; int max_user_token_number;
int semantic_parser; int semantic_parser;

View File

@@ -107,13 +107,9 @@ typedef enum
/* token translation table: indexed by a token number as returned by /* token translation table: indexed by a token number as returned by
the user's yylex routine, it yields the internal token number used the user's yylex routine, it yields the internal token number used
by the parser and throughout bison. If translations is zero, the by the parser and throughout bison. */
translation table is not used because the two kinds of token
numbers are the same. (It is noted in reader.c that "Nowadays
translations is always set to 1...") */
extern short *token_translations; extern short *token_translations;
extern int translations;
extern int max_user_token_number; extern int max_user_token_number;
/* SEMANTIC_PARSER is nonzero if the input file says to use the hairy /* SEMANTIC_PARSER is nonzero if the input file says to use the hairy

View File

@@ -26,7 +26,6 @@
#include "system.h" #include "system.h"
#include "types.h" #include "types.h"
#include "LR0.h" #include "LR0.h"
#include "xalloc.h"
#include "gram.h" #include "gram.h"
#include "complain.h" #include "complain.h"
#include "lalr.h" #include "lalr.h"

View File

@@ -25,7 +25,6 @@
#include "symtab.h" #include "symtab.h"
#include "options.h" #include "options.h"
#include "lex.h" #include "lex.h"
#include "xalloc.h"
#include "complain.h" #include "complain.h"
#include "gram.h" #include "gram.h"
#include "quote.h" #include "quote.h"
@@ -37,15 +36,24 @@ const char *token_buffer = NULL;
bucket *symval; bucket *symval;
int numval; int numval;
static int unlexed; /* these two describe a token to be reread */ /* these two describe a token to be reread */
static bucket *unlexed_symval; /* by the next call to lex */ static token_t unlexed = tok_undef;
/* by the next call to lex */
static bucket *unlexed_symval = NULL;
void void
init_lex (void) lex_init (void)
{ {
obstack_init (&token_obstack); obstack_init (&token_obstack);
unlexed = -1; unlexed = tok_undef;
}
void
lex_free (void)
{
obstack_free (&token_obstack, NULL);
} }
@@ -314,7 +322,7 @@ literalchar (struct obstack *out, int *pcode, char term)
void void
unlex (int token) unlex (token_t token)
{ {
unlexed = token; unlexed = token;
unlexed_symval = symval; unlexed_symval = symval;
@@ -357,12 +365,12 @@ lex (void)
/* Just to make sure. */ /* Just to make sure. */
token_buffer = NULL; token_buffer = NULL;
if (unlexed >= 0) if (unlexed != tok_undef)
{ {
token_t res = unlexed;
symval = unlexed_symval; symval = unlexed_symval;
c = unlexed; unlexed = tok_undef;
unlexed = -1; return res;
return c;
} }
c = skip_white_space (); c = skip_white_space ();
@@ -418,7 +426,6 @@ lex (void)
case '\'': case '\'':
/* parse the literal token and compute character code in code */ /* parse the literal token and compute character code in code */
translations = -1;
{ {
int code, discode; int code, discode;
@@ -446,7 +453,6 @@ lex (void)
case '\"': case '\"':
/* parse the literal string token and treat as an identifier */ /* parse the literal string token and treat as an identifier */
translations = -1;
{ {
int code; /* ignored here */ int code; /* ignored here */
@@ -464,32 +470,40 @@ lex (void)
} }
case ',': case ',':
token_buffer = ",";
return tok_comma; return tok_comma;
case ':': case ':':
token_buffer = ":";
return tok_colon; return tok_colon;
case ';': case ';':
token_buffer = ";";
return tok_semicolon; return tok_semicolon;
case '|': case '|':
token_buffer = "|";
return tok_bar; return tok_bar;
case '{': case '{':
token_buffer = "{";
return tok_left_curly; return tok_left_curly;
case '=': case '=':
obstack_1grow (&token_obstack, c);
do do
{ {
c = getc (finput); c = getc (finput);
obstack_1grow (&token_obstack, c);
if (c == '\n') if (c == '\n')
lineno++; lineno++;
} }
while (c == ' ' || c == '\n' || c == '\t'); while (c == ' ' || c == '\n' || c == '\t');
obstack_1grow (&token_obstack, '\0');
token_buffer = obstack_finish (&token_obstack);
if (c == '{') if (c == '{')
{ {
token_buffer = "={";
return tok_left_curly; return tok_left_curly;
} }
else else
@@ -506,6 +520,9 @@ lex (void)
return parse_percent_token (); return parse_percent_token ();
default: default:
obstack_1grow (&token_obstack, c);
obstack_1grow (&token_obstack, '\0');
token_buffer = obstack_finish (&token_obstack);
return tok_illegal; return tok_illegal;
} }
} }
@@ -516,28 +533,28 @@ lex (void)
static int static int
option_strcmp (const char *left, const char *right) option_strcmp (const char *left, const char *right)
{ {
const unsigned char *l, *r; const unsigned char *l, *r;
int c; int c;
assert(left != NULL && right != NULL); assert (left);
l = (const unsigned char *)left; assert (right);
r = (const unsigned char *)right; l = (const unsigned char *)left;
while (((c = *l - *r++) == 0 && *l != '\0') r = (const unsigned char *)right;
|| ((*l == '-' || *l == '_') && (*r == '_' || *r == '-'))) while (((c = *l - *r++) == 0 && *l != '\0')
l++; || ((*l == '-' || *l == '_') && (*r == '_' || *r == '-')))
return c; l++;
return c;
} }
/* Parse a token which starts with %. /* Parse a token which starts with %.
Assumes the % has already been read and discarded. */ Assumes the % has already been read and discarded. */
int token_t
parse_percent_token (void) parse_percent_token (void)
{ {
int c;
const struct option_table_struct *tx; const struct option_table_struct *tx;
c = getc (finput); int c = getc (finput);
switch (c) switch (c)
{ {
@@ -601,6 +618,10 @@ parse_percent_token (void)
case tok_obsolete: case tok_obsolete:
fatal (_("`%s' is no longer supported"), token_buffer); fatal (_("`%s' is no longer supported"), token_buffer);
break; break;
default:
/* Other cases do not apply here. */
break;
} }
return tx->ret_val; return tx->ret_val;

View File

@@ -24,6 +24,7 @@
/* Token-type codes. */ /* Token-type codes. */
typedef enum token_e typedef enum token_e
{ {
tok_undef, /* Not defined. Used to initial token_t vars. */
tok_eof, tok_eof,
tok_identifier, tok_identifier,
tok_comma, tok_comma,
@@ -47,8 +48,6 @@ typedef enum token_e
tok_number, tok_number,
tok_expect, tok_expect,
tok_thong, tok_thong,
tok_hdrext,
tok_srcext,
tok_define, tok_define,
tok_skel, tok_skel,
tok_noop, tok_noop,
@@ -61,9 +60,10 @@ extern const char *token_buffer;
extern bucket *symval; extern bucket *symval;
extern int numval; extern int numval;
void init_lex PARAMS ((void)); void lex_init PARAMS ((void));
void lex_free PARAMS ((void));
int skip_white_space PARAMS ((void)); int skip_white_space PARAMS ((void));
void unlex PARAMS ((int)); void unlex PARAMS ((token_t));
void read_type_name PARAMS ((FILE *fin)); void read_type_name PARAMS ((FILE *fin));
/* Return one of the token-type codes. When an identifier is seen, /* Return one of the token-type codes. When an identifier is seen,
@@ -73,6 +73,6 @@ void read_type_name PARAMS ((FILE *fin));
token_t lex PARAMS ((void)); token_t lex PARAMS ((void));
int parse_percent_token PARAMS ((void)); token_t parse_percent_token PARAMS ((void));
#endif /* !LEX_H_ */ #endif /* !LEX_H_ */

View File

@@ -1,5 +1,5 @@
/* Top level entry point of bison, /* Top level entry point of bison,
Copyright 1984, 1986, 1989, 1992, 1995, 2000 Copyright 1984, 1986, 1989, 1992, 1995, 2000, 2001
Free Software Foundation, Inc. Free Software Foundation, Inc.
This file is part of Bison, the GNU Compiler Compiler. This file is part of Bison, the GNU Compiler Compiler.
@@ -35,6 +35,8 @@
#include "conflicts.h" #include "conflicts.h"
#include "print_graph.h" #include "print_graph.h"
#include "muscle_tab.h" #include "muscle_tab.h"
#include "symtab.h"
#include "lex.h"
/* The name this program was run with, for messages. */ /* The name this program was run with, for messages. */
char *program_name; char *program_name;
@@ -81,7 +83,15 @@ main (int argc, char *argv[])
lookahead is not enough to disambiguate the parsing. In file lookahead is not enough to disambiguate the parsing. In file
conflicts. Also resolve s/r conflicts based on precedence conflicts. Also resolve s/r conflicts based on precedence
declarations. */ declarations. */
initialize_conflicts (); solve_conflicts ();
/* Output file names. */
compute_output_file_names ();
/* Stop if there were errors, to avoid trashing previous output
files. */
if (complain_message_count)
exit (1);
/* Print information about results, if requested. */ /* Print information about results, if requested. */
print_results (); print_results ();
@@ -92,12 +102,19 @@ main (int argc, char *argv[])
/* Output the tables and the parser to ftable. In file output. */ /* Output the tables and the parser to ftable. In file output. */
output (); output ();
finalize_conflicts (); /* Free the symbol table data structure. */
free_symtab ();
lex_free ();
/* Close the input files. */
close_files ();
free_conflicts ();
free_nullable (); free_nullable ();
free_derives (); free_derives ();
if (!complain_message_count) output_files ();
output_files ();
exit (complain_message_count ? 1 : 0); exit (complain_message_count ? 1 : 0);
} }

View File

@@ -26,7 +26,6 @@
#include "system.h" #include "system.h"
#include "types.h" #include "types.h"
#include "gram.h" #include "gram.h"
#include "xalloc.h"
#include "nullable.h" #include "nullable.h"
char *nullable = NULL; char *nullable = NULL;

View File

@@ -45,7 +45,7 @@ const struct option_table_struct option_table[] =
/* Operation modes. */ /* Operation modes. */
{opt_cmd_line, "help", no_argument, 0, 0, 'h'}, {opt_cmd_line, "help", no_argument, 0, 0, 'h'},
{opt_cmd_line, "version", no_argument, 0, 0, 'V'}, {opt_cmd_line, "version", no_argument, 0, 0, 'V'},
/* Parser. */ /* Parser. */
/* was 'a'; apparently unused -wjh */ /* was 'a'; apparently unused -wjh */
{opt_cmd_line, "name-prefix", required_argument, 0, 0, 'p'}, {opt_cmd_line, "name-prefix", required_argument, 0, 0, 'p'},
@@ -53,7 +53,7 @@ const struct option_table_struct option_table[] =
/* Output. */ /* Output. */
{opt_cmd_line, "file-prefix", required_argument, 0, 0, 'b'}, {opt_cmd_line, "file-prefix", required_argument, 0, 0, 'b'},
{opt_cmd_line, "output-file", required_argument, 0, 0, 'o'}, {opt_cmd_line, "output-file", required_argument, 0, 0, 'o'},
{opt_cmd_line, "graph", no_argument, 0, 0, 'g'}, {opt_cmd_line, "graph", optional_argument, 0, 0, 'g'},
/* Hidden. */ /* Hidden. */
{opt_cmd_line, "statistics", no_argument, &statistics_flag, 0, 1}, {opt_cmd_line, "statistics", no_argument, &statistics_flag, 0, 1},
@@ -86,8 +86,6 @@ const struct option_table_struct option_table[] =
{opt_both, "file-prefix", required_argument,&spec_file_prefix,tok_setopt,'b'}, {opt_both, "file-prefix", required_argument,&spec_file_prefix,tok_setopt,'b'},
{opt_both, "name-prefix", required_argument,&spec_name_prefix,tok_setopt,'p'}, {opt_both, "name-prefix", required_argument,&spec_name_prefix,tok_setopt,'p'},
#endif #endif
{opt_percent, "header-extension", 0, NULL, tok_hdrext, 0},
{opt_percent, "source-extension", 0, NULL, tok_srcext, 0},
{opt_percent, "define", 0, NULL, tok_define, 0}, {opt_percent, "define", 0, NULL, tok_define, 0},
{opt_percent, "semantic-parser", 0, &semantic_parser, tok_noop, 0}, {opt_percent, "semantic-parser", 0, &semantic_parser, tok_noop, 0},
{opt_percent, "pure-parser", 0, &pure_parser, tok_noop, 0}, {opt_percent, "pure-parser", 0, &pure_parser, tok_noop, 0},
@@ -97,11 +95,11 @@ const struct option_table_struct option_table[] =
*/ */
/* FIXME Usually option use `-' to separe words on command line /* FIXME Usually option use `-' to separe words on command line
and `_' for percent option. But here the separator are always and `_' for percent option. But here the separator are always
the same, the char `-'. */ the same, the char `-'. */
/* Output. */ /* Output. */
{opt_both, "defines", no_argument, &defines_flag, tok_noop, 'd'}, {opt_both, "defines", optional_argument, &defines_flag, tok_noop, 'd'},
{opt_both, "verbose", no_argument, &verbose_flag, tok_noop, 'v'}, {opt_both, "verbose", no_argument, &verbose_flag, tok_noop, 'v'},
/* Operation modes. */ /* Operation modes. */
@@ -109,7 +107,7 @@ const struct option_table_struct option_table[] =
{opt_both, "yacc", no_argument, &yacc_flag, tok_noop, 'y'}, {opt_both, "yacc", no_argument, &yacc_flag, tok_noop, 'y'},
/* Parser. */ /* Parser. */
{opt_both, "debug", no_argument, &debug_flag, tok_noop, 'd'}, {opt_both, "debug", no_argument, &debug_flag, tok_noop, 't'},
{opt_both, "locations", no_argument, &locations_flag, tok_noop, 1}, {opt_both, "locations", no_argument, &locations_flag, tok_noop, 1},
{opt_both, "no-lines", no_argument, &no_lines_flag, tok_noop, 'l'}, {opt_both, "no-lines", no_argument, &no_lines_flag, tok_noop, 'l'},
{opt_both, "no-parser", no_argument, &no_parser_flag, tok_noop, 'n'}, {opt_both, "no-parser", no_argument, &no_parser_flag, tok_noop, 'n'},

View File

@@ -94,7 +94,6 @@
#include "obstack.h" #include "obstack.h"
#include "quotearg.h" #include "quotearg.h"
#include "getargs.h" #include "getargs.h"
#include "xalloc.h"
#include "files.h" #include "files.h"
#include "gram.h" #include "gram.h"
#include "LR0.h" #include "LR0.h"
@@ -109,17 +108,17 @@ extern void berror PARAMS((const char *));
static int nvectors; static int nvectors;
static int nentries; static int nentries;
static short **froms; static short **froms = NULL;
static short **tos; static short **tos = NULL;
static short *tally; static short *tally = NULL;
static short *width; static short *width = NULL;
static short *actrow; static short *actrow = NULL;
static short *state_count; static short *state_count = NULL;
static short *order; static short *order = NULL;
static short *base; static short *base = NULL;
static short *pos; static short *pos = NULL;
static short *table; static short *table = NULL;
static short *check; static short *check = NULL;
static int lowzero; static int lowzero;
static int high; static int high;
@@ -129,15 +128,15 @@ struct obstack output_obstack;
/* FIXME. */ /* FIXME. */
static inline void static inline void
output_table_data (struct obstack *oout, output_table_data (struct obstack *oout,
short *table_data, short *table_data,
short first, short first,
short begin, short begin,
short end) short end)
{ {
int i; int i;
int j = 1; int j = 1;
obstack_fgrow1 (oout, "%6d", first); obstack_fgrow1 (oout, "%6d", first);
for (i = begin; i < end; ++i) for (i = begin; i < end; ++i)
{ {
@@ -158,19 +157,20 @@ output_table_data (struct obstack *oout,
static void static void
output_token_translations (void) output_token_translations (void)
{ {
output_table_data (&output_obstack, token_translations, output_table_data (&output_obstack, token_translations,
0, 1, max_user_token_number + 1); 0, 1, max_user_token_number + 1);
muscle_insert ("translate", obstack_finish (&output_obstack)); muscle_insert ("translate", obstack_finish (&output_obstack));
XFREE (token_translations);
} }
static void static void
output_gram (void) output_gram (void)
{ {
output_table_data (&output_obstack, rrhs, output_table_data (&output_obstack, rrhs,
0, 1, nrules + 1); 0, 1, nrules + 1);
muscle_insert ("prhs", obstack_finish (&output_obstack)); muscle_insert ("prhs", obstack_finish (&output_obstack));
{ {
size_t yyrhs_size = 1; size_t yyrhs_size = 1;
short *yyrhs, *sp; short *yyrhs, *sp;
@@ -183,7 +183,7 @@ output_gram (void)
for (sp = ritem + 1, i = 1; *sp; ++sp, ++i) for (sp = ritem + 1, i = 1; *sp; ++sp, ++i)
yyrhs[i] = *sp > 0 ? *sp : 0; yyrhs[i] = *sp > 0 ? *sp : 0;
output_table_data (&output_obstack, yyrhs, output_table_data (&output_obstack, yyrhs,
ritem[0], 1, yyrhs_size); ritem[0], 1, yyrhs_size);
muscle_insert ("rhs", obstack_finish (&output_obstack)); muscle_insert ("rhs", obstack_finish (&output_obstack));
@@ -200,7 +200,7 @@ output_gram (void)
static void static void
output_stos (void) output_stos (void)
{ {
output_table_data (&output_obstack, accessing_symbol, output_table_data (&output_obstack, accessing_symbol,
0, 1, nstates); 0, 1, nstates);
muscle_insert ("stos", obstack_finish (&output_obstack)); muscle_insert ("stos", obstack_finish (&output_obstack));
} }
@@ -275,7 +275,7 @@ output_rule_data (void)
muscle_insert ("toknum", obstack_finish (&output_obstack)); muscle_insert ("toknum", obstack_finish (&output_obstack));
/* Output YYR1. */ /* Output YYR1. */
output_table_data (&output_obstack, rlhs, output_table_data (&output_obstack, rlhs,
0, 1, nrules + 1); 0, 1, nrules + 1);
muscle_insert ("r1", obstack_finish (&output_obstack)); muscle_insert ("r1", obstack_finish (&output_obstack));
XFREE (rlhs + 1); XFREE (rlhs + 1);
@@ -285,7 +285,7 @@ output_rule_data (void)
for (i = 1; i < nrules; i++) for (i = 1; i < nrules; i++)
short_tab[i] = rrhs[i + 1] - rrhs[i] - 1; short_tab[i] = rrhs[i + 1] - rrhs[i] - 1;
short_tab[nrules] = nitems - rrhs[nrules] - 1; short_tab[nrules] = nitems - rrhs[nrules] - 1;
output_table_data (&output_obstack, short_tab, output_table_data (&output_obstack, short_tab,
0, 1, nrules + 1); 0, 1, nrules + 1);
muscle_insert ("r2", obstack_finish (&output_obstack)); muscle_insert ("r2", obstack_finish (&output_obstack));
XFREE (short_tab); XFREE (short_tab);
@@ -534,10 +534,10 @@ token_actions (void)
save_row (i); save_row (i);
} }
output_table_data (&output_obstack, yydefact, output_table_data (&output_obstack, yydefact,
yydefact[0], 1, nstates); yydefact[0], 1, nstates);
muscle_insert ("defact", obstack_finish (&output_obstack)); muscle_insert ("defact", obstack_finish (&output_obstack));
XFREE (actrow); XFREE (actrow);
XFREE (yydefact); XFREE (yydefact);
} }
@@ -675,7 +675,7 @@ goto_actions (void)
yydefgoto[i - ntokens] = default_state; yydefgoto[i - ntokens] = default_state;
} }
output_table_data (&output_obstack, yydefgoto, output_table_data (&output_obstack, yydefgoto,
yydefgoto[0], 1, nsyms - ntokens); yydefgoto[0], 1, nsyms - ntokens);
muscle_insert ("defgoto", obstack_finish (&output_obstack)); muscle_insert ("defgoto", obstack_finish (&output_obstack));
@@ -880,12 +880,12 @@ static void
output_base (void) output_base (void)
{ {
/* Output pact. */ /* Output pact. */
output_table_data (&output_obstack, base, output_table_data (&output_obstack, base,
base[0], 1, nstates); base[0], 1, nstates);
muscle_insert ("pact", obstack_finish (&output_obstack)); muscle_insert ("pact", obstack_finish (&output_obstack));
/* Output pgoto. */ /* Output pgoto. */
output_table_data (&output_obstack, base, output_table_data (&output_obstack, base,
base[nstates], nstates + 1, nvectors); base[nstates], nstates + 1, nvectors);
muscle_insert ("pgoto", obstack_finish (&output_obstack)); muscle_insert ("pgoto", obstack_finish (&output_obstack));
@@ -896,7 +896,7 @@ output_base (void)
static void static void
output_table (void) output_table (void)
{ {
output_table_data (&output_obstack, table, output_table_data (&output_obstack, table,
table[0], 1, high + 1); table[0], 1, high + 1);
muscle_insert ("table", obstack_finish (&output_obstack)); muscle_insert ("table", obstack_finish (&output_obstack));
XFREE (table); XFREE (table);
@@ -906,7 +906,7 @@ output_table (void)
static void static void
output_check (void) output_check (void)
{ {
output_table_data (&output_obstack, check, output_table_data (&output_obstack, check,
check[0], 1, high + 1); check[0], 1, high + 1);
muscle_insert ("check", obstack_finish (&output_obstack)); muscle_insert ("check", obstack_finish (&output_obstack));
XFREE (check); XFREE (check);
@@ -1109,7 +1109,7 @@ output (void)
output_stos (); output_stos ();
output_rule_data (); output_rule_data ();
output_actions (); output_actions ();
#if 0 #if 0
if (!no_parser_flag) */ if (!no_parser_flag) */
#endif #endif

View File

@@ -20,7 +20,6 @@
#include "system.h" #include "system.h"
#include "xalloc.h"
#include "files.h" #include "files.h"
#include "gram.h" #include "gram.h"
#include "LR0.h" #include "LR0.h"
@@ -35,17 +34,17 @@
static void static void
print_token (int extnum, int token) print_token (int extnum, int token)
{ {
obstack_fgrow2 (&output_obstack, _(" type %d is %s\n"), extnum, tags[token]); fprintf (out, _(" type %d is %s\n"), extnum, tags[token]);
} }
#endif #endif
/*================================\ /*--------------------------------.
| Report information on a state. | | Report information on a state. |
\================================*/ `--------------------------------*/
static void static void
print_core (int state) print_core (FILE *out, int state)
{ {
int i; int i;
int k; int k;
@@ -68,30 +67,30 @@ print_core (int state)
sp++; sp++;
rule = -(*sp); rule = -(*sp);
obstack_fgrow1 (&output_obstack, " %s -> ", tags[rlhs[rule]]); fprintf (out, " %s -> ", tags[rlhs[rule]]);
for (sp = ritem + rrhs[rule]; sp < sp1; sp++) for (sp = ritem + rrhs[rule]; sp < sp1; sp++)
{ {
obstack_fgrow1 (&output_obstack, "%s ", tags[*sp]); fprintf (out, "%s ", tags[*sp]);
} }
obstack_1grow (&output_obstack, '.'); fputc ('.', out);
while (*sp > 0) while (*sp > 0)
{ {
obstack_fgrow1 (&output_obstack, " %s", tags[*sp]); fprintf (out, " %s", tags[*sp]);
sp++; sp++;
} }
obstack_fgrow1 (&output_obstack, _(" (rule %d)"), rule); fprintf (out, _(" (rule %d)"), rule);
obstack_1grow (&output_obstack, '\n'); fputc ('\n', out);
} }
obstack_1grow (&output_obstack, '\n'); fputc ('\n', out);
} }
static void static void
print_actions (int state) print_actions (FILE *out, int state)
{ {
int i; int i;
int k; int k;
@@ -109,9 +108,9 @@ print_actions (int state)
if (!shiftp && !redp) if (!shiftp && !redp)
{ {
if (final_state == state) if (final_state == state)
obstack_sgrow (&output_obstack, _(" $default\taccept\n")); fprintf (out, _(" $default\taccept\n"));
else else
obstack_sgrow (&output_obstack, _(" NO ACTIONS\n")); fprintf (out, _(" NO ACTIONS\n"));
return; return;
} }
@@ -129,16 +128,16 @@ print_actions (int state)
if (ISVAR (symbol)) if (ISVAR (symbol))
break; break;
if (symbol == 0) /* I.e. strcmp(tags[symbol],"$")==0 */ if (symbol == 0) /* I.e. strcmp(tags[symbol],"$")==0 */
obstack_fgrow1 (&output_obstack, fprintf (out,
_(" $ \tgo to state %d\n"), state1); _(" $ \tgo to state %d\n"), state1);
else else
obstack_fgrow2 (&output_obstack, fprintf (out,
_(" %-4s\tshift, and go to state %d\n"), _(" %-4s\tshift, and go to state %d\n"),
tags[symbol], state1); tags[symbol], state1);
} }
if (i > 0) if (i > 0)
obstack_1grow (&output_obstack, '\n'); fputc ('\n', out);
} }
else else
{ {
@@ -157,21 +156,20 @@ print_actions (int state)
if (!errp->errs[j]) if (!errp->errs[j])
continue; continue;
symbol = errp->errs[j]; symbol = errp->errs[j];
obstack_fgrow1 (&output_obstack, _(" %-4s\terror (nonassociative)\n"), fprintf (out, _(" %-4s\terror (nonassociative)\n"),
tags[symbol]); tags[symbol]);
} }
if (j > 0) if (j > 0)
obstack_1grow (&output_obstack, '\n'); fputc ('\n', out);
} }
if (consistent[state] && redp) if (consistent[state] && redp)
{ {
rule = redp->rules[0]; rule = redp->rules[0];
symbol = rlhs[rule]; symbol = rlhs[rule];
obstack_fgrow2 (&output_obstack, fprintf (out, _(" $default\treduce using rule %d (%s)\n\n"),
_(" $default\treduce using rule %d (%s)\n\n"), rule, tags[symbol]);
rule, tags[symbol]);
} }
else if (redp) else if (redp)
{ {
@@ -186,42 +184,41 @@ print_actions (int state)
continue; continue;
state1 = shiftp->shifts[i]; state1 = shiftp->shifts[i];
symbol = accessing_symbol[state1]; symbol = accessing_symbol[state1];
obstack_fgrow2 (&output_obstack, fprintf (out, _(" %-4s\tgo to state %d\n"),
_(" %-4s\tgo to state %d\n"), tags[symbol], state1);
tags[symbol], state1);
} }
obstack_1grow (&output_obstack, '\n'); fputc ('\n', out);
} }
} }
static void static void
print_state (int state) print_state (FILE *out, int state)
{ {
obstack_sgrow (&output_obstack, "\n\n"); fputs ("\n\n", out);
obstack_fgrow1 (&output_obstack, _("state %d"), state); fprintf (out, _("state %d"), state);
obstack_sgrow (&output_obstack, "\n\n"); fputs ("\n\n", out);
print_core (state); print_core (out, state);
print_actions (state); print_actions (out, state);
} }
/*-----------------------------------------. /*-----------------------------------------.
| Print information on the whole grammar. | | Print information on the whole grammar. |
`-----------------------------------------*/ `-----------------------------------------*/
#define END_TEST(End) \ #define END_TEST(End) \
do { \ do { \
if (column + strlen(buffer) > (End)) \ if (column + strlen(buffer) > (End)) \
{ \ { \
obstack_fgrow1 (&output_obstack, "%s\n ", buffer); \ fprintf (out, "%s\n ", buffer); \
column = 3; \ column = 3; \
buffer[0] = 0; \ buffer[0] = 0; \
} \ } \
} while (0) } while (0)
static void static void
print_grammar (void) print_grammar (FILE *out)
{ {
int i, j; int i, j;
short *rule; short *rule;
@@ -229,78 +226,46 @@ print_grammar (void)
int column = 0; int column = 0;
/* rule # : LHS -> RHS */ /* rule # : LHS -> RHS */
obstack_1grow (&output_obstack, '\n'); fprintf (out, "\n%s\n", _("Grammar"));
obstack_sgrow (&output_obstack, _("Grammar"));
obstack_1grow (&output_obstack, '\n');
for (i = 1; i <= nrules; i++) for (i = 1; i <= nrules; i++)
/* Don't print rules disabled in reduce_grammar_tables. */ /* Don't print rules disabled in reduce_grammar_tables. */
if (rlhs[i] >= 0) if (rlhs[i] >= 0)
{ {
obstack_fgrow2 (&output_obstack, fprintf (out, _("rule %-4d %s ->"), i, tags[rlhs[i]]);
_("rule %-4d %s ->"), i, tags[rlhs[i]]);
rule = &ritem[rrhs[i]]; rule = &ritem[rrhs[i]];
if (*rule > 0) if (*rule > 0)
while (*rule > 0) while (*rule > 0)
obstack_fgrow1 (&output_obstack, " %s", tags[*rule++]); fprintf (out, " %s", tags[*rule++]);
else else
obstack_sgrow (&output_obstack, _(" /* empty */")); fprintf (out, " /* %s */\n", _("empty"));
obstack_1grow (&output_obstack, '\n');
} }
/* TERMINAL (type #) : rule #s terminal is on RHS */ /* TERMINAL (type #) : rule #s terminal is on RHS */
obstack_sgrow (&output_obstack, "\n"); fprintf (out, "\n%s\n\n", _("Terminals, with rules where they appear"));
obstack_sgrow (&output_obstack, fprintf (out, "%s (-1)\n", tags[0]);
_("Terminals, with rules where they appear"));
obstack_sgrow (&output_obstack, "\n\n");
obstack_fgrow1 (&output_obstack, "%s (-1)\n", tags[0]);
if (translations)
{
for (i = 0; i <= max_user_token_number; i++)
if (token_translations[i] != 2)
{
buffer[0] = 0;
column = strlen (tags[token_translations[i]]);
obstack_sgrow (&output_obstack, tags[token_translations[i]]);
END_TEST (50);
sprintf (buffer, " (%d)", i);
for (j = 1; j <= nrules; j++) for (i = 0; i <= max_user_token_number; i++)
for (rule = &ritem[rrhs[j]]; *rule > 0; rule++) if (token_translations[i] != 2)
if (*rule == token_translations[i]) {
{ buffer[0] = 0;
END_TEST (65); column = strlen (tags[token_translations[i]]);
sprintf (buffer + strlen (buffer), " %d", j); fputs (tags[token_translations[i]], out);
break; END_TEST (50);
} sprintf (buffer, " (%d)", i);
obstack_fgrow1 (&output_obstack, "%s\n", buffer);
}
}
else
{
for (i = 1; i < ntokens; i++)
{
buffer[0] = 0;
column = strlen (tags[i]);
obstack_sgrow (&output_obstack, tags[i]);
END_TEST (50);
sprintf (buffer, " (%d)", i);
for (j = 1; j <= nrules; j++) for (j = 1; j <= nrules; j++)
for (rule = &ritem[rrhs[j]]; *rule > 0; rule++) for (rule = &ritem[rrhs[j]]; *rule > 0; rule++)
if (*rule == i) if (*rule == token_translations[i])
{ {
END_TEST (65); END_TEST (65);
sprintf (buffer + strlen (buffer), " %d", j); sprintf (buffer + strlen (buffer), " %d", j);
break; break;
} }
obstack_fgrow1 (&output_obstack, "%s\n", buffer); fprintf (out, "%s\n", buffer);
} }
}
obstack_sgrow (&output_obstack, "\n"); fprintf (out, "\n%s\n\n",
obstack_sgrow (&output_obstack, _("Nonterminals, with rules where they appear"));
_("Nonterminals, with rules where they appear"));
obstack_sgrow (&output_obstack, "\n\n");
for (i = ntokens; i <= nsyms - 1; i++) for (i = ntokens; i <= nsyms - 1; i++)
{ {
int left_count = 0, right_count = 0; int left_count = 0, right_count = 0;
@@ -318,7 +283,7 @@ print_grammar (void)
} }
buffer[0] = 0; buffer[0] = 0;
obstack_sgrow (&output_obstack, tags[i]); fputs (tags[i], out);
column = strlen (tags[i]); column = strlen (tags[i]);
sprintf (buffer, " (%d)", i); sprintf (buffer, " (%d)", i);
END_TEST (0); END_TEST (0);
@@ -353,22 +318,33 @@ print_grammar (void)
} }
} }
} }
obstack_fgrow1 (&output_obstack, "%s\n", buffer); fprintf (out, "%s\n", buffer);
} }
} }
void void
print_results (void) print_results (void)
{ {
int i;
if (any_conflicts)
print_conflicts ();
if (verbose_flag) if (verbose_flag)
print_grammar (); {
int i;
if (verbose_flag) /* We used to use just .out if spec_name_prefix (-p) was used, but
for (i = 0; i < nstates; i++) that conflicts with Posix. */
print_state (i); FILE *out = xfopen (spec_verbose_file, "w");
size_t size = obstack_object_size (&output_obstack);
fwrite (obstack_finish (&output_obstack), 1, size, out);
if (any_conflicts)
print_conflicts (out);
print_grammar (out);
for (i = 0; i < nstates; i++)
print_state (out, i);
xfclose (out);
}
obstack_free (&output_obstack, NULL);
} }

View File

@@ -19,7 +19,6 @@
Boston, MA 02111-1307, USA. */ Boston, MA 02111-1307, USA. */
#include "system.h" #include "system.h"
#include "xalloc.h"
#include "files.h" #include "files.h"
#include "gram.h" #include "gram.h"
#include "LR0.h" #include "LR0.h"
@@ -35,8 +34,9 @@
#include "quotearg.h" #include "quotearg.h"
static graph_t graph; static graph_t graph;
static FILE *fgraph = NULL;
static unsigned node_output_size = 0; static size_t node_output_size = 0;
/* Return an unambiguous printable representated, allocated in slot 0, /* Return an unambiguous printable representated, allocated in slot 0,
for NAME, suitable for C strings. */ for NAME, suitable for C strings. */
@@ -136,7 +136,7 @@ print_actions (int state, const char *node_name, struct obstack *node_obstack)
if (state > state1) if (state > state1)
edge.type = back_edge; edge.type = back_edge;
open_edge (&edge, &graph_obstack); open_edge (&edge, fgraph);
/* The edge source is the current node. */ /* The edge source is the current node. */
edge.sourcename = node_name; edge.sourcename = node_name;
sprintf (buff, "%d", state1); sprintf (buff, "%d", state1);
@@ -145,8 +145,8 @@ print_actions (int state, const char *node_name, struct obstack *node_obstack)
/* FIXME: Be aware that quote uses static memory. The string /* FIXME: Be aware that quote uses static memory. The string
must be output immediately (which is the case here). */ must be output immediately (which is the case here). */
edge.label = tags[symbol] ? quote (tags[symbol]) : NULL; edge.label = tags[symbol] ? quote (tags[symbol]) : NULL;
output_edge (&edge, &graph_obstack); output_edge (&edge, fgraph);
close_edge (&graph_obstack); close_edge (fgraph);
} }
} }
} }
@@ -198,14 +198,14 @@ print_actions (int state, const char *node_name, struct obstack *node_obstack)
symbol = accessing_symbol[state1]; symbol = accessing_symbol[state1];
new_edge (&edge); new_edge (&edge);
open_edge (&edge, &graph_obstack); open_edge (&edge, fgraph);
edge.sourcename = node_name; edge.sourcename = node_name;
sprintf (buff, "%d", state1); sprintf (buff, "%d", state1);
edge.targetname = buff; edge.targetname = buff;
edge.color = red; edge.color = red;
edge.label = tags[symbol] ? quote (tags[symbol]) : NULL; edge.label = tags[symbol] ? quote (tags[symbol]) : NULL;
output_edge (&edge, &graph_obstack); output_edge (&edge, fgraph);
close_edge (&graph_obstack); close_edge (fgraph);
} }
} }
} }
@@ -223,9 +223,6 @@ print_state (int state)
new_node (&node); /* Set node attributs default value. */ new_node (&node); /* Set node attributs default value. */
sprintf (name, "%d", state); sprintf (name, "%d", state);
node.title = name; /* Give a name to the node. */ node.title = name; /* Give a name to the node. */
open_node (&node_obstack);
/* Output a VCG formatted attributs list. */
output_node (&node, &node_obstack);
{ {
/* Here we begin to compute the node label. */ /* Here we begin to compute the node label. */
@@ -241,15 +238,17 @@ print_state (int state)
print_actions (state, node.title, &node_obstack); print_actions (state, node.title, &node_obstack);
obstack_sgrow (&node_obstack, "\"\n"); /* Close Label. */ obstack_sgrow (&node_obstack, "\"\n"); /* Close Label. */
}
close_node (&node_obstack);
} open_node (fgraph);
/* Output a VCG formatted attributs list. */
/* `obstack_cat' NODE_OBSTACK to GRAPH_OBSTACK. */ output_node (&node, fgraph);
obstack_grow (&graph_obstack, /* Save the node label. */
obstack_base (&node_obstack), fwrite (obstack_base (&node_obstack),
obstack_object_size (&node_obstack)); obstack_object_size (&node_obstack), 1, fgraph);
obstack_finish (&node_obstack); close_node (fgraph);
obstack_free (&node_obstack, 0);
} }
@@ -257,9 +256,13 @@ void
print_graph (void) print_graph (void)
{ {
int i; int i;
if (!graph_flag) if (!graph_flag)
return; return;
/* Output file. */
fgraph = xfopen (spec_graph_file, "w");
new_graph (&graph); new_graph (&graph);
#if 0 #if 0
@@ -268,7 +271,7 @@ print_graph (void)
#endif #endif
graph.display_edge_labels = yes; graph.display_edge_labels = yes;
graph.layoutalgorithm = 0; graph.layoutalgorithm = normal;
graph.port_sharing = no; graph.port_sharing = no;
graph.finetuning = yes; graph.finetuning = yes;
@@ -279,13 +282,14 @@ print_graph (void)
graph.crossing_weight = median; graph.crossing_weight = median;
/* Output graph options. */ /* Output graph options. */
open_graph (&graph_obstack); open_graph (fgraph);
output_graph (&graph, &graph_obstack); output_graph (&graph, fgraph);
for (i = 0; i < nstates; i++) for (i = 0; i < nstates; i++)
/* Output nodes & edges. */ /* Output nodes & edges. */
print_state (i); print_state (i);
/* Close graph. */ /* Close graph. */
close_graph (&graph, &graph_obstack); close_graph (&graph, fgraph);
xfclose (fgraph);
} }

View File

@@ -26,7 +26,6 @@
#include "quote.h" #include "quote.h"
#include "getargs.h" #include "getargs.h"
#include "files.h" #include "files.h"
#include "xalloc.h"
#include "symtab.h" #include "symtab.h"
#include "options.h" #include "options.h"
#include "lex.h" #include "lex.h"
@@ -431,7 +430,7 @@ copy_definition (void)
if (!no_lines_flag) if (!no_lines_flag)
{ {
obstack_fgrow2 (&attrs_obstack, muscle_find ("linef"), obstack_fgrow2 (&attrs_obstack, muscle_find ("linef"),
lineno, quotearg_style (c_quoting_style, lineno, quotearg_style (c_quoting_style,
muscle_find("filename"))); muscle_find("filename")));
} }
#endif #endif
@@ -491,8 +490,8 @@ copy_definition (void)
static void static void
parse_token_decl (symbol_class what_is, symbol_class what_is_not) parse_token_decl (symbol_class what_is, symbol_class what_is_not)
{ {
token_t token = 0; token_t token = tok_undef;
char *typename = 0; char *typename = NULL;
/* The symbol being defined. */ /* The symbol being defined. */
struct bucket *symbol = NULL; struct bucket *symbol = NULL;
@@ -541,7 +540,6 @@ parse_token_decl (symbol_class what_is, symbol_class what_is_not)
/* symbol and symval combined are only one symbol */ /* symbol and symval combined are only one symbol */
nsyms--; nsyms--;
} }
translations = 1;
symbol = NULL; symbol = NULL;
} }
else if (token == tok_identifier) else if (token == tok_identifier)
@@ -566,7 +564,6 @@ parse_token_decl (symbol_class what_is, symbol_class what_is_not)
else if (symbol && token == tok_number) else if (symbol && token == tok_number)
{ {
symbol->user_token_number = numval; symbol->user_token_number = numval;
translations = 1;
} }
else else
{ {
@@ -708,7 +705,6 @@ parse_assoc_decl (associativity assoc)
if (prev == tok_identifier) if (prev == tok_identifier)
{ {
symval->user_token_number = numval; symval->user_token_number = numval;
translations = 1;
} }
else else
{ {
@@ -754,7 +750,7 @@ parse_union_decl (void)
if (no_lines_flag) if (no_lines_flag)
obstack_1grow (&attrs_obstack, '\n'); obstack_1grow (&attrs_obstack, '\n');
obstack_init (&union_obstack); obstack_init (&union_obstack);
obstack_sgrow (&union_obstack, "union"); obstack_sgrow (&union_obstack, "union");
if (defines_flag) if (defines_flag)
@@ -764,9 +760,13 @@ parse_union_decl (void)
while (c != EOF) while (c != EOF)
{ {
obstack_1grow (&union_obstack, c); /* If C contains '/', it is output by copy_comment (). */
if (defines_flag) if (c != '/')
obstack_1grow (&defines_obstack, c); {
obstack_1grow (&attrs_obstack, c);
if (defines_flag)
obstack_1grow (&defines_obstack, c);
}
switch (c) switch (c)
{ {
@@ -852,7 +852,6 @@ parse_thong_decl (void)
char *typename = 0; char *typename = 0;
int usrtoknum; int usrtoknum;
translations = 1;
token = lex (); /* fetch typename or first token */ token = lex (); /* fetch typename or first token */
if (token == tok_typename) if (token == tok_typename)
{ {
@@ -904,8 +903,6 @@ parse_thong_decl (void)
nsyms--; nsyms--;
} }
/* FIXME. */
static void static void
parse_muscle_decl (void) parse_muscle_decl (void)
{ {
@@ -923,7 +920,7 @@ parse_muscle_decl (void)
copy_identifier (finput, &muscle_obstack); copy_identifier (finput, &muscle_obstack);
obstack_1grow (&muscle_obstack, 0); obstack_1grow (&muscle_obstack, 0);
muscle_key = obstack_finish (&muscle_obstack); muscle_key = obstack_finish (&muscle_obstack);
/* Read value. */ /* Read value. */
ch = skip_white_space (); ch = skip_white_space ();
if (ch != '"') if (ch != '"')
@@ -957,36 +954,6 @@ parse_skel_decl (void)
/* Complete with parse_dquoted_param () on the CVS branch 1.29. */ /* Complete with parse_dquoted_param () on the CVS branch 1.29. */
} }
/*------------------------------------------.
| Parse what comes after %header_extension. |
`------------------------------------------*/
static void
parse_header_extension_decl (void)
{
char buff[32];
if (header_extension)
complain (_("multiple %%header_extension declarations"));
fscanf (finput, "%s", buff);
header_extension = xstrdup (buff);
}
/*------------------------------------------.
| Parse what comes after %source_extension. |
`------------------------------------------*/
static void
parse_source_extension_decl (void)
{
char buff[32];
if (src_extension)
complain (_("multiple %%source_extension declarations"));
fscanf (finput, "%s", buff);
src_extension = xstrdup (buff);
}
/*----------------------------------------------------------------. /*----------------------------------------------------------------.
| Read from finput until `%%' is seen. Discard the `%%'. Handle | | Read from finput until `%%' is seen. Discard the `%%'. Handle |
| any `%' declarations, and copy the contents of any `%{ ... %}' | | any `%' declarations, and copy the contents of any `%{ ... %}' |
@@ -1056,18 +1023,10 @@ read_declarations (void)
parse_assoc_decl (non_assoc); parse_assoc_decl (non_assoc);
break; break;
case tok_hdrext:
parse_header_extension_decl ();
break;
case tok_srcext:
parse_source_extension_decl ();
break;
case tok_define: case tok_define:
parse_muscle_decl (); parse_muscle_decl ();
break; break;
case tok_skel: case tok_skel:
parse_skel_decl (); parse_skel_decl ();
break; break;
@@ -1115,7 +1074,7 @@ copy_action (symbol_list *rule, int stack_offset)
if (!no_lines_flag) if (!no_lines_flag)
{ {
obstack_fgrow2 (&action_obstack, muscle_find ("linef"), obstack_fgrow2 (&action_obstack, muscle_find ("linef"),
lineno, quotearg_style (c_quoting_style, lineno, quotearg_style (c_quoting_style,
muscle_find ("filename"))); muscle_find ("filename")));
} }
obstack_1grow (&action_obstack, '{'); obstack_1grow (&action_obstack, '{');
@@ -1678,12 +1637,12 @@ read_additionnal_code (void)
{ {
char c; char c;
struct obstack el_obstack; struct obstack el_obstack;
obstack_init (&el_obstack); obstack_init (&el_obstack);
while ((c = getc (finput)) != EOF) while ((c = getc (finput)) != EOF)
obstack_1grow (&el_obstack, c); obstack_1grow (&el_obstack, c);
obstack_1grow (&el_obstack, 0); obstack_1grow (&el_obstack, 0);
muscle_insert ("epilogue", obstack_finish (&el_obstack)); muscle_insert ("epilogue", obstack_finish (&el_obstack));
} }
@@ -1729,9 +1688,10 @@ output_token_defines (struct obstack *oout)
continue; continue;
obstack_fgrow2 (oout, "# define\t%s\t%d\n", obstack_fgrow2 (oout, "# define\t%s\t%d\n",
symbol, symbol, bp->user_token_number);
(translations ? bp->user_token_number : bp->value));
if (semantic_parser) if (semantic_parser)
/* FIXME: This is certainly dead wrong, and should be just as
above. --akim. */
obstack_fgrow2 (oout, "# define\tT%s\t%d\n", symbol, bp->value); obstack_fgrow2 (oout, "# define\tT%s\t%d\n", symbol, bp->value);
} }
} }
@@ -1746,9 +1706,9 @@ output_token_defines (struct obstack *oout)
static void static void
packsymbols (void) packsymbols (void)
{ {
bucket *bp; bucket *bp = NULL;
int tokno = 1; int tokno = 1;
int i; int i, j;
int last_user_token_number; int last_user_token_number;
static char DOLLAR[] = "$"; static char DOLLAR[] = "$";
@@ -1812,7 +1772,7 @@ packsymbols (void)
if (bp->class == token_sym) if (bp->class == token_sym)
{ {
if (translations && !(bp->user_token_number)) if (!bp->user_token_number)
bp->user_token_number = ++last_user_token_number; bp->user_token_number = ++last_user_token_number;
if (bp->user_token_number > max_user_token_number) if (bp->user_token_number > max_user_token_number)
max_user_token_number = bp->user_token_number; max_user_token_number = bp->user_token_number;
@@ -1822,40 +1782,39 @@ packsymbols (void)
user_toknums[bp->value] = bp->user_token_number; user_toknums[bp->value] = bp->user_token_number;
sprec[bp->value] = bp->prec; sprec[bp->value] = bp->prec;
sassoc[bp->value] = bp->assoc; sassoc[bp->value] = bp->assoc;
} }
if (translations) token_translations = XCALLOC (short, max_user_token_number + 1);
/* initialize all entries for literal tokens to 2, the internal
token number for $undefined., which represents all invalid
inputs. */
for (j = 0; j <= max_user_token_number; j++)
token_translations[j] = 2;
for (bp = firstsymbol; bp; bp = bp->next)
{ {
int j; if (bp->value >= ntokens)
continue; /* non-terminal */
token_translations = XCALLOC (short, max_user_token_number + 1); if (bp->user_token_number == SALIAS)
continue;
/* initialize all entries for literal tokens to 2, the internal if (token_translations[bp->user_token_number] != 2)
token number for $undefined., which represents all invalid complain (_("tokens %s and %s both assigned number %d"),
inputs. */ tags[token_translations[bp->user_token_number]],
for (j = 0; j <= max_user_token_number; j++) bp->tag, bp->user_token_number);
token_translations[j] = 2; token_translations[bp->user_token_number] = bp->value;
for (bp = firstsymbol; bp; bp = bp->next)
{
if (bp->value >= ntokens)
continue; /* non-terminal */
if (bp->user_token_number == SALIAS)
continue;
if (token_translations[bp->user_token_number] != 2)
complain (_("tokens %s and %s both assigned number %d"),
tags[token_translations[bp->user_token_number]],
bp->tag, bp->user_token_number);
token_translations[bp->user_token_number] = bp->value;
}
} }
error_token_number = errtoken->value; error_token_number = errtoken->value;
output_token_defines (&output_obstack); {
obstack_1grow (&output_obstack, 0); struct obstack tokendefs;
muscle_insert ("tokendef", obstack_finish (&output_obstack)); obstack_init (&tokendefs);
output_token_defines (&tokendefs);
obstack_1grow (&tokendefs, 0);
muscle_insert ("tokendef", xstrdup (obstack_finish (&tokendefs)));
obstack_free (&tokendefs, NULL);
}
#if 0 #if 0
if (!no_parser_flag) if (!no_parser_flag)
@@ -1980,15 +1939,6 @@ reader (void)
start_flag = 0; start_flag = 0;
startval = NULL; /* start symbol not specified yet. */ startval = NULL; /* start symbol not specified yet. */
#if 0
/* initially assume token number translation not needed. */
translations = 0;
#endif
/* Nowadays translations is always set to 1, since we give `error' a
user-token-number to satisfy the Posix demand for YYERRCODE==256.
*/
translations = 1;
nsyms = 1; nsyms = 1;
nvars = 0; nvars = 0;
nrules = 0; nrules = 0;
@@ -2004,7 +1954,7 @@ reader (void)
grammar = NULL; grammar = NULL;
init_lex (); lex_init ();
lineno = 1; lineno = 1;
/* Initialize the muscle obstack. */ /* Initialize the muscle obstack. */
@@ -2043,7 +1993,4 @@ reader (void)
packsymbols (); packsymbols ();
/* Convert the grammar into the format described in gram.h. */ /* Convert the grammar into the format described in gram.h. */
packgram (); packgram ();
/* Free the symbol table data structure since symbols are now all
referred to by symbol number. */
free_symtab ();
} }

View File

@@ -29,7 +29,6 @@
#include "getargs.h" #include "getargs.h"
#include "files.h" #include "files.h"
#include "gram.h" #include "gram.h"
#include "xalloc.h"
#include "complain.h" #include "complain.h"
#include "reduce.h" #include "reduce.h"
#include "reader.h" #include "reader.h"
@@ -117,7 +116,7 @@ static void
useless_nonterminals (void) useless_nonterminals (void)
{ {
BSet Np, Ns; BSet Np, Ns;
int i, n; int i;
/* N is set as built. Np is set being built this iteration. P is /* N is set as built. Np is set being built this iteration. P is
set of all productions which have a RHS all in N. */ set of all productions which have a RHS all in N. */
@@ -140,7 +139,6 @@ useless_nonterminals (void)
saved to be used when finding useful productions: only saved to be used when finding useful productions: only
productions in this set will appear in the final grammar. */ productions in this set will appear in the final grammar. */
n = 0;
while (1) while (1)
{ {
for (i = WORDSIZE (nvars) - 1; i >= 0; i--) for (i = WORDSIZE (nvars) - 1; i >= 0; i--)
@@ -171,7 +169,7 @@ static void
inaccessable_symbols (void) inaccessable_symbols (void)
{ {
BSet Vp, Vs, Pp; BSet Vp, Vs, Pp;
int i, n; int i;
short t; short t;
rule r; rule r;
@@ -207,7 +205,6 @@ inaccessable_symbols (void)
SETBIT (V, start_symbol); SETBIT (V, start_symbol);
n = 0;
while (1) while (1)
{ {
for (i = WORDSIZE (nsyms) - 1; i >= 0; i--) for (i = WORDSIZE (nsyms) - 1; i >= 0; i--)

View File

@@ -20,7 +20,6 @@
#include "system.h" #include "system.h"
#include "xalloc.h"
#include "symtab.h" #include "symtab.h"
#include "gram.h" #include "gram.h"
@@ -143,6 +142,7 @@ free_symtab (void)
if (bp->type_name) if (bp->type_name)
XFREE (bp->type_name); XFREE (bp->type_name);
#endif #endif
XFREE (bp->tag);
XFREE (bp); XFREE (bp);
bp = bptmp; bp = bptmp;
} }

View File

@@ -73,7 +73,7 @@ extern int errno;
# define PARAMS(p) () # define PARAMS(p) ()
#endif #endif
# include "xalloc.h"
/*---------------------. /*---------------------.
| Missing prototypes. | | Missing prototypes. |
@@ -143,8 +143,6 @@ size_t strnlen PARAMS ((const char *s, size_t maxlen));
# define LOCALEDIR "/usr/local/share/locale" # define LOCALEDIR "/usr/local/share/locale"
#endif #endif
#endif /* BISON_SYSTEM_H */
/*-----------. /*-----------.
| Booleans. | | Booleans. |
@@ -161,9 +159,9 @@ typedef int bool;
| Obstacks. | | Obstacks. |
`-----------*/ `-----------*/
#define obstack_chunk_alloc xmalloc # define obstack_chunk_alloc xmalloc
#define obstack_chunk_free free # define obstack_chunk_free free
#include "obstack.h" # include "obstack.h"
#define obstack_sgrow(Obs, Str) \ #define obstack_sgrow(Obs, Str) \
obstack_grow (Obs, Str, strlen (Str)) obstack_grow (Obs, Str, strlen (Str))
@@ -264,3 +262,15 @@ do { \
# define BISON_HAIRY "c:/usr/local/lib/bison.hairy" # define BISON_HAIRY "c:/usr/local/lib/bison.hairy"
# endif # endif
#endif #endif
/*---------------------------------.
| Debugging the memory allocator. |
`---------------------------------*/
# if WITH_DMALLOC
# define DMALLOC_FUNC_CHECK
# include <dmalloc.h>
# endif /* WITH_DMALLOC */
#endif /* BISON_SYSTEM_H */

449
src/vcg.c
View File

@@ -21,8 +21,6 @@
#include "system.h" #include "system.h"
#include "vcg.h" #include "vcg.h"
#include "vcg_defaults.h" #include "vcg_defaults.h"
#include "xalloc.h"
#include "complain.h"
/* Initialize a graph with the default values. */ /* Initialize a graph with the default values. */
void void
@@ -51,6 +49,9 @@ new_graph (graph_t *g)
g->textmode = G_TEXTMODE; g->textmode = G_TEXTMODE;
g->shape = G_SHAPE; g->shape = G_SHAPE;
g->vertical_order = G_VERTICAL_ORDER;
g->horizontal_order = G_HORIZONTAL_ORDER;
g->xmax = G_XMAX; /* Not output. */ g->xmax = G_XMAX; /* Not output. */
g->ymax = G_YMAX; /* Not output. */ g->ymax = G_YMAX; /* Not output. */
@@ -231,8 +232,7 @@ get_color_str (enum color_e c)
case orchid: return "orchid"; case orchid: return "orchid";
case black: return "black"; case black: return "black";
default: default:
complain (_("vcg graph: no such color.")); assert (!"Not a default color.");
return get_color_str(G_COLOR);
} }
return NULL; return NULL;
} }
@@ -246,8 +246,7 @@ get_textmode_str (enum textmode_e t)
case left_justify: return "left_justify"; case left_justify: return "left_justify";
case right_justify: return "right_justify"; case right_justify: return "right_justify";
default: default:
complain (_("vcg graph: no such text mode")); assert (!"Not a text mode.");
return get_textmode_str(G_TEXTMODE);
} }
return NULL; return NULL;
} }
@@ -262,8 +261,7 @@ get_shape_str (enum shape_e s)
case ellipse: return "ellipse"; case ellipse: return "ellipse";
case triangle: return "triangle"; case triangle: return "triangle";
default: default:
complain (_("vcg graph: no such shape")); assert (!"Not a shape.");
return get_shape_str(G_SHAPE);
} }
return NULL; return NULL;
} }
@@ -288,21 +286,20 @@ get_layoutalgorithm_str (enum layoutalgorithm_e l)
case dfs: return "dfs"; case dfs: return "dfs";
case tree: return "tree"; case tree: return "tree";
default: default:
return "normal"; assert (!"Not a layout algorithm.");
} }
return NULL; return NULL;
} }
static const char * static const char *
get_decision_str (enum decision_e d, enum decision_e defaults) get_decision_str (enum decision_e d)
{ {
switch (d) switch (d)
{ {
case no: return "no"; case no: return "no";
case yes: return "yes"; case yes: return "yes";
default: default:
complain (_("vcg graph: no such decision")); assert (!"Either yes nor no.");
return get_decision_str(defaults, 0);
} }
return NULL; return NULL;
} }
@@ -317,8 +314,7 @@ get_orientation_str (enum orientation_e o)
case left_to_right: return "left_to_right"; case left_to_right: return "left_to_right";
case right_to_left: return "right_to_left"; case right_to_left: return "right_to_left";
default: default:
complain (_("vcg graph: no such an orientation")); assert (!"Not an orientation.");
return get_orientation_str(G_ORIENTATION);
} }
return NULL; return NULL;
} }
@@ -332,8 +328,7 @@ get_node_alignement_str (enum alignement_e a)
case top: return "top"; case top: return "top";
case bottom: return "bottom"; case bottom: return "bottom";
default: default:
complain (_("vcg graph: no such an alignement")); assert (!"Not an alignement.");
return get_node_alignement_str(G_NODE_ALIGNEMENT);
} }
return NULL; return NULL;
} }
@@ -346,8 +341,7 @@ get_arrow_mode_str (enum arrow_mode_e a)
case fixed: return "fixed"; case fixed: return "fixed";
case free_a: return "free"; case free_a: return "free";
default: default:
complain (_("vcg graph: no such an arrow mode")); assert (!"Not an arrow mode.");
return get_arrow_mode_str(G_ARROW_MODE);
} }
return NULL; return NULL;
} }
@@ -362,8 +356,7 @@ get_crossing_type_str (enum crossing_type_e c)
case barymedian: return "barymedian"; case barymedian: return "barymedian";
case medianbary: return "medianbary"; case medianbary: return "medianbary";
default: default:
complain (_("vcg graph: no such crossing_type")); assert (!"Not a crossing type.");
return get_crossing_type_str(G_CROSSING_WEIGHT);
} }
return NULL; return NULL;
} }
@@ -379,8 +372,7 @@ get_view_str (enum view_e v)
case fcfish: return "fcfish"; case fcfish: return "fcfish";
case fpfish: return "fpfish"; case fpfish: return "fpfish";
default: default:
complain (_("vcg graph: no such view")); assert (!"Not a view.");
return get_view_str(G_VIEW);
} }
return NULL; return NULL;
} }
@@ -395,8 +387,7 @@ get_linestyle_str (enum linestyle_e l)
case dotted: return "dotted"; case dotted: return "dotted";
case invisible: return "invisible"; case invisible: return "invisible";
default: default:
complain (_("vcg graph: no such linestyle")); assert (!"Not a line style.");
return get_linestyle_str(E_LINESTYLE);
} }
return NULL; return NULL;
} }
@@ -410,8 +401,7 @@ get_arrowstyle_str (enum arrowstyle_e a)
case line: return "line"; case line: return "line";
case none: return "none"; case none: return "none";
default: default:
complain (_("vcg graph: no such an arrowstyle")); assert (!"Not an arrow style.");
return get_arrowstyle_str(E_ARROWSTYLE);
} }
return NULL; return NULL;
} }
@@ -435,402 +425,461 @@ add_edge (graph_t *graph, edge_t *edge)
graph->edge_list = edge; graph->edge_list = edge;
} }
void
add_classname (graph_t *g, int val, const char *name)
{
struct classname_s *classname;
classname = XMALLOC (struct classname_s, 1);
classname->no = val;
classname->name = name;
classname->next = g->classname;
g->classname = classname;
}
void
add_infoname (graph_t *g, int integer, const char *string)
{
struct infoname_s *infoname;
infoname = XMALLOC (struct infoname_s, 1);
infoname->integer = integer;
infoname->string = string;
infoname->next = g->infoname;
g->infoname = infoname;
}
/* Build a colorentry struct and add it to the list. */
void
add_colorentry (graph_t *g, int color_idx, int red_cp,
int green_cp, int blue_cp)
{
struct colorentry_s *ce;
ce = XMALLOC (struct colorentry_s, 1);
ce->color_index = color_idx;
ce->red_cp = red_cp;
ce->green_cp = green_cp;
ce->blue_cp = blue_cp;
ce->next = g->colorentry;
g->colorentry = ce;
}
/*-------------------------------------. /*-------------------------------------.
| Open and close functions (formatted) | | Open and close functions (formatted) |
`-------------------------------------*/ `-------------------------------------*/
void void
open_edge(edge_t *edge, struct obstack *os) open_edge(edge_t *edge, FILE *fout)
{ {
switch (edge->type) switch (edge->type)
{ {
case normal_edge: case normal_edge:
obstack_sgrow (os, "\tedge: {\n"); fputs ("\tedge: {\n", fout);
break; break;
case back_edge: case back_edge:
obstack_sgrow (os, "\tbackedge: {\n"); fputs ("\tbackedge: {\n", fout);
break; break;
case near_edge: case near_edge:
obstack_sgrow (os, "\tnearedge: {\n"); fputs ("\tnearedge: {\n", fout);
break; break;
case bent_near_edge: case bent_near_edge:
obstack_sgrow (os, "\tbentnearedge: {\n"); fputs ("\tbentnearedge: {\n", fout);
break; break;
default: default:
obstack_sgrow (os, "\tedge: {\n"); fputs ("\tedge: {\n", fout);
} }
} }
void void
close_edge(struct obstack *os) close_edge(FILE *fout)
{ {
obstack_sgrow (os, "\t}\n"); fputs ("\t}\n", fout);
} }
void void
open_node(struct obstack *os) open_node(FILE *fout)
{ {
obstack_sgrow (os, "\tnode: {\n"); fputs ("\tnode: {\n", fout);
} }
void void
close_node(struct obstack *os) close_node(FILE *fout)
{ {
obstack_sgrow (os, "\t}\n"); fputs ("\t}\n", fout);
} }
void void
open_graph(struct obstack *os) open_graph(FILE *fout)
{ {
obstack_sgrow (os, "graph: {\n"); fputs ("graph: {\n", fout);
} }
void void
close_graph(graph_t *graph, struct obstack *os) close_graph(graph_t *graph, FILE *fout)
{ {
obstack_1grow (os, '\n'); fputc ('\n', fout);
/* FIXME: Unallocate nodes and edges if required. */
{ {
node_t *node; node_t *node;
for (node = graph->node_list; node; node = node->next) for (node = graph->node_list; node; node = node->next)
{ {
open_node (os); open_node (fout);
output_node (node, os); output_node (node, fout);
close_node (os); close_node (fout);
} }
} }
obstack_1grow (os, '\n'); fputc ('\n', fout);
{ {
edge_t *edge; edge_t *edge;
for (edge = graph->edge_list; edge; edge = edge->next) for (edge = graph->edge_list; edge; edge = edge->next)
{ {
open_edge (edge, os); open_edge (edge, fout);
output_edge (edge, os); output_edge (edge, fout);
close_edge (os); close_edge (fout);
} }
} }
obstack_sgrow (os, "}\n"); fputs ("}\n", fout);
} }
/*-------------------------------------------. /*-------------------------------------------.
| Output functions (formatted) in obstack os | | Output functions (formatted) in file FOUT |
`-------------------------------------------*/ `-------------------------------------------*/
void void
output_node (node_t *node, struct obstack *os) output_node (node_t *node, FILE *fout)
{ {
if (node->title != N_TITLE) if (node->title != N_TITLE)
obstack_fgrow1 (os, "\t\ttitle:\t\"%s\"\n", node->title); fprintf (fout, "\t\ttitle:\t\"%s\"\n", node->title);
if (node->label != N_LABEL) if (node->label != N_LABEL)
obstack_fgrow1 (os, "\t\tlabel:\t\"%s\"\n", node->label); fprintf (fout, "\t\tlabel:\t\"%s\"\n", node->label);
if ((node->locx != N_LOCX) && (node->locy != N_LOCY)) if ((node->locx != N_LOCX) && (node->locy != N_LOCY))
obstack_fgrow2 (os, "\t\tloc { x: %d y: %d }\t\n", node->locx, node->locy); fprintf (fout, "\t\tloc { x: %d y: %d }\t\n", node->locx, node->locy);
if (node->vertical_order != N_VERTICAL_ORDER) if (node->vertical_order != N_VERTICAL_ORDER)
obstack_fgrow1 (os, "\t\tvertical_order:\t%d\n", node->vertical_order); fprintf (fout, "\t\tvertical_order:\t%d\n", node->vertical_order);
if (node->horizontal_order != N_HORIZONTAL_ORDER) if (node->horizontal_order != N_HORIZONTAL_ORDER)
obstack_fgrow1 (os, "\t\thorizontal_order:\t%d\n", node->horizontal_order); fprintf (fout, "\t\thorizontal_order:\t%d\n", node->horizontal_order);
if (node->width != N_WIDTH) if (node->width != N_WIDTH)
obstack_fgrow1 (os, "\t\twidth:\t%d\n", node->width); fprintf (fout, "\t\twidth:\t%d\n", node->width);
if (node->height != N_HEIGHT) if (node->height != N_HEIGHT)
obstack_fgrow1 (os, "\t\theight:\t%d\n", node->height); fprintf (fout, "\t\theight:\t%d\n", node->height);
if (node->shrink != N_SHRINK) if (node->shrink != N_SHRINK)
obstack_fgrow1 (os, "\t\tshrink:\t%d\n", node->shrink); fprintf (fout, "\t\tshrink:\t%d\n", node->shrink);
if (node->stretch != N_STRETCH) if (node->stretch != N_STRETCH)
obstack_fgrow1 (os, "\t\tstretch:\t%d\n", node->stretch); fprintf (fout, "\t\tstretch:\t%d\n", node->stretch);
if (node->folding != N_FOLDING) if (node->folding != N_FOLDING)
obstack_fgrow1 (os, "\t\tfolding:\t%d\n", node->folding); fprintf (fout, "\t\tfolding:\t%d\n", node->folding);
if (node->textmode != N_TEXTMODE) if (node->textmode != N_TEXTMODE)
obstack_fgrow1 (os, "\t\ttextmode:\t%s\n", fprintf (fout, "\t\ttextmode:\t%s\n",
get_textmode_str (node->textmode)); get_textmode_str (node->textmode));
if (node->shape != N_SHAPE) if (node->shape != N_SHAPE)
obstack_fgrow1 (os, "\t\tshape:\t%s\n", get_shape_str (node->shape)); fprintf (fout, "\t\tshape:\t%s\n", get_shape_str (node->shape));
if (node->borderwidth != N_BORDERWIDTH) if (node->borderwidth != N_BORDERWIDTH)
obstack_fgrow1 (os, "\t\tborderwidth:\t%d\n", node->borderwidth); fprintf (fout, "\t\tborderwidth:\t%d\n", node->borderwidth);
if (node->color != N_COLOR) if (node->color != N_COLOR)
obstack_fgrow1 (os, "\t\tcolor:\t%s\n", get_color_str (node->color)); fprintf (fout, "\t\tcolor:\t%s\n", get_color_str (node->color));
if (node->textcolor != N_TEXTCOLOR) if (node->textcolor != N_TEXTCOLOR)
obstack_fgrow1 (os, "\t\ttextcolor:\t%s\n", fprintf (fout, "\t\ttextcolor:\t%s\n",
get_color_str (node->textcolor)); get_color_str (node->textcolor));
if (node->bordercolor != N_BORDERCOLOR) if (node->bordercolor != N_BORDERCOLOR)
obstack_fgrow1 (os, "\t\tbordercolor:\t%s\n", fprintf (fout, "\t\tbordercolor:\t%s\n",
get_color_str (node->bordercolor)); get_color_str (node->bordercolor));
if (node->infos[0]) if (node->infos[0])
obstack_fgrow1 (os, "\t\tinfo1:\t\"%s\"\n", node->infos[0]); fprintf (fout, "\t\tinfo1:\t\"%s\"\n", node->infos[0]);
if (node->infos[1]) if (node->infos[1])
obstack_fgrow1 (os, "\t\tinfo2:\t\"%s\"\n", node->infos[1]); fprintf (fout, "\t\tinfo2:\t\"%s\"\n", node->infos[1]);
if (node->infos[2]) if (node->infos[2])
obstack_fgrow1 (os, "\t\tinfo3:\t\"%s\"\n", node->infos[2]); fprintf (fout, "\t\tinfo3:\t\"%s\"\n", node->infos[2]);
} }
void void
output_edge (edge_t *edge, struct obstack *os) output_edge (edge_t *edge, FILE *fout)
{ {
/* FIXME: SOURCENAME and TARGETNAME are mandatory /* FIXME: SOURCENAME and TARGETNAME are mandatory
so it has to be fatal not to give these informations. */ so it has to be fatal not to give these informations. */
if (edge->sourcename != E_SOURCENAME) if (edge->sourcename != E_SOURCENAME)
obstack_fgrow1 (os, "\t\tsourcename:\t\"%s\"\n", edge->sourcename); fprintf (fout, "\t\tsourcename:\t\"%s\"\n", edge->sourcename);
if (edge->targetname != E_TARGETNAME) if (edge->targetname != E_TARGETNAME)
obstack_fgrow1 (os, "\t\ttargetname:\t\"%s\"\n", edge->targetname); fprintf (fout, "\t\ttargetname:\t\"%s\"\n", edge->targetname);
if (edge->label != E_LABEL) if (edge->label != E_LABEL)
obstack_fgrow1 (os, "\t\tlabel:\t\"%s\"\n", edge->label); fprintf (fout, "\t\tlabel:\t\"%s\"\n", edge->label);
if (edge->linestyle != E_LINESTYLE) if (edge->linestyle != E_LINESTYLE)
obstack_fgrow1 (os, "\t\tlinestyle:\t\"%s\"\n", fprintf (fout, "\t\tlinestyle:\t\"%s\"\n",
get_linestyle_str(edge->linestyle)); get_linestyle_str(edge->linestyle));
if (edge->thickness != E_THICKNESS) if (edge->thickness != E_THICKNESS)
obstack_fgrow1 (os, "\t\tthickness:\t%d\n", edge->thickness); fprintf (fout, "\t\tthickness:\t%d\n", edge->thickness);
if (edge->class != E_CLASS) if (edge->class != E_CLASS)
obstack_fgrow1 (os, "\t\tclass:\t%d\n", edge->class); fprintf (fout, "\t\tclass:\t%d\n", edge->class);
if (edge->color != E_COLOR) if (edge->color != E_COLOR)
obstack_fgrow1 (os, "\t\tcolor:\t%s\n", get_color_str (edge->color)); fprintf (fout, "\t\tcolor:\t%s\n", get_color_str (edge->color));
if (edge->color != E_TEXTCOLOR) if (edge->color != E_TEXTCOLOR)
obstack_fgrow1 (os, "\t\ttextcolor:\t%s\n", fprintf (fout, "\t\ttextcolor:\t%s\n",
get_color_str (edge->textcolor)); get_color_str (edge->textcolor));
if (edge->arrowcolor != E_ARROWCOLOR) if (edge->arrowcolor != E_ARROWCOLOR)
obstack_fgrow1 (os, "\t\tarrowcolor:\t%s\n", fprintf (fout, "\t\tarrowcolor:\t%s\n",
get_color_str (edge->arrowcolor)); get_color_str (edge->arrowcolor));
if (edge->backarrowcolor != E_BACKARROWCOLOR) if (edge->backarrowcolor != E_BACKARROWCOLOR)
obstack_fgrow1 (os, "\t\tbackarrowcolor:\t%s\n", fprintf (fout, "\t\tbackarrowcolor:\t%s\n",
get_color_str (edge->backarrowcolor)); get_color_str (edge->backarrowcolor));
if (edge->arrowsize != E_ARROWSIZE) if (edge->arrowsize != E_ARROWSIZE)
obstack_fgrow1 (os, "\t\tarrowsize:\t%d\n", edge->arrowsize); fprintf (fout, "\t\tarrowsize:\t%d\n", edge->arrowsize);
if (edge->backarrowsize != E_BACKARROWSIZE) if (edge->backarrowsize != E_BACKARROWSIZE)
obstack_fgrow1 (os, "\t\tbackarrowsize:\t%d\n", edge->backarrowsize); fprintf (fout, "\t\tbackarrowsize:\t%d\n", edge->backarrowsize);
if (edge->arrowstyle != E_ARROWSTYLE) if (edge->arrowstyle != E_ARROWSTYLE)
obstack_fgrow1 (os, "\t\tarrowstyle:\t%s\n", fprintf (fout, "\t\tarrowstyle:\t%s\n",
get_arrowstyle_str(edge->arrowstyle)); get_arrowstyle_str(edge->arrowstyle));
if (edge->backarrowstyle != E_BACKARROWSTYLE) if (edge->backarrowstyle != E_BACKARROWSTYLE)
obstack_fgrow1 (os, "\t\tbackarrowstyle:\t%s\n", fprintf (fout, "\t\tbackarrowstyle:\t%s\n",
get_arrowstyle_str(edge->backarrowstyle)); get_arrowstyle_str(edge->backarrowstyle));
if (edge->priority != E_PRIORITY) if (edge->priority != E_PRIORITY)
obstack_fgrow1 (os, "\t\tpriority:\t%d\n", edge->priority); fprintf (fout, "\t\tpriority:\t%d\n", edge->priority);
if (edge->anchor != E_ANCHOR) if (edge->anchor != E_ANCHOR)
obstack_fgrow1 (os, "\t\tanchor:\t%d\n", edge->anchor); fprintf (fout, "\t\tanchor:\t%d\n", edge->anchor);
if (edge->horizontal_order != E_HORIZONTAL_ORDER) if (edge->horizontal_order != E_HORIZONTAL_ORDER)
obstack_fgrow1 (os, "\t\thorizontal_order:\t%d\n", edge->horizontal_order); fprintf (fout, "\t\thorizontal_order:\t%d\n", edge->horizontal_order);
} }
void void
output_graph (graph_t *graph, struct obstack *os) output_graph (graph_t *graph, FILE *fout)
{ {
if (graph->title) if (graph->title)
obstack_fgrow1 (os, "\ttitle:\t\"%s\"\n", graph->title); fprintf (fout, "\ttitle:\t\"%s\"\n", graph->title);
if (graph->label) if (graph->label)
obstack_fgrow1 (os, "\tlabel:\t\"%s\"\n", graph->label); fprintf (fout, "\tlabel:\t\"%s\"\n", graph->label);
if (graph->infos[0]) if (graph->infos[0])
obstack_fgrow1 (os, "\tinfo1:\t\"%s\"\n", graph->infos[0]); fprintf (fout, "\tinfo1:\t\"%s\"\n", graph->infos[0]);
if (graph->infos[1]) if (graph->infos[1])
obstack_fgrow1 (os, "\tinfo2:\t\"%s\"\n", graph->infos[1]); fprintf (fout, "\tinfo2:\t\"%s\"\n", graph->infos[1]);
if (graph->infos[2]) if (graph->infos[2])
obstack_fgrow1 (os, "\tinfo3:\t\"%s\"\n", graph->infos[2]); fprintf (fout, "\tinfo3:\t\"%s\"\n", graph->infos[2]);
if (graph->color != G_COLOR) if (graph->color != G_COLOR)
obstack_fgrow1 (os, "\tcolor:\t%s\n", get_color_str (graph->color)); fprintf (fout, "\tcolor:\t%s\n", get_color_str (graph->color));
if (graph->textcolor != G_TEXTCOLOR) if (graph->textcolor != G_TEXTCOLOR)
obstack_fgrow1 (os, "\ttextcolor:\t%s\n", get_color_str (graph->textcolor)); fprintf (fout, "\ttextcolor:\t%s\n", get_color_str (graph->textcolor));
if (graph->bordercolor != G_BORDERCOLOR) if (graph->bordercolor != G_BORDERCOLOR)
obstack_fgrow1 (os, "\tbordercolor:\t%s\n", fprintf (fout, "\tbordercolor:\t%s\n",
get_color_str (graph->bordercolor)); get_color_str (graph->bordercolor));
if (graph->width != G_WIDTH) if (graph->width != G_WIDTH)
obstack_fgrow1 (os, "\twidth:\t%d\n", graph->width); fprintf (fout, "\twidth:\t%d\n", graph->width);
if (graph->height != G_HEIGHT) if (graph->height != G_HEIGHT)
obstack_fgrow1 (os, "\theight:\t%d\n", graph->height); fprintf (fout, "\theight:\t%d\n", graph->height);
if (graph->borderwidth != G_BORDERWIDTH) if (graph->borderwidth != G_BORDERWIDTH)
obstack_fgrow1 (os, "\tborderwidth:\t%d\n", graph->borderwidth); fprintf (fout, "\tborderwidth:\t%d\n", graph->borderwidth);
if (graph->x != G_X) if (graph->x != G_X)
obstack_fgrow1 (os, "\tx:\t%d\n", graph->x); fprintf (fout, "\tx:\t%d\n", graph->x);
if (graph->y != G_Y) if (graph->y != G_Y)
obstack_fgrow1 (os, "\ty:\t%d\n", graph->y); fprintf (fout, "\ty:\t%d\n", graph->y);
if (graph->folding != G_FOLDING) if (graph->folding != G_FOLDING)
obstack_fgrow1 (os, "\tfolding:\t%d\n", graph->folding); fprintf (fout, "\tfolding:\t%d\n", graph->folding);
if (graph->shrink != G_SHRINK) if (graph->shrink != G_SHRINK)
obstack_fgrow1 (os, "\tshrink:\t%d\n", graph->shrink); fprintf (fout, "\tshrink:\t%d\n", graph->shrink);
if (graph->stretch != G_STRETCH) if (graph->stretch != G_STRETCH)
obstack_fgrow1 (os, "\tstretch:\t%d\n", graph->stretch); fprintf (fout, "\tstretch:\t%d\n", graph->stretch);
if (graph->textmode != G_TEXTMODE) if (graph->textmode != G_TEXTMODE)
obstack_fgrow1 (os, "\ttextmode:\t%s\n", fprintf (fout, "\ttextmode:\t%s\n",
get_textmode_str (graph->textmode)); get_textmode_str (graph->textmode));
if (graph->shape != G_SHAPE) if (graph->shape != G_SHAPE)
obstack_fgrow1 (os, "\tshape:\t%s\n", get_shape_str (graph->shape)); fprintf (fout, "\tshape:\t%s\n", get_shape_str (graph->shape));
if (graph->vertical_order != G_VERTICAL_ORDER)
fprintf (fout, "\tvertical_order:\t%d\n", graph->vertical_order);
if (graph->horizontal_order != G_HORIZONTAL_ORDER)
fprintf (fout, "\thorizontal_order:\t%d\n", graph->horizontal_order);
if (graph->xmax != G_XMAX) if (graph->xmax != G_XMAX)
obstack_fgrow1 (os, "\txmax:\t%d\n", graph->xmax); fprintf (fout, "\txmax:\t%d\n", graph->xmax);
if (graph->ymax != G_YMAX) if (graph->ymax != G_YMAX)
obstack_fgrow1 (os, "\tymax:\t%d\n", graph->ymax); fprintf (fout, "\tymax:\t%d\n", graph->ymax);
if (graph->xbase != G_XBASE) if (graph->xbase != G_XBASE)
obstack_fgrow1 (os, "\txbase:\t%d\n", graph->xbase); fprintf (fout, "\txbase:\t%d\n", graph->xbase);
if (graph->ybase != G_YBASE) if (graph->ybase != G_YBASE)
obstack_fgrow1 (os, "\tybase:\t%d\n", graph->ybase); fprintf (fout, "\tybase:\t%d\n", graph->ybase);
if (graph->xspace != G_XSPACE) if (graph->xspace != G_XSPACE)
obstack_fgrow1 (os, "\txspace:\t%d\n", graph->xspace); fprintf (fout, "\txspace:\t%d\n", graph->xspace);
if (graph->yspace != G_YSPACE) if (graph->yspace != G_YSPACE)
obstack_fgrow1 (os, "\tyspace:\t%d\n", graph->yspace); fprintf (fout, "\tyspace:\t%d\n", graph->yspace);
if (graph->xlspace != G_XLSPACE) if (graph->xlspace != G_XLSPACE)
obstack_fgrow1 (os, "\txlspace:\t%d\n", graph->xlspace); fprintf (fout, "\txlspace:\t%d\n", graph->xlspace);
if (graph->xraster != G_XRASTER) if (graph->xraster != G_XRASTER)
obstack_fgrow1 (os, "\txraster:\t%d\n", graph->xraster); fprintf (fout, "\txraster:\t%d\n", graph->xraster);
if (graph->yraster != G_YRASTER) if (graph->yraster != G_YRASTER)
obstack_fgrow1 (os, "\tyraster:\t%d\n", graph->yraster); fprintf (fout, "\tyraster:\t%d\n", graph->yraster);
if (graph->xlraster != G_XLRASTER) if (graph->xlraster != G_XLRASTER)
obstack_fgrow1 (os, "\txlraster:\t%d\n", graph->xlraster); fprintf (fout, "\txlraster:\t%d\n", graph->xlraster);
if (graph->hidden != G_HIDDEN) if (graph->hidden != G_HIDDEN)
obstack_fgrow1 (os, "\thidden:\t%d\n", graph->hidden); fprintf (fout, "\thidden:\t%d\n", graph->hidden);
/* FIXME: Unallocate struct list if required.
Maybe with a little function. */
if (graph->classname != G_CLASSNAME) if (graph->classname != G_CLASSNAME)
{ {
struct classname_s *ite; struct classname_s *ite;
for (ite = graph->classname; ite; ite = ite->next) for (ite = graph->classname; ite; ite = ite->next)
obstack_fgrow2 (os, "\tclassname %d :\t%s\n", ite->no, ite->name); fprintf (fout, "\tclassname %d :\t%s\n", ite->no, ite->name);
}
if (graph->infoname != G_INFONAME)
{
struct infoname_s *ite;
for (ite = graph->infoname; ite; ite = ite->next)
fprintf (fout, "\tinfoname %d :\t%s\n", ite->integer, ite->string);
}
if (graph->colorentry != G_COLORENTRY)
{
struct colorentry_s *ite;
for (ite = graph->colorentry; ite; ite = ite->next)
{
fprintf (fout, "\tcolorentry %d :\t%d %d %d\n",
ite->color_index,
ite->red_cp,
ite->green_cp,
ite->blue_cp);
}
} }
if (graph->layoutalgorithm != G_LAYOUTALGORITHM) if (graph->layoutalgorithm != G_LAYOUTALGORITHM)
obstack_fgrow1 (os, "\tlayoutalgorithm:\t%s\n", fprintf (fout, "\tlayoutalgorithm:\t%s\n",
get_layoutalgorithm_str(graph->layoutalgorithm)); get_layoutalgorithm_str(graph->layoutalgorithm));
if (graph->layout_downfactor != G_LAYOUT_DOWNFACTOR) if (graph->layout_downfactor != G_LAYOUT_DOWNFACTOR)
obstack_fgrow1 (os, "\tlayout_downfactor:\t%d\n", graph->layout_downfactor); fprintf (fout, "\tlayout_downfactor:\t%d\n", graph->layout_downfactor);
if (graph->layout_upfactor != G_LAYOUT_UPFACTOR) if (graph->layout_upfactor != G_LAYOUT_UPFACTOR)
obstack_fgrow1 (os, "\tlayout_upfactor:\t%d\n", graph->layout_upfactor); fprintf (fout, "\tlayout_upfactor:\t%d\n", graph->layout_upfactor);
if (graph->layout_nearfactor != G_LAYOUT_NEARFACTOR) if (graph->layout_nearfactor != G_LAYOUT_NEARFACTOR)
obstack_fgrow1 (os, "\tlayout_nearfactor:\t%d\n", graph->layout_nearfactor); fprintf (fout, "\tlayout_nearfactor:\t%d\n", graph->layout_nearfactor);
if (graph->layout_splinefactor != G_LAYOUT_SPLINEFACTOR) if (graph->layout_splinefactor != G_LAYOUT_SPLINEFACTOR)
obstack_fgrow1 (os, "\tlayout_splinefactor:\t%d\n", fprintf (fout, "\tlayout_splinefactor:\t%d\n",
graph->layout_splinefactor); graph->layout_splinefactor);
if (graph->late_edge_labels != G_LATE_EDGE_LABELS) if (graph->late_edge_labels != G_LATE_EDGE_LABELS)
obstack_fgrow1 (os, "\tlate_edge_labels:\t%s\n", fprintf (fout, "\tlate_edge_labels:\t%s\n",
get_decision_str(graph->late_edge_labels, get_decision_str(graph->late_edge_labels));
G_LATE_EDGE_LABELS));
if (graph->display_edge_labels != G_DISPLAY_EDGE_LABELS) if (graph->display_edge_labels != G_DISPLAY_EDGE_LABELS)
obstack_fgrow1 (os, "\tdisplay_edge_labels:\t%s\n", fprintf (fout, "\tdisplay_edge_labels:\t%s\n",
get_decision_str(graph->display_edge_labels, get_decision_str(graph->display_edge_labels));
G_DISPLAY_EDGE_LABELS));
if (graph->dirty_edge_labels != G_DIRTY_EDGE_LABELS) if (graph->dirty_edge_labels != G_DIRTY_EDGE_LABELS)
obstack_fgrow1 (os, "\tdirty_edge_labels:\t%s\n", fprintf (fout, "\tdirty_edge_labels:\t%s\n",
get_decision_str(graph->dirty_edge_labels, get_decision_str(graph->dirty_edge_labels));
G_DIRTY_EDGE_LABELS));
if (graph->finetuning != G_FINETUNING) if (graph->finetuning != G_FINETUNING)
obstack_fgrow1 (os, "\tfinetuning:\t%s\n", fprintf (fout, "\tfinetuning:\t%s\n",
get_decision_str(graph->finetuning, G_FINETUNING)); get_decision_str(graph->finetuning));
if (graph->ignore_singles != G_IGNORE_SINGLES) if (graph->ignore_singles != G_IGNORE_SINGLES)
obstack_fgrow1 (os, "\tignore_singles:\t%s\n", fprintf (fout, "\tignore_singles:\t%s\n",
get_decision_str(graph->ignore_singles, G_IGNORE_SINGLES)); get_decision_str(graph->ignore_singles));
if (graph->straight_phase != G_STRAIGHT_PHASE) if (graph->straight_phase != G_STRAIGHT_PHASE)
obstack_fgrow1 (os, "\tstraight_phase:\t%s\n", fprintf (fout, "\tstraight_phase:\t%s\n",
get_decision_str(graph->straight_phase, G_STRAIGHT_PHASE)); get_decision_str(graph->straight_phase));
if (graph->priority_phase != G_PRIORITY_PHASE) if (graph->priority_phase != G_PRIORITY_PHASE)
obstack_fgrow1 (os, "\tpriority_phase:\t%s\n", fprintf (fout, "\tpriority_phase:\t%s\n",
get_decision_str(graph->priority_phase, G_PRIORITY_PHASE)); get_decision_str(graph->priority_phase));
if (graph->manhattan_edges != G_MANHATTAN_EDGES) if (graph->manhattan_edges != G_MANHATTAN_EDGES)
obstack_fgrow1 (os, fprintf (fout,
"\tmanhattan_edges:\t%s\n", "\tmanhattan_edges:\t%s\n",
get_decision_str(graph->manhattan_edges, get_decision_str(graph->manhattan_edges));
G_MANHATTAN_EDGES));
if (graph->smanhattan_edges != G_SMANHATTAN_EDGES) if (graph->smanhattan_edges != G_SMANHATTAN_EDGES)
obstack_fgrow1 (os, fprintf (fout,
"\tsmanhattan_edges:\t%s\n", "\tsmanhattan_edges:\t%s\n",
get_decision_str(graph->smanhattan_edges, get_decision_str(graph->smanhattan_edges));
G_SMANHATTAN_EDGES));
if (graph->near_edges != G_NEAR_EDGES) if (graph->near_edges != G_NEAR_EDGES)
obstack_fgrow1 (os, "\tnear_edges:\t%s\n", fprintf (fout, "\tnear_edges:\t%s\n",
get_decision_str(graph->near_edges, G_NEAR_EDGES)); get_decision_str(graph->near_edges));
if (graph->orientation != G_ORIENTATION) if (graph->orientation != G_ORIENTATION)
obstack_fgrow1 (os, "\torientation:\t%s\n", fprintf (fout, "\torientation:\t%s\n",
get_decision_str(graph->orientation, G_ORIENTATION)); get_orientation_str(graph->orientation));
if (graph->node_alignement != G_NODE_ALIGNEMENT) if (graph->node_alignement != G_NODE_ALIGNEMENT)
obstack_fgrow1 (os, "\tnode_alignement:\t%s\n", fprintf (fout, "\tnode_alignement:\t%s\n",
get_decision_str(graph->node_alignement, get_node_alignement_str(graph->node_alignement));
G_NODE_ALIGNEMENT));
if (graph->port_sharing != G_PORT_SHARING) if (graph->port_sharing != G_PORT_SHARING)
obstack_fgrow1 (os, "\tport_sharing:\t%s\n", fprintf (fout, "\tport_sharing:\t%s\n",
get_decision_str(graph->port_sharing, G_PORT_SHARING)); get_decision_str(graph->port_sharing));
if (graph->arrow_mode != G_ARROW_MODE) if (graph->arrow_mode != G_ARROW_MODE)
obstack_fgrow1 (os, "\tarrow_mode:\t%s\n", fprintf (fout, "\tarrow_mode:\t%s\n",
get_arrow_mode_str(graph->arrow_mode)); get_arrow_mode_str(graph->arrow_mode));
if (graph->treefactor != G_TREEFACTOR) if (graph->treefactor != G_TREEFACTOR)
obstack_fgrow1 (os, "\ttreefactor:\t%f\n", graph->treefactor); fprintf (fout, "\ttreefactor:\t%f\n", graph->treefactor);
if (graph->spreadlevel != G_SPREADLEVEL) if (graph->spreadlevel != G_SPREADLEVEL)
obstack_fgrow1 (os, "\tspreadlevel:\t%d\n", graph->spreadlevel); fprintf (fout, "\tspreadlevel:\t%d\n", graph->spreadlevel);
if (graph->crossing_weight != G_CROSSING_WEIGHT) if (graph->crossing_weight != G_CROSSING_WEIGHT)
obstack_fgrow1 (os, "\tcrossing_weight:\t%s\n", fprintf (fout, "\tcrossing_weight:\t%s\n",
get_crossing_type_str(graph->crossing_weight)); get_crossing_type_str(graph->crossing_weight));
if (graph->crossing_phase2 != G_CROSSING_PHASE2) if (graph->crossing_phase2 != G_CROSSING_PHASE2)
obstack_fgrow1 (os, "\tcrossing_phase2:\t%s\n", fprintf (fout, "\tcrossing_phase2:\t%s\n",
get_decision_str(graph->crossing_phase2, get_decision_str(graph->crossing_phase2));
G_CROSSING_PHASE2));
if (graph->crossing_optimization != G_CROSSING_OPTIMIZATION) if (graph->crossing_optimization != G_CROSSING_OPTIMIZATION)
obstack_fgrow1 (os, "\tcrossing_optimization:\t%s\n", fprintf (fout, "\tcrossing_optimization:\t%s\n",
get_decision_str(graph->crossing_optimization, get_decision_str(graph->crossing_optimization));
G_CROSSING_OPTIMIZATION));
if (graph->view != G_VIEW) if (graph->view != G_VIEW)
obstack_fgrow1 (os, "\tview:\t%s\n", get_view_str(graph->view)); fprintf (fout, "\tview:\t%s\n", get_view_str(graph->view));
if (graph->edges != G_EDGES) if (graph->edges != G_EDGES)
obstack_fgrow1 (os, "\tedges:\t%s\n", get_decision_str(graph->edges, fprintf (fout, "\tedges:\t%s\n", get_decision_str(graph->edges));
G_EDGES));
if (graph->nodes != G_NODES) if (graph->nodes != G_NODES)
obstack_fgrow1 (os,"\tnodes:\t%s\n", fprintf (fout,"\tnodes:\t%s\n", get_decision_str(graph->nodes));
get_decision_str(graph->nodes, G_NODES));
if (graph->splines != G_SPLINES) if (graph->splines != G_SPLINES)
obstack_fgrow1 (os, "\tsplines:\t%s\n", fprintf (fout, "\tsplines:\t%s\n", get_decision_str(graph->splines));
get_decision_str(graph->splines, G_SPLINES));
if (graph->bmax != G_BMAX) if (graph->bmax != G_BMAX)
obstack_fgrow1 (os, "\tbmax:\t%d\n", graph->bmax); fprintf (fout, "\tbmax:\t%d\n", graph->bmax);
if (graph->cmin != G_CMIN) if (graph->cmin != G_CMIN)
obstack_fgrow1 (os, "\tcmin:\t%d\n", graph->cmin); fprintf (fout, "\tcmin:\t%d\n", graph->cmin);
if (graph->cmax != G_CMAX) if (graph->cmax != G_CMAX)
obstack_fgrow1 (os, "\tcmax:\t%d\n", graph->cmax); fprintf (fout, "\tcmax:\t%d\n", graph->cmax);
if (graph->pmin != G_PMIN) if (graph->pmin != G_PMIN)
obstack_fgrow1 (os, "\tpmin:\t%d\n", graph->pmin); fprintf (fout, "\tpmin:\t%d\n", graph->pmin);
if (graph->pmax != G_PMAX) if (graph->pmax != G_PMAX)
obstack_fgrow1 (os, "\tpmax:\t%d\n", graph->pmax); fprintf (fout, "\tpmax:\t%d\n", graph->pmax);
if (graph->rmin != G_RMIN) if (graph->rmin != G_RMIN)
obstack_fgrow1 (os, "\trmin:\t%d\n", graph->rmin); fprintf (fout, "\trmin:\t%d\n", graph->rmin);
if (graph->rmax != G_RMAX) if (graph->rmax != G_RMAX)
obstack_fgrow1 (os, "\trmax:\t%d\n", graph->rmax); fprintf (fout, "\trmax:\t%d\n", graph->rmax);
if (graph->smax != G_SMAX) if (graph->smax != G_SMAX)
obstack_fgrow1 (os, "\tsmax:\t%d\n", graph->smax); fprintf (fout, "\tsmax:\t%d\n", graph->smax);
} }

View File

@@ -75,14 +75,32 @@ enum shape_e
triangle triangle
}; };
/* Structure for colorentries. */
struct colorentry_s
{
int color_index;
int red_cp;
int green_cp;
int blue_cp;
struct colorentry_s *next;
};
/* Structure to construct lists of classnames. */ /* Structure to construct lists of classnames. */
struct classname_s struct classname_s
{ {
int no; /* Class number */ int no; /* Class number */
char *name; /* Name associated to the class no. */ const char *name; /* Name associated to the class no. */
struct classname_s *next; /* next name class association. */ struct classname_s *next; /* next name class association. */
}; };
/* Structure is in infoname. */
struct infoname_s
{
int integer;
const char *string;
struct infoname_s *next;
};
/* Layout Algorithms which can be found in VCG. /* Layout Algorithms which can be found in VCG.
Details about each algoithm can be found below. */ Details about each algoithm can be found below. */
enum layoutalgorithm_e enum layoutalgorithm_e
@@ -161,13 +179,13 @@ struct node_s
{ {
/* Title the unique string identifying the node. This attribute is /* Title the unique string identifying the node. This attribute is
mandatory. */ mandatory. */
char *title; const char *title;
/* Label the text displayed inside the node. If no label is specified /* Label the text displayed inside the node. If no label is specified
then the title of the node will be used. Note that this text may then the title of the node will be used. Note that this text may
contain control characters like NEWLINE that influences the size of contain control characters like NEWLINE that influences the size of
the node. */ the node. */
char *label; const char *label;
/* loc is the location as x, y position relatively to the system of /* loc is the location as x, y position relatively to the system of
coordinates of the graph. Locations are specified in the form coordinates of the graph. Locations are specified in the form
@@ -277,7 +295,7 @@ struct node_s
/* info2, info3 can be selected from the menu. The corresponding text /* info2, info3 can be selected from the menu. The corresponding text
labels can be shown by mouse clicks on nodes. labels can be shown by mouse clicks on nodes.
Default are null strings. */ Default are null strings. */
char *infos[3]; const char *infos[3];
/* Node border color. /* Node border color.
Default is textcolor. */ Default is textcolor. */
@@ -483,19 +501,19 @@ struct graph_s
index 2, green has index 3, etc. index 2, green has index 3, etc.
Default is white for background and white or transparent for summary Default is white for background and white or transparent for summary
nodes. */ nodes. */
unsigned char color; enum color_e color;
/* Textcolor. /* Textcolor.
need explainations ??? need explainations ???
defalut is black for summary nodes. */ defalut is black for summary nodes. */
unsigned char textcolor; enum color_e textcolor;
/* Bordercolor is the color of the summary node's border. Default color /* Bordercolor is the color of the summary node's border. Default color
is the textcolor. width, height are width and height of the is the textcolor. width, height are width and height of the
displayed part of the window of the outermost graph in pixels, or displayed part of the window of the outermost graph in pixels, or
width and height of the summary node of inner subgraphs. width and height of the summary node of inner subgraphs.
Default is the defalut of the textcolor. */ Default is the defalut of the textcolor. */
unsigned char bordercolor; enum color_e bordercolor;
/* Width, height are width and height of the displayed part of the /* Width, height are width and height of the displayed part of the
window of the outermost graph in pixels, or width and height of the window of the outermost graph in pixels, or width and height of the
@@ -559,7 +577,22 @@ struct graph_s
Defalut is box, other: rhomb, ellipse, triangle. */ Defalut is box, other: rhomb, ellipse, triangle. */
enum shape_e shape; enum shape_e shape;
/* FIXME {vertival,horizontal}_order */ /* Vertical order is the level position (rank) of the summary node of an
inner subgraph, if this subgraph is folded. We can also specify
level: int. The level is only recognized, if an automatical layout is
calculated. */
int vertical_order;
/* Horizontal order is the horizontal position of the summary node within
a level. The nodes which are specified with horizontal positions are
ordered according to these positions within the levels. The nodes which
do not have this attribute are inserted into this ordering by the
crossing reduction mechanism. Note that connected components are
handled separately, thus it is not possible to intermix such components
by specifying a horizontal order. If the algorithm for downward laid
out trees is used, the horizontal order influences only the order of
the child nodes at a node, but not the order of the whole level. */
int horizontal_order;
/* xmax, ymax specify the maximal size of the virtual window that is /* xmax, ymax specify the maximal size of the virtual window that is
used to display the graph. This is usually larger than the displayed used to display the graph. This is usually larger than the displayed
@@ -630,8 +663,19 @@ struct graph_s
By default, no class names. */ By default, no class names. */
struct classname_s *classname; struct classname_s *classname;
/* FIXME : infoname. */ /* Infoname allows to introduce names for the additional text labels.
/* FIXME : colorentry. */ The names are used in the menus.
Infoname is given by an integer and a string.
The default value is NULL. */
struct infoname_s *infoname;
/* Colorentry allows to fill the color map. A color is a triplet of integer
values for the red/green/blue-part. Each integer is between 0 (off) and
255 (on), e.g., 0 0 0 is black and 255 255 255 is white. For instance
colorentry 75 : 70 130 180 sets the map entry 75 to steel blue. This
color can be used by specifying just the number 75.
Default id NULL. */
struct colorentry_s *colorentry;
/* layoutalgorithm chooses different graph layout algorithms /* layoutalgorithm chooses different graph layout algorithms
Possibilities are maxdepth, mindepth, maxdepthslow, mindepthslow, Possibilities are maxdepth, mindepth, maxdepthslow, mindepthslow,
@@ -955,16 +999,21 @@ void new_edge PARAMS ((edge_t *edge));
void add_node PARAMS ((graph_t *graph, node_t *node)); void add_node PARAMS ((graph_t *graph, node_t *node));
void add_edge PARAMS ((graph_t *graph, edge_t *edge)); void add_edge PARAMS ((graph_t *graph, edge_t *edge));
void open_node PARAMS ((struct obstack *os)); void add_colorentry PARAMS ((graph_t *g, int color_idx, int red_cp,
void output_node PARAMS ((node_t *node, struct obstack *os)); int green_cp, int blue_cp));
void close_node PARAMS ((struct obstack *os)); void add_classname PARAMS ((graph_t *g, int val, const char *name));
void add_infoname PARAMS ((graph_t *g, int val, const char *name));
void open_edge PARAMS ((edge_t *edge, struct obstack *os)); void open_node PARAMS ((FILE *fout));
void output_edge PARAMS ((edge_t *edge, struct obstack *os)); void output_node PARAMS ((node_t *node, FILE *fout));
void close_edge PARAMS ((struct obstack *os)); void close_node PARAMS ((FILE *fout));
void open_graph PARAMS ((struct obstack *os)); void open_edge PARAMS ((edge_t *edge, FILE *fout));
void output_graph PARAMS ((graph_t *graph, struct obstack *os)); void output_edge PARAMS ((edge_t *edge, FILE *fout));
void close_graph PARAMS ((graph_t *graph, struct obstack *os)); void close_edge PARAMS ((FILE *fout));
void open_graph PARAMS ((FILE *fout));
void output_graph PARAMS ((graph_t *graph, FILE *fout));
void close_graph PARAMS ((graph_t *graph, FILE *fout));
#endif /* VCG_H_ */ #endif /* VCG_H_ */

View File

@@ -47,8 +47,11 @@
# define G_TEXTMODE centered # define G_TEXTMODE centered
# define G_SHAPE box # define G_SHAPE box
# define G_XMAX 90 /* Not output */ # define G_VERTICAL_ORDER 0 /* Unspecified for subgraphs. */
# define G_YMAX 90 /* Not output */ # define G_HORIZONTAL_ORDER 0 /* Unspecified for subgraphs. */
# define G_XMAX 90 /* Not output */
# define G_YMAX 90 /* Not output */
# define G_XBASE 5 # define G_XBASE 5
# define G_YBASE 5 # define G_YBASE 5
@@ -61,9 +64,12 @@
# define G_YRASTER 1 # define G_YRASTER 1
# define G_XLRASTER 1 # define G_XLRASTER 1
# define G_HIDDEN -1 /* No default value. */ # define G_HIDDEN -1 /* No default value. */
# define G_CLASSNAME NULL /* No class name association */
# define G_INFONAME NULL
# define G_COLORENTRY NULL
# define G_CLASSNAME NULL /* No class name association */
# define G_LAYOUTALGORITHM normal # define G_LAYOUTALGORITHM normal
# define G_LAYOUT_DOWNFACTOR 1 # define G_LAYOUT_DOWNFACTOR 1
# define G_LAYOUT_UPFACTOR 1 # define G_LAYOUT_UPFACTOR 1

View File

@@ -1,7 +1,6 @@
Makefile Makefile
Makefile.in Makefile.in
at-* at-*
debug-*
atconfig atconfig
empty empty
experr experr
@@ -9,7 +8,12 @@ expout
stderr stderr
stdout stdout
testsuite testsuite
testsuite.[0-9]
testsuite.[0-9][0-9]
package.m4
calc.[chy] calc.[chy]
calc.tab.* calc.tab.*
calc calc
*.output *.vcg *.output *.vcg
autom4te.cache
bison

View File

@@ -18,23 +18,34 @@
## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA ## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
## 02111-1307, USA. ## 02111-1307, USA.
# Distribute the testsuite since GNU M4 is needed to build it. EXTRA_DIST = atlocal.in $(TESTSUITE_AT) testsuite
noinst_SCRIPTS = testsuite
SUITE = calc.at regression.at DISTCLEANFILES = atconfig atlocal bison package.m4
MAINTAINERCLEANFILES = Makefile.in $(TESTSUITE)
EXTRA_DIST = atgeneral.m4 suite.at $(SUITE) $(noinst_SCRIPTS) TESTSUITE_AT = \
testsuite.at \
output.at calc.at regression.at
TESTSUITE = $(srcdir)/testsuite
check-local: atconfig $(srcdir)/testsuite AUTOM4TE = autom4te
$(SHELL) $(srcdir)/testsuite AUTOTEST = $(AUTOM4TE) --language=autotest
$(srcdir)/$(TESTSUITE): $(TESTSUITE_AT)
$(AUTOTEST) -I $(srcdir) testsuite.at -o $@.tmp
mv $@.tmp $@
testsuite: atgeneral.m4 suite.at $(SUITE) atconfig: $(top_builddir)/config.status
$(M4) -I $(srcdir) atgeneral.m4 suite.at | \ cd $(top_builddir) && ./config.status tests/$@
sed -e 's/[ ]*$$//' | \
sed -e '/^$$/N;/\n$$/D' > $@-tmp
chmod +x $@-tmp
mv $@-tmp $@
CLEANFILES = debug-*.sh empty atlocal: $(srcdir)/atlocal.in $(top_builddir)/config.status
DISTCLEANFILES = atconfig cd $(top_builddir) && ./config.status tests/$@
MAINTAINERCLEANFILES = testsuite
clean-local:
$(SHELL) $(TESTSUITE) --clean
check-local: atconfig atlocal $(TESTSUITE)
$(SHELL) $(TESTSUITE)
# Run the test suite on the *installed* tree.
installcheck-local:
$(SHELL) $(TESTSUITE) AUTOTEST_PATH=$(exec_prefix)/bin

View File

@@ -1,97 +0,0 @@
# @configure_input@ -*- shell-script -*-
# Configurable variable values for building test suites.
# Copyright (C) 2000, 2001 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
# This script is part of Autotest. Unlimited permission to copy,
# distribute and modify the testing scripts that are the output of
# that Autotest script is given. You need not follow the terms of the
# GNU General Public License when using or distributing such scripts,
# even though portions of the text of Autotest appear in them. The
# GNU General Public License (GPL) does govern all other use of the
# material that constitutes the Autotest.
#
# Certain portions of the Autotest source text are designed to be
# copied (in certain cases, depending on the input) into the output of
# Autotest. We call these the "data" portions. The rest of the
# Autotest source text consists of comments plus executable code that
# decides which of the data portions to output in any given case. We
# call these comments and executable code the "non-data" portions.
# Autotest never copies any of the non-data portions into its output.
#
# This special exception to the GPL applies to versions of Autotest
# released by the Free Software Foundation. When you make and
# distribute a modified version of Autotest, you may extend this
# special exception to the GPL to apply to your modified version as
# well, *unless* your modified version has the potential to copy into
# its output some of the text that was the non-data portion of the
# version that you started with. (In other words, unless your change
# moves or copies text from the non-data portions to the data
# portions.) If your modification has such potential, you must delete
# any notice of this special exception to the GPL from your modified
# version.
# Snippet (1
# This debugging script has been automatically generated from `make check'.
# Call it with `--help' to get a quick usage summary.
at_package='@PACKAGE@'
at_version='@VERSION@'
# Snippet )1
# Snippet (2
at_n='@ECHO_N@'
at_c='@ECHO_C@'
test -f atlocal && . ./atlocal
# LC_MESSAGES is always shadowed by LC_ALL. Here are the only cases:
# - GNU: LANGUAGE -> LC_ALL -> LC_MESSAGES -> LANG
# - POSIX: LC_ALL -> LC_MESSAGES -> LANG
# - XPG4: LC_ALL -> LANG
# - SysV/XPG2: LANG
export LANGUAGE; LANGUAGE=C
export LANG; LANG=C
export LC_ALL; LC_ALL=C
srcdir=@srcdir@
top_srcdir=@top_srcdir@
# Use absolute file notations, as the test might change directories.
at_srcdir=`cd @srcdir@ && pwd`
at_top_srcdir=`cd @top_srcdir@ && pwd`
at_builddir=`pwd`
at_top_builddir=`cd .. && pwd`
if test -n "@AT_TESTPATH@"; then
export PATH; PATH=`pwd`:`cd @AT_TESTPATH@ && pwd`:$PATH
else
export PATH; PATH=`pwd`:$PATH
fi
# We need GNU M4.
M4='@M4@'
# We need a C compiler.
CC='@CC@'
CFLAGS='@CFLAGS@'
# We need `config.h'.
CPPFLAGS="-I$at_top_builddir @CPPFLAGS@"
# We want to use the files shipped with Bison.
BISON_SIMPLE=$at_top_srcdir/src/bison.simple
export BISON_SIMPLE
BISON_HAIRY=$at_top_srcdir/src/bison.hairy
export BISON_HAIRY
# Snippet )2

View File

@@ -1,420 +0,0 @@
divert(-1) -*- Autoconf -*-
# `m4' macros used in building test suites.
# Copyright (C) 2000 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
# This script is part of Autotest. Unlimited permission to copy,
# distribute and modify the testing scripts that are the output of
# that Autotest script is given. You need not follow the terms of the
# GNU General Public License when using or distributing such scripts,
# even though portions of the text of Autotest appear in them. The
# GNU General Public License (GPL) does govern all other use of the
# material that constitutes the Autotest.
#
# Certain portions of the Autotest source text are designed to be
# copied (in certain cases, depending on the input) into the output of
# Autotest. We call these the "data" portions. The rest of the
# Autotest source text consists of comments plus executable code that
# decides which of the data portions to output in any given case. We
# call these comments and executable code the "non-data" portions.
# Autotest never copies any of the non-data portions into its output.
#
# This special exception to the GPL applies to versions of Autotest
# released by the Free Software Foundation. When you make and
# distribute a modified version of Autotest, you may extend this
# special exception to the GPL to apply to your modified version as
# well, *unless* your modified version has the potential to copy into
# its output some of the text that was the non-data portion of the
# version that you started with. (In other words, unless your change
# moves or copies text from the non-data portions to the data
# portions.) If your modification has such potential, you must delete
# any notice of this special exception to the GPL from your modified
# version.
changequote()
changequote([, ])
define([AT_DEFINE], defn([define]))
define([AT_EVAL], defn([eval]))
define([AT_FORMAT], defn([format]))
define([AT_INCLUDE], defn([include]))
define([AT_SHIFT], defn([shift]))
define([AT_UNDEFINE], defn([undefine]))
undefine([define])
undefine([eval])
undefine([format])
undefine([include])
undefine([shift])
undefine([undefine])
# AT_CASE(SWITCH, VAL1, IF-VAL1, VAL2, IF-VAL2, ..., DEFAULT)
# -----------------------------------------------------------
# m4 equivalent of
# switch (SWITCH)
# {
# case VAL1:
# IF-VAL1;
# break;
# case VAL2:
# IF-VAL2;
# break;
# ...
# default:
# DEFAULT;
# break;
# }.
# All the values are optional, and the macro is robust to active
# symbols properly quoted.
AT_DEFINE([AT_CASE],
[ifelse([$#], 0, [],
[$#], 1, [],
[$#], 2, [$2],
[$1], [$2], [$3],
[AT_CASE([$1], AT_SHIFT(AT_SHIFT(AT_SHIFT($@))))])])
# Use of diversions:
# 0 - overall initialization; for each test group: skipping and cleanups;
# 1 - for each test group: proper code, to reinsert between cleanups;
# 2 - overall wrap up: generation of debugging scripts and statistics.
# AT_LINE
# -------
# Return the current file sans directory, a colon, and the current line.
AT_DEFINE([AT_LINE],
[patsubst(__file__, ^.*/\(.*\), \1):__line__])
# AT_INIT(PROGRAM)
# ----------------
# Begin testing suite, using PROGRAM to check version. The search path
# should be already preset so the proper executable will be selected.
AT_DEFINE([AT_INIT],
[AT_DEFINE(AT_ordinal, 0)
. ./atconfig
# Snippet (3
# -e sets to true
at_stop_on_error=false;
# Shall we save and check stdout and stderr?
# -n sets to false
at_check_stds=:;
# Shall we
# -s sets to false, and -v to true
at_verbose=false
at_usage="Usage: $[0] [OPTION]...
-e Abort the full suite and inhibit normal clean up if a test fails
-n Do not redirect stdout and stderr and do not test their contents
-s Inhibit verbosity while generating or executing debugging scripts
-v Force more detailed output, default for debugging scripts unless -s
-x Have the shell to trace command execution; also implies option -n"
# Snippet )3
# Snippet (4
while test $[#] -gt 0; do
case "$[1]" in
--help) echo "$at_usage"; exit 0 ;;
--version) echo "$[0] ($at_package) $at_version"; exit 0 ;;
-e) at_stop_on_error=:;;
-n) at_check_stds=false;;
-s) at_verbose=false; at_silent=1;;
-v) at_verbose=:; at_silent=;;
-x) at_traceon='set -vx'; at_traceoff='set +vx'; at_check_stds=false;;
*) echo 1>&2 "Try \`$[0] --help' for more information."; exit 1 ;;
esac
shift
done
# To check whether a test succeeded or not, we compare an expected
# output with a reference. In the testing suite, we just need `cmp'
# but in debugging scripts, we want more information, so we prefer
# `diff -u'. Nonetheless we will use `diff' only, because in DOS
# environments, `diff' considers that two files are equal included
# when there are only differences on the coding of new lines. `cmp'
# does not.
#
# Finally, not all the `diff' support `-u', and some, like Tru64, even
# refuse to `diff' /dev/null.
: >empty
if diff -u empty empty >/dev/null 2>&1; then
at_diff='diff -u'
else
at_diff='diff'
fi
# Each generated debugging script, containing a single test group, cleans
# up files at the beginning only, not at the end. This is so we can repeat
# the script many times and browse left over files. To cope with such left
# over files, the full test suite cleans up both before and after test groups.
# Snippet )4
if $1 --version | grep "$at_package.*$at_version" >/dev/null; then
at_banner="Testing suite for $at_package, version $at_version"
at_dashes=`echo $at_banner | sed s/./=/g`
echo "$at_dashes"
echo "$at_banner"
echo "$at_dashes"
else
echo '======================================================='
echo 'ERROR: Not using the proper version, no tests performed'
echo '======================================================='
exit 1
fi
# Remove any debugging script resulting from a previous run.
rm -f debug-*.sh
at_failed_list=
at_ignore_count=0
divert(2)[]dnl
# Wrap up the testing suite with summary statistics.
rm -f at-check-line at-setup-line
at_fail_count=0
if test -z "$at_failed_list"; then
if test "$at_ignore_count" = 0; then
at_banner="All $at_test_count tests were successful"
else
at_banner="All $at_test_count tests were successful ($at_ignore_count ignored)"
fi
else
echo
echo $at_n "Writing \`debug-NN.sh' scripts, NN =$at_c"
for at_group in $at_failed_list; do
echo $at_n " $at_group$at_c"
( echo '#!/bin/sh'
sed -n '/^[#] Snippet (1/,/^[#] Snippet )1/p' atconfig
sed -n '/^[#] Snippet (2/,/^[#] Snippet )2/p' atconfig
sed -n "/^[#] Snippet (3/,/^[#] Snippet )3/p" $[0]
test -z "$at_silent" && echo 'at_verbose=:'
sed -n "/^[#] Snippet (4/,/^[#] Snippet )4/p" $[0]
sed -n "/^[#] Snippet (c$at_group(/,/^[#] Snippet )c$at_group)/p" $[0]
at_desc=`sed -n \
'/^[#] Snippet (d'$at_group'(/,/^[#] Snippet )d'$at_group')/p' $[0] \
| sed -n '2s/^[#] //p'`
echo 'if $at_verbose; then'
echo ' at_banner="$[0]: '$at_desc'"'
echo ' at_dashes=`echo $at_banner | sed s/./=/g`'
echo ' echo'
echo ' echo "$at_dashes"'
echo ' echo "$at_banner"'
echo ' echo "$at_dashes"'
echo 'fi'
echo
sed -n "/^[#] Snippet (d$at_group(/,/^[#] Snippet )d$at_group)/p" $[0]
sed -n "/^[#] Snippet (s$at_group(/,/^[#] Snippet )s$at_group)/p" $[0]
echo 'exit 0'
) | grep -v '^[#] Snippet' > debug-$at_group.sh
chmod +x debug-$at_group.sh
at_fail_count=`expr $at_fail_count + 1`
done
echo ', done'
if $at_stop_on_error; then
at_banner='ERROR: One of the tests failed, inhibiting subsequent tests'
else
at_banner="ERROR: Suite unsuccessful, $at_fail_count of $at_test_count tests failed"
fi
fi
at_dashes=`echo $at_banner | sed s/./=/g`
echo
echo "$at_dashes"
echo "$at_banner"
echo "$at_dashes"
if test -n "$at_failed_list"; then
if test -z "$at_silent"; then
echo
echo 'When reporting failed tests to maintainers, do not merely list test'
echo 'numbers, as the numbering changes between releases and pretests.'
echo 'Be careful to give at least all the information you got about them.'
echo 'You may investigate any problem if you feel able to do so, in which'
echo 'case the generated debugging scripts provide good starting points.'
echo "Go on and modify them at will. \`./debug-NN --help' gives usage"
echo 'information. Now, failed tests will be executed again, verbosely.'
for at_group in $at_failed_list; do
./debug-$at_group.sh
done
fi
exit 1
fi
exit 0
divert[]dnl
])# AT_INIT
# AT_SETUP(DESCRIPTION)
# ---------------------
# Start a group of related tests, all to be executed in the same subshell.
# The group is testing what DESCRIPTION says.
AT_DEFINE([AT_SETUP],
[AT_DEFINE([AT_ordinal], AT_EVAL(AT_ordinal + 1))
pushdef([AT_group_description], [$1])
pushdef([AT_data_files], )
pushdef([AT_data_expout], )
pushdef([AT_data_experr], )
if $at_stop_on_error && test -n "$at_failed_list"; then :; else
divert(1)[]dnl
echo AT_LINE > at-check-line
echo AT_LINE > at-setup-line
if $at_verbose; then
echo 'testing AT_group_description'
echo $at_n " $at_c"
fi
if $at_verbose; then
echo "AT_ordinal. $srcdir/AT_LINE..."
else
echo $at_n "substr(AT_ordinal. $srcdir/AT_LINE , 0, 30)[]$at_c"
fi
if test -z "$at_skip_mode"; then
(
[#] Snippet (d[]AT_ordinal[](
[#] Testing AT_group_description
[#] Snippet )d[]AT_ordinal[])
[#] Snippet (s[]AT_ordinal[](
[#] starting from `AT_LINE'.
$at_traceon
])
# AT_CLEANUP(FILES)
# -----------------
# Complete a group of related tests, recursively remove those FILES
# created within the test. There is no need to list stdout, stderr,
# nor files created with AT_DATA.
AT_DEFINE([AT_CLEANUP],
$at_traceoff
[[#] Snippet )s[]AT_ordinal[])
)
at_status=$?
$at_verbose &&
echo $at_n " AT_ordinal. $srcdir/`cat at-setup-line`: $at_c"
case $at_status in
0) echo ok
;;
77) echo "ignored near \``cat at-check-line`'"
at_ignore_count=`expr $at_ignore_count + 1`
;;
*) echo "FAILED near \``cat at-check-line`'"
at_failed_list="$at_failed_list AT_ordinal"
;;
esac
else
echo 'ignored (skipped)'
at_ignore_count=`expr $at_ignore_count + 1`
fi
at_test_count=AT_ordinal
if $at_stop_on_error && test -n "$at_failed_list"; then :; else
divert(0)[]dnl
[#] Snippet (c[]AT_ordinal[](
rm ifelse([AT_data_files$1], , [-f], [-rf[]AT_data_files[]ifelse($1, , , [ $1])]) stdout stderr[]AT_data_expout[]AT_data_experr
[#] Snippet )c[]AT_ordinal[])
undivert(1)[]dnl
rm ifelse([AT_data_files$1], , [-f], [-rf[]AT_data_files[]ifelse($1, , , [ $1])]) stdout stderr[]AT_data_expout[]AT_data_experr
fi
fi
popdef([AT_data_experr])
popdef([AT_data_expout])
popdef([AT_data_files])
popdef([AT_group_description])[]dnl
])# AT_CLEANUP
# AT_DATA(FILE, CONTENTS)
# -----------------------
# Initialize an input data FILE with given CONTENTS, which should end with
# an end of line.
# This macro is not robust to active symbols in CONTENTS *on purpose*.
# If you don't want CONTENT to be evaluated, quote it twice.
AT_DEFINE([AT_DATA],
[AT_DEFINE([AT_data_files], AT_data_files[ ]$1)
cat >$1 <<'_ATEOF'
$2[]_ATEOF
])
# AT_CHECK(COMMANDS, [STATUS], STDOUT, STDERR)
# --------------------------------------------
# Execute a test by performing given shell COMMANDS. These commands
# should normally exit with STATUS, while producing expected STDOUT and
# STDERR contents. The special word `expout' for STDOUT means that file
# `expout' contents has been set to the expected stdout. The special word
# `experr' for STDERR means that file `experr' contents has been set to
# the expected stderr.
# STATUS is not checked if it is empty.
# STDOUT and STDERR can be the special value `ignore', in which case
# their content is not checked.
AT_DEFINE([AT_CHECK],
[$at_traceoff
$at_verbose && echo "$srcdir/AT_LINE: patsubst([$1], [\([\"`$]\)], \\\1)"
echo AT_LINE > at-check-line
$at_check_stds && exec 5>&1 6>&2 1>stdout 2>stderr
$at_traceon
$1
ifelse([$2], [], [],
[at_status=$?
if test $at_status != $2; then
$at_verbose && echo "Exit code was $at_status, expected $2" >&6
dnl Maybe there was an important message to read before it died.
$at_verbose && $at_check_stds && cat stderr >&6
dnl Preserve exit code 77.
test $at_status = 77 && exit 77
exit 1
fi
])dnl
$at_traceoff
if $at_check_stds; then
dnl Restore stdout to fd1 and stderr to fd2.
exec 1>&5 2>&6
dnl If not verbose, neutralize the output of diff.
$at_verbose || exec 1>/dev/null 2>/dev/null
at_failed=false;
AT_CASE([$4],
ignore, [$at_verbose && cat stderr;:],
experr, [AT_DEFINE([AT_data_experr], [ experr])dnl
$at_diff experr stderr || at_failed=:],
[], [$at_diff empty stderr || at_failed=:],
[echo $at_n "patsubst([$4], [\([\"`$]\)], \\\1)$at_c" | $at_diff - stderr || at_failed=:])
AT_CASE([$3],
ignore, [$at_verbose && cat stdout;:],
expout, [AT_DEFINE([AT_data_expout], [ expout])dnl
$at_diff expout stdout || at_failed=:],
[], [$at_diff empty stdout || at_failed=:],
[echo $at_n "patsubst([$3], [\([\"`$]\)], \\\1)$at_c" | $at_diff - stdout || at_failed=:])
if $at_failed; then
exit 1
else
:
fi
fi
$at_traceon
])# AT_CHECK
divert(0)dnl

10
tests/atlocal.in Normal file
View File

@@ -0,0 +1,10 @@
# @configure_input@ -*- shell-script -*-
# Configurable variable values for Bison test suite.
# Copyright 2000, 2001 Free Software Foundation, Inc.
# We need a C compiler.
CC='@CC@'
CFLAGS='@CFLAGS@'
# We need `config.h'.
CPPFLAGS="-I $top_builddir @CPPFLAGS@"

11
tests/bison.in Normal file
View File

@@ -0,0 +1,11 @@
#! /bin/sh
# @configure_generated@
# Wrapper around a non installed bison to make it work as an installed one.
# We want to use the files shipped with Bison.
BISON_SIMPLE='@top_srcpath@/src/bison.simple'
export BISON_SIMPLE
BISON_HAIRY='@top_srcpath@/src/bison.hairy'
export BISON_HAIRY
exec '@top_buildpath@/src/bison' ${1+"$@"}

View File

@@ -1,11 +1,22 @@
# -*- Autoconf -*- # Checking the output filenames. -*- Autotest -*-
# Copyright 2000, 2001 Free Software Foundation, Inc.
cat <<EOF # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
Simple Calculator. # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
EOF # You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
AT_BANNER([[Simple Calculator.]])
## ---------------------------------------------------- ## ## ---------------------------------------------------- ##
## Compile the grammar described in the documentation. ## ## Compile the grammar described in the documentation. ##
@@ -23,16 +34,16 @@ EOF
# some occurrences of `$1' etc. which will be interpreted by m4. So # some occurrences of `$1' etc. which will be interpreted by m4. So
# you should call it with $1, $2, and $3 as arguments, which is what # you should call it with $1, $2, and $3 as arguments, which is what
# AT_DATA_CALC_Y does. # AT_DATA_CALC_Y does.
AT_DEFINE([_AT_DATA_CALC_Y], m4_define([_AT_DATA_CALC_Y],
[ifelse([$1$2$3], [m4_if([$1$2$3], $[1]$[2]$[3], [],
$[1]$[2]$[3], [], [m4_fatal([$0: Invalid arguments: $@])])dnl
[errprint([$0: Invalid arguments: $@
])m4exit(1)])dnl
AT_DATA([calc.y], AT_DATA([calc.y],
[[/* Infix notation calculator--calc */ [[/* Infix notation calculator--calc */
%{ %{
#include <config.h> #include <config.h>
/* We don't need a perfect malloc for these tests. */
#undef malloc
#include <stdio.h> #include <stdio.h>
#if STDC_HEADERS #if STDC_HEADERS
@@ -211,14 +222,16 @@ power (int base, int exponent)
} }
int int
main (int argn, const char **argv) main (int argc, const char **argv)
{ {
if (argn == 2) yyin = NULL;
if (argc == 2)
yyin = fopen (argv[1], "r"); yyin = fopen (argv[1], "r");
else else
yyin = stdin; yyin = stdin;
if (!stdin) if (!yyin)
{ {
perror (argv[1]); perror (argv[1]);
exit (1); exit (1);
@@ -241,57 +254,83 @@ main (int argn, const char **argv)
# AT_DATA_CALC_Y([BISON-OPTIONS]) # AT_DATA_CALC_Y([BISON-OPTIONS])
# ------------------------------- # -------------------------------
# Produce `calc.y'. # Produce `calc.y'.
AT_DEFINE([AT_DATA_CALC_Y], m4_define([AT_DATA_CALC_Y],
[_AT_DATA_CALC_Y($[1], $[2], $[3], [_AT_DATA_CALC_Y($[1], $[2], $[3],
[ifelse(regexp([$1], [--yyerror-verbose]), [m4_match([$1], [--yyerror-verbose],
[-1], [], [[#define YYERROR_VERBOSE 1]])])])
[[#define YYERROR_VERBOSE 1]])])])
# _AT_CHECK_CALC(BISON-OPTIONS, INPUT) # _AT_CHECK_CALC(BISON-OPTIONS, INPUT, [NUM-STDERR-LINES = 0])
# ------------------------------------ # ------------------------------------------------------------
# Run `calc' on INPUT and expect no STDOUT nor STDERR. # Run `calc' on INPUT and expect no STDOUT nor STDERR.
# If `--debug' is passed to bison, discard all the debugging traces #
# preserving only the `parse errors'. Note that since there should be # If BISON-OPTIONS contains `--debug', then NUM-STDERR-LINES is the number
# none, the `grep' will fail with exit status 1. # of expected lines on stderr.
AT_DEFINE([_AT_CHECK_CALC], m4_define([_AT_CHECK_CALC],
[ifelse(regexp([$1], [--debug]), [AT_DATA([[input]],
[-1], [[$2
[AT_CHECK([echo "$2" | calc], ]])
[0], [], [])], AT_CHECK([calc input], 0, [], [stderr])dnl
[AT_CHECK([echo "$2" | calc 2>&1 >/dev/null | grep 'parse error' >&2], AT_CHECK([wc -l <stderr | sed 's/[[^0-9]]//g'], 0,
[1], [], [])])]) [m4_match([$1], [--debug],
[$3], [0])
])
])
# _AT_CHECK_CALC_ERROR(BISON-OPTIONS, INPUT, # _AT_CHECK_CALC_ERROR(BISON-OPTIONS, INPUT, [NUM-DEBUG-LINES],
# [ERROR-LOCATION], [IF-YYERROR-VERBOSE]) # [ERROR-LOCATION], [IF-YYERROR-VERBOSE])
# ------------------------------------------------------------ # ------------------------------------------------------------
# Run `calc' on INPUT, and expect STDERR. # Run `calc' on INPUT, and expect a `parse error' message.
AT_DEFINE([_AT_CHECK_CALC_ERROR], #
[AT_CHECK([echo "$2" | calc 2>&1 >/dev/null | grep 'parse error' >&2], 0, # If BISON-OPTIONS contains `--location', then make sure the ERROR-LOCATION
[], # is correctly output on stderr.
[ifelse(regexp([$1], [--location]), #
[-1], [], [$3: ])[]dnl # If BISON-OPTIONS contains `--yyerror-verbose', then make sure the
parse error[]dnl # IF-YYERROR-VERBOSE message is properly output after `parse error, '
ifelse(regexp([$1], [--yyerror-verbose]), # on STDERR.
[-1], [], [$4])[]dnl #
# If BISON-OPTIONS contains `--debug', then NUM-STDERR-LINES is the number
# of expected lines on stderr.
m4_define([_AT_CHECK_CALC_ERROR],
[AT_DATA([[input]],
[[$2
]])
])]) AT_CHECK([calc input], 0, [], [stderr])
AT_CHECK([wc -l <stderr | sed 's/[[^0-9]]//g'], 0,
[m4_match([$1], [--debug],
[$3], [1])
])
egrep -v '^((Start|Enter|Read|Reduc|Shift)ing|state|Error:) ' stderr >at-stderr
mv at-stderr stderr
AT_CHECK([cat stderr], 0,
[m4_match([$1], [--location], [$4: ])[]dnl
parse error[]dnl
m4_match([$1], [--yyerror-verbose], [, $5])[]dnl
])
])
# AT_CHECK_CALC([BISON-OPTIONS], [PARSER-EXPECTED-STDERR]) # AT_CHECK_CALC([BISON-OPTIONS], [PARSER-EXPECTED-STDERR])
# -------------------------------------------------------- # --------------------------------------------------------
# Start a testing chunk which compiles `calc' grammar with # Start a testing chunk which compiles `calc' grammar with
# BISON-OPTIONS, and performs several tests over the parser. # BISON-OPTIONS, and performs several tests over the parser.
AT_DEFINE([AT_CHECK_CALC], m4_define([AT_CHECK_CALC],
[# We use integers to avoid dependencies upon the precision of doubles. [# We use integers to avoid dependencies upon the precision of doubles.
AT_SETUP([Calculator $1]) AT_SETUP([Calculator $1])
AT_DATA_CALC_Y([$1]) AT_DATA_CALC_Y([$1])
# Specify the output files to avoid problems on different file systems. # Specify the output files to avoid problems on different file systems.
AT_CHECK([bison calc.y -o calc.c patsubst([$1], [--yyerror-verbose])], AT_CHECK([bison calc.y -o calc.c m4_patsubst([$1], [--yyerror-verbose])],
[0], [], []) [0], [], [])
AT_CHECK([$CC $CFLAGS $CPPFLAGS calc.c -o calc], 0, [], []) AT_CHECK([$CC $CFLAGS $CPPFLAGS calc.c -o calc], 0, [], [])
@@ -309,26 +348,27 @@ _AT_CHECK_CALC([$1],
1 - (2 - 3) = 2 1 - (2 - 3) = 2
2^2^3 = 256 2^2^3 = 256
(2^2)^3 = 64], [$2]) (2^2)^3 = 64], [491])
# Some parse errors. # Some parse errors.
_AT_CHECK_CALC_ERROR([$1], [+1], _AT_CHECK_CALC_ERROR([$1], [+1], [8],
[1.0:1.1], [1.0:1.1],
[, unexpected `'+'']) [unexpected `'+''])
_AT_CHECK_CALC_ERROR([$1], [1//2], _AT_CHECK_CALC_ERROR([$1], [1//2], [17],
[1.2:1.3], [1.2:1.3],
[, unexpected `'/'', expecting `NUM' or `'-'' or `'('']) [unexpected `'/'', expecting `NUM' or `'-'' or `'(''])
_AT_CHECK_CALC_ERROR([$1], [error], _AT_CHECK_CALC_ERROR([$1], [error], [8],
[1.0:1.1], [1.0:1.1],
[, unexpected `$undefined.']) [unexpected `$undefined.'])
_AT_CHECK_CALC_ERROR([$1], [1 = 2 = 3], _AT_CHECK_CALC_ERROR([$1], [1 = 2 = 3], [23],
[1.6:1.7], [1.6:1.7],
[, unexpected `'='']) [unexpected `'=''])
_AT_CHECK_CALC_ERROR([$1], _AT_CHECK_CALC_ERROR([$1],
[ [
+1], +1],
[16],
[2.0:2.1], [2.0:2.1],
[, unexpected `'+'']) [unexpected `'+''])
AT_CLEANUP(calc calc.c calc.h calc.output) AT_CLEANUP(calc calc.c calc.h calc.output)
])# AT_CHECK_CALC ])# AT_CHECK_CALC

70
tests/output.at Normal file
View File

@@ -0,0 +1,70 @@
# Checking the output filenames. -*- Autotest -*-
# Copyright 2000, 2001 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
AT_BANNER([[Output file names.]])
# AT_CHECK_OUTPUT(INPUT-FILE, [DIRECTIVES], [FLAGS], EXPECTED-FILES)
# ------------------------------------------------------------------
m4_define([AT_CHECK_OUTPUT],
[AT_SETUP([Output files: $2 & $3.])
AT_DATA([$1],
[[$2
%%
foo: {}
]])
AT_CHECK([bison $3 $1], 0)
AT_CHECK([ls $4], [], [ignore])
AT_CLEANUP($4)
])
AT_CHECK_OUTPUT([foo.y], [], [-dv],
[foo.output foo.tab.c foo.tab.h])
AT_CHECK_OUTPUT([foo.y], [], [-dv -o foo.c],
[foo.c foo.h foo.output])
AT_CHECK_OUTPUT([foo.y], [], [-dv -o foo.tab.c],
[foo.output foo.tab.c foo.tab.h])
AT_CHECK_OUTPUT([foo.y], [], [-dv -y],
[y.output y.tab.c y.tab.h])
AT_CHECK_OUTPUT([foo.y], [], [-dv -b bar],
[bar.output bar.tab.c bar.tab.h])
AT_CHECK_OUTPUT([foo.y], [], [-dv -g -o foo.c],
[foo.c foo.h foo.output foo.vcg])
AT_CHECK_OUTPUT([foo.y], [%defines %verbose], [],
[foo.output foo.tab.c foo.tab.h])
AT_CHECK_OUTPUT([foo.y], [%defines %verbose %yacc],[],
[y.output y.tab.c y.tab.h])
# Check priorities of extension control.
AT_CHECK_OUTPUT([foo.yy], [%defines %verbose], [],
[foo.output foo.tab.cc foo.tab.hh])
AT_CHECK_OUTPUT([foo.yy], [%defines %verbose ], [-o foo.c],
[foo.c foo.h foo.output])
AT_CHECK_OUTPUT([foo.yy], [],
[--defines=foo.hpp -o foo.c++],
[foo.c++ foo.hpp])
AT_CHECK_OUTPUT([foo.yy], [],
[-o foo.c++ --graph=foo.gph],
[foo.c++ foo.gph])

View File

@@ -1,11 +1,22 @@
# -*- Autoconf -*- # Bison Regressions. -*- Autotest -*-
# Copyright 2001 Free Software Foundation, Inc.
cat <<EOF # This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
Regression tests. # This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
EOF # You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
AT_BANNER([[Regression tests.]])
## ------------------ ## ## ------------------ ##
## Duplicate string. ## ## Duplicate string. ##
@@ -53,3 +64,68 @@ exp: {};
AT_CHECK([bison --defines union.y]) AT_CHECK([bison --defines union.y])
AT_CLEANUP([union.*]) AT_CLEANUP([union.*])
## --------------------------------------- ##
## Duplicate '/' in C comments in %union ##
## --------------------------------------- ##
AT_SETUP([%union and C comments])
AT_DATA([union-comment.y],
[%union
{
/* The int. */ int integer;
/* The string. */ char *string ;
}
%%
exp: {};
])
AT_CHECK([bison union-comment.y])
AT_CHECK([fgrep '//*' union-comment.tab.c], [1], [])
AT_CLEANUP([union-comment.*])
## --------------- ##
## invalid input. ##
## --------------- ##
AT_SETUP([Invalid input])
AT_DATA([input.y],
[[%%
?
]])
AT_CHECK([bison input.y], [1], [],
[input.y:2: invalid input: `?'
input.y:3: fatal error: no rules in the input grammar
])
AT_CLEANUP
## --------------------- ##
## Invalid CPP headers. ##
## --------------------- ##
AT_SETUP([Invalid CPP headers])
mkdir input
AT_DATA([input/input.y],
[%%
dummy:
])
AT_CHECK([bison --defines input/input.y])
AT_CHECK([sed 1q input/input.tab.h], 0,
[[#ifndef INPUT_INPUT_TAB_H
]])
AT_CLEANUP(input)

View File

@@ -1,61 +0,0 @@
#! /bin/sh
# -*- Autoconf -*-
# Validation suite for Bison.
# Copyright 2000 Free Software Foundation, Inc.
AT_INIT([bison])
## ---------------------------- ##
## Checking output file names. ##
## ---------------------------- ##
# AT_CHECK_BISON_FLAGS(FLAGS, EXPECTED-FILES-SORTED)
# --------------------------------------------------
AT_DEFINE([AT_CHECK_BISON_FLAGS],
[AT_SETUP([Output files: $1.])
AT_DATA([foo.y],
[[%%
foo: {}
]])
rm -rf $2
AT_CHECK([bison -dv foo.y $1], 0, ignore, ignore)
AT_CHECK([ls $2 | sort | tr '\n' ' ' | sed 's/.$//g'], 0, [$2])
rm -f $2
AT_CLEANUP
])
AT_CHECK_BISON_FLAGS([], [foo.output foo.tab.c foo.tab.h])
AT_CHECK_BISON_FLAGS([-o foo.c], [foo.c foo.h foo.output])
AT_CHECK_BISON_FLAGS([-o foo.tab.c], [foo.output foo.tab.c foo.tab.h])
AT_CHECK_BISON_FLAGS([-y], [y.output y.tab.c y.tab.h])
AT_CHECK_BISON_FLAGS([-b bar], [bar.output bar.tab.c bar.tab.h])
# AT_CHECK_BISON_PERCENT(GRAMMAR-OPTIONS, EXPECTED-FILES-SORTED)
# --------------------------------------------------------------
AT_DEFINE([AT_CHECK_BISON_PERCENT],
[AT_SETUP([Output files: $1.])
AT_DATA([foo.y],
[[$1
%defines
%verbose
%%
foo: {}
]])
rm -rf $2
AT_CHECK([bison foo.y], 0, ignore, ignore)
AT_CHECK([ls $2 | sort | tr '\n' ' ' | sed 's/.$//g'], 0, [$2])
rm -f $2
AT_CLEANUP
])
# The sames, but using the % directives.
AT_CHECK_BISON_PERCENT([], [foo.output foo.tab.c foo.tab.h])
# AT_CHECK_BISON_PERCENT([%output foo.c], [foo.c foo.h foo.output])
# AT_CHECK_BISON_PERCENT([%output foo.tab.c], [foo.output foo.tab.c foo.tab.h])
AT_CHECK_BISON_PERCENT([%yacc], [y.output y.tab.c y.tab.h])
# AT_CHECK_BISON_PERCENT([%file_prefix bar], [bar.output bar.tab.c bar.tab.h])
AT_INCLUDE([calc.at])
AT_INCLUDE([regression.at])

30
tests/testsuite.at Normal file
View File

@@ -0,0 +1,30 @@
# Process this file with autom4te to create testsuite. -*- Autotest -*-
# Test suite for GNU Bison.
# Copyright 2000, 2001 Free Software Foundation, Inc.
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
# 02111-1307, USA.
# We need a recent Autotest.
m4_version_prereq([2.52e])
AT_INIT
AT_TESTED([bison])
m4_include([output.at])
m4_include([calc.at])
m4_include([regression.at])