[comp.sources.wanted] YACC++ LEX++

rebecca@unssun.nevada.edu (Rebecca Hayhurst) (12/18/90)

I'm looking for information, source on a LEX and YACC to produce
C++ code.  
	Please email replies
		thanks

		rebecca@unssun.nevada.eedu 

ntanaka@trl.mei.co.jp (Nobuaki Tanaka) (12/18/90)

[rebecca@unssun.nevada.edu (Rebecca Hayhurst), <5140@tahoe.unr.edu>]:
 | I'm looking for information, source on a LEX and YACC to produce
 | C++ code.  
 | 	Please email replies
 | 		thanks
 | 
 | 		rebecca@unssun.nevada.eedu 

I'm also interested in YACC++ and LEX++. Would anyone explain about
those tools in this News Group?

Thanks.

ntanaka@trl.mei.co.jp

vera@fanaraaken.Stanford.EDU (James S. Vera) (12/18/90)

ntanaka@trl.mei.co.jp (Nobuaki Tanaka) writes:

>[rebecca@unssun.nevada.edu (Rebecca Hayhurst), <5140@tahoe.unr.edu>]:
> | I'm looking for information, source on a LEX and YACC to produce
> | C++ code.  
> | 	Please email replies
> | 		thanks
> | 
> | 		rebecca@unssun.nevada.eedu 

>I'm also interested in YACC++ and LEX++. Would anyone explain about
>those tools in this News Group?


There is a modified version of Bison create by Larry Augustin that
creates C++ parser objects.  Its available for anonymous ftp from
wilbur.stanford.edu.

James S. Vera      |         Internet	        |Standard Disclaimers
Stanford University|vera@fanaraaken.stanford.edu|Blah Blah Blah Blah
Bellcore           |vera2@rigel.cc.bellcore.com |

dag@control.lth.se (Dag Bruck) (12/18/90)

Rebecca Hayhurst writes:
> I'm looking for information, source on a LEX and YACC to produce
> C++ code.  

I have successfully used the plain YACC and LEX supplied with our Sun
system.  YACC and LEX do not have any particular views on the contents
of the actions; the trick is to make the C parser/scanner skeletons
acceptable to the C++ compiler.

The two files that must be changed are (on a Sun):

	/usr/lib/yaccpar
	/usr/lib/lex/ncform

The following steps should bring you a long way:

	1.  Include the header file (enclosed below) in your .y and .l
	files.  The file contains some declarations that the C++
	compiler needs.

	2.  Modify the skeletons so they become legal C++ code. This
	essentially means that you will have to change the formal
	argument lists of the functions, etc.

	If you wrap your changes in #ifdef __cplusplus/#else/#endif,
	you will get a parser/scanner that is useful for *both* C
	and C++.

Please note that your parser/scanner skeleton may be different from
mine, so you may run into trouble I haven't discovered.  Here is my
header file:

	/* C++ definition for lex programs */

	#ifdef __cplusplus
	#include <malloc.h>

	extern int yydebug;
	extern int yylineno;
	extern int yynerrs;
	extern YYSTYPE yylval;
	
	extern void yyerror(const char *);

	extern int yylook();
	extern int yyparse();
	extern int yylex();
	extern "C" {
	        int yyless();
	        int yyreject();
	        int yywrap();
	        int yyback(int *, int);
	        int yyinput();
	        void yyoutput(int);
	        void yyunput(int);
	}
	#endif

The `extern "C"' routines are in the LEX runtime library.

Good luck.

Dag M. Bruck
--
Department of Automatic Control		E-mail: dag@control.lth.se
Lund Institute of Technology
P. O. Box 118				Phone:	+46 46-104287
S-221 00 Lund, SWEDEN			Fax:    +46 46-138118

vern@daffy.ee.lbl.gov (Vern Paxson) (12/19/90)

In article <3706@atomic.trl.mei.co.jp> ntanaka@trl.mei.co.jp (Nobuaki Tanaka) writes:
> [rebecca@unssun.nevada.edu (Rebecca Hayhurst), <5140@tahoe.unr.edu>]:
>  | I'm looking for information, source on a LEX and YACC to produce
>  | C++ code.  
> ...
> I'm also interested in YACC++ and LEX++. Would anyone explain about
> those tools in this News Group?

On the lex side of things, flex is a freely available version of lex which
produces C++-compatible code (and you can write your actions in C++ if you
want).  You can get it via anonymous ftp to ftp.ee.lbl.gov (128.3.254.68;
retrieve flex-2.3.tar.Z, using binary mode, and any flex-2.3.patch-X files
you see, using ascii mode) or from the comp.sources.unix archives.

If you don't have anonymous ftp or comp.sources.unix access, let me know
and I'll mail you the uuencoded tar file.

		Vern

	Vern Paxson				vern@helios.ee.lbl.gov
	Real Time Systems			ucbvax!helios.ee.lbl.gov!vern
	Lawrence Berkeley Laboratory		(415) 486-7504

nicb@ctr@italy.eu.net (Nicola Bernardini) (12/19/90)

In article <5140@tahoe.unr.edu> rebecca@unssun.nevada.edu (Rebecca Hayhurst) writes:
>I'm looking for information, source on a LEX and YACC to produce
>C++ code.  

rebecca@unssun.nevada.edu asks for email replies, but I think that
some replies on the net about it would be more than appropriate.
------------------
nicb%ctr@italy.eu.net