how to resolve 2+2 and 2++2 conflict
问题 In larger program I have given the following (flex/bison) In flex: pn [\+|\-] dig [0-9]+ exp [e|E]{dig}+ . . . "+" {printf("+ detected\n"); return PLUS_SIGN;} {pn}?{dig}+ { printf("digit detected - %s\n",yytext); sscanf(yytext, "%d", (int*)&yylval); return TYPE_INT;} In Bison: expr: expr PLUS_SIGN expr { $$ = $1 + $3; printf(" $$=%f\n",$$); } | TYPE_INT { $$ = (int)$1; printf(" $$=%f\n",$$); } ; The problem is: When I give 2+2 it recognizes 2 and +2 instead of 2 , + , 2 How can I get it to do