From b34d96c1c3f10dcbd0b55f61f2456e46585f1b42 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 7 Jul 2005 23:16:46 +0000 Subject: [PATCH] * examples/calc++/calc++-driver.cc, examples/calc++/calc++-driver.hh: * examples/calc++/calc++-scanner.ll, examples/calc++/calc++.cc: Remove from CVS. These files are automatically generated. * examples/extexi: Clarify that this file is now part of Bison, not GNU M4, and that it works with any POSIX-compatible Awk. * examples/calc++/Makefile.am (run_extexi): Remove; not used. ($(calc_extracted)): Renamed from $(calc_sources_extracted), so that we also get calc++-parser.yy. Geneate it. Use $(AWK), not gawk, since any conforming Awk will do. Put comment before action, since older 'make' can't handle comment in action. $(BUILT_SOURCES): List all built sources, not just some of them. $(MAINTAINERCLEANFILES): Remove *.stamp, and all built sources. $($(srcdir)/calc++-parser.stamp): Work even if POSIXLY_CORRECT. $($(calc_sources_generated)): Remove unnecessary test for existence of target. (This had a shell syntax error anyway; a stray "x".) (calc_extracted): List $(srcdir)/calc++-parser.yy, not calc++-parser.yy. * examples/.cvsignore, examples/calc++/.cvsignore: New files. --- ChangeLog | 20 +++++++++++++ examples/.cvsignore | 2 ++ examples/calc++/.cvsignore | 9 ++++++ examples/calc++/Makefile.am | 26 ++++++++--------- examples/calc++/calc++-driver.cc | 37 ------------------------ examples/calc++/calc++-driver.hh | 47 ------------------------------- examples/calc++/calc++-scanner.ll | 42 --------------------------- examples/calc++/calc++.cc | 19 ------------- examples/extexi | 8 +++--- 9 files changed, 47 insertions(+), 163 deletions(-) create mode 100644 examples/.cvsignore create mode 100644 examples/calc++/.cvsignore delete mode 100644 examples/calc++/calc++-driver.cc delete mode 100644 examples/calc++/calc++-driver.hh delete mode 100644 examples/calc++/calc++-scanner.ll delete mode 100644 examples/calc++/calc++.cc diff --git a/ChangeLog b/ChangeLog index aec6d3b1..1ec5667d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,25 @@ 2005-07-07 Paul Eggert + * examples/calc++/calc++-driver.cc, examples/calc++/calc++-driver.hh: + * examples/calc++/calc++-scanner.ll, examples/calc++/calc++.cc: + Remove from CVS. These files are automatically generated. + * examples/extexi: Clarify that this file is now part of Bison, + not GNU M4, and that it works with any POSIX-compatible Awk. + * examples/calc++/Makefile.am (run_extexi): Remove; not used. + ($(calc_extracted)): Renamed from $(calc_sources_extracted), + so that we also get calc++-parser.yy. Geneate it. + Use $(AWK), not gawk, since any conforming Awk will do. + Put comment before action, since older 'make' can't handle comment + in action. + $(BUILT_SOURCES): List all built sources, not just some of them. + $(MAINTAINERCLEANFILES): Remove *.stamp, and all built sources. + $($(srcdir)/calc++-parser.stamp): Work even if POSIXLY_CORRECT. + $($(calc_sources_generated)): Remove unnecessary test for existence + of target. (This had a shell syntax error anyway; a stray "x".) + (calc_extracted): List $(srcdir)/calc++-parser.yy, not + calc++-parser.yy. + * examples/.cvsignore, examples/calc++/.cvsignore: New files. + * bootstrap (gnulib_modules): Add gettext, now that it's no longer implied by the other modules. diff --git a/examples/.cvsignore b/examples/.cvsignore new file mode 100644 index 00000000..282522db --- /dev/null +++ b/examples/.cvsignore @@ -0,0 +1,2 @@ +Makefile +Makefile.in diff --git a/examples/calc++/.cvsignore b/examples/calc++/.cvsignore new file mode 100644 index 00000000..730050f0 --- /dev/null +++ b/examples/calc++/.cvsignore @@ -0,0 +1,9 @@ +*.cc +*.hh +*.output +*.stamp +*.tmp +.deps +Makefile +Makefile.in +calc++ diff --git a/examples/calc++/Makefile.am b/examples/calc++/Makefile.am index 0894483f..627b20c9 100644 --- a/examples/calc++/Makefile.am +++ b/examples/calc++/Makefile.am @@ -32,11 +32,11 @@ $(BISON): $(BISON_IN) doc = $(top_srcdir)/doc/bison.texinfo extexi = $(top_srcdir)/examples/extexi -run_extexi = gawk -f $(extexi) -$(calc_sources_extracted): $(doc) $(extexi) # Extract in src. +$(calc_extracted): $(doc) $(extexi) cd $(srcdir) && \ - gawk -f ../extexi ../../doc/bison.texinfo -- \ + $(AWK) -f ../extexi ../../doc/bison.texinfo -- \ + calc++-parser.yy \ calc++-scanner.ll calc++.cc calc++-driver.hh calc++-driver.cc @@ -44,9 +44,9 @@ $(calc_sources_extracted): $(doc) $(extexi) ## Parser generation. ## ## ------------------- ## -# We do not use Automake features here. -BUILT_SOURCES = $(calc_sources_generated) -MAINTAINERCLEANFILES = $(calc_sources_generated) +BUILT_SOURCES = $(calc_extracted) $(calc_sources_generated) +CLEANFILES = $(srcdir)/*.output *.tmp +MAINTAINERCLEANFILES = $(srcdir)/*.stamp $(BUILT_SOURCES) # Compile the parser and save cycles. # This code comes from "Handling Tools that Produce Many Outputs", @@ -57,15 +57,13 @@ EXTRA_DIST = $(srcdir)/calc++-parser.stamp $(srcdir)/calc++-parser.yy $(srcdir)/calc++-parser.stamp: $(srcdir)/calc++-parser.yy $(BISON_IN) @rm -f calc++-parser.tmp @touch calc++-parser.tmp - $(BISON) -S lalr1.cc $(srcdir)/calc++-parser.yy -o $(srcdir)/calc++-parser.cc -d -ra + $(BISON) -d -ra -S lalr1.cc -o $(srcdir)/calc++-parser.cc \ + $(srcdir)/calc++-parser.yy @mv -f calc++-parser.tmp $@ $(calc_sources_generated): $(srcdir)/calc++-parser.stamp - @if test -f $@; then :; else x\ - rm -f $(srcdir)/calc++-parser.stamp; \ - $(MAKE) $(AM_MAKEFLAGS) $(srcdir)/calc++-parser.stamp; \ - fi - + rm -f $(srcdir)/calc++-parser.stamp + $(MAKE) $(AM_MAKEFLAGS) $(srcdir)/calc++-parser.stamp ## --------------------------- ## ## Building & testing calc++. ## @@ -74,8 +72,8 @@ $(calc_sources_generated): $(srcdir)/calc++-parser.stamp noinst_PROGRAMS = calc++ calc_sources_extracted = $(srcdir)/calc++-scanner.ll $(srcdir)/calc++.cc \ -$(srcdir)/calc++-driver.hh $(srcdir)/calc++-driver.cc -calc_extracted = $(calc_sources_extracted) calc++-parser.yy + $(srcdir)/calc++-driver.hh $(srcdir)/calc++-driver.cc +calc_extracted = $(calc_sources_extracted) $(srcdir)/calc++-parser.yy calc_sources_generated = \ $(srcdir)/stack.hh $(srcdir)/position.hh $(srcdir)/location.hh \ $(srcdir)/calc++-parser.hh $(srcdir)/calc++-parser.cc diff --git a/examples/calc++/calc++-driver.cc b/examples/calc++/calc++-driver.cc deleted file mode 100644 index cfce494d..00000000 --- a/examples/calc++/calc++-driver.cc +++ /dev/null @@ -1,37 +0,0 @@ -#line 7140 "../../doc/bison.texinfo" -#include "calc++-driver.hh" -#include "calc++-parser.hh" - -calcxx_driver::calcxx_driver () - : trace_scanning (false), trace_parsing (false) -{ - variables["one"] = 1; - variables["two"] = 2; -} - -calcxx_driver::~calcxx_driver () -{ -} - -void -calcxx_driver::parse (const std::string &f) -{ - file = f; - scan_begin (); - yy::calcxx_parser parser (*this); - parser.set_debug_level (trace_parsing); - parser.parse (); - scan_end (); -} - -void -calcxx_driver::error (const yy::location& l, const std::string& m) -{ - std::cerr << l << ": " << m << std::endl; -} - -void -calcxx_driver::error (const std::string& m) -{ - std::cerr << m << std::endl; -} diff --git a/examples/calc++/calc++-driver.hh b/examples/calc++/calc++-driver.hh deleted file mode 100644 index fc3f5c23..00000000 --- a/examples/calc++/calc++-driver.hh +++ /dev/null @@ -1,47 +0,0 @@ -#line 7036 "../../doc/bison.texinfo" -#ifndef CALCXX_DRIVER_HH -# define CALCXX_DRIVER_HH -# include -# include -#line 7051 "../../doc/bison.texinfo" -// Forward declarations. -union YYSTYPE; -namespace yy -{ - class location; - class calcxx_parser; -} -class calcxx_driver; -#line 7069 "../../doc/bison.texinfo" -// Announce to Flex the prototype we want for lexing function, ... -# define YY_DECL \ - int yylex (YYSTYPE* yylval, yy::location* yylloc, calcxx_driver& driver) -// ... and declare it for the parser's sake. -YY_DECL; -#line 7082 "../../doc/bison.texinfo" -// Conducting the whole scanning and parsing of Calc++. -class calcxx_driver -{ -public: - calcxx_driver (); - virtual ~calcxx_driver (); - - std::map variables; - - int result; -#line 7101 "../../doc/bison.texinfo" - // Handling the scanner. - void scan_begin (); - void scan_end (); - bool trace_scanning; -#line 7112 "../../doc/bison.texinfo" - // Handling the parser. - void parse (const std::string& f); - std::string file; - bool trace_parsing; -#line 7126 "../../doc/bison.texinfo" - // Error handling. - void error (const yy::location& l, const std::string& m); - void error (const std::string& m); -}; -#endif // ! CALCXX_DRIVER_HH diff --git a/examples/calc++/calc++-scanner.ll b/examples/calc++/calc++-scanner.ll deleted file mode 100644 index 750e6ca7..00000000 --- a/examples/calc++/calc++-scanner.ll +++ /dev/null @@ -1,42 +0,0 @@ -%{ /* -*- C++ -*- */ -# include -# include "calc++-driver.hh" -# include "calc++-parser.hh" -%} - -%option noyywrap nounput batch debug - -id [a-zA-Z][a-zA-Z_0-9]* -int [0-9]+ -blank [ \t] - -%{ -# define YY_USER_ACTION yylloc->columns (yyleng); -%} -%% -%{ - yylloc->step (); -%} -{blank}+ yylloc->step (); -[\n]+ yylloc->lines (yyleng); yylloc->step (); - -[-+*/] return yytext[0]; -":=" return TOKEN_ASSIGN; -{int} yylval->ival = atoi (yytext); return TOKEN_NUMBER; -{id} yylval->sval = new std::string (yytext); return TOKEN_IDENTIFIER; -. driver.error (*yylloc, "invalid character"); -%% - -void -calcxx_driver::scan_begin () -{ - yy_flex_debug = trace_scanning; - if (!(yyin = fopen (file.c_str (), "r"))) - error (std::string ("cannot open ") + file); -} - -void -calcxx_driver::scan_end () -{ - fclose (yyin); -} diff --git a/examples/calc++/calc++.cc b/examples/calc++/calc++.cc deleted file mode 100644 index 5a59d741..00000000 --- a/examples/calc++/calc++.cc +++ /dev/null @@ -1,19 +0,0 @@ -#line 7416 "../../doc/bison.texinfo" -#include -#include "calc++-driver.hh" - -int -main (int argc, const char* argv[]) -{ - calcxx_driver driver; - for (++argv; argv[0]; ++argv) - if (*argv == std::string ("-p")) - driver.trace_parsing = true; - else if (*argv == std::string ("-s")) - driver.trace_scanning = true; - else - { - driver.parse (*argv); - std::cout << driver.result << std::endl; - } -} diff --git a/examples/extexi b/examples/extexi index b7af17a1..c0f67df2 100644 --- a/examples/extexi +++ b/examples/extexi @@ -1,7 +1,7 @@ # Extract all examples from the manual source. -*- AWK -*- -# This file is part of GNU M4 -# Copyright 1992, 2000, 2001 Free Software Foundation, Inc. +# This file is part of GNU Bison +# Copyright 1992, 2000, 2001, 2005 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 @@ -18,8 +18,8 @@ # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA # 02111-1307 USA -# This script is for use with any New AWK. -# Well, now it uses ARGV/ARGC, and I don't know if it's New AWK portable. +# This script is for use with any Awk that conforms to POSIX. +# It was derived from a similar script tests/generate.awk in GNU m4. # # Usage: extexi input-file.texi ... -- [FILES to extract] BEGIN { -- 2.47.2