[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Bison 3.3.2 released [stable]
From: |
Akim Demaille |
Subject: |
Re: Bison 3.3.2 released [stable] |
Date: |
Mon, 4 Feb 2019 12:28:49 +0100 |
> Le 3 févr. 2019 à 18:24, Frank Heckenbach <address@hidden> a écrit :
>
>>> My only suggestion is about the wording in this announcement
>>> (and also in the manual):
>>
>> [...]
>>
>> You are right, this is much better. I'll install this:
>>
>> [...]
>
> Thanks. However, this accouncement still contains the old wording,
> and the documentation (bison.texi:11672) similarly. Is this
> intentional or just an oversight?
:( Stupid oversight... I copied/pasted the bottom of the previous
announcement, completely forgetting about the update... As for the doc, I
didn't remember it looked the same. I propose the following change:
commit 8a1d89e07301a44a704be50fad1b6a39ff998448
Author: Akim Demaille <address@hidden>
Date: Mon Feb 4 12:26:35 2019 +0100
doc: clarify the purpose of symbol_type constructors
Reported by Frank Heckenbach.
* doc/bison.texi (Complete Symbols): Here.
diff --git a/doc/bison.texi b/doc/bison.texi
index 279b73d2..c241473b 100644
--- a/doc/bison.texi
+++ b/doc/bison.texi
@@ -11668,15 +11668,21 @@ symbol_type (int token, const int&, const
location_type&);
symbol_type (int token, const location_type&);
@end example
address@hidden
-which should be used in a Flex-scanner as follows.
+Correct matching between token types and value types is checked via
address@hidden; for instance, @samp{symbol_type (ID, 42)} would abort. Named
+constructors are preferable (see below), as they offer better type safety
+(for instance @samp{make_ID (42)} would not even compile), but symbol_type
+constructors may help when token types are discovered at run-time, e.g.,
@example
-%%
-[a-z]+ return yy::parser::symbol_type (TOK_IDENTIFIER, yytext, loc);
-[0-9]+ return yy::parser::symbol_type (TOK_INTEGER, text_to_int (yytext),
loc);
-":" return yy::parser::symbol_type (':', loc);
-<<EOF>> return yy::parser::symbol_type (0, loc);
address@hidden
+[a-z]+ @{
+ if (auto i = lookup_keyword (yytext))
+ return yy::parser::symbol_type (i, loc);
+ else
+ return yy::parser::make_ID (yytext, loc);
+ @}
address@hidden group
@end example
@sp 1
Sorry, and thanks!