我有以下野牛文件-
%union
{
int integer_value;
double double_value;
char* string_value;
}
%token <integer_value> INTEGER
%token <string_value> VAR
%token <string_value> INTEGER_DECLARATION
%token <double_value> DOUBLE
%token <string_value> DOUBLE_DECLARATION
%%
program:
program statement '\n'
|
;
statement:
| INTEGER_DECLARATION VAR '=' INTEGER {//implementation}
| INTEGER_DECLARATION VAR '=' DOUBLE {//implementation as above}
%%
由于两者的实现INTEGER_DECLARATION VAR '=' INTEGER
是INTEGER_DECLARATION VAR '=' DOUBLE
相同的,是否可以在语句结构中设置OR
条件 bwINTEGER
和?DOUBLE
我试过INTEGER_DECLARATION VAR '=' INTEGER|DOUBLE
了,但它提示 warning: rule useless in parser due to conflicts: statement: DOUBLE
并且确实引用DOUBLE
被忽略了。