Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watnot!watmath!clyde!rutgers!husc6!think!!rose From: rose@.UUCP Newsgroups: comp.lang.c++ Subject: Re: Yacc and lex with C++; is it possible? Message-ID: <3271@think.UUCP> Date: Sat, 4-Apr-87 14:40:14 EST Article-I.D.: think.3271 Posted: Sat Apr 4 14:40:14 1987 Date-Received: Sun, 5-Apr-87 12:36:22 EST References: <4475@columbia.UUCP> Sender: news@think.UUCP Reply-To: rose@think.com (John Rose) Organization: Thinking Machines Corporation, Cambridge, MA Lines: 29 Clifford Beshers writes: >How well do yacc and lex work with C++? Are there major problems, minor >kludges. Must yacc and lex be re-written in C++, and, if so, has this been >done? We use both Yacc and Lex with C++. The Makefile is vanilla, except for a line which says "CC = CC". There is only one glitch, which you may not care about: If the YYSTYPE is a union of types which have constructors, you've got to change it to a struct, and probably give it an explicit member-wise operator=. (Reason: C++ supports guaranteed initialization. The flip side of this is that C++ will not trust the programmer with uninitialized objects [when the type has G.I.], and so there's no way to say "trust me, this union object contains a Foo, and the Bar of it can stay uninitialized." Yacc type-checks your use of the union, so it should be trust-worthy.) Making the union into a struct amounts to allocating separate stacks, one for each type. ---------------------------------------------------------- John R. Rose Thinking Machines Corporation 245 First St., Cambridge, MA 02142 (617) 876-1111 rose@think.arpa ihnp4!think!rose ---------------------------------------------------------- John R. Rose Thinking Machines Corporation 245 First St., Cambridge, MA 02142 (617) 876-1111 rose@think.arpa ihnp4!think!rose