Multiple flex generated scanners are giving me trouble with duplicate symbols. I am using automake-1.10.
What is the best practice for organizing a program that includes multiple lex generated scanners? I am using the recommended practice of using defines to rename all of the yacc/lex symbols as described in the automake manual (e.g. "#define yylex c_lex", "#define yyerror c_error", etc.) for the yacc generated parser. The problem I encounter is that yyin is hard to get redefined. Flex outputs a definition for it before outputing my define for it in the top of the scan.l file. Basically what I have looks like this: myprog_SOURCES = parse.y scan.l BUILT_SOURCES = parse.c parse.h scan.c AM_YFLAGS = -d That is all well and good but then yyin is a global symbol defined by the flex generated scanner. This appears before I can redefine it inside the source. I guess I can add an AM_CPPFLAGS=-Dyyin=myprogin and list out all of the symbols to redefine there. But that fails to work if I have two flex generated scanners in the same directory. I would rather find a more general solution. If I add an option to flex to rename the symbols like this then the scanner flex generates renames the symbols for me. AM_LFLAGS = -l -Pmyprog But in this case ylwrap fails because -P also renames the output file to lex.myprog.c and ylwrap fails to find the produced file. And it has the same problem of failing if there are two flex generated scanners in the same directory. I am about ready to write a custom rule to sed the generated file. I am sure that will work but I must be missing something obvious since this is a common enough problem that there must be a standard solution that I am missing. Thanks Bob