Using of nonterminals with same name in rule

眉间皱痕 提交于 2021-02-11 13:33:58

问题


How can I use as reciever two nonterminals with same name? For example, a have this rule:

expression returns [int value] : 'min' factor factor { 
    $expression.value = min($factor1.value, $factor2.value) //here
}

I need to get value from both factors, but they names are the same. So, if I write $factor.value twice, I get value of first factor.


回答1:


I think that it is solution for your problem:

expression returns [int value] : 'min' f1=factor f2=factor { 
    $expression.value = min($f1.value, $f2.value)
}


来源:https://stackoverflow.com/questions/59372023/using-of-nonterminals-with-same-name-in-rule

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!