@@ -373,6 +373,9 @@ static int parser_yyerror(struct parser_params*, const char*);
373
373
374
374
#define NODE_CALL_Q (q ) (((q) == tDOTQ) ? NODE_QCALL : NODE_CALL)
375
375
#define NEW_QCALL (q,r,m,a ) NEW_NODE(NODE_CALL_Q(q),r,m,a)
376
+ #define NO_QCALL (q, here ) \
377
+ ((q) != tDOTQ ? (void )0 : \
378
+ yyerror (" .? in " here" is not supported yet" ))
376
379
377
380
static int yylex(YYSTYPE*, struct parser_params *);
378
381
@@ -847,7 +850,7 @@ static void token_info_pop(struct parser_params*, const char *token, size_t len)
847
850
%type <node> mlhs mlhs_head mlhs_basic mlhs_item mlhs_node mlhs_post mlhs_inner
848
851
%type <id> fsym keyword_variable user_variable sym symbol operation operation2 operation3
849
852
%type <id> cname fname op f_rest_arg f_block_arg opt_f_block_arg f_norm_arg f_bad_arg
850
- %type <id> f_kwrest f_label f_arg_asgn call_op call_op2
853
+ %type <id> f_kwrest f_label f_arg_asgn call_op call_op2 lbracket
851
854
/* %%%*/
852
855
/* %
853
856
%type <val> program reswords then do dot_or_colon
@@ -1243,11 +1246,15 @@ stmt : keyword_alias fitem {lex_state = EXPR_FNAME;} fitem
1243
1246
value_expr ($3 );
1244
1247
$$ = new_op_assign($1 , $2 , $3 );
1245
1248
}
1246
- | primary_value ' [ ' opt_call_args rbracket tOP_ASGN command_call
1249
+ | primary_value lbracket opt_call_args rbracket tOP_ASGN command_call
1247
1250
{
1248
1251
/* %%%*/
1249
1252
NODE *args;
1253
+ /* %
1254
+ %*/
1250
1255
1256
+ NO_QCALL ($2 , " lhs of op_asgn" );
1257
+ /* %%%*/
1251
1258
value_expr ($6 );
1252
1259
if (!$3 ) $3 = NEW_ZARRAY();
1253
1260
args = arg_concat($3 , $6 );
@@ -1709,8 +1716,9 @@ mlhs_node : user_variable
1709
1716
{
1710
1717
$$ = assignable($1 , 0 );
1711
1718
}
1712
- | primary_value ' [ ' opt_call_args rbracket
1719
+ | primary_value lbracket opt_call_args rbracket
1713
1720
{
1721
+ NO_QCALL ($2 , " mlhs" );
1714
1722
/* %%%*/
1715
1723
$$ = aryset($1 , $3 );
1716
1724
/* %
@@ -1800,8 +1808,9 @@ lhs : user_variable
1800
1808
$$ = dispatch1(var_field, $$);
1801
1809
%*/
1802
1810
}
1803
- | primary_value ' [ ' opt_call_args rbracket
1811
+ | primary_value lbracket opt_call_args rbracket
1804
1812
{
1813
+ NO_QCALL ($2 , " lhs" );
1805
1814
/* %%%*/
1806
1815
$$ = aryset($1 , $3 );
1807
1816
/* %
@@ -2042,11 +2051,15 @@ arg : lhs '=' arg
2042
2051
%*/
2043
2052
$$ = new_op_assign($1 , $2 , $3 );
2044
2053
}
2045
- | primary_value ' [ ' opt_call_args rbracket tOP_ASGN arg
2054
+ | primary_value lbracket opt_call_args rbracket tOP_ASGN arg
2046
2055
{
2047
2056
/* %%%*/
2048
2057
NODE *args;
2058
+ /* %
2059
+ %*/
2049
2060
2061
+ NO_QCALL ($2 , " lhs of op_asgn" );
2062
+ /* %%%*/
2050
2063
value_expr ($6 );
2051
2064
if (!$3 ) $3 = NEW_ZARRAY();
2052
2065
if (nd_type($3 ) == NODE_BLOCK_PASS) {
@@ -3741,13 +3754,13 @@ method_call : fcall paren_args
3741
3754
$$ = dispatch0(zsuper);
3742
3755
%*/
3743
3756
}
3744
- | primary_value ' [ ' opt_call_args rbracket
3757
+ | primary_value lbracket opt_call_args rbracket
3745
3758
{
3746
3759
/* %%%*/
3747
- if ($1 && nd_type($1 ) == NODE_SELF)
3760
+ if ($2 != tDOTQ && $ 1 && nd_type($1 ) == NODE_SELF)
3748
3761
$$ = NEW_FCALL(tAREF, $3 );
3749
3762
else
3750
- $$ = NEW_CALL( $1 , tAREF, $3 );
3763
+ $$ = NEW_QCALL( $2 , $1 , tAREF, $3 );
3751
3764
fixpos ($$, $1 );
3752
3765
/* %
3753
3766
$$ = dispatch2(aref, $1, escape_Qundef($3));
@@ -5158,6 +5171,10 @@ opt_nl : /* none */
5158
5171
rparen : opt_nl ' )'
5159
5172
;
5160
5173
5174
+ lbracket : ' [' {$$ = 0 ;}
5175
+ | tDOTQ ' [' {$$ = tDOTQ;}
5176
+ ;
5177
+
5161
5178
rbracket : opt_nl ' ]'
5162
5179
;
5163
5180
0 commit comments