This maybe is somewhat off topic, but I've been exploring Bison to generate a C parser. The Bison manual has an example (Multi-function Calc) which demonstrates how to describe the rules for parsing a function for the form fctname(argument). I'm wondering if there is a general way to do this for any number of arguments. For simplicity, I will restrict all argument types to double precision floating point values.

The grammer rules from the example mentioned above are:

The 4th line is of interest to me:Code:exp: NUM { $$ = $1; } | VAR { $$ = $1->value.var; } | VAR '=' exp { $$ = $3; $1->value.var = $3; } | FNCT '(' exp ')' { $$ = (*($1->value.fnctptr))($3); } | exp '+' exp { $$ = $1 + $3; } | exp '-' exp { $$ = $1 - $3; } | exp '*' exp { $$ = $1 * $3; } | exp '/' exp { $$ = $1 / $3; } | '-' exp %prec NEG { $$ = -$2; } | exp '^' exp { $$ = pow ($1, $3); } | '(' exp ')' { $$ = $2; }

If worst came to worst, I could make similar rules for 2, 3, ... arguments up to the max number of the functions I need to work with. However, I was hoping to allow for a plug-in system where users could provide their own functions which would be read in via dlopen()/dlsym() and passed along to the symbol table used by the parser. Thus, a more general approach is more desirable.Code:| FNCT '(' exp ')' { $$ = (*($1->value.fnctptr))($3); }

Any one know of a way to do this?

Thanks,

Jason