home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!brunix!cs.brown.edu!hm
- From: hm@cs.brown.edu (Harry Mamaysky)
- Subject: yacc and C++
- Message-ID: <1992Nov9.013842.28215@cs.brown.edu>
- Sender: news@cs.brown.edu
- Organization: Somewhere East or Somewhere West
- Date: Mon, 9 Nov 1992 01:38:42 GMT
- Lines: 43
-
- Howdy C++ faithful,
-
- I have a slight problem. I am trying to use a YACC generated parser in
- a C++ system I have. This leads to the problem of getting YACC to know
- about my C++ objects and such. Of course, I can't include C++ header
- files YACC (or can I?). SO I have a wrapper program whose routines are
- called by YACC. I turn before I call yyparse() I set a global variable
- to point to the object which is making the call. Then the wrapper
- routines use this global pointer top call the correspondiong class
- methods in my C++ code. So far so good.
-
- BUT, the compiler I am using ( v.3.0.1 AT&T C++ ) translates C++ code
- into C code and in so doing tacks on type specifier codes to the end
- of my routines. SO, for example, a routine called foo becomes
- _foo__FP5 in the symbol table of the object file which results from
- the code. Unfortunately, this same function foo, which is called by
- the YACC generated parser, is _foo is\n the corresponding symbol
- table. So, the linker gets screwed in the head and does not know what
- to do. I have to actually look up the routine names in the object file
- from the C++ program which acts as a wrapper and tack on the weird
- endings to the correspondings routines which are defined in the YACC
- file. Not pretty.
-
- Also, yyparse() is called by C++ code. So, the C++ translator makes
- yyparse() into yyparse__Fv() in its symbol table. This means that I
- have to call yyparse by its new name in the actual y.tab.c file.
- Again, not pretty.
-
- Although, the method I described works (so you can use it too if a
- better one does not exist), it is incredibly ugly and hack-like.
-
- So, does any one have a better way of using YACC with C++?
-
- Does a better way exist?
-
- Does a (free) YACC like tool exist for C++? If so, where?
-
- Please respond either by email or to comp.lang.c++. If any one out
- there has a nicer solution, I am most eager to hear about it.
-
- Harry.
-
- hm@cs.brown.edu
-