Print a better error message for a '~' token in front of ('&' | '|' | '^')

Some users may expect this to work so this patch catches these
specific cases and tells the user to use the singe unary operators
'~&', etc. instead.
This commit is contained in:
Cary R 2009-05-20 09:14:39 -07:00 committed by Stephen Williams
parent 3ae3e34732
commit 9f07e3c16e
1 changed files with 15 additions and 0 deletions

15
parse.y
View File

@ -921,6 +921,21 @@ expression
FILE_NAME(tmp, @2);
$$ = tmp;
}
| '~' '&' expr_primary %prec UNARY_PREC
{ yyerror(@1, "error: '~' '&' is not a valid expression. "
"Please use operator '~&' instead.");
$$ = 0;
}
| '~' '|' expr_primary %prec UNARY_PREC
{ yyerror(@1, "error: '~' '|' is not a valid expression. "
"Please use operator '~|' instead.");
$$ = 0;
}
| '~' '^' expr_primary %prec UNARY_PREC
{ yyerror(@1, "error: '~' '^' is not a valid expression. "
"Please use operator '~^' instead.");
$$ = 0;
}
| K_NAND expr_primary %prec UNARY_PREC
{ PEUnary*tmp = new PEUnary('A', $2);
FILE_NAME(tmp, @2);