mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-21 18:23:03 +00:00
doc: simplify the extraction of example snippets
* doc/bison.texi: Use qualified paths. * examples/extexi: Comment changes.
This commit is contained in:
104
doc/bison.texi
104
doc/bison.texi
@@ -1659,7 +1659,7 @@ calculator. As in C, comments are placed between @samp{/*@dots{}*/} or
|
|||||||
after @samp{//}.
|
after @samp{//}.
|
||||||
|
|
||||||
@ignore
|
@ignore
|
||||||
@comment file: rpcalc.y
|
@comment file: c/rpcalc/rpcalc.y
|
||||||
@example
|
@example
|
||||||
/* Parser for rpcalc. -*- C -*-
|
/* Parser for rpcalc. -*- C -*-
|
||||||
|
|
||||||
@@ -1683,7 +1683,7 @@ after @samp{//}.
|
|||||||
@end example
|
@end example
|
||||||
@end ignore
|
@end ignore
|
||||||
|
|
||||||
@comment file: rpcalc.y
|
@comment file: c/rpcalc/rpcalc.y
|
||||||
@example
|
@example
|
||||||
/* Reverse Polish Notation calculator. */
|
/* Reverse Polish Notation calculator. */
|
||||||
|
|
||||||
@@ -1737,7 +1737,7 @@ declared is @code{NUM}, the token kind for numeric constants.
|
|||||||
|
|
||||||
Here are the grammar rules for the Reverse Polish Notation calculator.
|
Here are the grammar rules for the Reverse Polish Notation calculator.
|
||||||
|
|
||||||
@comment file: rpcalc.y
|
@comment file: c/rpcalc/rpcalc.y
|
||||||
@example
|
@example
|
||||||
@group
|
@group
|
||||||
input:
|
input:
|
||||||
@@ -1957,7 +1957,7 @@ A token kind code of zero is returned if the end-of-input is encountered.
|
|||||||
|
|
||||||
Here is the code for the lexical analyzer:
|
Here is the code for the lexical analyzer:
|
||||||
|
|
||||||
@comment file: rpcalc.y
|
@comment file: c/rpcalc/rpcalc.y
|
||||||
@example
|
@example
|
||||||
@group
|
@group
|
||||||
/* The lexical analyzer returns a double floating point
|
/* The lexical analyzer returns a double floating point
|
||||||
@@ -2008,7 +2008,7 @@ In keeping with the spirit of this example, the controlling function is
|
|||||||
kept to the bare minimum. The only requirement is that it call
|
kept to the bare minimum. The only requirement is that it call
|
||||||
@code{yyparse} to start the process of parsing.
|
@code{yyparse} to start the process of parsing.
|
||||||
|
|
||||||
@comment file: rpcalc.y
|
@comment file: c/rpcalc/rpcalc.y
|
||||||
@example
|
@example
|
||||||
@group
|
@group
|
||||||
int
|
int
|
||||||
@@ -2029,7 +2029,7 @@ always @code{"syntax error"}). It is up to the programmer to supply
|
|||||||
@code{yyerror} (@pxref{Interface}), so
|
@code{yyerror} (@pxref{Interface}), so
|
||||||
here is the definition we will use:
|
here is the definition we will use:
|
||||||
|
|
||||||
@comment file: rpcalc.y
|
@comment file: c/rpcalc/rpcalc.y
|
||||||
@example
|
@example
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
|
|
||||||
@@ -2545,7 +2545,7 @@ Note that multiple assignment and nested function calls are permitted.
|
|||||||
Here are the C and Bison declarations for the multi-function calculator.
|
Here are the C and Bison declarations for the multi-function calculator.
|
||||||
|
|
||||||
@ignore
|
@ignore
|
||||||
@comment file: mfcalc.y
|
@comment file: c/mfcalc/mfcalc.y
|
||||||
@example
|
@example
|
||||||
/* Parser for mfcalc. -*- C -*-
|
/* Parser for mfcalc. -*- C -*-
|
||||||
|
|
||||||
@@ -2569,7 +2569,7 @@ Here are the C and Bison declarations for the multi-function calculator.
|
|||||||
@end example
|
@end example
|
||||||
@end ignore
|
@end ignore
|
||||||
|
|
||||||
@comment file: mfcalc.y: 1
|
@comment file: c/mfcalc/mfcalc.y: 1
|
||||||
@example
|
@example
|
||||||
@group
|
@group
|
||||||
%@{
|
%@{
|
||||||
@@ -2623,7 +2623,7 @@ Here are the grammar rules for the multi-function calculator.
|
|||||||
Most of them are copied directly from @code{calc}; three rules,
|
Most of them are copied directly from @code{calc}; three rules,
|
||||||
those which mention @code{VAR} or @code{FUN}, are new.
|
those which mention @code{VAR} or @code{FUN}, are new.
|
||||||
|
|
||||||
@comment file: mfcalc.y: 3
|
@comment file: c/mfcalc/mfcalc.y: 3
|
||||||
@example
|
@example
|
||||||
%% /* The grammar follows. */
|
%% /* The grammar follows. */
|
||||||
@group
|
@group
|
||||||
@@ -2674,7 +2674,7 @@ definition, which is kept in the header @file{calc.h}, is as follows. It
|
|||||||
provides for either functions or variables to be placed in the table.
|
provides for either functions or variables to be placed in the table.
|
||||||
|
|
||||||
@ignore
|
@ignore
|
||||||
@comment file: calc.h
|
@comment file: c/mfcalc/calc.h
|
||||||
@example
|
@example
|
||||||
/* Functions for mfcalc. -*- C -*-
|
/* Functions for mfcalc. -*- C -*-
|
||||||
|
|
||||||
@@ -2698,7 +2698,7 @@ provides for either functions or variables to be placed in the table.
|
|||||||
@end example
|
@end example
|
||||||
@end ignore
|
@end ignore
|
||||||
|
|
||||||
@comment file: calc.h
|
@comment file: c/mfcalc/calc.h
|
||||||
@example
|
@example
|
||||||
@group
|
@group
|
||||||
/* Function type. */
|
/* Function type. */
|
||||||
@@ -2734,7 +2734,7 @@ symrec *getsym (char const *name);
|
|||||||
The new version of @code{main} will call @code{init_table} to initialize
|
The new version of @code{main} will call @code{init_table} to initialize
|
||||||
the symbol table:
|
the symbol table:
|
||||||
|
|
||||||
@comment file: mfcalc.y: 3
|
@comment file: c/mfcalc/mfcalc.y: 3
|
||||||
@example
|
@example
|
||||||
@group
|
@group
|
||||||
struct init
|
struct init
|
||||||
@@ -2788,7 +2788,7 @@ linked to the front of the list, and a pointer to the object is returned.
|
|||||||
The function @code{getsym} is passed the name of the symbol to look up. If
|
The function @code{getsym} is passed the name of the symbol to look up. If
|
||||||
found, a pointer to that symbol is returned; otherwise zero is returned.
|
found, a pointer to that symbol is returned; otherwise zero is returned.
|
||||||
|
|
||||||
@comment file: mfcalc.y: 3
|
@comment file: c/mfcalc/mfcalc.y: 3
|
||||||
@example
|
@example
|
||||||
@group
|
@group
|
||||||
/* The mfcalc code assumes that malloc and realloc
|
/* The mfcalc code assumes that malloc and realloc
|
||||||
@@ -2844,7 +2844,7 @@ returned to @code{yyparse}.
|
|||||||
No change is needed in the handling of numeric values and arithmetic
|
No change is needed in the handling of numeric values and arithmetic
|
||||||
operators in @code{yylex}.
|
operators in @code{yylex}.
|
||||||
|
|
||||||
@comment file: mfcalc.y: 3
|
@comment file: c/mfcalc/mfcalc.y: 3
|
||||||
@example
|
@example
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <stddef.h>
|
#include <stddef.h>
|
||||||
@@ -2879,7 +2879,7 @@ yylex (void)
|
|||||||
Bison generated a definition of @code{YYSTYPE} with a member named
|
Bison generated a definition of @code{YYSTYPE} with a member named
|
||||||
@code{NUM} to store value of @code{NUM} symbols.
|
@code{NUM} to store value of @code{NUM} symbols.
|
||||||
|
|
||||||
@comment file: mfcalc.y: 3
|
@comment file: c/mfcalc/mfcalc.y: 3
|
||||||
@example
|
@example
|
||||||
@group
|
@group
|
||||||
/* Char starts an identifier => read the name. */
|
/* Char starts an identifier => read the name. */
|
||||||
@@ -2932,7 +2932,7 @@ The error reporting function is unchanged, and the new version of
|
|||||||
@code{main} includes a call to @code{init_table} and sets the @code{yydebug}
|
@code{main} includes a call to @code{init_table} and sets the @code{yydebug}
|
||||||
on user demand (@xref{Tracing}, for details):
|
on user demand (@xref{Tracing}, for details):
|
||||||
|
|
||||||
@comment file: mfcalc.y: 3
|
@comment file: c/mfcalc/mfcalc.y: 3
|
||||||
@example
|
@example
|
||||||
@group
|
@group
|
||||||
/* Called by yyparse on error. */
|
/* Called by yyparse on error. */
|
||||||
@@ -10954,7 +10954,7 @@ calculator, @code{mfcalc} (@pxref{Multi-function Calc}). To enable run-time
|
|||||||
traces, and semantic value reports, insert the following directives in its
|
traces, and semantic value reports, insert the following directives in its
|
||||||
prologue:
|
prologue:
|
||||||
|
|
||||||
@comment file: mfcalc.y: 2
|
@comment file: c/mfcalc/mfcalc.y: 2
|
||||||
@example
|
@example
|
||||||
/* Generate the parser description file. */
|
/* Generate the parser description file. */
|
||||||
%verbose
|
%verbose
|
||||||
@@ -13079,7 +13079,7 @@ The first part includes the CPP guard and imports the required standard
|
|||||||
library components, and the declaration of the parser class.
|
library components, and the declaration of the parser class.
|
||||||
|
|
||||||
@ignore
|
@ignore
|
||||||
@comment file: calc++/driver.hh
|
@comment file: c++/calc++/driver.hh
|
||||||
@example
|
@example
|
||||||
/* Driver for calc++. -*- C++ -*-
|
/* Driver for calc++. -*- C++ -*-
|
||||||
|
|
||||||
@@ -13102,7 +13102,7 @@ library components, and the declaration of the parser class.
|
|||||||
@end example
|
@end example
|
||||||
@end ignore
|
@end ignore
|
||||||
|
|
||||||
@comment file: calc++/driver.hh
|
@comment file: c++/calc++/driver.hh
|
||||||
@example
|
@example
|
||||||
#ifndef DRIVER_HH
|
#ifndef DRIVER_HH
|
||||||
# define DRIVER_HH
|
# define DRIVER_HH
|
||||||
@@ -13117,7 +13117,7 @@ Then comes the declaration of the scanning function. Flex expects the
|
|||||||
signature of @code{yylex} to be defined in the macro @code{YY_DECL}, and the
|
signature of @code{yylex} to be defined in the macro @code{YY_DECL}, and the
|
||||||
C++ parser expects it to be declared. We can factor both as follows.
|
C++ parser expects it to be declared. We can factor both as follows.
|
||||||
|
|
||||||
@comment file: calc++/driver.hh
|
@comment file: c++/calc++/driver.hh
|
||||||
@example
|
@example
|
||||||
// Give Flex the prototype of yylex we want ...
|
// Give Flex the prototype of yylex we want ...
|
||||||
# define YY_DECL \
|
# define YY_DECL \
|
||||||
@@ -13129,7 +13129,7 @@ YY_DECL;
|
|||||||
@noindent
|
@noindent
|
||||||
The @code{driver} class is then declared with its most obvious members.
|
The @code{driver} class is then declared with its most obvious members.
|
||||||
|
|
||||||
@comment file: calc++/driver.hh
|
@comment file: c++/calc++/driver.hh
|
||||||
@example
|
@example
|
||||||
// Conducting the whole scanning and parsing of Calc++.
|
// Conducting the whole scanning and parsing of Calc++.
|
||||||
class driver
|
class driver
|
||||||
@@ -13145,7 +13145,7 @@ public:
|
|||||||
@noindent
|
@noindent
|
||||||
The main routine is of course calling the parser.
|
The main routine is of course calling the parser.
|
||||||
|
|
||||||
@comment file: calc++/driver.hh
|
@comment file: c++/calc++/driver.hh
|
||||||
@example
|
@example
|
||||||
// Run the parser on file F. Return 0 on success.
|
// Run the parser on file F. Return 0 on success.
|
||||||
int parse (const std::string& f);
|
int parse (const std::string& f);
|
||||||
@@ -13159,7 +13159,7 @@ The main routine is of course calling the parser.
|
|||||||
To encapsulate the coordination with the Flex scanner, it is useful to have
|
To encapsulate the coordination with the Flex scanner, it is useful to have
|
||||||
member functions to open and close the scanning phase.
|
member functions to open and close the scanning phase.
|
||||||
|
|
||||||
@comment file: calc++/driver.hh
|
@comment file: c++/calc++/driver.hh
|
||||||
@example
|
@example
|
||||||
// Handling the scanner.
|
// Handling the scanner.
|
||||||
void scan_begin ();
|
void scan_begin ();
|
||||||
@@ -13175,7 +13175,7 @@ member functions to open and close the scanning phase.
|
|||||||
The implementation of the driver (@file{driver.cc}) is straightforward.
|
The implementation of the driver (@file{driver.cc}) is straightforward.
|
||||||
|
|
||||||
@ignore
|
@ignore
|
||||||
@comment file: calc++/driver.cc
|
@comment file: c++/calc++/driver.cc
|
||||||
@example
|
@example
|
||||||
/* Driver for calc++. -*- C++ -*-
|
/* Driver for calc++. -*- C++ -*-
|
||||||
|
|
||||||
@@ -13198,7 +13198,7 @@ The implementation of the driver (@file{driver.cc}) is straightforward.
|
|||||||
@end example
|
@end example
|
||||||
@end ignore
|
@end ignore
|
||||||
|
|
||||||
@comment file: calc++/driver.cc
|
@comment file: c++/calc++/driver.cc
|
||||||
@example
|
@example
|
||||||
#include "driver.hh"
|
#include "driver.hh"
|
||||||
#include "parser.hh"
|
#include "parser.hh"
|
||||||
@@ -13215,7 +13215,7 @@ driver::driver ()
|
|||||||
|
|
||||||
The @code{parse} member function deserves some attention.
|
The @code{parse} member function deserves some attention.
|
||||||
|
|
||||||
@comment file: calc++/driver.cc
|
@comment file: c++/calc++/driver.cc
|
||||||
@example
|
@example
|
||||||
@group
|
@group
|
||||||
int
|
int
|
||||||
@@ -13242,7 +13242,7 @@ skeleton changed several times, it is safer to require the version you
|
|||||||
designed the grammar for.
|
designed the grammar for.
|
||||||
|
|
||||||
@ignore
|
@ignore
|
||||||
@comment file: calc++/parser.yy
|
@comment file: c++/calc++/parser.yy
|
||||||
@example
|
@example
|
||||||
/* Parser for calc++. -*- C++ -*-
|
/* Parser for calc++. -*- C++ -*-
|
||||||
|
|
||||||
@@ -13265,7 +13265,7 @@ designed the grammar for.
|
|||||||
@end example
|
@end example
|
||||||
@end ignore
|
@end ignore
|
||||||
|
|
||||||
@comment file: calc++/parser.yy
|
@comment file: c++/calc++/parser.yy
|
||||||
@example
|
@example
|
||||||
%skeleton "lalr1.cc" // -*- C++ -*-
|
%skeleton "lalr1.cc" // -*- C++ -*-
|
||||||
%require "@value{VERSION}"
|
%require "@value{VERSION}"
|
||||||
@@ -13277,7 +13277,7 @@ designed the grammar for.
|
|||||||
Because our scanner returns only genuine tokens and never simple characters
|
Because our scanner returns only genuine tokens and never simple characters
|
||||||
(i.e., it returns @samp{PLUS}, not @samp{'+'}), we can avoid conversions.
|
(i.e., it returns @samp{PLUS}, not @samp{'+'}), we can avoid conversions.
|
||||||
|
|
||||||
@comment file: calc++/parser.yy
|
@comment file: c++/calc++/parser.yy
|
||||||
@example
|
@example
|
||||||
%define api.token.raw
|
%define api.token.raw
|
||||||
@end example
|
@end example
|
||||||
@@ -13291,7 +13291,7 @@ properly use it, we enable assertions. To fully benefit from type-safety
|
|||||||
and more natural definition of ``symbol'', we enable
|
and more natural definition of ``symbol'', we enable
|
||||||
@code{api.token.constructor}.
|
@code{api.token.constructor}.
|
||||||
|
|
||||||
@comment file: calc++/parser.yy
|
@comment file: c++/calc++/parser.yy
|
||||||
@example
|
@example
|
||||||
%define api.token.constructor
|
%define api.token.constructor
|
||||||
%define api.value.type variant
|
%define api.value.type variant
|
||||||
@@ -13308,7 +13308,7 @@ driver's header needs detailed knowledge about the parser class (in
|
|||||||
particular its inner types), it is the parser's header which will use a
|
particular its inner types), it is the parser's header which will use a
|
||||||
forward declaration of the driver. @xref{%code Summary}.
|
forward declaration of the driver. @xref{%code Summary}.
|
||||||
|
|
||||||
@comment file: calc++/parser.yy
|
@comment file: c++/calc++/parser.yy
|
||||||
@example
|
@example
|
||||||
@group
|
@group
|
||||||
%code requires @{
|
%code requires @{
|
||||||
@@ -13323,7 +13323,7 @@ The driver is passed by reference to the parser and to the scanner.
|
|||||||
This provides a simple but effective pure interface, not relying on
|
This provides a simple but effective pure interface, not relying on
|
||||||
global variables.
|
global variables.
|
||||||
|
|
||||||
@comment file: calc++/parser.yy
|
@comment file: c++/calc++/parser.yy
|
||||||
@example
|
@example
|
||||||
// The parsing context.
|
// The parsing context.
|
||||||
%param @{ driver& drv @}
|
%param @{ driver& drv @}
|
||||||
@@ -13332,7 +13332,7 @@ global variables.
|
|||||||
@noindent
|
@noindent
|
||||||
Then we request location tracking.
|
Then we request location tracking.
|
||||||
|
|
||||||
@comment file: calc++/parser.yy
|
@comment file: c++/calc++/parser.yy
|
||||||
@example
|
@example
|
||||||
%locations
|
%locations
|
||||||
@end example
|
@end example
|
||||||
@@ -13342,7 +13342,7 @@ Use the following two directives to enable parser tracing and detailed error
|
|||||||
messages. However, detailed error messages can contain incorrect
|
messages. However, detailed error messages can contain incorrect
|
||||||
information if lookahead correction is not enabled (@pxref{LAC}).
|
information if lookahead correction is not enabled (@pxref{LAC}).
|
||||||
|
|
||||||
@comment file: calc++/parser.yy
|
@comment file: c++/calc++/parser.yy
|
||||||
@example
|
@example
|
||||||
%define parse.trace
|
%define parse.trace
|
||||||
%define parse.error detailed
|
%define parse.error detailed
|
||||||
@@ -13354,7 +13354,7 @@ information if lookahead correction is not enabled (@pxref{LAC}).
|
|||||||
The code between @samp{%code @{} and @samp{@}} is output in the @file{*.cc}
|
The code between @samp{%code @{} and @samp{@}} is output in the @file{*.cc}
|
||||||
file; it needs detailed knowledge about the driver.
|
file; it needs detailed knowledge about the driver.
|
||||||
|
|
||||||
@comment file: calc++/parser.yy
|
@comment file: c++/calc++/parser.yy
|
||||||
@example
|
@example
|
||||||
@group
|
@group
|
||||||
%code @{
|
%code @{
|
||||||
@@ -13369,7 +13369,7 @@ User friendly names are provided for each symbol. To avoid name clashes in
|
|||||||
the generated files (@pxref{Calc++ Scanner}), prefix tokens with @code{TOK_}
|
the generated files (@pxref{Calc++ Scanner}), prefix tokens with @code{TOK_}
|
||||||
(@pxref{%define Summary}).
|
(@pxref{%define Summary}).
|
||||||
|
|
||||||
@comment file: calc++/parser.yy
|
@comment file: c++/calc++/parser.yy
|
||||||
@example
|
@example
|
||||||
%define api.token.prefix @{TOK_@}
|
%define api.token.prefix @{TOK_@}
|
||||||
%token
|
%token
|
||||||
@@ -13388,7 +13388,7 @@ Since we use variant-based semantic values, @code{%union} is not used, and
|
|||||||
@code{%token}, @code{%nterm} and @code{%type} expect genuine types, not type
|
@code{%token}, @code{%nterm} and @code{%type} expect genuine types, not type
|
||||||
tags.
|
tags.
|
||||||
|
|
||||||
@comment file: calc++/parser.yy
|
@comment file: c++/calc++/parser.yy
|
||||||
@example
|
@example
|
||||||
%token <std::string> IDENTIFIER "identifier"
|
%token <std::string> IDENTIFIER "identifier"
|
||||||
%token <int> NUMBER "number"
|
%token <int> NUMBER "number"
|
||||||
@@ -13401,7 +13401,7 @@ recovery; the memory, for strings for instance, will be reclaimed by the
|
|||||||
regular destructors. All the values are printed using their
|
regular destructors. All the values are printed using their
|
||||||
@code{operator<<} (@pxref{Printer Decl}).
|
@code{operator<<} (@pxref{Printer Decl}).
|
||||||
|
|
||||||
@comment file: calc++/parser.yy
|
@comment file: c++/calc++/parser.yy
|
||||||
@example
|
@example
|
||||||
%printer @{ yyo << $$; @} <*>;
|
%printer @{ yyo << $$; @} <*>;
|
||||||
@end example
|
@end example
|
||||||
@@ -13409,7 +13409,7 @@ regular destructors. All the values are printed using their
|
|||||||
@noindent
|
@noindent
|
||||||
The grammar itself is straightforward (@pxref{Location Tracking Calc}).
|
The grammar itself is straightforward (@pxref{Location Tracking Calc}).
|
||||||
|
|
||||||
@comment file: calc++/parser.yy
|
@comment file: c++/calc++/parser.yy
|
||||||
@example
|
@example
|
||||||
%%
|
%%
|
||||||
%start unit;
|
%start unit;
|
||||||
@@ -13438,7 +13438,7 @@ exp:
|
|||||||
@noindent
|
@noindent
|
||||||
Finally the @code{error} member function reports the errors.
|
Finally the @code{error} member function reports the errors.
|
||||||
|
|
||||||
@comment file: calc++/parser.yy
|
@comment file: c++/calc++/parser.yy
|
||||||
@example
|
@example
|
||||||
void
|
void
|
||||||
yy::parser::error (const location_type& l, const std::string& m)
|
yy::parser::error (const location_type& l, const std::string& m)
|
||||||
@@ -13454,7 +13454,7 @@ In addition to standard headers, the Flex scanner includes the driver's,
|
|||||||
then the parser's to get the set of defined tokens.
|
then the parser's to get the set of defined tokens.
|
||||||
|
|
||||||
@ignore
|
@ignore
|
||||||
@comment file: calc++/scanner.ll
|
@comment file: c++/calc++/scanner.ll
|
||||||
@example
|
@example
|
||||||
/* Scanner for calc++. -*- C++ -*-
|
/* Scanner for calc++. -*- C++ -*-
|
||||||
|
|
||||||
@@ -13477,7 +13477,7 @@ then the parser's to get the set of defined tokens.
|
|||||||
@end example
|
@end example
|
||||||
@end ignore
|
@end ignore
|
||||||
|
|
||||||
@comment file: calc++/scanner.ll
|
@comment file: c++/calc++/scanner.ll
|
||||||
@example
|
@example
|
||||||
%@{ /* -*- C++ -*- */
|
%@{ /* -*- C++ -*- */
|
||||||
# include <cerrno>
|
# include <cerrno>
|
||||||
@@ -13491,7 +13491,7 @@ then the parser's to get the set of defined tokens.
|
|||||||
@end example
|
@end example
|
||||||
|
|
||||||
@ignore
|
@ignore
|
||||||
@comment file: calc++/scanner.ll
|
@comment file: c++/calc++/scanner.ll
|
||||||
@example
|
@example
|
||||||
%@{
|
%@{
|
||||||
#if defined __clang__
|
#if defined __clang__
|
||||||
@@ -13564,7 +13564,7 @@ Since our calculator has no @code{#include}-like feature, we don't need
|
|||||||
either, and we parse an actual file, this is not an interactive session with
|
either, and we parse an actual file, this is not an interactive session with
|
||||||
the user. Finally, we enable scanner tracing.
|
the user. Finally, we enable scanner tracing.
|
||||||
|
|
||||||
@comment file: calc++/scanner.ll
|
@comment file: c++/calc++/scanner.ll
|
||||||
@example
|
@example
|
||||||
%option noyywrap nounput noinput batch debug
|
%option noyywrap nounput noinput batch debug
|
||||||
@end example
|
@end example
|
||||||
@@ -13573,7 +13573,7 @@ the user. Finally, we enable scanner tracing.
|
|||||||
The following function will be handy to convert a string denoting a number
|
The following function will be handy to convert a string denoting a number
|
||||||
into a @code{NUMBER} token.
|
into a @code{NUMBER} token.
|
||||||
|
|
||||||
@comment file: calc++/scanner.ll
|
@comment file: c++/calc++/scanner.ll
|
||||||
@example
|
@example
|
||||||
%@{
|
%@{
|
||||||
// A number symbol corresponding to the value in S.
|
// A number symbol corresponding to the value in S.
|
||||||
@@ -13585,7 +13585,7 @@ into a @code{NUMBER} token.
|
|||||||
@noindent
|
@noindent
|
||||||
Abbreviations allow for more readable rules.
|
Abbreviations allow for more readable rules.
|
||||||
|
|
||||||
@comment file: calc++/scanner.ll
|
@comment file: c++/calc++/scanner.ll
|
||||||
@example
|
@example
|
||||||
id [a-zA-Z][a-zA-Z_0-9]*
|
id [a-zA-Z][a-zA-Z_0-9]*
|
||||||
int [0-9]+
|
int [0-9]+
|
||||||
@@ -13600,7 +13600,7 @@ matching ends of lines, the end cursor is adjusted, and each time blanks are
|
|||||||
matched, the begin cursor is moved onto the end cursor to effectively ignore
|
matched, the begin cursor is moved onto the end cursor to effectively ignore
|
||||||
the blanks preceding tokens. Comments would be treated equally.
|
the blanks preceding tokens. Comments would be treated equally.
|
||||||
|
|
||||||
@comment file: calc++/scanner.ll
|
@comment file: c++/calc++/scanner.ll
|
||||||
@example
|
@example
|
||||||
@group
|
@group
|
||||||
%@{
|
%@{
|
||||||
@@ -13624,7 +13624,7 @@ the blanks preceding tokens. Comments would be treated equally.
|
|||||||
@noindent
|
@noindent
|
||||||
The rules are simple. The driver is used to report errors.
|
The rules are simple. The driver is used to report errors.
|
||||||
|
|
||||||
@comment file: calc++/scanner.ll
|
@comment file: c++/calc++/scanner.ll
|
||||||
@example
|
@example
|
||||||
"-" return yy::parser::make_MINUS (loc);
|
"-" return yy::parser::make_MINUS (loc);
|
||||||
"+" return yy::parser::make_PLUS (loc);
|
"+" return yy::parser::make_PLUS (loc);
|
||||||
@@ -13650,7 +13650,7 @@ The rules are simple. The driver is used to report errors.
|
|||||||
You should keep your rules simple, both in the parser and in the scanner.
|
You should keep your rules simple, both in the parser and in the scanner.
|
||||||
Throwing from the auxiliary functions is then very handy to report errors.
|
Throwing from the auxiliary functions is then very handy to report errors.
|
||||||
|
|
||||||
@comment file: calc++/scanner.ll
|
@comment file: c++/calc++/scanner.ll
|
||||||
@example
|
@example
|
||||||
@group
|
@group
|
||||||
yy::parser::symbol_type
|
yy::parser::symbol_type
|
||||||
@@ -13669,7 +13669,7 @@ make_NUMBER (const std::string &s, const yy::parser::location_type& loc)
|
|||||||
Finally, because the scanner-related driver's member-functions depend
|
Finally, because the scanner-related driver's member-functions depend
|
||||||
on the scanner's data, it is simpler to implement them in this file.
|
on the scanner's data, it is simpler to implement them in this file.
|
||||||
|
|
||||||
@comment file: calc++/scanner.ll
|
@comment file: c++/calc++/scanner.ll
|
||||||
@example
|
@example
|
||||||
@group
|
@group
|
||||||
void
|
void
|
||||||
@@ -13701,7 +13701,7 @@ driver::scan_end ()
|
|||||||
The top level file, @file{calc++.cc}, poses no problem.
|
The top level file, @file{calc++.cc}, poses no problem.
|
||||||
|
|
||||||
@ignore
|
@ignore
|
||||||
@comment file: calc++/calc++.cc
|
@comment file: c++/calc++/calc++.cc
|
||||||
@example
|
@example
|
||||||
/* Main for calc++. -*- C++ -*-
|
/* Main for calc++. -*- C++ -*-
|
||||||
|
|
||||||
@@ -13724,7 +13724,7 @@ The top level file, @file{calc++.cc}, poses no problem.
|
|||||||
@end example
|
@end example
|
||||||
@end ignore
|
@end ignore
|
||||||
|
|
||||||
@comment file: calc++/calc++.cc
|
@comment file: c++/calc++/calc++.cc
|
||||||
@example
|
@example
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "driver.hh"
|
#include "driver.hh"
|
||||||
|
|||||||
@@ -23,21 +23,21 @@
|
|||||||
|
|
||||||
# Look for @example environments preceded with lines such as:
|
# Look for @example environments preceded with lines such as:
|
||||||
#
|
#
|
||||||
# @comment file calc.y
|
# @comment file c/mfcalc/calc.y
|
||||||
# or
|
# or
|
||||||
# @comment file calc.y: 3
|
# @comment file c/mfcalc/calc.y: 3
|
||||||
#
|
#
|
||||||
# and output their content in that file (calc.y). When numbers are
|
# and output their content in that file (c/mfcalc/calc.y). When
|
||||||
# provided, use them to decide the output order (block numbered 1 is
|
# numbers are provided, use them to decide the output order (block 1
|
||||||
# output before block 2, even if the latter appears before). The same
|
# is output before block 2, even if the latter appears before). The
|
||||||
# number may be used several time, in which case the order of
|
# same number may be used several time, in which case the order of
|
||||||
# appearance is used.
|
# appearance is used.
|
||||||
#
|
#
|
||||||
# Use @ignore for code to extract that must not be part of the
|
# Use @ignore for code to extract that must not be part of the
|
||||||
# documentation. For instance:
|
# documentation. For instance:
|
||||||
#
|
#
|
||||||
# @ignore
|
# @ignore
|
||||||
# @comment file: calc++/scanner.ll
|
# @comment file: c++/calc++/scanner.ll
|
||||||
# @example
|
# @example
|
||||||
# // Work around an incompatibility in Flex.
|
# // Work around an incompatibility in Flex.
|
||||||
# # undef yywrap
|
# # undef yywrap
|
||||||
@@ -87,7 +87,9 @@ sub message($)
|
|||||||
# The list of files we should extract.
|
# The list of files we should extract.
|
||||||
my @file_wanted;
|
my @file_wanted;
|
||||||
|
|
||||||
# Whether we should extract that file, and then under which path.
|
# Whether we should extract that file, and then under which path. We
|
||||||
|
# check if the prefix matches. So for instance if "foo/bar.y" is
|
||||||
|
# wanted (i.e., in @FILE_WANTED), "file: bar.y" matches.
|
||||||
sub file_wanted ($)
|
sub file_wanted ($)
|
||||||
{
|
{
|
||||||
my ($f) = @_;
|
my ($f) = @_;
|
||||||
|
|||||||
Reference in New Issue
Block a user