From 9f07e3c16ec85994b7a50760671b86b982a68e8b Mon Sep 17 00:00:00 2001 From: Cary R Date: Wed, 20 May 2009 09:14:39 -0700 Subject: [PATCH] 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. --- parse.y | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/parse.y b/parse.y index 764d99ffc..84a0f2005 100644 --- a/parse.y +++ b/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);