config.h
config.log
config.status
-stamp-h
+stamp-h*
bison-*
patches
*.patch *.log log patches applied
*.prj
releases
-*.flc
\ No newline at end of file
+*.flc
+autom4te.cache
+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>
* src/output.c (output_master_parser): Don't finish action_obstack.
2001-09-20 Pascal Bart <pascal.bart@epita.fr>
* src/options.c (symtab.h): Include it, need by lex.h.
-
+
2001-09-20 Pascal Bart <pascal.bart@epita.fr>
* src/lex.c (parse_percent_token): Change type of variable `tx', which
* src/output.c (output): Delete call to reader_output_yylsp.
* src/reader.c (reader): Likewise.
* src/reader.h: Delete declaration of reader_output_yylsp.
-
+
2001-09-02 Marc Autret <autret_m@epita.fr>
* src/reader.c: Include muscle_tab.h.
(read_declarations, copy_action, read_additionnal_code, : Updated
with correct variables and functions names.
(packsymbols, reader): Likewise.
-
+
* src/reader.h (muscle_obstack): Extern declaration update.
-
+
* src/output.c: Include muscle_tab.h
In all functions using macro_insert, change by using muscle_insert ().
(macro_obstack): Rename muscle_obstack.
* src/muscle_tab.h: Update double inclusion macros.
(macro_entry_s): Rename muscle_entry_s.
Update prototypes.
-
+
* src/muscle_tab.c: Include muscle_tab.h.
Rename macro_tabble to muscle_table.
(mhash1, mhash2, mcmp): Use muscle_entry.
2001-09-02 Marc Autret <autret_m@epita.fr>
Now the files macro_tab.[ch] are named muscle_tab.[ch].
-
+
* src/muscle_tab.c, src/muscle_tab.h: Add files.
2001-09-02 Marc Autret <autret_m@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.
2001-09-01 Marc Autret <autret_m@epita.fr>
and insert the `prefix' muscles.
* src/macrotab.c (macro_init): Likewise.
(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,
yylval, yydebug, yyerror, yynerrs and yyparse.
- New directive `#define' to substitute yydebug, ... with option
+ New directive `#define' to substitute yydebug, ... with option
name_prefix.
2001-08-31 Pascal Bart <pascal.bart@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.
* src/output.c (output): Rename %%declarations to %%prologue.
* src/bison.simple: Echo modifications.
-
+
2001-08-31 Marc Autret <autret_m@epita.fr>
* src/reader.c (readgram): CleanUp.
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.
* src/output.h: Remove obsolete functions prototypes of output_headers
and output_trailers.
2001-08-30 Pascal Bart <pascal.bart@epita.fr>
* 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.
* src/macrotab.c (macro_insert): Constify key and value.
(macro_find): Constify key.
2001-08-30 Marc Autret <autret_m@epita.fr>
* 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.c (percent_table): Add skeleton option entry.
Standardize.
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.
* src/bison.simple: Add `%%definitions'.
## 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
# Files to update automatically.
wget_files = $(srcdir)/config/config.guess $(srcdir)/config/config.sub \
$(srcdir)/config/texinfo.tex
+
+cvs_files = $(srcdir)/config/missing
# Do not save the original name or timestamp in the .tar.gz file.
GZIP_ENV = '--no-name --best'
-# Automake 1.4 does not define AMTAR.
-AMTAR ?= $(TAR)
-
CVS = cvs
prev_version_file ?= .prev-version
+## ---------------- ##
+## 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. ##
## --------------- ##
-# Checks that don't require cvs.
-local-check: changelog-check po-check writable-files copyright-check
+# Checks that don't require cvs. Run `changelog-check' last as
+# previous test may reveal problems requiring new ChangeLog entries.
+local-check: po-check copyright-check writable-files changelog-check
changelog-check:
if head ChangeLog | grep 'Version $(VERSION)' >/dev/null; then \
$(MAKE) my-distcheck
+
+## -------------- ##
+## Making dists. ##
+## -------------- ##
+
+
# Tag before making distribution. Also, don't make a distribution if
# checks fail. Also, make sure the NEWS file is up-to-date.
# 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) tag -c $(this-cvs-tag)
$(MAKE) dist
null_AM_MAKEFLAGS = \
ACLOCAL=false \
AUTOCONF=false \
+ AUTOM4TE=false \
AUTOMAKE=false \
AUTOHEADER=false \
MAKEINFO=false
md5_tmp=/tmp/rel-check-md5-$$$$; \
set -e; \
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; \
md5sum -c $$md5_tmp < $$tarz
-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
echo =====================================
echo =====================================
$(xd-delta): $(release_archive_dir)/$(prev-tgz) $(distdir).tar.gz
xdelta delta -9 $^ $@ || :
-alpha: local-check
+alpha:
$(MAKE) cvs-dist
$(MAKE) $(xd-delta)
$(MAKE) -s announcement > /tmp/announce-$(my_distdir)
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.
Bison was originally written by Robert Corbett. It would not be what
it is today without the invaluable help of these people:
-Akim Demaille akim@epita.fr
-Daniel Hagerty hag@gnu.org
-David J. MacKenzie djm@gnu.org
-Fabrice Bauzac noon@cote-dazur.com
-Hans Aberg haberg@matematik.su.se
-Jesse Thilo jthilo@gnu.org
-Jim Meyering meyering@gnu.org
-Laurent Mascherpa laurent.mascherpa@epita.fr
+Akim Demaille akim@epita.fr
+Albert Chin-A-Young china@thewrittenword.com
+Alexander Belopolsky alexb@rentec.com
+Daniel Hagerty hag@gnu.org
+David J. MacKenzie djm@gnu.org
+Fabrice Bauzac noon@cote-dazur.com
+Hans Aberg haberg@matematik.su.se
+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
-Neil Booth NeilB@earthling.net
-Noah Friedman friedman@gnu.org
+Neil Booth NeilB@earthling.net
+Noah Friedman friedman@gnu.org
Pascal Bart pascal.bart@epita.fr
-Paul Eggert eggert@twinsun.com
-Piotr Gackiewicz gacek@intertel.com.pl
-Richard Stallman rms@gnu.org
+Paul Eggert eggert@twinsun.com
+Piotr Gackiewicz gacek@intertel.com.pl
+Richard Stallman rms@gnu.org
Robert Anisko anisko_r@epita.fr
+Shura debil_urod@ngs.ru
Many people are not named here because we lost track of them. We
thank them! Please, help us keeping this list up to date.
-# Process this file with autoconf to produce a configure script.
-AC_PREREQ(2.52)
-AC_INIT(bison, 1.28c, bug-bison@gnu.org)
+# Configure template for GNU Bison. -*-Autoconf-*-
+#
+# 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)
-AM_INIT_AUTOMAKE(bison, 1.28c)
+
+AM_INIT_AUTOMAKE([bison], [1.29d])
AM_CONFIG_HEADER(config.h:config.hin)
# Initialize the test suite.
-AT_CONFIG(../src)
+AC_CONFIG_TESTDIR(tests)
+AC_CONFIG_FILES([tests/bison], [chmod +x tests/bison])
# Checks for programs.
AC_PROG_CC
jm_FUNC_REALLOC
jm_PREREQ_QUOTEARG
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
# This is necessary so that .o files in LIBOBJS are also built via
intl/Makefile po/Makefile.in
lib/Makefile src/Makefile doc/Makefile
m4/Makefile
- tests/Makefile tests/atconfig])
+ tests/Makefile])
] [
.B \-d
] [
-.B \-\-defines
+.BI \-\-defines= defines-file
+] [
+.B \-g
+] [
+.BI \-\-graph= graph-file
] [
.B \-k
] [
.B \-d
.br
.ns
-.TP
-.B \-\-defines
Write an extra output file containing macro definitions for the token
type names defined in the grammar and the semantic value type
.BR YYSTYPE ,
needs to be able to refer to token type codes and the variable
.BR yylval .
.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
.br
.ns
.sp
.RE
.SH FILES
-/usr/local/lib/bison.simple simple parser
+/usr/local/share/bison/bison.simple simple parser
.br
-/usr/local/lib/bison.hairy complicated parser
+/usr/local/share/bison/bison.hairy complicated parser
.SH "ENVIRONMENT VARIABLES"
.TP
.SM BISON_SIMPLE
@contents
-@node Top, Introduction, (dir), (dir)
+@ifnottex
+@node Top
+@top Bison
-@ifinfo
-This manual documents version @value{VERSION} of Bison.
-@end ifinfo
+This manual documents version @value{VERSION} of Bison, updated
+@value{UPDATED}.
+@end ifnottex
@menu
* Introduction::
* Copying This Manual:: License for copying this manual.
* Index:: Cross-references to the text.
- --- The Detailed Node Listing ---
+@detailmenu --- The Detailed Node Listing ---
The Concepts of Bison
* Infix Calc:: Infix (algebraic) notation calculator.
Operator precedence is introduced.
* Simple Error Recovery:: Continuing after syntax errors.
+* Location Tracking Calc:: Demonstrating the use of @@@var{n} and @@$.
* Multi-function Calc:: Calculator with memory and trig functions.
It uses multiple data-types for semantic values.
* Exercises:: Ideas for improving the multi-function calculator.
* Rpcalc Line::
* Rpcalc Expr::
+Location Tracking Calculator: @code{ltcalc}
+
+* Decls: Ltcalc Decls. Bison and C declarations for ltcalc.
+* Rules: Ltcalc Rules. Grammar rules for ltcalc, with explanations.
+* Lexer: Ltcalc Lexer. The lexical analyzer.
+
Multi-Function Calculator: @code{mfcalc}
* Decl: Mfcalc Decl. Bison declarations for multi-function calculator.
* GNU Free Documentation License:: License for copying this manual.
+@end detailmenu
@end menu
-@node Introduction, Conditions, Top, Top
+@node Introduction
@unnumbered Introduction
@cindex introduction
This edition corresponds to version @value{VERSION} of Bison.
-@node Conditions, Copying, Introduction, Top
+@node Conditions
@unnumbered Conditions for Using Bison
As of Bison version 1.24, we have changed the distribution terms for
@include gpl.texi
-@node Concepts, Examples, Copying, Top
+@node Concepts
@chapter The Concepts of Bison
This chapter introduces many of the basic concepts without which the
* Grammar Layout:: Overall structure of a Bison grammar file.
@end menu
-@node Language and Grammar, Grammar in Bison, , Concepts
+@node Language and Grammar
@section Languages and Context-Free Grammars
@cindex context-free grammar
must be a `sequence of definitions and declarations'. If not, the parser
reports a syntax error.
-@node Grammar in Bison, Semantic Values, Language and Grammar, Concepts
+@node Grammar in Bison
@section From Formal Rules to Bison Input
@cindex Bison grammar
@cindex grammar, Bison
@noindent
@xref{Rules, ,Syntax of Grammar Rules}.
-@node Semantic Values, Semantic Actions, Grammar in Bison, Concepts
+@node Semantic Values
@section Semantic Values
@cindex semantic value
@cindex value, semantic
language, an expression typically has a semantic value that is a tree
structure describing the meaning of the expression.
-@node Semantic Actions, Locations Overview, Semantic Values, Concepts
+@node Semantic Actions
@section Semantic Actions
@cindex semantic actions
@cindex actions, semantic
The action says how to produce the semantic value of the sum expression
from the values of the two subexpressions.
-@node Locations Overview, Bison Parser, Semantic Actions, Concepts
+@node Locations Overview
@section Locations
@cindex location
@cindex textual position
grouping, the default behavior of the output parser is to take the beginning
of the first symbol, and the end of the last symbol.
-@node Bison Parser, Stages, Locations Overview, Concepts
+@node Bison Parser
@section Bison Output: the Parser File
@cindex Bison parser
@cindex Bison utility
or @samp{YY} in the Bison grammar file except for the ones defined in
this manual.
-@node Stages, Grammar Layout, Bison Parser, Concepts
+@node Stages
@section Stages in Using Bison
@cindex stages in using Bison
@cindex using Bison
Link the object files to produce the finished product.
@end enumerate
-@node Grammar Layout, , Stages, Concepts
+@node Grammar Layout
@section The Overall Layout of a Bison Grammar
@cindex grammar file
@cindex file format
The @samp{%%}, @samp{%@{} and @samp{%@}} are punctuation that appears
in every Bison grammar file to separate the sections.
-The prologue may define types and variables used in the actions. You can
-also use preprocessor commands to define macros used there, and use
+The prologue may define types and variables used in the actions. You can
+also use preprocessor commands to define macros used there, and use
@code{#include} to include header files that do any of these things.
The Bison declarations declare the names of the terminal and nonterminal
The grammar rules define how to construct each nonterminal symbol from its
parts.
-The epilogue can contain any code you want to use. Often the definition of
-the lexical analyzer @code{yylex} goes here, plus subroutines called by the
-actions in the grammar rules. In a simple program, all the rest of the
+The epilogue can contain any code you want to use. Often the definition of
+the lexical analyzer @code{yylex} goes here, plus subroutines called by the
+actions in the grammar rules. In a simple program, all the rest of the
program can go here.
-@node Examples, Grammar File, Concepts, Top
+@node Examples
@chapter Examples
@cindex simple examples
@cindex examples, simple
* Infix Calc:: Infix (algebraic) notation calculator.
Operator precedence is introduced.
* Simple Error Recovery:: Continuing after syntax errors.
+* Location Tracking Calc:: Demonstrating the use of @@@var{n} and @@$.
* Multi-function Calc:: Calculator with memory and trig functions.
It uses multiple data-types for semantic values.
* Exercises:: Ideas for improving the multi-function calculator.
@end menu
-@node RPN Calc, Infix Calc, , Examples
+@node RPN Calc
@section Reverse Polish Notation Calculator
@cindex reverse polish notation
@cindex polish notation calculator
* Comp: Rpcalc Compile. Run the C compiler on the output code.
@end menu
-@node Rpcalc Decls, Rpcalc Rules, , RPN Calc
+@node Rpcalc Decls
@subsection Declarations for @code{rpcalc}
Here are the C and Bison declarations for the reverse polish notation
only terminal symbol that needs to be declared is @code{NUM}, the token
type for numeric constants.
-@node Rpcalc Rules, Rpcalc Lexer, Rpcalc Decls, RPN Calc
+@node Rpcalc Rules
@subsection Grammar Rules for @code{rpcalc}
Here are the grammar rules for the reverse polish notation calculator.
* Rpcalc Expr::
@end menu
-@node Rpcalc Input, Rpcalc Line, , Rpcalc Rules
+@node Rpcalc Input
@subsubsection Explanation of @code{input}
Consider the definition of @code{input}:
grammatical error is seen or the lexical analyzer says there are no more
input tokens; we will arrange for the latter to happen at end of file.
-@node Rpcalc Line, Rpcalc Expr, Rpcalc Input, Rpcalc Rules
+@node Rpcalc Line
@subsubsection Explanation of @code{line}
Now consider the definition of @code{line}:
that value were ever used, but we don't use it: once rpcalc has printed the
value of the user's input line, that value is no longer needed.
-@node Rpcalc Expr, , Rpcalc Line, Rpcalc Rules
+@node Rpcalc Expr
@subsubsection Explanation of @code{expr}
The @code{exp} grouping has several rules, one for each kind of expression.
@noindent
The latter, however, is much more readable.
-@node Rpcalc Lexer, Rpcalc Main, Rpcalc Rules, RPN Calc
+@node Rpcalc Lexer
@subsection The @code{rpcalc} Lexical Analyzer
@cindex writing a lexical analyzer
@cindex lexical analyzer, writing
@end group
@end example
-@node Rpcalc Main, Rpcalc Error, Rpcalc Lexer, RPN Calc
+@node Rpcalc Main
@subsection The Controlling Function
@cindex controlling function
@cindex main function in simple example
@end group
@end example
-@node Rpcalc Error, Rpcalc Gen, Rpcalc Main, RPN Calc
+@node Rpcalc Error
@subsection The Error Reporting Routine
@cindex error reporting routine
cause the calculator program to exit. This is not clean behavior for a
real calculator, but it is adequate for the first example.
-@node Rpcalc Gen, Rpcalc Compile, Rpcalc Error, RPN Calc
+@node Rpcalc Gen
@subsection Running Bison to Make the Parser
@cindex running Bison (introduction)
arrange all the source code in one or more source files. For such a
simple example, the easiest thing is to put everything in one file. The
definitions of @code{yylex}, @code{yyerror} and @code{main} go at the
-end, in the epilogue of the file
+end, in the epilogue of the file
(@pxref{Grammar Layout, ,The Overall Layout of a Bison Grammar}).
For a large project, you would probably have several source files, and use
functions in the input file (@code{yylex}, @code{yyerror} and @code{main})
are copied verbatim to the output.
-@node Rpcalc Compile, , Rpcalc Gen, RPN Calc
+@node Rpcalc Compile
@subsection Compiling the Parser File
@cindex compiling the parser
%
@end example
-@node Infix Calc, Simple Error Recovery, RPN Calc, Examples
+@node Infix Calc
@section Infix Notation Calculator: @code{calc}
@cindex infix notation calculator
@cindex @code{calc}
9
@end example
-@node Simple Error Recovery, Multi-function Calc, Infix Calc, Examples
+@node Simple Error Recovery
@section Simple Error Recovery
@cindex error recovery, simple
input. We won't discuss this issue further because it is not specific to
Bison programs.
-@node Multi-function Calc, Exercises, Simple Error Recovery, Examples
+@node Location Tracking Calc
+@section Location Tracking Calculator: @code{ltcalc}
+@cindex location tracking calculator
+@cindex @code{ltcalc}
+@cindex calculator, location tracking
+
+This example extends the infix notation calculator with location tracking.
+This feature will be used to improve error reporting, and provide better
+error messages.
+
+For the sake of clarity, we will switch for this example to an integer
+calculator, since most of the work needed to use locations will be done
+in the lexical analyser.
+
+@menu
+* Decls: Ltcalc Decls. Bison and C declarations for ltcalc.
+* Rules: Ltcalc Rules. Grammar rules for ltcalc, with explanations.
+* Lexer: Ltcalc Lexer. The lexical analyzer.
+@end menu
+
+@node Ltcalc Decls
+@subsection Declarations for @code{ltcalc}
+
+The C and Bison declarations for the location tracking calculator are the same
+as the declarations for the infix notation calculator.
+
+@example
+/* Location tracking calculator. */
+
+%@{
+#define YYSTYPE int
+#include <math.h>
+%@}
+
+/* Bison declarations. */
+%token NUM
+
+%left '-' '+'
+%left '*' '/'
+%left NEG
+%right '^'
+
+%% /* Grammar follows */
+@end example
+
+In the code above, there are no declarations specific to locations. Defining
+a data type for storing locations is not needed: we will use the type provided
+by default (@pxref{Location Type, ,Data Types of Locations}), which is a four
+member structure with the following integer fields: @code{first_line},
+@code{first_column}, @code{last_line} and @code{last_column}.
+
+@node Ltcalc Rules
+@subsection Grammar Rules for @code{ltcalc}
+
+Whether you choose to handle locations or not has no effect on the syntax of
+your language. Therefore, grammar rules for this example will be very close to
+those of the previous example: we will only modify them to benefit from the new
+informations we will have.
+
+Here, we will use locations to report divisions by zero, and locate the wrong
+expressions or subexpressions.
+
+@example
+@group
+input : /* empty */
+ | input line
+;
+@end group
+
+@group
+line : '\n'
+ | exp '\n' @{ printf ("%d\n", $1); @}
+;
+@end group
+
+@group
+exp : NUM @{ $$ = $1; @}
+ | exp '+' exp @{ $$ = $1 + $3; @}
+ | exp '-' exp @{ $$ = $1 - $3; @}
+ | exp '*' exp @{ $$ = $1 * $3; @}
+@end group
+ | exp '/' exp
+@group
+ @{
+ if ($3)
+ $$ = $1 / $3;
+ else
+ @{
+ $$ = 1;
+ printf("Division by zero, l%d,c%d-l%d,c%d",
+ @@3.first_line, @@3.first_column,
+ @@3.last_line, @@3.last_column);
+ @}
+ @}
+@end group
+@group
+ | '-' exp %preg NEG @{ $$ = -$2; @}
+ | exp '^' exp @{ $$ = pow ($1, $3); @}
+ | '(' exp ')' @{ $$ = $2; @}
+@end group
+@end example
+
+This code shows how to reach locations inside of semantic actions, by
+using the pseudo-variables @code{@@@var{n}} for rule components, and the
+pseudo-variable @code{@@$} for groupings.
+
+In this example, we never assign a value to @code{@@$}, because the
+output parser can do this automatically. By default, before executing
+the C code of each action, @code{@@$} is set to range from the beginning
+of @code{@@1} to the end of @code{@@@var{n}}, for a rule with @var{n}
+components.
+
+Of course, this behavior can be redefined (@pxref{Location Default
+Action, , Default Action for Locations}), and for very specific rules,
+@code{@@$} can be computed by hand.
+
+@node Ltcalc Lexer
+@subsection The @code{ltcalc} Lexical Analyzer.
+
+Until now, we relied on Bison's defaults to enable location tracking. The next
+step is to rewrite the lexical analyser, and make it able to feed the parser
+with locations of tokens, as he already does for semantic values.
+
+To do so, we must take into account every single character of the input text,
+to avoid the computed locations of being fuzzy or wrong:
+
+@example
+@group
+int
+yylex (void)
+@{
+ int c;
+
+ /* skip white space */
+ while ((c = getchar ()) == ' ' || c == '\t')
+ ++yylloc.last_column;
+
+ /* step */
+ yylloc.first_line = yylloc.last_line;
+ yylloc.first_column = yylloc.last_column;
+@end group
+
+@group
+ /* process numbers */
+ if (isdigit (c))
+ @{
+ yylval = c - '0';
+ ++yylloc.last_column;
+ while (isdigit (c = getchar ()))
+ @{
+ ++yylloc.last_column;
+ yylval = yylval * 10 + c - '0';
+ @}
+ ungetc (c, stdin);
+ return NUM;
+ @}
+@end group
+
+ /* return end-of-file */
+ if (c == EOF)
+ return 0;
+
+ /* return single chars and update location */
+ if (c == '\n')
+ @{
+ ++yylloc.last_line;
+ yylloc.last_column = 0;
+ @}
+ else
+ ++yylloc.last_column;
+ return c;
+@}
+@end example
+
+Basically, the lexical analyzer does the same processing as before: it skips
+blanks and tabs, and reads numbers or single-character tokens. In addition
+to this, it updates the @code{yylloc} global variable (of type @code{YYLTYPE}),
+where the location of tokens is stored.
+
+Now, each time this function returns a token, the parser has it's number as
+well as it's semantic value, and it's position in the text. The last needed
+change is to initialize @code{yylloc}, for example in the controlling
+function:
+
+@example
+int
+main (void)
+@{
+ yylloc.first_line = yylloc.last_line = 1;
+ yylloc.first_column = yylloc.last_column = 0;
+ return yyparse ();
+@}
+@end example
+
+Remember that computing locations is not a matter of syntax. Every character
+must be associated to a location update, whether it is in valid input, in
+comments, in literal strings, and so on...
+
+@node Multi-function Calc
@section Multi-Function Calculator: @code{mfcalc}
@cindex multi-function calculator
@cindex @code{mfcalc}
* Symtab: Mfcalc Symtab. Symbol table management subroutines.
@end menu
-@node Mfcalc Decl, Mfcalc Rules, , Multi-function Calc
+@node Mfcalc Decl
@subsection Declarations for @code{mfcalc}
Here are the C and Bison declarations for the multi-function calculator.
implicitly by the rules that define them. But @code{exp} must be declared
explicitly so we can specify its value type. @xref{Type Decl, ,Nonterminal Symbols}.
-@node Mfcalc Rules, Mfcalc Symtab, Mfcalc Decl, Multi-function Calc
+@node Mfcalc Rules
@subsection Grammar Rules for @code{mfcalc}
Here are the grammar rules for the multi-function calculator.
%%
@end smallexample
-@node Mfcalc Symtab, , Mfcalc Rules, Multi-function Calc
+@node Mfcalc Symtab
@subsection The @code{mfcalc} Symbol Table
@cindex symbol table example
functions, and it is a simple job to modify this code to install predefined
variables such as @code{pi} or @code{e} as well.
-@node Exercises, , Multi-function Calc, Examples
+@node Exercises
@section Exercises
@cindex exercises
uninitialized variable in any way except to store a value in it.
@end enumerate
-@node Grammar File, Interface, Examples, Top
+@node Grammar File
@chapter Bison Grammar Files
Bison takes as input a context-free grammar specification and produces a
* Multiple Parsers:: Putting more than one Bison parser in one program.
@end menu
-@node Grammar Outline, Symbols, , Grammar File
+@node Grammar Outline
@section Outline of a Bison Grammar
A Bison grammar file has four main sections, shown here with the
need any C declarations, you may omit the @samp{%@{} and @samp{%@}}
delimiters that bracket this section.
-@node Bison Declarations, Grammar Rules, Prologue, Grammar Outline
+@node Bison Declarations
@subsection The Bison Declarations Section
@cindex Bison declarations (introduction)
@cindex declarations, Bison (introduction)
In some simple grammars you may not need any declarations.
@xref{Declarations, ,Bison Declarations}.
-@node Grammar Rules, Epilogue, Bison Declarations, Grammar Outline
+@node Grammar Rules
@subsection The Grammar Rules Section
@cindex grammar rules section
@cindex rules section for grammar
@cindex epilogue
@cindex C code, section for additional
-The @var{epilogue} is copied verbatim to the end of the parser file, just as
-the @var{prologue} is copied to the beginning. This is the most convenient
-place to put anything that you want to have in the parser file but which need
-not come before the definition of @code{yyparse}. For example, the
-definitions of @code{yylex} and @code{yyerror} often go here.
+The @var{epilogue} is copied verbatim to the end of the parser file, just as
+the @var{prologue} is copied to the beginning. This is the most convenient
+place to put anything that you want to have in the parser file but which need
+not come before the definition of @code{yyparse}. For example, the
+definitions of @code{yylex} and @code{yyerror} often go here.
@xref{Interface, ,Parser C-Language Interface}.
If the last section is empty, you may omit the @samp{%%} that separates it
good idea to avoid using any such names (except those documented in this
manual) in the epilogue of the grammar file.
-@node Symbols, Rules, Grammar Outline, Grammar File
+@node Symbols
@section Symbols, Terminal and Nonterminal
@cindex nonterminal symbol
@cindex terminal symbol
(@pxref{Error Recovery}); you shouldn't use it for any other purpose.
In particular, @code{yylex} should never return this value.
-@node Rules, Recursion, Symbols, Grammar File
+@node Rules
@section Syntax of Grammar Rules
@cindex rule syntax
@cindex grammar rule syntax
It is customary to write a comment @samp{/* empty */} in each rule
with no components.
-@node Recursion, Semantics, Rules, Grammar File
+@node Recursion
@section Recursive Rules
@cindex recursive rule
defines two mutually-recursive nonterminals, since each refers to the
other.
-@node Semantics, Locations, Recursion, Grammar File
+@node Semantics
@section Defining Language Semantics
@cindex defining language semantics
@cindex language semantics, defining
action in the middle of a rule.
@end menu
-@node Value Type, Multiple Types, , Semantics
+@node Value Type
@subsection Data Types of Semantic Values
@cindex semantic value type
@cindex value type, semantic
@end example
@noindent
-This macro definition must go in the prologue of the grammar file
+This macro definition must go in the prologue of the grammar file
(@pxref{Grammar Outline, ,Outline of a Bison Grammar}).
-@node Multiple Types, Actions, Value Type, Semantics
+@node Multiple Types
@subsection More Than One Value Type
In most programs, you will need different data types for different kinds
Decl, ,Nonterminal Symbols}).
@end itemize
-@node Actions, Action Types, Multiple Types, Semantics
+@node Actions
@subsection Actions
@cindex action
@vindex $$
always refers to the @code{expr} which precedes @code{bar} in the
definition of @code{foo}.
-@node Action Types, Mid-Rule Actions, Actions, Semantics
+@node Action Types
@subsection Data Types of Values in Actions
@cindex action data types
@cindex data types in actions
then you can write @code{$<itype>1} to refer to the first subunit of the
rule as an integer, or @code{$<dtype>1} to refer to it as a double.
-@node Mid-Rule Actions, , Action Types, Semantics
+@node Mid-Rule Actions
@subsection Actions in Mid-Rule
@cindex actions in mid-rule
@cindex mid-rule actions
converted to an end-of-rule action in this way, and this is what Bison
actually does to implement mid-rule actions.
-@node Locations, Declarations, Semantics, Grammar File
+@node Locations
@section Tracking Locations
@cindex location
@cindex textual position
* Location Default Action:: Defining a general way to compute locations.
@end menu
-@node Location Type, Actions and Locations, , Locations
+@node Location Type
@subsection Data Type of Locations
@cindex data type of locations
@cindex default location type
@}
@end example
-@node Actions and Locations, Location Default Action, Location Type, Locations
+@node Actions and Locations
@subsection Actions and Locations
@cindex location actions
@cindex actions, location
@end group
@end example
-@node Location Default Action, , Actions and Locations, Locations
+@node Location Default Action
@subsection Default Action for Locations
@vindex YYLLOC_DEFAULT
range from 1 to @var{n}.
@end itemize
-@node Declarations, Multiple Parsers, Locations, Grammar File
+@node Declarations
@section Bison Declarations
@cindex declarations, Bison
@cindex Bison declarations
* Decl Summary:: Table of all Bison declarations.
@end menu
-@node Token Decl, Precedence Decl, , Declarations
+@node Token Decl
@subsection Token Type Names
@cindex declaring token type names
@cindex token type names, declaring
@code{yylex} function can use the token name or the literal string to
obtain the token type code number (@pxref{Calling Convention}).
-@node Precedence Decl, Union Decl, Token Decl, Declarations
+@node Precedence Decl
@subsection Operator Precedence
@cindex precedence declarations
@cindex declaring operator precedence
the one declared later has the higher precedence and is grouped first.
@end itemize
-@node Union Decl, Type Decl, Precedence Decl, Declarations
+@node Union Decl
@subsection The Collection of Value Types
@cindex declaring value types
@cindex value types, declaring
Note that, unlike making a @code{union} declaration in C, you do not write
a semicolon after the closing brace.
-@node Type Decl, Expect Decl, Union Decl, Declarations
+@node Type Decl
@subsection Nonterminal Symbols
@cindex declaring value types, nonterminals
@cindex value types, nonterminals, declaring
terminal symbol. All kinds of token declarations allow
@code{<@var{type}>}.
-@node Expect Decl, Start Decl, Type Decl, Declarations
+@node Expect Decl
@subsection Suppressing Conflict Warnings
@cindex suppressing conflict warnings
@cindex preventing warnings about conflicts
it will warn you again if changes in the grammar result in additional
conflicts.
-@node Start Decl, Pure Decl, Expect Decl, Declarations
+@node Start Decl
@subsection The Start-Symbol
@cindex declaring the start symbol
@cindex start symbol, declaring
%start @var{symbol}
@end example
-@node Pure Decl, Decl Summary, Start Decl, Declarations
+@node Pure Decl
@subsection A Pure (Reentrant) Parser
@cindex reentrant parser
@cindex pure parser
You can generate either a pure parser or a nonreentrant parser from any
valid grammar.
-@node Decl Summary, , Pure Decl, Declarations
+@node Decl Summary
@subsection Bison Declaration Summary
@cindex Bison declaration summary
@cindex declaration summary
@end table
@end table
-@node Multiple Parsers,, Declarations, Grammar File
+@node Multiple Parsers
@section Multiple Parsers in the Same Program
Most programs that use Bison parse only one language and therefore contain
@code{@var{prefix}parse}, and so on. This effectively substitutes one
name for the other in the entire parser file.
-@node Interface, Algorithm, Grammar File, Top
+@node Interface
@chapter Parser C-Language Interface
@cindex C-language interface
@cindex interface
* Action Features:: Special features for use in actions.
@end menu
-@node Parser Function, Lexical, , Interface
+@node Parser Function
@section The Parser Function @code{yyparse}
@findex yyparse
Return immediately with value 1 (to report failure).
@end table
-@node Lexical, Error Reporting, Parser Function, Interface
+@node Lexical
@section The Lexical Analyzer Function @code{yylex}
@findex yylex
@cindex lexical analyzer
in a pure parser (@pxref{Pure Decl, ,A Pure (Reentrant) Parser}).
@end menu
-@node Calling Convention, Token Values, , Lexical
+@node Calling Convention
@subsection Calling Convention for @code{yylex}
The value that @code{yylex} returns must be the numeric code for the type
@code{%token_table} declaration. @xref{Decl Summary}.
@end itemize
-@node Token Values, Token Positions, Calling Convention, Lexical
+@node Token Values
@subsection Semantic Values of Tokens
@vindex yylval
@end group
@end example
-@node Token Positions, Pure Calling, Token Values, Lexical
+@node Token Positions
@subsection Textual Positions of Tokens
@vindex yylloc
@tindex YYLTYPE
The data type of @code{yylloc} has the name @code{YYLTYPE}.
-@node Pure Calling, , Token Positions, Lexical
+@node Pure Calling
@subsection Calling Conventions for Pure Parsers
When you use the Bison declaration @code{%pure_parser} to request a
also using @code{YYPARSE_PARAM}. Then you should call @code{yyparse}
with no arguments, as usual.
-@node Error Reporting, Action Features, Lexical, Interface
+@node Error Reporting
@section The Error Reporting Function @code{yyerror}
@cindex error reporting function
@findex yyerror
request a pure parser (@pxref{Pure Decl, ,A Pure (Reentrant) Parser}) then it is a local variable
which only the actions can access.
-@node Action Features, , Error Reporting, Interface
+@node Action Features
@section Special Features for Use in Actions
@cindex summary, action features
@cindex action features summary
@end table
-@node Algorithm, Error Recovery, Interface, Top
+@node Algorithm
@chapter The Bison Parser Algorithm
@cindex Bison parser algorithm
@cindex algorithm of parser
* Stack Overflow:: What happens when stack gets full. How to avoid it.
@end menu
-@node Look-Ahead, Shift/Reduce, , Algorithm
+@node Look-Ahead
@section Look-Ahead Tokens
@cindex look-ahead token
The current look-ahead token is stored in the variable @code{yychar}.
@xref{Action Features, ,Special Features for Use in Actions}.
-@node Shift/Reduce, Precedence, Look-Ahead, Algorithm
+@node Shift/Reduce
@section Shift/Reduce Conflicts
@cindex conflicts
@cindex shift/reduce conflicts
;
@end example
-@node Precedence, Contextual Precedence, Shift/Reduce, Algorithm
+@node Precedence
@section Operator Precedence
@cindex operator precedence
@cindex precedence of operators
* How Precedence:: How they work.
@end menu
-@node Why Precedence, Using Precedence, , Precedence
+@node Why Precedence
@subsection When Precedence is Needed
Consider the following ambiguous grammar fragment (ambiguous because the
contains @w{@samp{1 - 2}} and the look-ahead token is @samp{-}: shifting
makes right-associativity.
-@node Using Precedence, Precedence Examples, Why Precedence, Precedence
+@node Using Precedence
@subsection Specifying Operator Precedence
@findex %left
@findex %right
precedence is lowest, the next such declaration declares the operators
whose precedence is a little higher, and so on.
-@node Precedence Examples, How Precedence, Using Precedence, Precedence
+@node Precedence Examples
@subsection Precedence Examples
In our example, we would want the following declarations:
and so on. We assume that these tokens are more than one character long
and therefore are represented by names, not character literals.)
-@node How Precedence, , Precedence Examples, Precedence
+@node How Precedence
@subsection How Precedence Works
The first effect of the precedence declarations is to assign precedence
Not all rules and not all tokens have precedence. If either the rule or
the look-ahead token has no precedence, then the default is to shift.
-@node Contextual Precedence, Parser States, Precedence, Algorithm
+@node Contextual Precedence
@section Context-Dependent Precedence
@cindex context-dependent precedence
@cindex unary operator precedence
@end group
@end example
-@node Parser States, Reduce/Reduce, Contextual Precedence, Algorithm
+@node Parser States
@section Parser States
@cindex finite-state machine
@cindex parser state
is erroneous in the current state. This causes error processing to begin
(@pxref{Error Recovery}).
-@node Reduce/Reduce, Mystery Conflicts, Parser States, Algorithm
+@node Reduce/Reduce
@section Reduce/Reduce Conflicts
@cindex reduce/reduce conflict
@cindex conflicts, reduce/reduce
;
@end example
-@node Mystery Conflicts, Stack Overflow, Reduce/Reduce, Algorithm
+@node Mystery Conflicts
@section Mysterious Reduce/Reduce Conflicts
Sometimes reduce/reduce conflicts can occur that don't look warranted.
;
@end example
-@node Stack Overflow, , Mystery Conflicts, Algorithm
+@node Stack Overflow
@section Stack Overflow, and How to Avoid It
@cindex stack overflow
@cindex parser stack overflow
macro @code{YYINITDEPTH}. This value too must be a compile-time
constant integer. The default is 200.
-@node Error Recovery, Context Dependency, Algorithm, Top
+@node Error Recovery
@chapter Error Recovery
@cindex error recovery
@cindex recovery from errors
rest of the time. A value of 1 indicates that error messages are
currently suppressed for new syntax errors.
-@node Context Dependency, Debugging, Error Recovery, Top
+@node Context Dependency
@chapter Handling Context Dependencies
The Bison paradigm is to parse tokens first, then group them into larger
(Actually, ``kludge'' means any technique that gets its job done but is
neither clean nor robust.)
-@node Semantic Tokens, Lexical Tie-ins, , Context Dependency
+@node Semantic Tokens
@section Semantic Info in Token Types
The C language has a context dependency: the way an identifier is used
program. A true lexical tie-in has a special-purpose flag controlled by
the syntactic context.
-@node Lexical Tie-ins, Tie-in Recovery, Semantic Tokens, Context Dependency
+@node Lexical Tie-ins
@section Lexical Tie-ins
@cindex lexical tie-in
it is nonzero, all integers are parsed in hexadecimal, and tokens starting
with letters are parsed as integers if possible.
-The declaration of @code{hexflag} shown in the prologue of the parser file
-is needed to make it accessible to the actions (@pxref{Prologue, ,The Prologue}).
+The declaration of @code{hexflag} shown in the prologue of the parser file
+is needed to make it accessible to the actions (@pxref{Prologue, ,The Prologue}).
You must also write the code in @code{yylex} to obey the flag.
-@node Tie-in Recovery, , Lexical Tie-ins, Context Dependency
+@node Tie-in Recovery
@section Lexical Tie-ins and Error Recovery
Lexical tie-ins make strict demands on any error recovery rules you have.
be such that you can be sure that it always will, or always won't, have to
clear the flag.
-@node Debugging, Invocation, Context Dependency, Top
+@node Debugging
@chapter Debugging Your Parser
@findex YYDEBUG
@findex yydebug
runs, the @code{yydebug} parser-trace feature can help you figure out why.
To enable compilation of trace facilities, you must define the macro
-@code{YYDEBUG} when you compile the parser. You could use @samp{-DYYDEBUG=1}
-as a compiler option or you could put @samp{#define YYDEBUG 1} in the prologue
-of the grammar file (@pxref{Prologue, , The Prologue}). Alternatively, use the
-@samp{-t} option when you run Bison (@pxref{Invocation, ,Invoking Bison}).
+@code{YYDEBUG} when you compile the parser. You could use @samp{-DYYDEBUG=1}
+as a compiler option or you could put @samp{#define YYDEBUG 1} in the prologue
+of the grammar file (@pxref{Prologue, , The Prologue}). Alternatively, use the
+@samp{-t} option when you run Bison (@pxref{Invocation, ,Invoking Bison}).
We always define @code{YYDEBUG} so that debugging is always possible.
-The trace facility uses @code{stderr}, so you must add
+The trace facility uses @code{stderr}, so you must add
@w{@code{#include <stdio.h>}} to the prologue unless it is already there.
Once you have compiled the program with trace facilities, the way to
@}
@end smallexample
-@node Invocation, Table of Symbols, Debugging, Top
+@node Invocation
@chapter Invoking Bison
@cindex invoking Bison
@cindex Bison invocation
* VMS Invocation:: Bison command syntax on VMS.
@end menu
-@node Bison Options, Environment Variables, , Invocation
+@node Bison Options
@section Bison Options
Bison supports both traditional single-letter options and mnemonic long
@table @option
@item -d
-@itemx --defines
Pretend that @code{%verbose} was specified, i.e., write an extra output
file containing macro definitions for the token type names defined in
the grammar and the semantic value type @code{YYSTYPE}, as well as a few
@code{extern} variable declarations. @xref{Decl Summary}.
+@item --defines=@var{defines-file}
+The behaviour of @var{--defines} is the same than @samp{-d}. The only
+difference is that it has an optionnal argument which is the name of
+the output filename.
+
@item -b @var{file-prefix}
@itemx --file-prefix=@var{prefix}
Specify a prefix to use for all Bison output file names. The names are
The other output files' names are constructed from @var{outfile}
as described under the @samp{-v} and @samp{-d} options.
+
+@item -g
+Output a VCG definition of the LALR(1) grammar automaton computed by
+Bison. If the grammar file is @file{foo.y}, the VCG output file will
+be @file{foo.vcg}.
+
+@item --graph=@var{graph-file}
+The behaviour of @var{--graph} is the same than @samp{-g}. The only
+difference is that it has an optionnal argument which is the name of
+the output graph filename.
@end table
-@node Environment Variables, Option Cross Key, Bison Options, Invocation
+@node Environment Variables
@section Environment Variables
@cindex environment variables
@cindex BISON_HAIRY
@end table
-@node Option Cross Key, VMS Invocation, Environment Variables, Invocation
+@node Option Cross Key
@section Option Cross Key
Here is a list of options, alphabetized by long option, to help you find
\line{ --defines \leaderfill -d}
\line{ --file-prefix \leaderfill -b}
\line{ --fixed-output-files \leaderfill -y}
+\line{ --graph \leaderfill -g}
\line{ --help \leaderfill -h}
\line{ --name-prefix \leaderfill -p}
\line{ --no-lines \leaderfill -l}
@ifinfo
@example
--debug -t
---defines -d
+--defines=@var{defines-file} -d
--file-prefix=@var{prefix} -b @var{file-prefix}
--fixed-output-files --yacc -y
+--graph=@var{graph-file} -d
--help -h
--name-prefix=@var{prefix} -p @var{name-prefix}
--no-lines -l
@end example
@end ifinfo
-@node VMS Invocation, , Option Cross Key, Invocation
+@node VMS Invocation
@section Invoking Bison under VMS
@cindex invoking Bison under VMS
@cindex VMS
@file{foo.tab.c}. In the above example, the output file
would instead be named @file{foo_tab.c}.
-@node Table of Symbols, Glossary, Invocation, Top
+@node Table of Symbols
@appendix Bison Symbols
@cindex Bison symbols, table of
@cindex symbols in Bison, table of
@item %@{ %@}
All code listed between @samp{%@{} and @samp{%@}} is copied directly to
-the output file uninterpreted. Such code forms the prologue of the input
+the output file uninterpreted. Such code forms the prologue of the input
file. @xref{Grammar Outline, ,Outline of a Bison
Grammar}.
@xref{Rules, ,Syntax of Grammar Rules}.
@end table
-@node Glossary, Copying This Manual, Table of Symbols, Top
+@node Glossary
@appendix Glossary
@cindex glossary
@xref{Language and Grammar, ,Languages and Context-Free Grammars}.
@end table
-@node Copying This Manual, Index, Glossary, Top
+@node Copying This Manual
@appendix Copying This Manual
@menu
@include fdl.texi
-@node Index, , Copying This Manual, Top
+@node Index
@unnumbered Index
@printindex cp
#endif
#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>
#endif
# undef MB_CUR_MAX
# define MB_CUR_MAX 1
# define mbrtowc(pwc, s, n, ps) ((*(pwc) = *(s)) != 0)
-# define mbsinit(ps) 1
# define iswprint(wc) ISPRINT ((unsigned char) (wc))
+# undef HAVE_MBSINIT
+#endif
+
+#if !defined mbsinit && !HAVE_MBSINIT
+# define mbsinit(ps) 1
#endif
#ifndef iswprint
## Process this file with automake to produce Makefile.in -*-Makefile-*-
EXTRA_DIST = \
-atconfig.m4 \
c-bs-a.m4 \
codeset.m4 \
+dmalloc.m4 \
error.m4 \
gettext.m4 \
glibc21.m4 \
lcmessage.m4 \
m4.m4 \
malloc.m4 \
+mbrtowc.m4 \
mbstate_t.m4 \
prereq.m4 \
progtest.m4 \
+++ /dev/null
-## ----------------------##
-## 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
-])
--- /dev/null
+## ----------------------------------- ##
+## 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)])
+])
--- /dev/null
+#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
+])
-#serial 1
+#serial 2
dnl These are the prerequisite macros for files in the lib/
dnl directories of Bison.
AC_DEFUN([jm_PREREQ_QUOTEARG],
[
- AC_CHECK_FUNCS(isascii iswprint mbrtowc)
- AC_CHECK_HEADERS(limits.h stdlib.h string.h wchar.h wctype.h)
+ AC_CHECK_FUNCS(isascii iswprint mbsinit)
+ jm_FUNC_MBRTOWC
+ AC_CHECK_HEADERS(limits.h stddef.h stdlib.h string.h wchar.h wctype.h)
AC_HEADER_STDC
AC_C_BACKSLASH_A
AC_MBSTATE_T
POTFILES
bison.pot
stamp-cat-id
+*.gmo
+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>
* Makefile.in.in: Upgrade to gettext-0.10.39.
src/print_graph.c
src/reader.c
src/reduce.c
-src/vcg.c
lib/error.c
lib/getopt.c
The entry point is generate_states. */
#include "system.h"
-#include "xalloc.h"
#include "gram.h"
#include "state.h"
#include "complain.h"
int nstates;
int final_state;
-core *first_state;
-shifts *first_shift;
-reductions *first_reduction;
+core *first_state = NULL;
+shifts *first_shift = NULL;
+reductions *first_reduction = NULL;
-static core *this_state;
-static core *last_state;
-static shifts *last_shift;
-static reductions *last_reduction;
+static core *this_state = NULL;
+static core *last_state = NULL;
+static shifts *last_shift = NULL;
+static reductions *last_reduction = NULL;
static int nshifts;
-static short *shift_symbol;
+static short *shift_symbol = NULL;
-static short *redset;
-static short *shiftset;
+static short *redset = NULL;
+static short *shiftset = NULL;
-static short **kernel_base;
-static short **kernel_end;
-static short *kernel_items;
+static short **kernel_base = NULL;
+static short **kernel_end = NULL;
+static short *kernel_items = NULL;
/* hash table for states, to recognize equivalent ones. */
#define STATE_TABLE_SIZE 1009
-static core **state_table;
+static core **state_table = NULL;
\f
static void
allocate_itemsets (void)
{
- short *itemp;
+ short *itemp = NULL;
int symbol;
int i;
int count;
- short *symbol_count;
+ short *symbol_count = NULL;
count = 0;
symbol_count = XCALLOC (short, nsyms);
We allocate that much space for each symbol. */
kernel_base = XCALLOC (short *, nsyms);
- kernel_items = XCALLOC (short, count);
+ if (count)
+ kernel_items = XCALLOC (short, count);
count = 0;
for (i = 0; i < nsyms; i++)
/*------------------------------------------------------------.
| yynewstate -- Push a new state, which is found in yystate. |
`------------------------------------------------------------*/
-yynewstate:
+ yynewstate:
/* In all cases, when you get here, the value and location stacks
have just been pushed. so pushing a state here evens the stacks.
*/
yyssp++;
-yysetstate:
+ yysetstate:
*yyssp = yystate;
if (yyssp >= yyss + yystacksize - 1)
#line %%input_line "%%filename"
%%epilogue
-
02111-1307, USA. */
#include "system.h"
-#include "xalloc.h"
#include "gram.h"
#include "closure.h"
#include "derives.h"
/* Based on error.c and error.h,
written by David MacKenzie <djm@gnu.ai.mit.edu>. */
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-#include <stdio.h>
+#include "system.h"
#if HAVE_VPRINTF || HAVE_DOPRNT || _LIBC
-# if __STDC__
+# ifdef __STDC__
# include <stdarg.h>
# define VA_START(args, lastarg) va_start(args, lastarg)
# else
`--------------------------------*/
void
-#if defined VA_START && __STDC__
+#if defined VA_START && defined __STDC__
warn (const char *message, ...)
#else
warn (message, va_alist)
`-----------------------------------------------------------*/
void
-#if defined VA_START && __STDC__
+#if defined VA_START && defined __STDC__
complain (const char *message, ...)
#else
complain (message, va_alist)
`-------------------------------------------------*/
void
-#if defined VA_START && __STDC__
+#if defined VA_START && defined __STDC__
fatal (const char *message, ...)
#else
fatal (message, va_alist)
`------------------------------------------------------------------*/
void
-#if defined VA_START && __STDC__
+#if defined VA_START && defined __STDC__
error (int status, int errnum,
const char *message, ...)
#else
extern "C" {
#endif
-#if defined (__STDC__) && __STDC__
+#ifdef __STDC__
/* Informative messages, but we proceed. */
#include "system.h"
#include "getargs.h"
-#include "xalloc.h"
#include "files.h"
#include "gram.h"
#include "state.h"
#include "LR0.h"
int any_conflicts = 0;
-errs **err_table;
+errs **err_table = NULL;
int expected_conflicts;
-static char *conflicts;
+static char *conflicts = NULL;
-static unsigned *shiftset;
-static unsigned *lookaheadset;
+static unsigned *shiftset = NULL;
+static unsigned *lookaheadset = NULL;
static int src_total;
static int rrc_total;
static int src_count;
}
void
-initialize_conflicts (void)
+solve_conflicts (void)
{
int i;
`---------------------------------------------*/
void
-print_conflicts (void)
+print_conflicts (FILE *out)
{
int i;
if (verbose_flag)
{
- obstack_fgrow1 (&output_obstack, _("State %d contains"), i);
- obstack_sgrow (&output_obstack,
- conflict_report (src_count, rrc_count));
+ fprintf (out, _("State %d contains"), i);
+ fputs (conflict_report (src_count, rrc_count), out);
}
}
}
void
-finalize_conflicts (void)
+free_conflicts (void)
{
XFREE (conflicts);
XFREE (shiftset);
# define CONFLICTS_H_
# include "state.h"
-void initialize_conflicts PARAMS ((void));
-void print_conflicts PARAMS ((void));
+void solve_conflicts PARAMS ((void));
+void print_conflicts PARAMS ((FILE *out));
void print_reductions PARAMS ((int));
-void finalize_conflicts PARAMS ((void));
+void free_conflicts PARAMS ((void));
/* Were there conflicts? */
extern int any_conflicts;
*/
#include "system.h"
-#include "xalloc.h"
#include "types.h"
#include "gram.h"
#include "derives.h"
#include "system.h"
#include "getargs.h"
#include "files.h"
-#include "xalloc.h"
#include "gram.h"
#include "complain.h"
struct obstack defines_obstack;
struct obstack guard_obstack;
struct obstack output_obstack;
-struct obstack graph_obstack;
char *spec_outfile = NULL; /* for -o. */
char *spec_file_prefix = NULL; /* for -b. */
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 *attrsfile = NULL;
static char *
compute_header_macro (void)
{
- int ite;
- char *macro_name;
+ char *macro_name, *cp;
- macro_name = XMALLOC (char,
- strlen (base_name) +
- strlen (header_extension) + 1);
+ if (spec_defines_file)
+ macro_name = xstrdup (spec_defines_file);
+ else
+ {
+ macro_name = XMALLOC (char,
+ strlen (base_name) +
+ strlen (header_extension) + 1);
- stpcpy (macro_name, base_name);
- strcat (macro_name, header_extension);
+ stpcpy (macro_name, base_name);
+ 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;
}
{
const char *res = getenv (envvar);
-#ifdef MSDOS
- const char *cp;
-
- /* File doesn't exist in current directory; try in INIT directory. */
- if (!res && (cp = getenv ("INIT")))
+#if defined (MSDOS) || defined (_WIN32)
+ if (!res)
{
- res = XMALLOC (char, strlen (cp) + strlen (skeleton_name) + 2);
- sprintf (res, "%s%c%s", cp, '/', skeleton_name);
+ /* Skeleton file name without path */
+ const char *skel_name = strrchr(skeleton_name, '/');
+ if (!skel_name)
+ 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 /* !MSDOS */
-
+#endif /* defined (MSDOS) || defined (_WIN32) */
if (!res)
res = skeleton_name;
static void
compute_exts_from_gf (const char *ext)
{
- /* Checks if SRC_EXTENSION is NULL. In the other case, %source_extension
- was specified in the grammar file. */
- if (src_extension == NULL)
- {
- 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');
- }
+ src_extension = tr (ext, 'y', 'c');
+ src_extension = tr (src_extension, 'Y', 'C');
+ header_extension = tr (ext, 'y', 'h');
+ header_extension = tr (header_extension, 'Y', 'H');
}
/* Computes extensions from the given c source file extension. */
}
}
+/*-------------------------------------------------------.
+| 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 |
| the output files. Prepare the obstacks. |
obstack_init (&defines_obstack);
obstack_init (&guard_obstack);
obstack_init (&output_obstack);
- obstack_init (&graph_obstack);
}
-/*-----------------------------------------------------.
-| Close the open files, produce all the output files. |
-`-----------------------------------------------------*/
+/*-----------------------.
+| Close the open file.. |
+`-----------------------*/
void
-output_files (void)
+close_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 */
+/*---------------------------.
+| Produce the output files. |
+`---------------------------*/
+void
+output_files (void)
+{
/* Output the main file. */
if (spec_outfile)
obstack_save (&table_obstack, spec_outfile);
else
obstack_save (&table_obstack, stringappend (base_name, src_extension));
+ obstack_free (&table_obstack, NULL);
/* Output the header file if wanted. */
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 (no_parser_flag)
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
into its own file, ATTTRSFILE. */
char *temp_name;
obstack_save (&attrs_obstack, attrsfile);
+ obstack_free (&attrs_obstack, NULL);
temp_name = stringappend (short_base_name, EXT_GUARD_C);
#ifndef MSDOS
temp_name = stringappend (temp_name, src_extension);
#endif /* MSDOS */
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"));
}
/* File name pfx specified with -b, or 0 if no -b. */
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. */
extern FILE *finput;
+
/* Output all the action code; precise form depends on which parser. */
extern struct obstack action_obstack;
/* The verbose output. */
extern struct obstack output_obstack;
-/* The VCG graph output. */
-extern struct obstack graph_obstack;
-
extern char *infile;
extern char *attrsfile;
-extern const char *src_extension;
-extern const char *header_extension;
-
void open_files PARAMS((void));
+void close_files PARAMS((void));
+void compute_output_file_names PARAMS((void));
void output_files PARAMS((void));
FILE *xfopen PARAMS ((const char *name, const char *mode));
-d, --defines also produce a header file\n\
-v, --verbose also produce an explanation of the automaton\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);
fputs (_("\
exit (0);
case 'g':
+ /* Here, the -g and --graph=FILE options are differentiated. */
graph_flag = 1;
+ spec_graph_file = optarg;
break;
case 'v':
break;
case 'd':
+ /* Here, the -d and --defines options are differentiated. */
defines_flag = 1;
+ spec_defines_file = optarg;
break;
case 'l':
int ntokens;
int nvars;
-short *ritem;
-short *rlhs;
-short *rrhs;
-short *rprec;
-short *rprecsym;
-short *sprec;
-short *rassoc;
-short *sassoc;
-short *token_translations;
-short *rline;
+short *ritem = NULL;
+short *rlhs = NULL;
+short *rrhs = NULL;
+short *rprec = NULL;
+short *rprecsym = NULL;
+short *sprec = NULL;
+short *rassoc = NULL;
+short *sassoc = NULL;
+short *token_translations = NULL;
+short *rline = NULL;
int start_symbol;
-int translations;
-
int max_user_token_number;
int semantic_parser;
/* token translation table: indexed by a token number as returned by
the user's yylex routine, it yields the internal token number used
- by the parser and throughout bison. If translations is zero, the
- 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...") */
+ by the parser and throughout bison. */
extern short *token_translations;
-extern int translations;
extern int max_user_token_number;
/* SEMANTIC_PARSER is nonzero if the input file says to use the hairy
#include "system.h"
#include "types.h"
#include "LR0.h"
-#include "xalloc.h"
#include "gram.h"
#include "complain.h"
#include "lalr.h"
#include "symtab.h"
#include "options.h"
#include "lex.h"
-#include "xalloc.h"
#include "complain.h"
#include "gram.h"
#include "quote.h"
bucket *symval;
int numval;
-static int unlexed; /* these two describe a token to be reread */
-static bucket *unlexed_symval; /* by the next call to lex */
+/* these two describe a token to be reread */
+static token_t unlexed = tok_undef;
+/* by the next call to lex */
+static bucket *unlexed_symval = NULL;
void
-init_lex (void)
+lex_init (void)
{
obstack_init (&token_obstack);
- unlexed = -1;
+ unlexed = tok_undef;
+}
+
+
+void
+lex_free (void)
+{
+ obstack_free (&token_obstack, NULL);
}
void
-unlex (int token)
+unlex (token_t token)
{
unlexed = token;
unlexed_symval = symval;
/* Just to make sure. */
token_buffer = NULL;
- if (unlexed >= 0)
+ if (unlexed != tok_undef)
{
+ token_t res = unlexed;
symval = unlexed_symval;
- c = unlexed;
- unlexed = -1;
- return c;
+ unlexed = tok_undef;
+ return res;
}
c = skip_white_space ();
case '\'':
/* parse the literal token and compute character code in code */
- translations = -1;
{
int code, discode;
case '\"':
/* parse the literal string token and treat as an identifier */
- translations = -1;
{
int code; /* ignored here */
}
case ',':
+ token_buffer = ",";
return tok_comma;
case ':':
+ token_buffer = ":";
return tok_colon;
case ';':
+ token_buffer = ";";
return tok_semicolon;
case '|':
+ token_buffer = "|";
return tok_bar;
case '{':
+ token_buffer = "{";
return tok_left_curly;
case '=':
+ obstack_1grow (&token_obstack, c);
do
{
c = getc (finput);
+ obstack_1grow (&token_obstack, c);
if (c == '\n')
lineno++;
}
while (c == ' ' || c == '\n' || c == '\t');
+ obstack_1grow (&token_obstack, '\0');
+ token_buffer = obstack_finish (&token_obstack);
if (c == '{')
{
- token_buffer = "={";
return tok_left_curly;
}
else
return parse_percent_token ();
default:
+ obstack_1grow (&token_obstack, c);
+ obstack_1grow (&token_obstack, '\0');
+ token_buffer = obstack_finish (&token_obstack);
return tok_illegal;
}
}
static int
option_strcmp (const char *left, const char *right)
{
- const unsigned char *l, *r;
- int c;
-
- assert(left != NULL && right != NULL);
- l = (const unsigned char *)left;
- r = (const unsigned char *)right;
- while (((c = *l - *r++) == 0 && *l != '\0')
- || ((*l == '-' || *l == '_') && (*r == '_' || *r == '-')))
- l++;
- return c;
+ const unsigned char *l, *r;
+ int c;
+
+ assert (left);
+ assert (right);
+ l = (const unsigned char *)left;
+ r = (const unsigned char *)right;
+ while (((c = *l - *r++) == 0 && *l != '\0')
+ || ((*l == '-' || *l == '_') && (*r == '_' || *r == '-')))
+ l++;
+ return c;
}
/* Parse a token which starts with %.
Assumes the % has already been read and discarded. */
-int
+token_t
parse_percent_token (void)
{
- int c;
const struct option_table_struct *tx;
- c = getc (finput);
+ int c = getc (finput);
switch (c)
{
case tok_obsolete:
fatal (_("`%s' is no longer supported"), token_buffer);
break;
+
+ default:
+ /* Other cases do not apply here. */
+ break;
}
return tx->ret_val;
/* Token-type codes. */
typedef enum token_e
{
+ tok_undef, /* Not defined. Used to initial token_t vars. */
tok_eof,
tok_identifier,
tok_comma,
tok_number,
tok_expect,
tok_thong,
- tok_hdrext,
- tok_srcext,
tok_define,
tok_skel,
tok_noop,
extern bucket *symval;
extern int numval;
-void init_lex PARAMS ((void));
+void lex_init PARAMS ((void));
+void lex_free PARAMS ((void));
int skip_white_space PARAMS ((void));
-void unlex PARAMS ((int));
+void unlex PARAMS ((token_t));
void read_type_name PARAMS ((FILE *fin));
/* Return one of the token-type codes. When an identifier is seen,
token_t lex PARAMS ((void));
-int parse_percent_token PARAMS ((void));
+token_t parse_percent_token PARAMS ((void));
#endif /* !LEX_H_ */
/* 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.
This file is part of Bison, the GNU Compiler Compiler.
#include "conflicts.h"
#include "print_graph.h"
#include "muscle_tab.h"
+#include "symtab.h"
+#include "lex.h"
/* The name this program was run with, for messages. */
char *program_name;
lookahead is not enough to disambiguate the parsing. In file
conflicts. Also resolve s/r conflicts based on precedence
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_results ();
/* Output the tables and the parser to ftable. In file 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_derives ();
- if (!complain_message_count)
- output_files ();
+ output_files ();
exit (complain_message_count ? 1 : 0);
}
#include "system.h"
#include "types.h"
#include "gram.h"
-#include "xalloc.h"
#include "nullable.h"
char *nullable = NULL;
/* Operation modes. */
{opt_cmd_line, "help", no_argument, 0, 0, 'h'},
{opt_cmd_line, "version", no_argument, 0, 0, 'V'},
-
+
/* Parser. */
/* was 'a'; apparently unused -wjh */
{opt_cmd_line, "name-prefix", required_argument, 0, 0, 'p'},
/* Output. */
{opt_cmd_line, "file-prefix", required_argument, 0, 0, 'b'},
{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. */
{opt_cmd_line, "statistics", no_argument, &statistics_flag, 0, 1},
{opt_both, "file-prefix", required_argument,&spec_file_prefix,tok_setopt,'b'},
{opt_both, "name-prefix", required_argument,&spec_name_prefix,tok_setopt,'p'},
#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, "semantic-parser", 0, &semantic_parser, tok_noop, 0},
{opt_percent, "pure-parser", 0, &pure_parser, tok_noop, 0},
*/
/* 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 `-'. */
/* 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'},
/* Operation modes. */
{opt_both, "yacc", no_argument, &yacc_flag, tok_noop, 'y'},
/* 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, "no-lines", no_argument, &no_lines_flag, tok_noop, 'l'},
{opt_both, "no-parser", no_argument, &no_parser_flag, tok_noop, 'n'},
#include "obstack.h"
#include "quotearg.h"
#include "getargs.h"
-#include "xalloc.h"
#include "files.h"
#include "gram.h"
#include "LR0.h"
static int nvectors;
static int nentries;
-static short **froms;
-static short **tos;
-static short *tally;
-static short *width;
-static short *actrow;
-static short *state_count;
-static short *order;
-static short *base;
-static short *pos;
-static short *table;
-static short *check;
+static short **froms = NULL;
+static short **tos = NULL;
+static short *tally = NULL;
+static short *width = NULL;
+static short *actrow = NULL;
+static short *state_count = NULL;
+static short *order = NULL;
+static short *base = NULL;
+static short *pos = NULL;
+static short *table = NULL;
+static short *check = NULL;
static int lowzero;
static int high;
/* FIXME. */
static inline void
-output_table_data (struct obstack *oout,
- short *table_data,
- short first,
- short begin,
+output_table_data (struct obstack *oout,
+ short *table_data,
+ short first,
+ short begin,
short end)
{
int i;
int j = 1;
-
+
obstack_fgrow1 (oout, "%6d", first);
for (i = begin; i < end; ++i)
{
static 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);
muscle_insert ("translate", obstack_finish (&output_obstack));
+ XFREE (token_translations);
}
static void
output_gram (void)
{
- output_table_data (&output_obstack, rrhs,
+ output_table_data (&output_obstack, rrhs,
0, 1, nrules + 1);
muscle_insert ("prhs", obstack_finish (&output_obstack));
-
+
{
size_t yyrhs_size = 1;
short *yyrhs, *sp;
for (sp = ritem + 1, i = 1; *sp; ++sp, ++i)
yyrhs[i] = *sp > 0 ? *sp : 0;
- output_table_data (&output_obstack, yyrhs,
+ output_table_data (&output_obstack, yyrhs,
ritem[0], 1, yyrhs_size);
muscle_insert ("rhs", obstack_finish (&output_obstack));
static void
output_stos (void)
{
- output_table_data (&output_obstack, accessing_symbol,
+ output_table_data (&output_obstack, accessing_symbol,
0, 1, nstates);
muscle_insert ("stos", obstack_finish (&output_obstack));
}
muscle_insert ("toknum", obstack_finish (&output_obstack));
/* Output YYR1. */
- output_table_data (&output_obstack, rlhs,
+ output_table_data (&output_obstack, rlhs,
0, 1, nrules + 1);
muscle_insert ("r1", obstack_finish (&output_obstack));
XFREE (rlhs + 1);
for (i = 1; i < nrules; i++)
short_tab[i] = rrhs[i + 1] - rrhs[i] - 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);
muscle_insert ("r2", obstack_finish (&output_obstack));
XFREE (short_tab);
save_row (i);
}
- output_table_data (&output_obstack, yydefact,
+ output_table_data (&output_obstack, yydefact,
yydefact[0], 1, nstates);
muscle_insert ("defact", obstack_finish (&output_obstack));
-
+
XFREE (actrow);
XFREE (yydefact);
}
yydefgoto[i - ntokens] = default_state;
}
- output_table_data (&output_obstack, yydefgoto,
+ output_table_data (&output_obstack, yydefgoto,
yydefgoto[0], 1, nsyms - ntokens);
muscle_insert ("defgoto", obstack_finish (&output_obstack));
output_base (void)
{
/* Output pact. */
- output_table_data (&output_obstack, base,
+ output_table_data (&output_obstack, base,
base[0], 1, nstates);
muscle_insert ("pact", obstack_finish (&output_obstack));
/* Output pgoto. */
- output_table_data (&output_obstack, base,
+ output_table_data (&output_obstack, base,
base[nstates], nstates + 1, nvectors);
muscle_insert ("pgoto", obstack_finish (&output_obstack));
static void
output_table (void)
{
- output_table_data (&output_obstack, table,
+ output_table_data (&output_obstack, table,
table[0], 1, high + 1);
muscle_insert ("table", obstack_finish (&output_obstack));
XFREE (table);
static void
output_check (void)
{
- output_table_data (&output_obstack, check,
+ output_table_data (&output_obstack, check,
check[0], 1, high + 1);
muscle_insert ("check", obstack_finish (&output_obstack));
XFREE (check);
output_stos ();
output_rule_data ();
output_actions ();
-
+
#if 0
if (!no_parser_flag) */
#endif
#include "system.h"
-#include "xalloc.h"
#include "files.h"
#include "gram.h"
#include "LR0.h"
static void
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
\f
-/*================================\
+/*--------------------------------.
| Report information on a state. |
-\================================*/
+`--------------------------------*/
static void
-print_core (int state)
+print_core (FILE *out, int state)
{
int i;
int k;
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++)
{
- obstack_fgrow1 (&output_obstack, "%s ", tags[*sp]);
+ fprintf (out, "%s ", tags[*sp]);
}
- obstack_1grow (&output_obstack, '.');
+ fputc ('.', out);
while (*sp > 0)
{
- obstack_fgrow1 (&output_obstack, " %s", tags[*sp]);
+ fprintf (out, " %s", tags[*sp]);
sp++;
}
- obstack_fgrow1 (&output_obstack, _(" (rule %d)"), rule);
- obstack_1grow (&output_obstack, '\n');
+ fprintf (out, _(" (rule %d)"), rule);
+ fputc ('\n', out);
}
- obstack_1grow (&output_obstack, '\n');
+ fputc ('\n', out);
}
static void
-print_actions (int state)
+print_actions (FILE *out, int state)
{
int i;
int k;
if (!shiftp && !redp)
{
if (final_state == state)
- obstack_sgrow (&output_obstack, _(" $default\taccept\n"));
+ fprintf (out, _(" $default\taccept\n"));
else
- obstack_sgrow (&output_obstack, _(" NO ACTIONS\n"));
+ fprintf (out, _(" NO ACTIONS\n"));
return;
}
if (ISVAR (symbol))
break;
if (symbol == 0) /* I.e. strcmp(tags[symbol],"$")==0 */
- obstack_fgrow1 (&output_obstack,
- _(" $ \tgo to state %d\n"), state1);
+ fprintf (out,
+ _(" $ \tgo to state %d\n"), state1);
else
- obstack_fgrow2 (&output_obstack,
- _(" %-4s\tshift, and go to state %d\n"),
- tags[symbol], state1);
+ fprintf (out,
+ _(" %-4s\tshift, and go to state %d\n"),
+ tags[symbol], state1);
}
if (i > 0)
- obstack_1grow (&output_obstack, '\n');
+ fputc ('\n', out);
}
else
{
if (!errp->errs[j])
continue;
symbol = errp->errs[j];
- obstack_fgrow1 (&output_obstack, _(" %-4s\terror (nonassociative)\n"),
+ fprintf (out, _(" %-4s\terror (nonassociative)\n"),
tags[symbol]);
}
if (j > 0)
- obstack_1grow (&output_obstack, '\n');
+ fputc ('\n', out);
}
if (consistent[state] && redp)
{
rule = redp->rules[0];
symbol = rlhs[rule];
- obstack_fgrow2 (&output_obstack,
- _(" $default\treduce using rule %d (%s)\n\n"),
- rule, tags[symbol]);
+ fprintf (out, _(" $default\treduce using rule %d (%s)\n\n"),
+ rule, tags[symbol]);
}
else if (redp)
{
continue;
state1 = shiftp->shifts[i];
symbol = accessing_symbol[state1];
- obstack_fgrow2 (&output_obstack,
- _(" %-4s\tgo to state %d\n"),
- tags[symbol], state1);
+ fprintf (out, _(" %-4s\tgo to state %d\n"),
+ tags[symbol], state1);
}
- obstack_1grow (&output_obstack, '\n');
+ fputc ('\n', out);
}
}
static void
-print_state (int state)
+print_state (FILE *out, int state)
{
- obstack_sgrow (&output_obstack, "\n\n");
- obstack_fgrow1 (&output_obstack, _("state %d"), state);
- obstack_sgrow (&output_obstack, "\n\n");
- print_core (state);
- print_actions (state);
+ fputs ("\n\n", out);
+ fprintf (out, _("state %d"), state);
+ fputs ("\n\n", out);
+ print_core (out, state);
+ print_actions (out, state);
}
\f
/*-----------------------------------------.
| Print information on the whole grammar. |
`-----------------------------------------*/
-#define END_TEST(End) \
-do { \
- if (column + strlen(buffer) > (End)) \
- { \
- obstack_fgrow1 (&output_obstack, "%s\n ", buffer); \
- column = 3; \
- buffer[0] = 0; \
- } \
+#define END_TEST(End) \
+do { \
+ if (column + strlen(buffer) > (End)) \
+ { \
+ fprintf (out, "%s\n ", buffer); \
+ column = 3; \
+ buffer[0] = 0; \
+ } \
} while (0)
static void
-print_grammar (void)
+print_grammar (FILE *out)
{
int i, j;
short *rule;
int column = 0;
/* rule # : LHS -> RHS */
- obstack_1grow (&output_obstack, '\n');
- obstack_sgrow (&output_obstack, _("Grammar"));
- obstack_1grow (&output_obstack, '\n');
+ fprintf (out, "\n%s\n", _("Grammar"));
for (i = 1; i <= nrules; i++)
/* Don't print rules disabled in reduce_grammar_tables. */
if (rlhs[i] >= 0)
{
- obstack_fgrow2 (&output_obstack,
- _("rule %-4d %s ->"), i, tags[rlhs[i]]);
+ fprintf (out, _("rule %-4d %s ->"), i, tags[rlhs[i]]);
rule = &ritem[rrhs[i]];
if (*rule > 0)
while (*rule > 0)
- obstack_fgrow1 (&output_obstack, " %s", tags[*rule++]);
+ fprintf (out, " %s", tags[*rule++]);
else
- obstack_sgrow (&output_obstack, _(" /* empty */"));
- obstack_1grow (&output_obstack, '\n');
+ fprintf (out, " /* %s */\n", _("empty"));
}
/* TERMINAL (type #) : rule #s terminal is on RHS */
- obstack_sgrow (&output_obstack, "\n");
- obstack_sgrow (&output_obstack,
- _("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 (rule = &ritem[rrhs[j]]; *rule > 0; rule++)
- if (*rule == token_translations[i])
- {
- END_TEST (65);
- sprintf (buffer + strlen (buffer), " %d", j);
- break;
- }
- 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);
+ fprintf (out, "\n%s\n\n", _("Terminals, with rules where they appear"));
+ fprintf (out, "%s (-1)\n", tags[0]);
- for (j = 1; j <= nrules; j++)
- for (rule = &ritem[rrhs[j]]; *rule > 0; rule++)
- if (*rule == i)
- {
- END_TEST (65);
- sprintf (buffer + strlen (buffer), " %d", j);
- break;
- }
- obstack_fgrow1 (&output_obstack, "%s\n", buffer);
- }
- }
+ for (i = 0; i <= max_user_token_number; i++)
+ if (token_translations[i] != 2)
+ {
+ buffer[0] = 0;
+ column = strlen (tags[token_translations[i]]);
+ fputs (tags[token_translations[i]], out);
+ END_TEST (50);
+ sprintf (buffer, " (%d)", i);
- obstack_sgrow (&output_obstack, "\n");
- obstack_sgrow (&output_obstack,
- _("Nonterminals, with rules where they appear"));
- obstack_sgrow (&output_obstack, "\n\n");
+ for (j = 1; j <= nrules; j++)
+ for (rule = &ritem[rrhs[j]]; *rule > 0; rule++)
+ if (*rule == token_translations[i])
+ {
+ END_TEST (65);
+ sprintf (buffer + strlen (buffer), " %d", j);
+ break;
+ }
+ fprintf (out, "%s\n", buffer);
+ }
+
+ fprintf (out, "\n%s\n\n",
+ _("Nonterminals, with rules where they appear"));
for (i = ntokens; i <= nsyms - 1; i++)
{
int left_count = 0, right_count = 0;
}
buffer[0] = 0;
- obstack_sgrow (&output_obstack, tags[i]);
+ fputs (tags[i], out);
column = strlen (tags[i]);
sprintf (buffer, " (%d)", i);
END_TEST (0);
}
}
}
- obstack_fgrow1 (&output_obstack, "%s\n", buffer);
+ fprintf (out, "%s\n", buffer);
}
}
\f
void
print_results (void)
{
- int i;
+ if (verbose_flag)
+ {
+ int i;
- if (any_conflicts)
- print_conflicts ();
+ /* We used to use just .out if spec_name_prefix (-p) was used, but
+ that conflicts with Posix. */
+ FILE *out = xfopen (spec_verbose_file, "w");
- if (verbose_flag)
- print_grammar ();
+ size_t size = obstack_object_size (&output_obstack);
+ fwrite (obstack_finish (&output_obstack), 1, size, out);
- if (verbose_flag)
- for (i = 0; i < nstates; i++)
- print_state (i);
+ 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);
}
Boston, MA 02111-1307, USA. */
#include "system.h"
-#include "xalloc.h"
#include "files.h"
#include "gram.h"
#include "LR0.h"
#include "quotearg.h"
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,
for NAME, suitable for C strings. */
if (state > state1)
edge.type = back_edge;
- open_edge (&edge, &graph_obstack);
+ open_edge (&edge, fgraph);
/* The edge source is the current node. */
edge.sourcename = node_name;
sprintf (buff, "%d", state1);
/* FIXME: Be aware that quote uses static memory. The string
must be output immediately (which is the case here). */
edge.label = tags[symbol] ? quote (tags[symbol]) : NULL;
- output_edge (&edge, &graph_obstack);
- close_edge (&graph_obstack);
+ output_edge (&edge, fgraph);
+ close_edge (fgraph);
}
}
}
symbol = accessing_symbol[state1];
new_edge (&edge);
- open_edge (&edge, &graph_obstack);
+ open_edge (&edge, fgraph);
edge.sourcename = node_name;
sprintf (buff, "%d", state1);
edge.targetname = buff;
edge.color = red;
edge.label = tags[symbol] ? quote (tags[symbol]) : NULL;
- output_edge (&edge, &graph_obstack);
- close_edge (&graph_obstack);
+ output_edge (&edge, fgraph);
+ close_edge (fgraph);
}
}
}
new_node (&node); /* Set node attributs default value. */
sprintf (name, "%d", state);
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. */
print_actions (state, node.title, &node_obstack);
obstack_sgrow (&node_obstack, "\"\n"); /* Close Label. */
-
- close_node (&node_obstack);
- }
-
- /* `obstack_cat' NODE_OBSTACK to GRAPH_OBSTACK. */
- obstack_grow (&graph_obstack,
- obstack_base (&node_obstack),
- obstack_object_size (&node_obstack));
- obstack_finish (&node_obstack);
+ }
+
+ open_node (fgraph);
+ /* Output a VCG formatted attributs list. */
+ output_node (&node, fgraph);
+ /* Save the node label. */
+ fwrite (obstack_base (&node_obstack),
+ obstack_object_size (&node_obstack), 1, fgraph);
+ close_node (fgraph);
+
+ obstack_free (&node_obstack, 0);
}
\f
print_graph (void)
{
int i;
-
+
if (!graph_flag)
return;
+
+ /* Output file. */
+ fgraph = xfopen (spec_graph_file, "w");
+
new_graph (&graph);
#if 0
#endif
graph.display_edge_labels = yes;
- graph.layoutalgorithm = 0;
+ graph.layoutalgorithm = normal;
graph.port_sharing = no;
graph.finetuning = yes;
graph.crossing_weight = median;
/* Output graph options. */
- open_graph (&graph_obstack);
- output_graph (&graph, &graph_obstack);
+ open_graph (fgraph);
+ output_graph (&graph, fgraph);
for (i = 0; i < nstates; i++)
/* Output nodes & edges. */
print_state (i);
/* Close graph. */
- close_graph (&graph, &graph_obstack);
+ close_graph (&graph, fgraph);
+ xfclose (fgraph);
}
#include "quote.h"
#include "getargs.h"
#include "files.h"
-#include "xalloc.h"
#include "symtab.h"
#include "options.h"
#include "lex.h"
if (!no_lines_flag)
{
obstack_fgrow2 (&attrs_obstack, muscle_find ("linef"),
- lineno, quotearg_style (c_quoting_style,
+ lineno, quotearg_style (c_quoting_style,
muscle_find("filename")));
}
#endif
static void
parse_token_decl (symbol_class what_is, symbol_class what_is_not)
{
- token_t token = 0;
- char *typename = 0;
+ token_t token = tok_undef;
+ char *typename = NULL;
/* The symbol being defined. */
struct bucket *symbol = NULL;
/* symbol and symval combined are only one symbol */
nsyms--;
}
- translations = 1;
symbol = NULL;
}
else if (token == tok_identifier)
else if (symbol && token == tok_number)
{
symbol->user_token_number = numval;
- translations = 1;
}
else
{
if (prev == tok_identifier)
{
symval->user_token_number = numval;
- translations = 1;
}
else
{
if (no_lines_flag)
obstack_1grow (&attrs_obstack, '\n');
-
+
obstack_init (&union_obstack);
obstack_sgrow (&union_obstack, "union");
if (defines_flag)
while (c != EOF)
{
- obstack_1grow (&union_obstack, c);
- if (defines_flag)
- obstack_1grow (&defines_obstack, c);
+ /* If C contains '/', it is output by copy_comment (). */
+ if (c != '/')
+ {
+ obstack_1grow (&attrs_obstack, c);
+ if (defines_flag)
+ obstack_1grow (&defines_obstack, c);
+ }
switch (c)
{
char *typename = 0;
int usrtoknum;
- translations = 1;
token = lex (); /* fetch typename or first token */
if (token == tok_typename)
{
nsyms--;
}
-/* FIXME. */
-
static void
parse_muscle_decl (void)
{
copy_identifier (finput, &muscle_obstack);
obstack_1grow (&muscle_obstack, 0);
muscle_key = obstack_finish (&muscle_obstack);
-
+
/* Read value. */
ch = skip_white_space ();
if (ch != '"')
/* 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 |
| any `%' declarations, and copy the contents of any `%{ ... %}' |
parse_assoc_decl (non_assoc);
break;
- case tok_hdrext:
- parse_header_extension_decl ();
- break;
-
- case tok_srcext:
- parse_source_extension_decl ();
- break;
-
case tok_define:
parse_muscle_decl ();
break;
-
+
case tok_skel:
parse_skel_decl ();
break;
if (!no_lines_flag)
{
obstack_fgrow2 (&action_obstack, muscle_find ("linef"),
- lineno, quotearg_style (c_quoting_style,
+ lineno, quotearg_style (c_quoting_style,
muscle_find ("filename")));
}
obstack_1grow (&action_obstack, '{');
{
char c;
struct obstack el_obstack;
-
+
obstack_init (&el_obstack);
while ((c = getc (finput)) != EOF)
obstack_1grow (&el_obstack, c);
-
+
obstack_1grow (&el_obstack, 0);
muscle_insert ("epilogue", obstack_finish (&el_obstack));
}
continue;
obstack_fgrow2 (oout, "# define\t%s\t%d\n",
- symbol,
- (translations ? bp->user_token_number : bp->value));
+ symbol, bp->user_token_number);
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);
}
}
static void
packsymbols (void)
{
- bucket *bp;
+ bucket *bp = NULL;
int tokno = 1;
- int i;
+ int i, j;
int last_user_token_number;
static char DOLLAR[] = "$";
if (bp->class == token_sym)
{
- if (translations && !(bp->user_token_number))
+ if (!bp->user_token_number)
bp->user_token_number = ++last_user_token_number;
if (bp->user_token_number > max_user_token_number)
max_user_token_number = bp->user_token_number;
user_toknums[bp->value] = bp->user_token_number;
sprec[bp->value] = bp->prec;
sassoc[bp->value] = bp->assoc;
-
}
- if (translations)
- {
- int j;
+ token_translations = XCALLOC (short, max_user_token_number + 1);
- 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;
- /* 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)
- {
- 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;
- }
+ 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;
- output_token_defines (&output_obstack);
- obstack_1grow (&output_obstack, 0);
- muscle_insert ("tokendef", obstack_finish (&output_obstack));
+ {
+ struct obstack tokendefs;
+ 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 (!no_parser_flag)
start_flag = 0;
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;
nvars = 0;
nrules = 0;
grammar = NULL;
- init_lex ();
+ lex_init ();
lineno = 1;
/* Initialize the muscle obstack. */
packsymbols ();
/* Convert the grammar into the format described in gram.h. */
packgram ();
- /* Free the symbol table data structure since symbols are now all
- referred to by symbol number. */
- free_symtab ();
}
#include "getargs.h"
#include "files.h"
#include "gram.h"
-#include "xalloc.h"
#include "complain.h"
#include "reduce.h"
#include "reader.h"
useless_nonterminals (void)
{
BSet Np, Ns;
- int i, n;
+ int i;
/* 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. */
saved to be used when finding useful productions: only
productions in this set will appear in the final grammar. */
- n = 0;
while (1)
{
for (i = WORDSIZE (nvars) - 1; i >= 0; i--)
inaccessable_symbols (void)
{
BSet Vp, Vs, Pp;
- int i, n;
+ int i;
short t;
rule r;
SETBIT (V, start_symbol);
- n = 0;
while (1)
{
for (i = WORDSIZE (nsyms) - 1; i >= 0; i--)
#include "system.h"
-#include "xalloc.h"
#include "symtab.h"
#include "gram.h"
if (bp->type_name)
XFREE (bp->type_name);
#endif
+ XFREE (bp->tag);
XFREE (bp);
bp = bptmp;
}
# define PARAMS(p) ()
#endif
-
+# include "xalloc.h"
/*---------------------.
| Missing prototypes. |
# define LOCALEDIR "/usr/local/share/locale"
#endif
-#endif /* BISON_SYSTEM_H */
-
/*-----------.
| Booleans. |
| Obstacks. |
`-----------*/
-#define obstack_chunk_alloc xmalloc
-#define obstack_chunk_free free
-#include "obstack.h"
+# define obstack_chunk_alloc xmalloc
+# define obstack_chunk_free free
+# include "obstack.h"
#define obstack_sgrow(Obs, Str) \
obstack_grow (Obs, Str, strlen (Str))
# define BISON_HAIRY "c:/usr/local/lib/bison.hairy"
# endif
#endif
+
+
+/*---------------------------------.
+| Debugging the memory allocator. |
+`---------------------------------*/
+
+# if WITH_DMALLOC
+# define DMALLOC_FUNC_CHECK
+# include <dmalloc.h>
+# endif /* WITH_DMALLOC */
+
+#endif /* BISON_SYSTEM_H */
#include "system.h"
#include "vcg.h"
#include "vcg_defaults.h"
-#include "xalloc.h"
-#include "complain.h"
/* Initialize a graph with the default values. */
void
g->textmode = G_TEXTMODE;
g->shape = G_SHAPE;
+ g->vertical_order = G_VERTICAL_ORDER;
+ g->horizontal_order = G_HORIZONTAL_ORDER;
+
g->xmax = G_XMAX; /* Not output. */
g->ymax = G_YMAX; /* Not output. */
case orchid: return "orchid";
case black: return "black";
default:
- complain (_("vcg graph: no such color."));
- return get_color_str(G_COLOR);
+ assert (!"Not a default color.");
}
return NULL;
}
case left_justify: return "left_justify";
case right_justify: return "right_justify";
default:
- complain (_("vcg graph: no such text mode"));
- return get_textmode_str(G_TEXTMODE);
+ assert (!"Not a text mode.");
}
return NULL;
}
case ellipse: return "ellipse";
case triangle: return "triangle";
default:
- complain (_("vcg graph: no such shape"));
- return get_shape_str(G_SHAPE);
+ assert (!"Not a shape.");
}
return NULL;
}
case dfs: return "dfs";
case tree: return "tree";
default:
- return "normal";
+ assert (!"Not a layout algorithm.");
}
return NULL;
}
static const char *
-get_decision_str (enum decision_e d, enum decision_e defaults)
+get_decision_str (enum decision_e d)
{
switch (d)
{
case no: return "no";
case yes: return "yes";
default:
- complain (_("vcg graph: no such decision"));
- return get_decision_str(defaults, 0);
+ assert (!"Either yes nor no.");
}
return NULL;
}
case left_to_right: return "left_to_right";
case right_to_left: return "right_to_left";
default:
- complain (_("vcg graph: no such an orientation"));
- return get_orientation_str(G_ORIENTATION);
+ assert (!"Not an orientation.");
}
return NULL;
}
case top: return "top";
case bottom: return "bottom";
default:
- complain (_("vcg graph: no such an alignement"));
- return get_node_alignement_str(G_NODE_ALIGNEMENT);
+ assert (!"Not an alignement.");
}
return NULL;
}
case fixed: return "fixed";
case free_a: return "free";
default:
- complain (_("vcg graph: no such an arrow mode"));
- return get_arrow_mode_str(G_ARROW_MODE);
+ assert (!"Not an arrow mode.");
}
return NULL;
}
case barymedian: return "barymedian";
case medianbary: return "medianbary";
default:
- complain (_("vcg graph: no such crossing_type"));
- return get_crossing_type_str(G_CROSSING_WEIGHT);
+ assert (!"Not a crossing type.");
}
return NULL;
}
case fcfish: return "fcfish";
case fpfish: return "fpfish";
default:
- complain (_("vcg graph: no such view"));
- return get_view_str(G_VIEW);
+ assert (!"Not a view.");
}
return NULL;
}
case dotted: return "dotted";
case invisible: return "invisible";
default:
- complain (_("vcg graph: no such linestyle"));
- return get_linestyle_str(E_LINESTYLE);
+ assert (!"Not a line style.");
}
return NULL;
}
case line: return "line";
case none: return "none";
default:
- complain (_("vcg graph: no such an arrowstyle"));
- return get_arrowstyle_str(E_ARROWSTYLE);
+ assert (!"Not an arrow style.");
}
return NULL;
}
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) |
`-------------------------------------*/
void
-open_edge(edge_t *edge, struct obstack *os)
+open_edge(edge_t *edge, FILE *fout)
{
switch (edge->type)
{
case normal_edge:
- obstack_sgrow (os, "\tedge: {\n");
+ fputs ("\tedge: {\n", fout);
break;
case back_edge:
- obstack_sgrow (os, "\tbackedge: {\n");
+ fputs ("\tbackedge: {\n", fout);
break;
case near_edge:
- obstack_sgrow (os, "\tnearedge: {\n");
+ fputs ("\tnearedge: {\n", fout);
break;
case bent_near_edge:
- obstack_sgrow (os, "\tbentnearedge: {\n");
+ fputs ("\tbentnearedge: {\n", fout);
break;
default:
- obstack_sgrow (os, "\tedge: {\n");
+ fputs ("\tedge: {\n", fout);
}
}
void
-close_edge(struct obstack *os)
+close_edge(FILE *fout)
{
- obstack_sgrow (os, "\t}\n");
+ fputs ("\t}\n", fout);
}
void
-open_node(struct obstack *os)
+open_node(FILE *fout)
{
- obstack_sgrow (os, "\tnode: {\n");
+ fputs ("\tnode: {\n", fout);
}
void
-close_node(struct obstack *os)
+close_node(FILE *fout)
{
- obstack_sgrow (os, "\t}\n");
+ fputs ("\t}\n", fout);
}
void
-open_graph(struct obstack *os)
+open_graph(FILE *fout)
{
- obstack_sgrow (os, "graph: {\n");
+ fputs ("graph: {\n", fout);
}
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;
for (node = graph->node_list; node; node = node->next)
{
- open_node (os);
- output_node (node, os);
- close_node (os);
+ open_node (fout);
+ output_node (node, fout);
+ close_node (fout);
}
}
- obstack_1grow (os, '\n');
+ fputc ('\n', fout);
{
edge_t *edge;
for (edge = graph->edge_list; edge; edge = edge->next)
{
- open_edge (edge, os);
- output_edge (edge, os);
- close_edge (os);
+ open_edge (edge, fout);
+ output_edge (edge, fout);
+ close_edge (fout);
}
}
- obstack_sgrow (os, "}\n");
+ fputs ("}\n", fout);
}
/*-------------------------------------------.
-| Output functions (formatted) in obstack os |
+| Output functions (formatted) in file FOUT |
`-------------------------------------------*/
void
-output_node (node_t *node, struct obstack *os)
+output_node (node_t *node, FILE *fout)
{
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)
- 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))
- 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)
- 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)
- 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)
- obstack_fgrow1 (os, "\t\twidth:\t%d\n", node->width);
+ fprintf (fout, "\t\twidth:\t%d\n", node->width);
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)
- obstack_fgrow1 (os, "\t\tshrink:\t%d\n", node->shrink);
+ fprintf (fout, "\t\tshrink:\t%d\n", node->shrink);
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)
- obstack_fgrow1 (os, "\t\tfolding:\t%d\n", node->folding);
+ fprintf (fout, "\t\tfolding:\t%d\n", node->folding);
if (node->textmode != N_TEXTMODE)
- obstack_fgrow1 (os, "\t\ttextmode:\t%s\n",
- get_textmode_str (node->textmode));
+ fprintf (fout, "\t\ttextmode:\t%s\n",
+ get_textmode_str (node->textmode));
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)
- obstack_fgrow1 (os, "\t\tborderwidth:\t%d\n", node->borderwidth);
+ fprintf (fout, "\t\tborderwidth:\t%d\n", node->borderwidth);
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)
- obstack_fgrow1 (os, "\t\ttextcolor:\t%s\n",
- get_color_str (node->textcolor));
+ fprintf (fout, "\t\ttextcolor:\t%s\n",
+ get_color_str (node->textcolor));
if (node->bordercolor != N_BORDERCOLOR)
- obstack_fgrow1 (os, "\t\tbordercolor:\t%s\n",
- get_color_str (node->bordercolor));
+ fprintf (fout, "\t\tbordercolor:\t%s\n",
+ get_color_str (node->bordercolor));
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])
- 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])
- obstack_fgrow1 (os, "\t\tinfo3:\t\"%s\"\n", node->infos[2]);
+ fprintf (fout, "\t\tinfo3:\t\"%s\"\n", node->infos[2]);
}
void
-output_edge (edge_t *edge, struct obstack *os)
+output_edge (edge_t *edge, FILE *fout)
{
/* FIXME: SOURCENAME and TARGETNAME are mandatory
so it has to be fatal not to give these informations. */
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)
- obstack_fgrow1 (os, "\t\ttargetname:\t\"%s\"\n", edge->targetname);
+ fprintf (fout, "\t\ttargetname:\t\"%s\"\n", edge->targetname);
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)
- obstack_fgrow1 (os, "\t\tlinestyle:\t\"%s\"\n",
- get_linestyle_str(edge->linestyle));
+ fprintf (fout, "\t\tlinestyle:\t\"%s\"\n",
+ get_linestyle_str(edge->linestyle));
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)
- obstack_fgrow1 (os, "\t\tclass:\t%d\n", edge->class);
+ fprintf (fout, "\t\tclass:\t%d\n", edge->class);
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)
- obstack_fgrow1 (os, "\t\ttextcolor:\t%s\n",
- get_color_str (edge->textcolor));
+ fprintf (fout, "\t\ttextcolor:\t%s\n",
+ get_color_str (edge->textcolor));
if (edge->arrowcolor != E_ARROWCOLOR)
- obstack_fgrow1 (os, "\t\tarrowcolor:\t%s\n",
- get_color_str (edge->arrowcolor));
+ fprintf (fout, "\t\tarrowcolor:\t%s\n",
+ get_color_str (edge->arrowcolor));
if (edge->backarrowcolor != E_BACKARROWCOLOR)
- obstack_fgrow1 (os, "\t\tbackarrowcolor:\t%s\n",
- get_color_str (edge->backarrowcolor));
+ fprintf (fout, "\t\tbackarrowcolor:\t%s\n",
+ get_color_str (edge->backarrowcolor));
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)
- obstack_fgrow1 (os, "\t\tbackarrowsize:\t%d\n", edge->backarrowsize);
+ fprintf (fout, "\t\tbackarrowsize:\t%d\n", edge->backarrowsize);
if (edge->arrowstyle != E_ARROWSTYLE)
- obstack_fgrow1 (os, "\t\tarrowstyle:\t%s\n",
- get_arrowstyle_str(edge->arrowstyle));
+ fprintf (fout, "\t\tarrowstyle:\t%s\n",
+ get_arrowstyle_str(edge->arrowstyle));
if (edge->backarrowstyle != E_BACKARROWSTYLE)
- obstack_fgrow1 (os, "\t\tbackarrowstyle:\t%s\n",
- get_arrowstyle_str(edge->backarrowstyle));
+ fprintf (fout, "\t\tbackarrowstyle:\t%s\n",
+ get_arrowstyle_str(edge->backarrowstyle));
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)
- 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)
- obstack_fgrow1 (os, "\t\thorizontal_order:\t%d\n", edge->horizontal_order);
+ fprintf (fout, "\t\thorizontal_order:\t%d\n", edge->horizontal_order);
}
void
-output_graph (graph_t *graph, struct obstack *os)
+output_graph (graph_t *graph, FILE *fout)
{
if (graph->title)
- obstack_fgrow1 (os, "\ttitle:\t\"%s\"\n", graph->title);
+ fprintf (fout, "\ttitle:\t\"%s\"\n", graph->title);
if (graph->label)
- obstack_fgrow1 (os, "\tlabel:\t\"%s\"\n", graph->label);
+ fprintf (fout, "\tlabel:\t\"%s\"\n", graph->label);
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])
- obstack_fgrow1 (os, "\tinfo2:\t\"%s\"\n", graph->infos[1]);
+ fprintf (fout, "\tinfo2:\t\"%s\"\n", graph->infos[1]);
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)
- 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)
- 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)
- obstack_fgrow1 (os, "\tbordercolor:\t%s\n",
- get_color_str (graph->bordercolor));
+ fprintf (fout, "\tbordercolor:\t%s\n",
+ get_color_str (graph->bordercolor));
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)
- obstack_fgrow1 (os, "\theight:\t%d\n", graph->height);
+ fprintf (fout, "\theight:\t%d\n", graph->height);
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)
- obstack_fgrow1 (os, "\tx:\t%d\n", graph->x);
+ fprintf (fout, "\tx:\t%d\n", graph->x);
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)
- obstack_fgrow1 (os, "\tfolding:\t%d\n", graph->folding);
+ fprintf (fout, "\tfolding:\t%d\n", graph->folding);
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)
- obstack_fgrow1 (os, "\tstretch:\t%d\n", graph->stretch);
+ fprintf (fout, "\tstretch:\t%d\n", graph->stretch);
if (graph->textmode != G_TEXTMODE)
- obstack_fgrow1 (os, "\ttextmode:\t%s\n",
- get_textmode_str (graph->textmode));
+ fprintf (fout, "\ttextmode:\t%s\n",
+ get_textmode_str (graph->textmode));
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)
- obstack_fgrow1 (os, "\txmax:\t%d\n", graph->xmax);
+ fprintf (fout, "\txmax:\t%d\n", graph->xmax);
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)
- obstack_fgrow1 (os, "\txbase:\t%d\n", graph->xbase);
+ fprintf (fout, "\txbase:\t%d\n", graph->xbase);
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)
- obstack_fgrow1 (os, "\txspace:\t%d\n", graph->xspace);
+ fprintf (fout, "\txspace:\t%d\n", graph->xspace);
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)
- obstack_fgrow1 (os, "\txlspace:\t%d\n", graph->xlspace);
+ fprintf (fout, "\txlspace:\t%d\n", graph->xlspace);
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)
- obstack_fgrow1 (os, "\tyraster:\t%d\n", graph->yraster);
+ fprintf (fout, "\tyraster:\t%d\n", graph->yraster);
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)
- 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)
{
struct classname_s *ite;
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)
- obstack_fgrow1 (os, "\tlayoutalgorithm:\t%s\n",
- get_layoutalgorithm_str(graph->layoutalgorithm));
+ fprintf (fout, "\tlayoutalgorithm:\t%s\n",
+ get_layoutalgorithm_str(graph->layoutalgorithm));
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)
- 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)
- 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)
- obstack_fgrow1 (os, "\tlayout_splinefactor:\t%d\n",
- graph->layout_splinefactor);
+ fprintf (fout, "\tlayout_splinefactor:\t%d\n",
+ graph->layout_splinefactor);
if (graph->late_edge_labels != G_LATE_EDGE_LABELS)
- obstack_fgrow1 (os, "\tlate_edge_labels:\t%s\n",
- get_decision_str(graph->late_edge_labels,
- G_LATE_EDGE_LABELS));
+ fprintf (fout, "\tlate_edge_labels:\t%s\n",
+ get_decision_str(graph->late_edge_labels));
if (graph->display_edge_labels != G_DISPLAY_EDGE_LABELS)
- obstack_fgrow1 (os, "\tdisplay_edge_labels:\t%s\n",
- get_decision_str(graph->display_edge_labels,
- G_DISPLAY_EDGE_LABELS));
+ fprintf (fout, "\tdisplay_edge_labels:\t%s\n",
+ get_decision_str(graph->display_edge_labels));
if (graph->dirty_edge_labels != G_DIRTY_EDGE_LABELS)
- obstack_fgrow1 (os, "\tdirty_edge_labels:\t%s\n",
- get_decision_str(graph->dirty_edge_labels,
- G_DIRTY_EDGE_LABELS));
+ fprintf (fout, "\tdirty_edge_labels:\t%s\n",
+ get_decision_str(graph->dirty_edge_labels));
if (graph->finetuning != G_FINETUNING)
- obstack_fgrow1 (os, "\tfinetuning:\t%s\n",
- get_decision_str(graph->finetuning, G_FINETUNING));
+ fprintf (fout, "\tfinetuning:\t%s\n",
+ get_decision_str(graph->finetuning));
if (graph->ignore_singles != G_IGNORE_SINGLES)
- obstack_fgrow1 (os, "\tignore_singles:\t%s\n",
- get_decision_str(graph->ignore_singles, G_IGNORE_SINGLES));
+ fprintf (fout, "\tignore_singles:\t%s\n",
+ get_decision_str(graph->ignore_singles));
if (graph->straight_phase != G_STRAIGHT_PHASE)
- obstack_fgrow1 (os, "\tstraight_phase:\t%s\n",
- get_decision_str(graph->straight_phase, G_STRAIGHT_PHASE));
+ fprintf (fout, "\tstraight_phase:\t%s\n",
+ get_decision_str(graph->straight_phase));
if (graph->priority_phase != G_PRIORITY_PHASE)
- obstack_fgrow1 (os, "\tpriority_phase:\t%s\n",
- get_decision_str(graph->priority_phase, G_PRIORITY_PHASE));
+ fprintf (fout, "\tpriority_phase:\t%s\n",
+ get_decision_str(graph->priority_phase));
if (graph->manhattan_edges != G_MANHATTAN_EDGES)
- obstack_fgrow1 (os,
- "\tmanhattan_edges:\t%s\n",
- get_decision_str(graph->manhattan_edges,
- G_MANHATTAN_EDGES));
+ fprintf (fout,
+ "\tmanhattan_edges:\t%s\n",
+ get_decision_str(graph->manhattan_edges));
if (graph->smanhattan_edges != G_SMANHATTAN_EDGES)
- obstack_fgrow1 (os,
- "\tsmanhattan_edges:\t%s\n",
- get_decision_str(graph->smanhattan_edges,
- G_SMANHATTAN_EDGES));
+ fprintf (fout,
+ "\tsmanhattan_edges:\t%s\n",
+ get_decision_str(graph->smanhattan_edges));
if (graph->near_edges != G_NEAR_EDGES)
- obstack_fgrow1 (os, "\tnear_edges:\t%s\n",
- get_decision_str(graph->near_edges, G_NEAR_EDGES));
+ fprintf (fout, "\tnear_edges:\t%s\n",
+ get_decision_str(graph->near_edges));
if (graph->orientation != G_ORIENTATION)
- obstack_fgrow1 (os, "\torientation:\t%s\n",
- get_decision_str(graph->orientation, G_ORIENTATION));
+ fprintf (fout, "\torientation:\t%s\n",
+ get_orientation_str(graph->orientation));
if (graph->node_alignement != G_NODE_ALIGNEMENT)
- obstack_fgrow1 (os, "\tnode_alignement:\t%s\n",
- get_decision_str(graph->node_alignement,
- G_NODE_ALIGNEMENT));
+ fprintf (fout, "\tnode_alignement:\t%s\n",
+ get_node_alignement_str(graph->node_alignement));
if (graph->port_sharing != G_PORT_SHARING)
- obstack_fgrow1 (os, "\tport_sharing:\t%s\n",
- get_decision_str(graph->port_sharing, G_PORT_SHARING));
+ fprintf (fout, "\tport_sharing:\t%s\n",
+ get_decision_str(graph->port_sharing));
if (graph->arrow_mode != G_ARROW_MODE)
- obstack_fgrow1 (os, "\tarrow_mode:\t%s\n",
- get_arrow_mode_str(graph->arrow_mode));
+ fprintf (fout, "\tarrow_mode:\t%s\n",
+ get_arrow_mode_str(graph->arrow_mode));
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)
- obstack_fgrow1 (os, "\tspreadlevel:\t%d\n", graph->spreadlevel);
+ fprintf (fout, "\tspreadlevel:\t%d\n", graph->spreadlevel);
if (graph->crossing_weight != G_CROSSING_WEIGHT)
- obstack_fgrow1 (os, "\tcrossing_weight:\t%s\n",
- get_crossing_type_str(graph->crossing_weight));
+ fprintf (fout, "\tcrossing_weight:\t%s\n",
+ get_crossing_type_str(graph->crossing_weight));
if (graph->crossing_phase2 != G_CROSSING_PHASE2)
- obstack_fgrow1 (os, "\tcrossing_phase2:\t%s\n",
- get_decision_str(graph->crossing_phase2,
- G_CROSSING_PHASE2));
+ fprintf (fout, "\tcrossing_phase2:\t%s\n",
+ get_decision_str(graph->crossing_phase2));
if (graph->crossing_optimization != G_CROSSING_OPTIMIZATION)
- obstack_fgrow1 (os, "\tcrossing_optimization:\t%s\n",
- get_decision_str(graph->crossing_optimization,
- G_CROSSING_OPTIMIZATION));
+ fprintf (fout, "\tcrossing_optimization:\t%s\n",
+ get_decision_str(graph->crossing_optimization));
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)
- obstack_fgrow1 (os, "\tedges:\t%s\n", get_decision_str(graph->edges,
- G_EDGES));
+ fprintf (fout, "\tedges:\t%s\n", get_decision_str(graph->edges));
if (graph->nodes != G_NODES)
- obstack_fgrow1 (os,"\tnodes:\t%s\n",
- get_decision_str(graph->nodes, G_NODES));
+ fprintf (fout,"\tnodes:\t%s\n", get_decision_str(graph->nodes));
if (graph->splines != G_SPLINES)
- obstack_fgrow1 (os, "\tsplines:\t%s\n",
- get_decision_str(graph->splines, G_SPLINES));
+ fprintf (fout, "\tsplines:\t%s\n", get_decision_str(graph->splines));
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)
- obstack_fgrow1 (os, "\tcmin:\t%d\n", graph->cmin);
+ fprintf (fout, "\tcmin:\t%d\n", graph->cmin);
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)
- obstack_fgrow1 (os, "\tpmin:\t%d\n", graph->pmin);
+ fprintf (fout, "\tpmin:\t%d\n", graph->pmin);
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)
- obstack_fgrow1 (os, "\trmin:\t%d\n", graph->rmin);
+ fprintf (fout, "\trmin:\t%d\n", graph->rmin);
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)
- obstack_fgrow1 (os, "\tsmax:\t%d\n", graph->smax);
+ fprintf (fout, "\tsmax:\t%d\n", graph->smax);
}
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. */
struct classname_s
{
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. */
};
+/* Structure is in infoname. */
+struct infoname_s
+{
+ int integer;
+ const char *string;
+ struct infoname_s *next;
+};
+
/* Layout Algorithms which can be found in VCG.
Details about each algoithm can be found below. */
enum layoutalgorithm_e
{
/* Title the unique string identifying the node. This attribute is
mandatory. */
- char *title;
+ const char *title;
/* 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
contain control characters like NEWLINE that influences the size of
the node. */
- char *label;
+ const char *label;
/* loc is the location as x, y position relatively to the system of
coordinates of the graph. Locations are specified in the form
/* info2, info3 can be selected from the menu. The corresponding text
labels can be shown by mouse clicks on nodes.\f
Default are null strings. */
- char *infos[3];
+ const char *infos[3];
/* Node border color.
Default is textcolor. */
index 2, green has index 3, etc.
Default is white for background and white or transparent for summary
nodes. */
- unsigned char color;
+ enum color_e color;
/* Textcolor.
need explainations ???
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
is the textcolor. 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 summary node of inner subgraphs.
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
window of the outermost graph in pixels, or width and height of the
Defalut is box, other: rhomb, ellipse, triangle. */
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
used to display the graph. This is usually larger than the displayed
By default, no class names. */
struct classname_s *classname;
- /* FIXME : infoname. */
- /* FIXME : colorentry. */
+ /* Infoname allows to introduce names for the additional text labels.
+ 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
Possibilities are maxdepth, mindepth, maxdepthslow, mindepthslow,
void add_node PARAMS ((graph_t *graph, node_t *node));
void add_edge PARAMS ((graph_t *graph, edge_t *edge));
-void open_node PARAMS ((struct obstack *os));
-void output_node PARAMS ((node_t *node, struct obstack *os));
-void close_node PARAMS ((struct obstack *os));
+void add_colorentry PARAMS ((graph_t *g, int color_idx, int red_cp,
+ int green_cp, int blue_cp));
+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_node PARAMS ((FILE *fout));
+void output_node PARAMS ((node_t *node, FILE *fout));
+void close_node PARAMS ((FILE *fout));
-void open_edge PARAMS ((edge_t *edge, struct obstack *os));
-void output_edge PARAMS ((edge_t *edge, struct obstack *os));
-void close_edge PARAMS ((struct obstack *os));
+void open_edge PARAMS ((edge_t *edge, FILE *fout));
+void output_edge PARAMS ((edge_t *edge, FILE *fout));
+void close_edge PARAMS ((FILE *fout));
-void open_graph PARAMS ((struct obstack *os));
-void output_graph PARAMS ((graph_t *graph, struct obstack *os));
-void close_graph PARAMS ((graph_t *graph, struct obstack *os));
+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_ */
# define G_TEXTMODE centered
# define G_SHAPE box
-# define G_XMAX 90 /* Not output */
-# define G_YMAX 90 /* Not output */
+# define G_VERTICAL_ORDER 0 /* Unspecified for subgraphs. */
+# 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_YBASE 5
# define G_YRASTER 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_LAYOUT_DOWNFACTOR 1
# define G_LAYOUT_UPFACTOR 1
Makefile
Makefile.in
at-*
-debug-*
atconfig
empty
experr
stderr
stdout
testsuite
+testsuite.[0-9]
+testsuite.[0-9][0-9]
+package.m4
calc.[chy]
calc.tab.*
calc
*.output *.vcg
+autom4te.cache
+bison
## Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
## 02111-1307, USA.
-# Distribute the testsuite since GNU M4 is needed to build it.
-noinst_SCRIPTS = testsuite
+EXTRA_DIST = atlocal.in $(TESTSUITE_AT) 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
- $(SHELL) $(srcdir)/testsuite
+AUTOM4TE = autom4te
+AUTOTEST = $(AUTOM4TE) --language=autotest
+$(srcdir)/$(TESTSUITE): $(TESTSUITE_AT)
+ $(AUTOTEST) -I $(srcdir) testsuite.at -o $@.tmp
+ mv $@.tmp $@
-testsuite: atgeneral.m4 suite.at $(SUITE)
- $(M4) -I $(srcdir) atgeneral.m4 suite.at | \
- sed -e 's/[ ]*$$//' | \
- sed -e '/^$$/N;/\n$$/D' > $@-tmp
- chmod +x $@-tmp
- mv $@-tmp $@
+atconfig: $(top_builddir)/config.status
+ cd $(top_builddir) && ./config.status tests/$@
-CLEANFILES = debug-*.sh empty
-DISTCLEANFILES = atconfig
-MAINTAINERCLEANFILES = testsuite
+atlocal: $(srcdir)/atlocal.in $(top_builddir)/config.status
+ cd $(top_builddir) && ./config.status tests/$@
+
+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
+++ /dev/null
-# @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
+++ /dev/null
-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
--- /dev/null
+# @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@"
--- /dev/null
+#! /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+"$@"}
-# -*- 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. ##
# 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
# AT_DATA_CALC_Y does.
-AT_DEFINE([_AT_DATA_CALC_Y],
-[ifelse([$1$2$3],
- $[1]$[2]$[3], [],
- [errprint([$0: Invalid arguments: $@
-])m4exit(1)])dnl
+m4_define([_AT_DATA_CALC_Y],
+[m4_if([$1$2$3], $[1]$[2]$[3], [],
+ [m4_fatal([$0: Invalid arguments: $@])])dnl
AT_DATA([calc.y],
[[/* Infix notation calculator--calc */
%{
#include <config.h>
+/* We don't need a perfect malloc for these tests. */
+#undef malloc
#include <stdio.h>
#if STDC_HEADERS
}
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");
else
yyin = stdin;
- if (!stdin)
+ if (!yyin)
{
perror (argv[1]);
exit (1);
# AT_DATA_CALC_Y([BISON-OPTIONS])
# -------------------------------
# Produce `calc.y'.
-AT_DEFINE([AT_DATA_CALC_Y],
+m4_define([AT_DATA_CALC_Y],
[_AT_DATA_CALC_Y($[1], $[2], $[3],
- [ifelse(regexp([$1], [--yyerror-verbose]),
- [-1], [],
- [[#define YYERROR_VERBOSE 1]])])])
+ [m4_match([$1], [--yyerror-verbose],
+ [[#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.
-# If `--debug' is passed to bison, discard all the debugging traces
-# preserving only the `parse errors'. Note that since there should be
-# none, the `grep' will fail with exit status 1.
-AT_DEFINE([_AT_CHECK_CALC],
-[ifelse(regexp([$1], [--debug]),
- [-1],
- [AT_CHECK([echo "$2" | calc],
- [0], [], [])],
- [AT_CHECK([echo "$2" | calc 2>&1 >/dev/null | grep 'parse error' >&2],
- [1], [], [])])])
-
-
-# _AT_CHECK_CALC_ERROR(BISON-OPTIONS, INPUT,
+#
+# If BISON-OPTIONS contains `--debug', then NUM-STDERR-LINES is the number
+# of expected lines on stderr.
+m4_define([_AT_CHECK_CALC],
+[AT_DATA([[input]],
+[[$2
+]])
+AT_CHECK([calc input], 0, [], [stderr])dnl
+AT_CHECK([wc -l <stderr | sed 's/[[^0-9]]//g'], 0,
+ [m4_match([$1], [--debug],
+ [$3], [0])
+])
+])
+
+
+# _AT_CHECK_CALC_ERROR(BISON-OPTIONS, INPUT, [NUM-DEBUG-LINES],
# [ERROR-LOCATION], [IF-YYERROR-VERBOSE])
# ------------------------------------------------------------
-# Run `calc' on INPUT, and expect STDERR.
-AT_DEFINE([_AT_CHECK_CALC_ERROR],
-[AT_CHECK([echo "$2" | calc 2>&1 >/dev/null | grep 'parse error' >&2], 0,
- [],
-[ifelse(regexp([$1], [--location]),
- [-1], [], [$3: ])[]dnl
+# Run `calc' on INPUT, and expect a `parse error' message.
+#
+# If BISON-OPTIONS contains `--location', then make sure the ERROR-LOCATION
+# is correctly output on stderr.
+#
+# If BISON-OPTIONS contains `--yyerror-verbose', then make sure the
+# IF-YYERROR-VERBOSE message is properly output after `parse error, '
+# on STDERR.
+#
+# 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
-ifelse(regexp([$1], [--yyerror-verbose]),
- [-1], [], [$4])[]dnl
+m4_match([$1], [--yyerror-verbose], [, $5])[]dnl
+
+])
-])])
+])
# AT_CHECK_CALC([BISON-OPTIONS], [PARSER-EXPECTED-STDERR])
# --------------------------------------------------------
# Start a testing chunk which compiles `calc' grammar with
# 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.
AT_SETUP([Calculator $1])
AT_DATA_CALC_Y([$1])
# 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], [], [])
AT_CHECK([$CC $CFLAGS $CPPFLAGS calc.c -o calc], 0, [], [])
1 - (2 - 3) = 2
2^2^3 = 256
-(2^2)^3 = 64], [$2])
+(2^2)^3 = 64], [491])
# Some parse errors.
-_AT_CHECK_CALC_ERROR([$1], [+1],
+_AT_CHECK_CALC_ERROR([$1], [+1], [8],
[1.0:1.1],
- [, unexpected `'+''])
-_AT_CHECK_CALC_ERROR([$1], [1//2],
+ [unexpected `'+''])
+_AT_CHECK_CALC_ERROR([$1], [1//2], [17],
[1.2:1.3],
- [, unexpected `'/'', expecting `NUM' or `'-'' or `'(''])
-_AT_CHECK_CALC_ERROR([$1], [error],
+ [unexpected `'/'', expecting `NUM' or `'-'' or `'(''])
+_AT_CHECK_CALC_ERROR([$1], [error], [8],
[1.0:1.1],
- [, unexpected `$undefined.'])
-_AT_CHECK_CALC_ERROR([$1], [1 = 2 = 3],
+ [unexpected `$undefined.'])
+_AT_CHECK_CALC_ERROR([$1], [1 = 2 = 3], [23],
[1.6:1.7],
- [, unexpected `'=''])
+ [unexpected `'=''])
_AT_CHECK_CALC_ERROR([$1],
[
+1],
+ [16],
[2.0:2.1],
- [, unexpected `'+''])
+ [unexpected `'+''])
AT_CLEANUP(calc calc.c calc.h calc.output)
])# AT_CHECK_CALC
--- /dev/null
+# 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])
-# -*- 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. ##
AT_CHECK([bison --defines union.y])
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)
+++ /dev/null
-#! /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])
--- /dev/null
+# 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])