Re: Where are there both yytokentype and the corresponding macro definitions?

Akim Demaille <[email protected]>
Newsgroups gmane.comp.parsers.bison.general
Message-ID <[email protected]>
Hi,

> Le 7 févr. 2019 à 17:43, Peng Yu <[email protected]> a écrit :
> 
> Hi,
> 
> I see both yytokentype and the corresponding macro definitions in
> y.tab.h. It sounds like just one of them will be sufficient. Why are
> there both of them?
> 
> /* Token type.  */
> #ifndef YYTOKENTYPE
> # define YYTOKENTYPE
>  enum yytokentype
>  {
>    IF = 258,
> 
> /* Tokens.  */
> #define IF 258

You don't specify the version of Bison you ran.  Let's assume it was an ancient version, say 2.3 for instance.  In which case I read this:

/* Tokens.  */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
   /* Put the tokens into the symbol table, so that GDB and other debuggers
      know about them.  */
   enum yytokentype {
     IF = 258
   };
#endif
/* Tokens.  */
#define IF 258

which has some quite explicit comments.

If you take a recent version of Bison, you'll get this:

/* Token type.  */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
  enum yytokentype
  {
    IF = 258
  };
#endif

and nothing else.

Cheers.
_______________________________________________
[email protected] https://lists.gnu.org/mailman/listinfo/help-bison
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.