Skip to content

Commit

Permalink
Print a better error message for a '~' token in front of ('&' | '|' |…
Browse files Browse the repository at this point in the history
… '^')

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.
  • Loading branch information
caryr authored and steveicarus committed May 23, 2009
1 parent 9c02c7d commit 22416b4
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions parse.y
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 22416b4

Please sign in to comment.