bug-bison
[Top][All Lists]
Advanced

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

Re: beta testing


From: Hans Aberg
Subject: Re: beta testing
Date: Tue, 20 Feb 2001 19:01:53 +0100

At 16:12 +0100 2001/02/20, Philippe Bekaert wrote:
>My Parser objects inherit from a flex Scanner object, which has a yylex
>member taking a (union! not a struct or class) YYSTYPE* as its argument,
>so I need to include y.tab.h in the scanner class declaration, and
>because my parser class is a sub-class of the scanner class, the
>declaration also appears in the bison script.

You should not derive from the Flex lexer class, as it is not always that
one wants to use it. -- Or at least not as a requirement, but only as an
option.

The way I use it, the .tab.h is included from the .l file, and therefore
from the lex...cc file.

>So I have to get rid of one of the YYSTYPE declarations.

This problem  is due to the fact that the .tab.h file does not have the
standard type of header macro-conditionals
  #ifndef foo_bar_header
  #define foo_bar_header
  ...
  #endif /* foo_bar_header */

So if you write a header defining YYSTYPE as usual, having such macro
conditionals, then you can include that header instead. For example, if the
YYSTYPE of my_project.y is defined in my_project.h, write in the latter
  #ifndef my_project_h
  #define my_project_h
  class my_type {
  public:
    ...
  };
  #define YYSTYPE my_type
  #endif /* my_project_h */

-- Note however, that one might want to use make use of namespaces, so that
different parsers using different --name-prefix end up in different
namespaces.

  Hans Aberg





reply via email to

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