bug-bison
[Top][All Lists]
Advanced

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

Re: yylval is pointer


From: Akim Demaille
Subject: Re: yylval is pointer
Date: Tue, 3 Mar 2015 16:32:10 +0100

> Le 24 févr. 2015 à 20:12, Askar Safin <address@hidden> a écrit :
> 
> Another bug in the same section 10.1.5.1. We see the declaration "int yylex 
> (semantic_type* yylval, location_type* yylloc, type1 arg1, ...)", i. e. 
> yylval is a pointer. And then we see "yylval.build<int>()". It seems 
> "yylval->build<int>()" should be. CC me.

Hi Askar,

You are right again.

I'll apply the following patch.

commit 75fbe357c896d84b9dedff98c8b0d43ca536bc95
Author: Akim Demaille <address@hidden>
Date:   Tue Mar 3 16:10:30 2015 +0100

    doc: fixes in the C++ part
    
    Reported by Askar Safin.
    
    http://lists.gnu.org/archive/html/bug-bison/2015-02/msg00018.html
    http://lists.gnu.org/archive/html/bug-bison/2015-02/msg00019.html
    
    * doc/bison.texi (Split Symbols): Fix access to token types.
    yylval is a pointer, so use ->.
    Fix coding style issues: space before paren.

diff --git a/THANKS b/THANKS
index 32fc67f..12086a9 100644
--- a/THANKS
+++ b/THANKS
@@ -15,6 +15,7 @@ Anthony Heading           address@hidden
 Antonio Silva Correia     address@hidden
 Arnold Robbins            address@hidden
 Art Haas                  address@hidden
+Askar Safin               address@hidden
 Baron Schwartz            address@hidden
 Ben Pfaff                 address@hidden
 Benoit Perrot             address@hidden
diff --git a/doc/bison.texi b/doc/bison.texi
index 26c17d6..41c0c2b 100644
--- a/doc/bison.texi
+++ b/doc/bison.texi
@@ -10901,12 +10901,12 @@ Regular union-based code in Lex scanner typically 
look like:
 
 @example
 [0-9]+   @{
-           yylval.ival = text_to_int (yytext);
-           return yy::parser::INTEGER;
+           yylval->ival = text_to_int (yytext);
+           return yy::parser::token::INTEGER;
          @}
 [a-z]+   @{
-           yylval.sval = new std::string (yytext);
-           return yy::parser::IDENTIFIER;
+           yylval->sval = new std::string (yytext);
+           return yy::parser::token::IDENTIFIER;
          @}
 @end example
 
@@ -10915,12 +10915,12 @@ initialized.  So the code would look like:
 
 @example
 [0-9]+   @{
-           yylval.build<int>() = text_to_int (yytext);
-           return yy::parser::INTEGER;
+           yylval->build<int> () = text_to_int (yytext);
+           return yy::parser::token::INTEGER;
          @}
 [a-z]+   @{
-           yylval.build<std::string> = yytext;
-           return yy::parser::IDENTIFIER;
+           yylval->build<std::string> () = yytext;
+           return yy::parser::token::IDENTIFIER;
          @}
 @end example
 
@@ -10929,12 +10929,12 @@ or
 
 @example
 [0-9]+   @{
-           yylval.build(text_to_int (yytext));
-           return yy::parser::INTEGER;
+           yylval->build (text_to_int (yytext));
+           return yy::parser::token::INTEGER;
          @}
 [a-z]+   @{
-           yylval.build(yytext);
-           return yy::parser::IDENTIFIER;
+           yylval->build (yytext);
+           return yy::parser::token::IDENTIFIER;
          @}
 @end example
 
@@ -10983,20 +10983,18 @@ For instance, given the following declarations:
 Bison generates the following functions:
 
 @example
-symbol_type make_IDENTIFIER(const std::string& v,
-                            const location_type& l);
-symbol_type make_INTEGER(const int& v,
-                         const location_type& loc);
-symbol_type make_COLON(const location_type& loc);
+symbol_type make_IDENTIFIER (const std::string& v, const location_type& loc);
+symbol_type make_INTEGER (const int& v, const location_type& loc);
+symbol_type make_COLON (const location_type& loc);
 @end example
 
 @noindent
 which should be used in a Lex-scanner as follows.
 
 @example
-[0-9]+   return yy::parser::make_INTEGER(text_to_int (yytext), loc);
-[a-z]+   return yy::parser::make_IDENTIFIER(yytext, loc);
-":"      return yy::parser::make_COLON(loc);
+[0-9]+   return yy::parser::make_INTEGER (text_to_int (yytext), loc);
+[a-z]+   return yy::parser::make_IDENTIFIER (yytext, loc);
+":"      return yy::parser::make_COLON (loc);
 @end example
 
 Tokens that do not have an identifier are not accessible: you cannot simply
@@ -11461,13 +11459,13 @@ The rules are simple.  The driver is used to report 
errors.
 
 @comment file: calc++-scanner.ll
 @example
-"-"      return yy::calcxx_parser::make_MINUS(loc);
-"+"      return yy::calcxx_parser::make_PLUS(loc);
-"*"      return yy::calcxx_parser::make_STAR(loc);
-"/"      return yy::calcxx_parser::make_SLASH(loc);
-"("      return yy::calcxx_parser::make_LPAREN(loc);
-")"      return yy::calcxx_parser::make_RPAREN(loc);
-":="     return yy::calcxx_parser::make_ASSIGN(loc);
+"-"      return yy::calcxx_parser::make_MINUS  (loc);
+"+"      return yy::calcxx_parser::make_PLUS   (loc);
+"*"      return yy::calcxx_parser::make_STAR   (loc);
+"/"      return yy::calcxx_parser::make_SLASH  (loc);
+"("      return yy::calcxx_parser::make_LPAREN (loc);
+")"      return yy::calcxx_parser::make_RPAREN (loc);
+":="     return yy::calcxx_parser::make_ASSIGN (loc);
 
 @group
 @address@hidden      @{
@@ -11475,12 +11473,12 @@ The rules are simple.  The driver is used to report 
errors.
   long n = strtol (yytext, NULL, 10);
   if (! (INT_MIN <= n && n <= INT_MAX && errno != ERANGE))
     driver.error (loc, "integer is out of range");
-  return yy::calcxx_parser::make_NUMBER(n, loc);
+  return yy::calcxx_parser::make_NUMBER (n, loc);
 @}
 @end group
address@hidden@}       return yy::calcxx_parser::make_IDENTIFIER(yytext, loc);
address@hidden@}       return yy::calcxx_parser::make_IDENTIFIER (yytext, loc);
 .          driver.error (loc, "invalid character");
-<<EOF>>    return yy::calcxx_parser::make_END(loc);
+<<EOF>>    return yy::calcxx_parser::make_END (loc);
 %%
 @end example
 




reply via email to

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