[antlr-interest] How does one handle variable number of function parameters?

Sohail Somani sohail at taggedtype.net
Mon Nov 28 22:25:39 PST 2005


On Mon, 2005-28-11 at 22:05 -0600, Rob Greene wrote:
> On 11/28/05, Sohail Somani <sohail at taggedtype.net> wrote:
> > On Mon, 2005-28-11 at 21:00 -0600, Rob Greene wrote:
> > > At work, I'm trying to get functions to work within expressions but I
> > > have no clue how to handle the variable number of parameters (the
> > > functions will be defined outside of the grammar file). The example
> > > (the basic interpreter) doesn't explain what's going on, so is simply
> > > baffling to me.
> >
> > Functions within expressions? Could you elaborate a bit? Do you mean
> > that an expression can contain a function call?
> 
> Exactly. I may be embedding something like
> "veryImportantFunction(32/3, anotherFunc(3, 2)) < 25" or
> "nameOfThis(12356) = 'Fred'". How do I get the subexpressions? (ie,
> "32/3" and "anotherFunc(3,2)" for the veryImportantFunction.
> 
> I want to have the functions expandable without embedding them into
> the grammar - especially since I'm the only one at this time with an
> idea on how the whole thing works! Setting up the functions and
> identifying them is pretty easy.
> 
> As an FYI, these functions will be going against various sets of data
> as well as accessing the database. Not that it matters for the
> exercise. :-)

It might do you good to print out (and thoroughly read)
http://www.javadude.com/articles/antlrtut



More information about the antlr-interest mailing list