Xref: utzoo comp.lang.c:32019 comp.lang.c++:9633 Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!yale!cmcl2!phri!cooper!aardvark From: aardvark@cooper.cooper.EDU (Rob Horn ) Newsgroups: comp.lang.c,comp.lang.c++ Subject: Re: Interfacing yacc/lex with C++ Message-ID: <2947@cooper.cooper.EDU> Date: 19 Sep 90 23:39:35 GMT References: <1635@software.software.org> Distribution: usa Organization: The Cooper Union (NY, NY) Lines: 22 interfacing C++ with Yacc is messy, but easily done. Yacc itself produces C code with the users actions imbedded in it unchanged. Yacc does not care if your actions are valid C since C++ is a superset of C, the Yacc/Lex generated code can be compiled with the C++ compiler. example: %token SPAM MOOSE FOOBAR . . . ferret : SPAM MOOSE { // C++ code } | SPAM SPAM { // C++ code } ; %% Yacc will completely ignore what the actions you give it are and will put them unchanged into the file it produces. The version of Yacc I have used produces an old style C code, and thus the C++ compiler will print out a bunch of horrible warnings "warning: yyparse() old style declaration. type int assumed. " and such, but will produce no errors, provided the actions are acceptable C++ code.