908 |
$$ = $1; |
$$ = $1; |
909 |
} |
} |
910 |
| '+' unary_expr { |
| '+' unary_expr { |
911 |
$$ = $2; |
if (isNumber($2->exprType())) { |
912 |
|
$$ = $2; |
913 |
|
} else { |
914 |
|
PARSE_ERR(@2, (String("Unary '+' operator requires number, is ") + typeStr($2->exprType()) + " though.").c_str()); |
915 |
|
$$ = new IntLiteral({ .value = 0 }); |
916 |
|
} |
917 |
} |
} |
918 |
| '-' unary_expr { |
| '-' unary_expr { |
919 |
$$ = new Neg($2); |
if (isNumber($2->exprType())) { |
920 |
|
$$ = new Neg($2); |
921 |
|
} else { |
922 |
|
PARSE_ERR(@2, (String("Unary '-' operator requires number, is ") + typeStr($2->exprType()) + " though.").c_str()); |
923 |
|
$$ = new IntLiteral({ .value = 0 }); |
924 |
|
} |
925 |
} |
} |
926 |
| BITWISE_NOT unary_expr { |
| BITWISE_NOT unary_expr { |
927 |
if ($2->exprType() != INT_EXPR) { |
if ($2->exprType() != INT_EXPR) { |