mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-26 12:43:03 +00:00
* 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.
This commit is contained in:
20
ChangeLog
20
ChangeLog
@@ -1,5 +1,25 @@
|
|||||||
2005-07-07 Paul Eggert <eggert@cs.ucla.edu>
|
2005-07-07 Paul Eggert <eggert@cs.ucla.edu>
|
||||||
|
|
||||||
|
* 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
|
* bootstrap (gnulib_modules): Add gettext, now that it's no longer
|
||||||
implied by the other modules.
|
implied by the other modules.
|
||||||
|
|
||||||
|
|||||||
2
examples/.cvsignore
Normal file
2
examples/.cvsignore
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
Makefile
|
||||||
|
Makefile.in
|
||||||
9
examples/calc++/.cvsignore
Normal file
9
examples/calc++/.cvsignore
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
*.cc
|
||||||
|
*.hh
|
||||||
|
*.output
|
||||||
|
*.stamp
|
||||||
|
*.tmp
|
||||||
|
.deps
|
||||||
|
Makefile
|
||||||
|
Makefile.in
|
||||||
|
calc++
|
||||||
@@ -32,11 +32,11 @@ $(BISON): $(BISON_IN)
|
|||||||
|
|
||||||
doc = $(top_srcdir)/doc/bison.texinfo
|
doc = $(top_srcdir)/doc/bison.texinfo
|
||||||
extexi = $(top_srcdir)/examples/extexi
|
extexi = $(top_srcdir)/examples/extexi
|
||||||
run_extexi = gawk -f $(extexi)
|
|
||||||
$(calc_sources_extracted): $(doc) $(extexi)
|
|
||||||
# Extract in src.
|
# Extract in src.
|
||||||
|
$(calc_extracted): $(doc) $(extexi)
|
||||||
cd $(srcdir) && \
|
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
|
calc++-scanner.ll calc++.cc calc++-driver.hh calc++-driver.cc
|
||||||
|
|
||||||
|
|
||||||
@@ -44,9 +44,9 @@ $(calc_sources_extracted): $(doc) $(extexi)
|
|||||||
## Parser generation. ##
|
## Parser generation. ##
|
||||||
## ------------------- ##
|
## ------------------- ##
|
||||||
|
|
||||||
# We do not use Automake features here.
|
BUILT_SOURCES = $(calc_extracted) $(calc_sources_generated)
|
||||||
BUILT_SOURCES = $(calc_sources_generated)
|
CLEANFILES = $(srcdir)/*.output *.tmp
|
||||||
MAINTAINERCLEANFILES = $(calc_sources_generated)
|
MAINTAINERCLEANFILES = $(srcdir)/*.stamp $(BUILT_SOURCES)
|
||||||
|
|
||||||
# Compile the parser and save cycles.
|
# Compile the parser and save cycles.
|
||||||
# This code comes from "Handling Tools that Produce Many Outputs",
|
# 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)
|
$(srcdir)/calc++-parser.stamp: $(srcdir)/calc++-parser.yy $(BISON_IN)
|
||||||
@rm -f calc++-parser.tmp
|
@rm -f calc++-parser.tmp
|
||||||
@touch 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 $@
|
@mv -f calc++-parser.tmp $@
|
||||||
|
|
||||||
$(calc_sources_generated): $(srcdir)/calc++-parser.stamp
|
$(calc_sources_generated): $(srcdir)/calc++-parser.stamp
|
||||||
@if test -f $@; then :; else x\
|
rm -f $(srcdir)/calc++-parser.stamp
|
||||||
rm -f $(srcdir)/calc++-parser.stamp; \
|
$(MAKE) $(AM_MAKEFLAGS) $(srcdir)/calc++-parser.stamp
|
||||||
$(MAKE) $(AM_MAKEFLAGS) $(srcdir)/calc++-parser.stamp; \
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
## --------------------------- ##
|
## --------------------------- ##
|
||||||
## Building & testing calc++. ##
|
## Building & testing calc++. ##
|
||||||
@@ -74,8 +72,8 @@ $(calc_sources_generated): $(srcdir)/calc++-parser.stamp
|
|||||||
noinst_PROGRAMS = calc++
|
noinst_PROGRAMS = calc++
|
||||||
|
|
||||||
calc_sources_extracted = $(srcdir)/calc++-scanner.ll $(srcdir)/calc++.cc \
|
calc_sources_extracted = $(srcdir)/calc++-scanner.ll $(srcdir)/calc++.cc \
|
||||||
$(srcdir)/calc++-driver.hh $(srcdir)/calc++-driver.cc
|
$(srcdir)/calc++-driver.hh $(srcdir)/calc++-driver.cc
|
||||||
calc_extracted = $(calc_sources_extracted) calc++-parser.yy
|
calc_extracted = $(calc_sources_extracted) $(srcdir)/calc++-parser.yy
|
||||||
calc_sources_generated = \
|
calc_sources_generated = \
|
||||||
$(srcdir)/stack.hh $(srcdir)/position.hh $(srcdir)/location.hh \
|
$(srcdir)/stack.hh $(srcdir)/position.hh $(srcdir)/location.hh \
|
||||||
$(srcdir)/calc++-parser.hh $(srcdir)/calc++-parser.cc
|
$(srcdir)/calc++-parser.hh $(srcdir)/calc++-parser.cc
|
||||||
|
|||||||
@@ -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;
|
|
||||||
}
|
|
||||||
@@ -1,47 +0,0 @@
|
|||||||
#line 7036 "../../doc/bison.texinfo"
|
|
||||||
#ifndef CALCXX_DRIVER_HH
|
|
||||||
# define CALCXX_DRIVER_HH
|
|
||||||
# include <string>
|
|
||||||
# include <map>
|
|
||||||
#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<std::string, int> 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
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
%{ /* -*- C++ -*- */
|
|
||||||
# include <string>
|
|
||||||
# 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);
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
#line 7416 "../../doc/bison.texinfo"
|
|
||||||
#include <iostream>
|
|
||||||
#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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
# Extract all examples from the manual source. -*- AWK -*-
|
# Extract all examples from the manual source. -*- AWK -*-
|
||||||
|
|
||||||
# This file is part of GNU M4
|
# This file is part of GNU Bison
|
||||||
# Copyright 1992, 2000, 2001 Free Software Foundation, Inc.
|
# Copyright 1992, 2000, 2001, 2005 Free Software Foundation, Inc.
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# 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
|
# 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
|
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
|
||||||
# 02111-1307 USA
|
# 02111-1307 USA
|
||||||
|
|
||||||
# This script is for use with any New AWK.
|
# This script is for use with any Awk that conforms to POSIX.
|
||||||
# Well, now it uses ARGV/ARGC, and I don't know if it's New AWK portable.
|
# It was derived from a similar script tests/generate.awk in GNU m4.
|
||||||
#
|
#
|
||||||
# Usage: extexi input-file.texi ... -- [FILES to extract]
|
# Usage: extexi input-file.texi ... -- [FILES to extract]
|
||||||
BEGIN {
|
BEGIN {
|
||||||
|
|||||||
Reference in New Issue
Block a user