Extract calc++ from the documentation.

* doc/bison.texinfo (Calc++): Add the extraction marks.
* examples/extexi: New, from the aborted GNU Programming 2E.
Separate the different paragraph of a file with empty lines.
* examples/Makefile: Use it to extract the whole calc++ example.
This commit is contained in:
Akim Demaille
2005-07-05 07:21:30 +00:00
parent 8a0adb0183
commit 1c59e0a121
9 changed files with 235 additions and 66 deletions

View File

@@ -1,48 +1,44 @@
%skeleton "lalr1.cc" /* -*- C++ -*- */
#line 7188 "../../doc/bison.texinfo"
%skeleton "lalr1.cc" /* -*- C++ -*- */
%define "parser_class_name" "calcxx_parser"
%defines
%{
# include <string>
# include "calc++-driver.hh"
%}
%error-verbose
#line 7204 "../../doc/bison.texinfo"
// The parsing context.
%parse-param { calcxx_driver& driver }
%lex-param { calcxx_driver& driver }
#line 7217 "../../doc/bison.texinfo"
%locations
%initial-action
{
// Initialize the initial location.
@$.begin.filename = @$.end.filename = &driver.file;
};
// Define yydebug.
#line 7231 "../../doc/bison.texinfo"
%debug
%error-verbose
#line 7241 "../../doc/bison.texinfo"
// Symbols.
%union
{
/// Value of a numeric literal.
int ival;
/// Name of a variable.
std::string *sval;
};
#line 7258 "../../doc/bison.texinfo"
%token YYEOF 0 "end of file"
%token TOKEN_ASSIGN ":="
%token <sval> TOKEN_IDENTIFIER "identifier"
%token <ival> TOKEN_NUMBER "number"
%type <ival> exp "expression"
#line 7271 "../../doc/bison.texinfo"
%printer { debug_stream () << *$$; } "identifier"
%destructor { delete $$; } "identifier"
%printer { debug_stream () << $$; } "number" "expression"
#line 7282 "../../doc/bison.texinfo"
%%
%start unit;
unit: assignments exp { driver.result = $2; };
@@ -61,8 +57,10 @@ exp: exp '+' exp { $$ = $1 + $3; }
| TOKEN_IDENTIFIER { $$ = driver.variables[*$1]; }
| TOKEN_NUMBER { $$ = $1; };
%%
#line 7308 "../../doc/bison.texinfo"
void
yy::calcxx_parser::error (const location& l, const std::string& m)
yy::calcxx_parser::error (const yy::calcxx_parser::location_type& l,
const std::string& m)
{
driver.error (l, m);
}