如何修复这个antlr语法,多个节点

时间:2022-12-11 20:24:40

all, here is the gramma:

全部,这是语法:

columnName (',' columnName)* -> ^(SM_TOK columnName)

columnName(','columnName)* - > ^(SM_TOK columnName)

I want the output ast of "A,B" to have multiple SM_TOK nodes , like : (SM_TOK A) (SM_TOK B)

我希望“A,B”的输出ast有多个SM_TOK节点,如:(SM_TOK A)(SM_TOK B)

But,currently,I only have: (SM_TOK A)

但是,目前,我只有:(SM_TOK A)

It seems that 'B' will be ignored.

似乎'B'将被忽略。

Can anyone help me to fix this gramma?

任何人都可以帮我修复这个语法吗?

Thanks!

1 个解决方案

#1


2  

Your left side specifies one or more columnName items, but the right side mentions only one. Try adding a +, like this:

您的左侧指定了一个或多个columnName项,但右侧仅提到一个。尝试添加+,如下所示:

columnName (',' columnName)* -> ^((SM_TOK columnName)+)

#1


2  

Your left side specifies one or more columnName items, but the right side mentions only one. Try adding a +, like this:

您的左侧指定了一个或多个columnName项,但右侧仅提到一个。尝试添加+,如下所示:

columnName (',' columnName)* -> ^((SM_TOK columnName)+)