bug-bison
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [doc] Error in C++ interface to yylex


From: Akim Demaille
Subject: Re: [doc] Error in C++ interface to yylex
Date: Mon, 10 May 2010 10:44:12 +0200

Le 24 avr. 2010 à 16:33, Jerry Quinn a écrit :

> Hi, again,

Hi Jerry,

> The info docs describe the interface from C++ parser to yylex as
> 
> int yylex(semantic_value_type&, location_value_type&)
> 
> but the code generated requires:
> 
> int yylex(semantic_type*, location_type*)

Thanks for your reports.  It's amazing that these errors had not been noticed 
before.  Thanks a lot!

I installed the following patch in 2.4.3, 2.5, and master.

From 0100cd629d91e3e799b9feb7182965ff348ba61c Mon Sep 17 00:00:00 2001
From: Akim Demaille <address@hidden>
Date: Mon, 10 May 2010 10:27:23 +0200
Subject: [PATCH] doc: fix lalr1.cc documentation.

        * doc/bison.texinfo (C++ Scanner Interface): Fix yylex signature.
        (C++ Bison Interface): Fix lalr1.cc skeleton name.
        (C++ Parser Interface): Fix semantic_type and location_type names.
        Document yy::parser::token.
        Reported by Jerry Quinn.
---
 ChangeLog         |    9 +++++++++
 THANKS            |    1 +
 doc/bison.texinfo |   22 +++++++++++++++-------
 3 files changed, 25 insertions(+), 7 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 6dc0c02..398f39b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2010-05-10  Akim Demaille  <address@hidden>
+
+       doc: fix lalr1.cc documentation.
+       * doc/bison.texinfo (C++ Scanner Interface): Fix yylex signature.
+       (C++ Bison Interface): Fix lalr1.cc skeleton name.
+       (C++ Parser Interface): Fix semantic_type and location_type names.
+       Document yy::parser::token.
+       Reported by Jerry Quinn.
+
 2010-05-07  Akim Demaille  <address@hidden>
 
        doc: fix typo.
diff --git a/THANKS b/THANKS
index 6efa2ef..ae79e63 100644
--- a/THANKS
+++ b/THANKS
@@ -44,6 +44,7 @@ Guido Trentalancia        address@hidden
 H. Merijn Brand           address@hidden
 Hans Aberg                address@hidden
 Jan Nieuwenhuizen         address@hidden
+Jerry Quinn               address@hidden
 Jesse Thilo               address@hidden
 Jim Kent                  address@hidden
 Jim Meyering              address@hidden
diff --git a/doc/bison.texinfo b/doc/bison.texinfo
index 6583dbd..b385e39 100644
--- a/doc/bison.texinfo
+++ b/doc/bison.texinfo
@@ -8013,8 +8013,8 @@ int yyparse (void);
 @c - initial action
 
 The C++ @acronym{LALR}(1) parser is selected using the skeleton directive,
address@hidden "lalr1.c"}, or the synonymous command-line option
address@hidden
address@hidden "lalr1.cc"}, or the synonymous command-line option
address@hidden
 @xref{Decl Summary}.
 
 When run, @command{bison} will create several entities in the @samp{yy}
@@ -8163,11 +8163,19 @@ this class is detailed below.  It can be extended using 
the
 it describes an additional member of the parser class, and an
 additional argument for its constructor.
 
address@hidden {Type} {parser} {semantic_value_type}
address@hidden {Type} {parser} {location_value_type}
address@hidden {Type} {parser} {semantic_type}
address@hidden {Type} {parser} {location_type}
 The types for semantics value and locations.
 @end defcv
 
address@hidden {Type} {parser} {token}
+A structure that contains (only) the definition of the tokens as the
address@hidden enumeration.  To refer to the token @code{FOO}, the
+scanner should use @code{yy::parser::token::FOO}.  The scanner can use
address@hidden yy::parser::token token;} to ``import'' the token enumeration
+(@pxref{Calc++ Scanner}).
address@hidden defcv
+
 @deftypemethod {parser} {} parser (@var{type1} @var{arg1}, ...)
 Build a new parser object.  There are no arguments by default, unless
 @samp{%parse-param @address@hidden @address@hidden was used.
@@ -8206,7 +8214,7 @@ The parser invokes the scanner by calling @code{yylex}.  
Contrary to C
 parsers, C++ parsers are always pure: there is no point in using the
 @code{%define api.pure} directive.  Therefore the interface is as follows.
 
address@hidden {parser} {int} yylex (semantic_value_type& @var{yylval}, 
location_type& @var{yylloc}, @var{type1} @var{arg1}, ...)
address@hidden {parser} {int} yylex (semantic_type* @var{yylval}, 
location_type* @var{yylloc}, @var{type1} @var{arg1}, ...)
 Return the next token.  Its type is the return value, its semantic
 value and location being @var{yylval} and @var{yylloc}.  Invocations of
 @samp{%lex-param @address@hidden @address@hidden yield additional arguments.
@@ -8850,7 +8858,7 @@ The first, inclusive, position of the range, and the 
first beyond.
 @end deftypeivar
 
 @deftypeop {Constructor} {Location} {} Location (Position @var{loc})
-Create a @code{Location} denoting an empty range located at a given point. 
+Create a @code{Location} denoting an empty range located at a given point.
 @end deftypeop
 
 @deftypeop {Constructor} {Location} {} Location (Position @var{begin}, 
Position @var{end})
@@ -9064,7 +9072,7 @@ Return immediately from the parser, indicating success.
 @end deffn
 
 @deffn {Statement} {return YYERROR;}
-Start error recovery without printing an error message. 
+Start error recovery without printing an error message.
 @xref{Error Recovery}.
 @end deffn
 
-- 
1.7.0.5






reply via email to

[Prev in Thread] Current Thread [Next in Thread]