bug-bison
[Top][All Lists]
Advanced

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

Re: missing YYEMPTY #define in C skeleton


From: Akim Demaille
Subject: Re: missing YYEMPTY #define in C skeleton
Date: Tue, 10 Nov 2020 07:47:52 +0100

Hi Todd,

> Le 9 nov. 2020 à 21:22, Todd C. Miller <Todd.Miller@sudo.ws> a écrit :
> 
> When generating a C parser, YYEMPTY is present in enum yytokentype
> but there is no corresponding #define like there is for the other
> values.  There is a special case for YYEMPTY in b4_token_enums but
> no corresponding case in b4_token_defines.

Doh...  Good catch, and sorry about that.

> Something like the following works, but is quite ugly.  I expected
> to be able to use b4_token_define([-2]) here but that produces an
> error.  Someone more familiar with bison's m4 macros can probably
> come up with a much better fix.

You are right it's ugly, but YYEMPTY is not a symbol, so it is
indeed kind of ugly to deal with.  Your patch is the right one.
It would be slightly less ugly in master, but this bug is
bad, so I will release 3.7.4 soon with the fix.  This patch is
therefore for the 'maint' branch.

Cheers!

commit d831b4ec39c4ed6edb44180f73cdfe7ebb5558b9
Author: Todd C. Miller <Todd.Miller@sudo.ws>
Date:   Tue Nov 10 07:36:11 2020 +0100

    yacc.c: fix #definition of YYEMPTY
    
    When generating a C parser, YYEMPTY is present in enum yytokentype but
    there is no corresponding #define like there is for the other values.
    There is a special case for YYEMPTY in b4_token_enums but no
    corresponding case in b4_token_defines.
    
    * data/skeletons/c.m4 (b4_token_defines): Do define YYEMPTY.

diff --git a/NEWS b/NEWS
index 32671d01..e7854838 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,9 @@ GNU Bison NEWS
 
 * Noteworthy changes in release ?.? (????-??-??) [?]
 
+** Bug fixes
+
+  Fix missing #definition of YYEMPTY in Yacc mode.
 
 * Noteworthy changes in release 3.7.3 (2020-10-13) [stable]
 
diff --git a/data/skeletons/c.m4 b/data/skeletons/c.m4
index 2452ed2e..50e81ee6 100644
--- a/data/skeletons/c.m4
+++ b/data/skeletons/c.m4
@@ -509,10 +509,11 @@ m4_define([b4_token_define],
 # ----------------
 # Output the definition of the tokens.
 m4_define([b4_token_defines],
-[b4_any_token_visible_if([/* Token kinds.  */
+[[/* Token kinds.  */
+#define ]b4_symbol([-2], [id])[ -2
 m4_join([
 ], b4_symbol_map([b4_token_define]))
-])])
+]])
 
 
 # b4_token_enum(TOKEN-NUM)




reply via email to

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