[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Extending Functions from Manual Example
From: |
Jason Melbye |
Subject: |
Extending Functions from Manual Example |
Date: |
Tue, 9 Sep 2008 22:39:09 -0500 |
Hi all,
I have been reading through the Bison manual the past couple days. I really
liked the three examples, especially the last - the multifunction
calculator. Since reading that I have been wondering if there was a general
way to describe a function that can take on any number of arguments in the
grammer rules?
I suppose that I could just do something like,
| FNCT '(' exp ')' { $$ = (*($1->value.fnctptr))($3); }
| FNCT '(' exp ',' exp ')' { $$ = (*($1->value.fnctptr))($3,$5); }
| FNCT '(' exp ',' exp ',' exp ')' ...
I could go on like that to all for as many arguments as I wanted to / needed
to. However, I would also like to create a "plug-in" system where users can
create their own functions and add them to the application. Thus a avoiding
a limit on arguments would be desirable.
Thanks,
Jason
- Extending Functions from Manual Example,
Jason Melbye <=