[comp.unix.wizards] Multiple Lex Program Question

dave@andromeda.rutgers.edu.rutgers.edu (Dave Bloom) (07/19/88)

Here's a question for all you lex(1) fanatics out there:

What I need to do is create several lex functions to be
called from the same program at different times... so
instead of calling yylex(), I may want to call yylex_a(),
yylex_b()... etc.

Unfortunately, lex(1) has no flag that tells it to generate
the automaton WITHOUT the supporting functions and externals
(yycrank, yyline, etc.). So, while you can use an editor to
change the name yylex() everywhere in the file, the linker
still can't cope with the multiply defined symbols at link
time.

Does anyone have an elegant solution to this problem?  I could
always apply lex, then change the names of all variables/functions
whose names are prefixed with "yy" in the resulting lex.yy.c, but
then I wind up with duplicate functions under different names.

If you have any ideas, please respond by e-mail and I will summarize
(I don't normally subscribe to this group)

Thanx.
_______________________________________________________________________________
rutgers\                                                 | Dave Bloom
 galaxy >!andromeda!dave -or- dave@andromeda.rutgers.edu | Work: (201)648-5085
pyramid/                                                 |

jau@tut.fi (Jukka Ukkonen) (07/27/88)

From article <690@galaxy>, by dave@andromeda.rutgers.edu.rutgers.edu (Dave Bloom):
> Here's a question for all you lex(1) fanatics out there:
> 
> What I need to do is create several lex functions to be
> called from the same program at different times... so
> instead of calling yylex(), I may want to call yylex_a(),
> yylex_b()... etc.

	There is a program called 'flex' (for fast lex) that enables
	one to define the name (and even the call parameters if you
	wish) of the generated lex-function to avoid naming conflicts.
	The same supporting routines can be used for all lex-functions.
	It has many other advantages over the ordinary 'lex' as well.
	According to the manual page the author of flex is:
		Vern Paxson
		Real Time Systems
		Bldg. 46A
		Lawrence Barkeley Laboratory
		1 Cyclotron Road
		Berkeley, CA 94720
	Mail addresses:
		vern@lbl-csam.arpa
		ucbvax!lbl-csam!vern

	I hope this helps you to find a solution to your problem.

					- jau -