bug-bison
[Top][All Lists]
Advanced

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

Re: problem compiling bison with gcc 3.0.5


From: Martin Trautmann
Subject: Re: problem compiling bison with gcc 3.0.5
Date: Sat, 02 Mar 2002 10:49:57 +0100
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:0.9.8) Gecko/20020204

Hi,

Akim Demaille wrote:
"Martin" == Martin Trautmann <address@hidden> writes:


Please, always keeps the messages on the lists.
Ok.


Martin> Hi, I compiled bison-1.33 with gcc 3.0.5.
Are you sure 3.0.5 exists?

Yes, try a cvs checkout. I also tried the 3.0.3beta. But there I thought its because of the beta.

Martin> Using the work around I sent you, I had no problem...

This part must have been lost in the cyberspace, I don't know what
workaround you are referring to.

Oh sorry, it was my fault.


Martin> Another independant question: I code C++ and did some tricks
Martin> to integrate the bison parser in my program. But in the newest
Martin> versions you put the token itself into a union. I am very sad
Martin> about that, because this makes it impossible to use a class
Martin> with constructor and destructor as token.

I know.  Nevertheless, I see no relationship at all with the tokens.
Could you be more specific?  You were not using %union?

No, I have two parsers. One is quite simple, but uses a std::string which is very much more comfortable than char* (I know it needs more memory)
  struct Token
  {
    std::string string;
    union{
      double scalar;
      bool boolean;
      Expression *exp;
    }u;
  };
And one is very complex and keeps track of the memory:
    class Token
    {
      int type;
      union{
        void *ptr;

        std::string *identifier;
        values::Flag   *flag;
        values::Scalar *scalar;
        values::Vector *vector;
        ...
    }
    public:

//*********************************************************************
// Token member funktions //*********************************************************************

      inline int get_type() const;

      // access functions by references
      inline std::string &identifier();
      inline values::Flag   &flag();
      inline values::Scalar &scalar();
      inline values::Vector &vector();
      ...
      // readonly access functions
      inline std::string get_identifier() const;
      inline values::Flag   get_flag() const;
      inline values::Scalar get_scalar() const;
      inline values::Vector get_vector() const;
      ...
      // is a value stored in that token?
      inline bool has_value() const;

      // delete stored token
      inline int consumed();

      // returns this token (needed by parser)
      inline Token &tok();

      //************
      // operators
      Token &operator=(const Token &t);


      //***************************
      // constuctors/destructors

      Token();
      // copy constructor
      Token(const Token &t);

      ~Token();
    };

  }


Martin> I used this to create a token which takes care of memory
Martin> allocation and freeing itself which is less fault prone than
Martin> having to destroy each element in the actions.

We hope to release a C== producing Bison in the next couple of months.

who is in charge of this? What are the C++ features?
I would like:
- everything in one class
- passing an object as info object to the parser
- class as token type

bye

Martin




reply via email to

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