[antlr-interest] How to deal with this kind of situation?
Stefan Mätje
Stefan.Maetje at esd-electronics.com
Mon Jun 4 08:17:35 PDT 2012
Am 04.06.2012 14:14, schrieb Felix.徐:
> Hi,all, here is the gramma:
>
> columnName (',' columnName)* -> ^(SM_TOK columnName)
>
> I want the output ast of "A,B" to have multiple SM_TOK , like : (SM_TOK A)
> (SM_TOK B)
>
> But,currently,I only have: (SM_TOK A)
>
> It seems that 'B' will be ignored.
>
> Can anyone help me to fix this gramma?
Use something like:
columnName (',' columnName)* -> ^(SM_TOK columnName)+
Please note the '+' sign I added to your rewrite rule.
If you want to have something like
^(SM_TOK A B)
instead use
columnName (',' columnName)* -> ^(SM_TOK columnName+)
Please observe the different position of '+' here.
Best regards,
Stefan
More information about the antlr-interest
mailing list