[antlr-interest] ANTLR tree walker , multiple times return....
Michael Angelo
mangelo.mailing at gmail.com
Tue Jun 19 06:54:20 PDT 2012
I'm pretty sure that I had a similar problem to yours. Its matching the
first parameter where the others are separated by ',' correct?
I'm parsing SQL so its not exactly the same, but very close when I have a
function in place of a table. Here is how I got mine to work:
t='table' '(' func=IDENT '(' arguments ')' ')' alias
{
Table tbl = new Table($t.text + "(" + $func.text + "(" +
$arguments.text + ")" + ")", $alias.text);
tables.add(tbl);
}
;
arguments
:
argument (',' argument)*
;
argument
:
'?' | '\u0027' '\u0027' | '\u0027' ',' '\u0027'
;
The 'u0027' are the single quote characters. I wouldn't think you need
that, but I'm hoping there is a pattern in here for you.
Let me know if this helps!!
Mike
On Tue, Jun 19, 2012 at 9:20 AM, Felix.徐 <ygnhzeus at gmail.com> wrote:
> Hi,all .
>
> I have a tree walker like this:
>
> function:
> ^(FUNCTION_TOK fcname=IDENTIFIER param=functionParameters*){
> a_param_arrayList.add(param);
> }
> ;
>
> functionParameters returns [Object sth]:
> ^(PARAM_TOK value=IDENTIFIER){ sth = $value.getText();}
> ;
>
> This is a simple scenario,I just want to add the parameters to an
> arraylist, but the code above(*a_param_arrayList.add(param)*) will only
> collects the first parameter and ignores the
> others.But*functionParameters* actually
> parases multiple parameters.
>
> Does anyone know how to fix this tree walker? Thanks very much!
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
More information about the antlr-interest
mailing list