问题
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