@@ -7940,7 +7940,7 @@ yp_binding_powers_t yp_binding_powers[YP_TOKEN_MAXIMUM] = {
7940
7940
7941
7941
// -@
7942
7942
[YP_TOKEN_UMINUS] = RIGHT_ASSOCIATIVE_UNARY(YP_BINDING_POWER_UMINUS),
7943
- [YP_TOKEN_UMINUS_NUM] = RIGHT_ASSOCIATIVE_UNARY( YP_BINDING_POWER_UMINUS) ,
7943
+ [YP_TOKEN_UMINUS_NUM] = { YP_BINDING_POWER_UMINUS, YP_BINDING_POWER_MAX, false } ,
7944
7944
7945
7945
// **
7946
7946
[YP_TOKEN_STAR_STAR] = RIGHT_ASSOCIATIVE(YP_BINDING_POWER_EXPONENT),
@@ -12790,16 +12790,23 @@ parse_expression_prefix(yp_parser_t *parser, yp_binding_power_t binding_power) {
12790
12790
yp_token_t operator = parser->previous;
12791
12791
yp_node_t *node = parse_expression(parser, yp_binding_powers[parser->previous.type].right, YP_ERR_UNARY_RECEIVER_MINUS);
12792
12792
12793
- switch (YP_NODE_TYPE(node)) {
12794
- case YP_INTEGER_NODE:
12795
- case YP_FLOAT_NODE:
12796
- case YP_RATIONAL_NODE:
12797
- case YP_IMAGINARY_NODE:
12798
- parse_negative_numeric(node);
12799
- break;
12800
- default:
12801
- node = (yp_node_t *) yp_call_node_unary_create(parser, &operator, node, "-@");
12802
- break;
12793
+ if (accept(parser, YP_TOKEN_STAR_STAR)) {
12794
+ yp_token_t exponent_operator = parser->previous;
12795
+ yp_node_t *exponent = parse_expression(parser, yp_binding_powers[exponent_operator.type].right, YP_ERR_EXPECT_ARGUMENT);
12796
+ node = (yp_node_t *) yp_call_node_binary_create(parser, node, &exponent_operator, exponent);
12797
+ node = (yp_node_t *) yp_call_node_unary_create(parser, &operator, node, "-@");
12798
+ } else {
12799
+ switch (YP_NODE_TYPE(node)) {
12800
+ case YP_INTEGER_NODE:
12801
+ case YP_FLOAT_NODE:
12802
+ case YP_RATIONAL_NODE:
12803
+ case YP_IMAGINARY_NODE:
12804
+ parse_negative_numeric(node);
12805
+ break;
12806
+ default:
12807
+ node = (yp_node_t *) yp_call_node_unary_create(parser, &operator, node, "-@");
12808
+ break;
12809
+ }
12803
12810
}
12804
12811
12805
12812
return node;
0 commit comments