mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-14 23:03:04 +00:00
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.
This commit is contained in:
1
THANKS
1
THANKS
@@ -15,6 +15,7 @@ Anthony Heading ajrh@ajrh.net
|
|||||||
Antonio Silva Correia amsilvacorreia@hotmail.com
|
Antonio Silva Correia amsilvacorreia@hotmail.com
|
||||||
Arnold Robbins arnold@skeeve.com
|
Arnold Robbins arnold@skeeve.com
|
||||||
Art Haas ahaas@neosoft.com
|
Art Haas ahaas@neosoft.com
|
||||||
|
Askar Safin safinaskar@mail.ru
|
||||||
Baron Schwartz baron@sequent.org
|
Baron Schwartz baron@sequent.org
|
||||||
Ben Pfaff blp@cs.stanford.edu
|
Ben Pfaff blp@cs.stanford.edu
|
||||||
Benoit Perrot benoit.perrot@epita.fr
|
Benoit Perrot benoit.perrot@epita.fr
|
||||||
|
|||||||
@@ -10901,12 +10901,12 @@ Regular union-based code in Lex scanner typically look like:
|
|||||||
|
|
||||||
@example
|
@example
|
||||||
[0-9]+ @{
|
[0-9]+ @{
|
||||||
yylval.ival = text_to_int (yytext);
|
yylval->ival = text_to_int (yytext);
|
||||||
return yy::parser::INTEGER;
|
return yy::parser::token::INTEGER;
|
||||||
@}
|
@}
|
||||||
[a-z]+ @{
|
[a-z]+ @{
|
||||||
yylval.sval = new std::string (yytext);
|
yylval->sval = new std::string (yytext);
|
||||||
return yy::parser::IDENTIFIER;
|
return yy::parser::token::IDENTIFIER;
|
||||||
@}
|
@}
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
@@ -10915,12 +10915,12 @@ initialized. So the code would look like:
|
|||||||
|
|
||||||
@example
|
@example
|
||||||
[0-9]+ @{
|
[0-9]+ @{
|
||||||
yylval.build<int>() = text_to_int (yytext);
|
yylval->build<int> () = text_to_int (yytext);
|
||||||
return yy::parser::INTEGER;
|
return yy::parser::token::INTEGER;
|
||||||
@}
|
@}
|
||||||
[a-z]+ @{
|
[a-z]+ @{
|
||||||
yylval.build<std::string> = yytext;
|
yylval->build<std::string> () = yytext;
|
||||||
return yy::parser::IDENTIFIER;
|
return yy::parser::token::IDENTIFIER;
|
||||||
@}
|
@}
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
@@ -10929,12 +10929,12 @@ or
|
|||||||
|
|
||||||
@example
|
@example
|
||||||
[0-9]+ @{
|
[0-9]+ @{
|
||||||
yylval.build(text_to_int (yytext));
|
yylval->build (text_to_int (yytext));
|
||||||
return yy::parser::INTEGER;
|
return yy::parser::token::INTEGER;
|
||||||
@}
|
@}
|
||||||
[a-z]+ @{
|
[a-z]+ @{
|
||||||
yylval.build(yytext);
|
yylval->build (yytext);
|
||||||
return yy::parser::IDENTIFIER;
|
return yy::parser::token::IDENTIFIER;
|
||||||
@}
|
@}
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
@@ -10983,20 +10983,18 @@ For instance, given the following declarations:
|
|||||||
Bison generates the following functions:
|
Bison generates the following functions:
|
||||||
|
|
||||||
@example
|
@example
|
||||||
symbol_type make_IDENTIFIER(const std::string& v,
|
symbol_type make_IDENTIFIER (const std::string& v, const location_type& loc);
|
||||||
const location_type& l);
|
symbol_type make_INTEGER (const int& v, const location_type& loc);
|
||||||
symbol_type make_INTEGER(const int& v,
|
symbol_type make_COLON (const location_type& loc);
|
||||||
const location_type& loc);
|
|
||||||
symbol_type make_COLON(const location_type& loc);
|
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
@noindent
|
@noindent
|
||||||
which should be used in a Lex-scanner as follows.
|
which should be used in a Lex-scanner as follows.
|
||||||
|
|
||||||
@example
|
@example
|
||||||
[0-9]+ return yy::parser::make_INTEGER(text_to_int (yytext), loc);
|
[0-9]+ return yy::parser::make_INTEGER (text_to_int (yytext), loc);
|
||||||
[a-z]+ return yy::parser::make_IDENTIFIER(yytext, loc);
|
[a-z]+ return yy::parser::make_IDENTIFIER (yytext, loc);
|
||||||
":" return yy::parser::make_COLON(loc);
|
":" return yy::parser::make_COLON (loc);
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
Tokens that do not have an identifier are not accessible: you cannot simply
|
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
|
@comment file: calc++-scanner.ll
|
||||||
@example
|
@example
|
||||||
"-" return yy::calcxx_parser::make_MINUS(loc);
|
"-" return yy::calcxx_parser::make_MINUS (loc);
|
||||||
"+" return yy::calcxx_parser::make_PLUS(loc);
|
"+" return yy::calcxx_parser::make_PLUS (loc);
|
||||||
"*" return yy::calcxx_parser::make_STAR(loc);
|
"*" return yy::calcxx_parser::make_STAR (loc);
|
||||||
"/" return yy::calcxx_parser::make_SLASH(loc);
|
"/" return yy::calcxx_parser::make_SLASH (loc);
|
||||||
"(" return yy::calcxx_parser::make_LPAREN(loc);
|
"(" return yy::calcxx_parser::make_LPAREN (loc);
|
||||||
")" return yy::calcxx_parser::make_RPAREN(loc);
|
")" return yy::calcxx_parser::make_RPAREN (loc);
|
||||||
":=" return yy::calcxx_parser::make_ASSIGN(loc);
|
":=" return yy::calcxx_parser::make_ASSIGN (loc);
|
||||||
|
|
||||||
@group
|
@group
|
||||||
@{int@} @{
|
@{int@} @{
|
||||||
@@ -11475,12 +11473,12 @@ The rules are simple. The driver is used to report errors.
|
|||||||
long n = strtol (yytext, NULL, 10);
|
long n = strtol (yytext, NULL, 10);
|
||||||
if (! (INT_MIN <= n && n <= INT_MAX && errno != ERANGE))
|
if (! (INT_MIN <= n && n <= INT_MAX && errno != ERANGE))
|
||||||
driver.error (loc, "integer is out of range");
|
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
|
@end group
|
||||||
@{id@} return yy::calcxx_parser::make_IDENTIFIER(yytext, loc);
|
@{id@} return yy::calcxx_parser::make_IDENTIFIER (yytext, loc);
|
||||||
. driver.error (loc, "invalid character");
|
. driver.error (loc, "invalid character");
|
||||||
<<EOF>> return yy::calcxx_parser::make_END(loc);
|
<<EOF>> return yy::calcxx_parser::make_END (loc);
|
||||||
%%
|
%%
|
||||||
@end example
|
@end example
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user