[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Name Conflict With Multiple Parsers In Same Program

From: Bob Smith
Subject: Name Conflict With Multiple Parsers In Same Program
Date: Tue, 12 Jun 2007 09:36:48 -0500
User-agent: Thunderbird (Windows/20070326)

I'm trying to use two parsers in the same program to parse different
grammars.  The %name-prefix declaration works fine for as far as it goes.

However, I'm also using

    #define YYDEBUG 1
    %lex-param {LPPLLOCALVARS lpplLocalVars}
    %parse-param {LPPLLOCALVARS lpplLocalVars}

as well as function prototypes which complicates the picture.

Each source file (including the .c files generated from the .y files) has its own separate file with an extension of .pro which consists of
the compiler's output from generating the source file's prototypes.
For example, one of the generated .pro files has an entry for

extern int __cdecl fh_yyparse(void );

while the other has

extern int __cdecl pl_yyparse(void );

corresponding to %name-prefix="fh_yy" and %name-prefix="pl_yy"
respectively in the two source files.  All of the prototype files are
#included in one header file and that file is #included in every
source file (with appropriate #ifdefs around it for when the
prototypes are being generated).

Thus, there is a file called "compro.h" which has a line for each
prototype file such as

#include "fnhdr.pro"
#include "parseline.pro"

and all source files (such as fnhdr.y/.c and parseline.y/.c) have

#include "compro.h"

The problem occurs with the following four function names not subject
to %name-prefix:  yy_symbol_value_print, yy_symbol_print,
yy_reduce_print, and yydestruct.  In one file I use %lex-param {...}
which defines parameters to yylex, and yyparse, but also passes those
parameters to each of the above four functions.

Thus, there is a conflict between the two occurrences of (say)
yydestruct because they have different prototypes.  That is, in one
prototype file, yydestruct is declared as

static void __cdecl yydestruct(const char *yymsg,int yytype,struct
tagYYSTYPE *yyvaluep,struct tagPLLOCALVARS *lpplLocalVars);

and in the other it is declared with the last struct omitted because that file doesn't use %lex-param (the error msg is "warning: second formal parameter list longer than the first list").

Eventually, I figured out that I can work around this problem using

#define yy_symbol_print         fh_yy_symbol_print
#define yy_symbol_value_print   fh_yy_symbol_value_print
#define yy_reduce_print         fh_yy_reduce_print
#define yydestruct              fh_yydestruct

however, it was suggested to me on the help-bison list that this is really a bug in %name-prefix and should be reported as such.
Bob Smith - address@hidden - http://www.sudleyplace.com

reply via email to

[Prev in Thread] Current Thread [Next in Thread]