[Top][All Lists]

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

Re: Small documentation feature request

From: Akim Demaille
Subject: Re: Small documentation feature request
Date: Tue, 30 Jun 2020 19:41:31 +0200

Hi Rici!

> Le 30 juin 2020 à 18:23, Rici Lake <ricilake@gmail.com> a écrit :
> Hi, Akim and bisonistas,
> This came up today on SO:
> https://stackoverflow.com/questions/62658368/unknown-type-yypcontext-t-in-bison.

Thanks for pointing this out.

> The user complained that their attempt to declare `yyreport_syntax_error`
> failed because `yypcontext_t` was not defined. (The declaration was put in
> a `%{` code section in the prologue.)
> That seems to be expected, since the structure is not declared until after
> all the prologue code has been included, and furthermore
> yyreport_syntax_error is declared as `static`, implying that it must be
> defined in the bison input file in the final code section.

Yes, all this is in the *.c file only, nothing in the header file.

> However, the manual does not mention this fact, and I think that it is not
> immediately obvious. It would, IMHO, be a good idea to put a small note
> about that in the manual chapter which describes that function.

You're right.  WDYT about this?

commit fd022d632d2b77288769e410f3332ecc44d45ba7
Author: Akim Demaille <akim.demaille@gmail.com>
Date:   Tue Jun 30 19:35:45 2020 +0200

    doc: clarify that the pcontext interface is *.c only
    Reported by Rici Lake.
    * doc/bison.texi (Syntax Error Reporting Function): Make it clear that
    this is not exported.
    Remove C++ details that landed in the C doc.

diff --git a/doc/bison.texi b/doc/bison.texi
index 985b1d7c..02676190 100644
--- a/doc/bison.texi
+++ b/doc/bison.texi
@@ -7619,7 +7619,11 @@ Declarations}), then the parser no longer passes syntax 
error messages to
 @code{yyerror}, rather it delegates that task to the user by calling the
 @code{yyreport_syntax_error} function.
-@deftypefun int yyreport_syntax_error (@code{const yypcontext_t *}@var{ctx})
+The following functions and types are ``@code{static}'': they are defined in
+the implementation file (@file{*.c}) and available only from there.  They
+are meant to be used from the grammar's epilogue.
+@deftypefun {static int} yyreport_syntax_error (@code{const yypcontext_t 
 Report a syntax error to the user.  Return 0 on success, @code{YYENOMEM} on
 memory exhaustion.  Whether it uses @code{yyerror} is up to the user.
 @end deftypefun
@@ -7654,16 +7658,16 @@ typedef enum yysymbol_kind_t yysymbol_kind_t;
 @end example
 @end deffn
-@deftypefun {yysymbol_kind_t} yypcontext_token (@code{const yypcontext_t 
+@deftypefun {static yysymbol_kind_t} yypcontext_token (@code{const 
yypcontext_t *}@var{ctx})
 The ``unexpected'' token: the symbol kind of the lookahead token that caused
 the syntax error.  Return @code{YYSYMBOL_YYEMPTY} if there is no lookahead.
 @end deftypefun
-@deftypefun {YYLTYPE *} yypcontext_location (@code{const yypcontext_t 
+@deftypefun {static YYLTYPE *} yypcontext_location (@code{const yypcontext_t 
 The location of the syntax error (that of the unexpected token).
 @end deftypefun
-@deftypefun int yypcontext_expected_tokens (@code{const yypcontext_t *}ctx, 
@code{yysymbol_kind_t} @var{argv}@code{[]}, @code{int} @var{argc})
+@deftypefun {static int} yypcontext_expected_tokens (@code{const yypcontext_t 
*}ctx, @code{yysymbol_kind_t} @var{argv}@code{[]}, @code{int} @var{argc})
 Fill @var{argv} with the expected tokens, which never includes
 @code{YYSYMBOL_YYEMPTY}, @code{YYSYMBOL_YYerror}, or
@@ -7681,10 +7685,8 @@ If @var{argv} is null, return the size needed to store 
all the possible
 values, which is always less than @code{YYNTOKENS}.
 @end deftypefun
-@deftypefun {@r{string type}} yysymbol_name (@code{symbol_kind_t} @var{symbol})
+@deftypefun {static const char *} yysymbol_name (@code{symbol_kind_t} 
 The name of the symbol whose kind is @var{symbol}, possibly translated.
-Depending on the options, may return a @code{const char*} or a
 @end deftypefun
 A custom syntax error function looks as follows.  This implementation is
@@ -7692,7 +7694,7 @@ inappropriate for internationalization, see the 
 example for a better alternative.
+static int
 yyreport_syntax_error (const yypcontext_t *ctx)
   int res = 0;

reply via email to

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