mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-28 13:43:02 +00:00
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:
@@ -1,33 +1,28 @@
|
||||
%{ /* -*- C++ -*- */
|
||||
|
||||
%{ /* -*- C++ -*- */
|
||||
# include <string>
|
||||
# include <cerrno>
|
||||
# include "calc++-driver.hh"
|
||||
# include "calc++-parser.hh"
|
||||
%}
|
||||
|
||||
%option noyywrap nounput debug batch
|
||||
%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 ();
|
||||
# define YY_USER_ACTION yylloc->columns (yyleng);
|
||||
%}
|
||||
{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
|
||||
|
||||
Reference in New Issue
Block a user