How can I parse a self define function ?
1 posts in topic
Flat View  Flat View

Posted By:   Benz_Huang
Posted On:   Monday, January 28, 2002 10:41 PM

Hello all!

I want to recognise a function define as: min(i,j) .

I have define it in "class ExprParser extends Parser;"


and atom is the and so on elements

My question is :what should I do in the "class ExprTreeWalker extends TreeParser;" like

: #(PLUS a=expr b=expr) {r = a.plus(b);}

to recognise the function "Min"

Expecting your kindly answer .

Re: How can I parse a self define function ?

Posted By:   joe_kraska  
Posted On:   Tuesday, January 29, 2002 09:44 AM

Ordinarily these kinds of things are
accomplished by making the function-
invocation part ("(" args ")") of the
expression a postfix expression and the
name of the function is left as either
an identifier or as a specific lvalue.

To get a better idea how this is done,
read the java grammar in detail. If
you are unfamiliar with the format of
the java grammar definition and the way
it handles operator precedence, I highly
recommend that you brace yourself, read
it very carefully, and figure out how it
works. It's essential that you under-
stand what you find there: the approach
is extremely common in setting up
grammars of all kinds.

Hope this helps,

About | Sitemap | Contact