test:
'( expr ')'
{
cout << $<string_type>2 << endl;
}
;
expr:
or_expr
;
or_expr:
and_expr
| or_expr T_OR and_expr
;
and_expr:
equality_expr
| and_expr T_AND equality_expr
;
equality_expr:
relational_expr
| equality_expr T_EQU relational_expr
| equality_expr T_NEQ relational_expr
;
relational_expr:
unary_expr
etc...
如果我尝试解析:var_i!= var_j,cout&lt;&lt; $ 2&lt;&lt; ENDL;返回给我只是var_i而不是整个var_i!= var_j。我该如何解决?
答案 0 :(得分:0)
(在评论中回答:见Question with no answers, but issue solved in the comments (or extended in chat)。)
@Chris Dodd写道:看起来你没有在任何expr规则中设置$$
,所以当你阅读$2
时,你应该得到随机垃圾......