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:
parent
3ae3e34732
commit
9f07e3c16e
15
parse.y
15
parse.y
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Reference in New Issue