bug-bison
[Top][All Lists]
Advanced

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

Bison 3.0: enhancement request proposal


From: Francis ANDRE
Subject: Bison 3.0: enhancement request proposal
Date: Sun, 30 Aug 2015 12:21:27 +0200
User-agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.2.0

Hi

I am using Bison for a grammar that brings conflicting names like the following use case:

%token IDENTIFIER "IDENTIFIER"   // the keyword IDENTIFIER
%token identifier // the terminal identifier for lower case name

Bison  generates then

#ifndef YYTOKENTYPE
# define YYTOKENTYPE
  enum yytokentype
  {
    IDENTIFIER = 100,
    identifier = 101,
...

fine... but I would like to use the name "identifier" in some parser C++ code and that's not possible because it is already used in the enum yytokentype. Thus I am proposing to add a directive to Bison for specifying the list of token as an C++ enum class type as

% enum-class = "MyTokens";

so that Bison would generate

#ifndef YYTOKENTYPE
# define YYTOKENTYPE
  enum class MyTokens
  {
    IDENTIFIER = 100,
    identifier = 101,
...

and replace yytokentype by MyTokens everywhere. As such, the token would need to be qualified by MyTokens:: in the lexer and in semantic actions and that exactly what is needed to keep the name "identifier" used out of the parser's code.

Regards





reply via email to

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