Skip to content
This repository was archived by the owner on Nov 23, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions ext/ripper/eventids2.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ ripper_token2eventid(enum yytokentype tok)
[tNMATCH] = O(op),
[tNTH_REF] = O(backref),
[tOP_ASGN] = O(op),
[tINCOP] = O(op),
[tOROP] = O(op),
[tPOW] = O(op),
[tQWORDS_BEG] = O(qwords_beg),
Expand Down
32 changes: 31 additions & 1 deletion parse.y
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,7 @@ parser_token2id(enum yytokentype tok)
TOKEN2ID(tCOLON2);
TOKEN2ID(tCOLON3);
TOKEN2ID(tOP_ASGN);
TOKEN2ID(tINCOP);
TOKEN2ID(tASSOC);
TOKEN2ID(tLPAREN);
TOKEN2ID(tLPAREN_ARG);
Expand Down Expand Up @@ -1520,6 +1521,7 @@ static int looking_at_eol_p(struct parser_params *p);
%token <id> tCOLON2 RUBY_TOKEN(COLON2) "::"
%token tCOLON3 ":: at EXPR_BEG"
%token <id> tOP_ASGN "operator-assignment" /* +=, -= etc. */
%token <id> tINCOP "increment-operator" /* ++ */
%token tASSOC "=>"
%token tLPAREN "("
%token tLPAREN_ARG "( arg"
Expand Down Expand Up @@ -1557,7 +1559,7 @@ static int looking_at_eol_p(struct parser_params *p);
%left keyword_or keyword_and
%right keyword_not
%nonassoc keyword_defined
%right '=' tOP_ASGN
%right '=' tOP_ASGN tINCOP
%left modifier_rescue
%right '?' ':'
%nonassoc tDOT2 tDOT3 tBDOT2 tBDOT3
Expand Down Expand Up @@ -2640,6 +2642,30 @@ arg : lhs '=' lex_ctxt arg_rhs
/*% %*/
/*% ripper: opassign!($1, $2, $4) %*/
}
| var_lhs lex_ctxt tINCOP
{
/*%%%*/
SET_LEX_STATE(EXPR_END);

VALUE v = rb_cstr_to_inum("1", 16, FALSE);
NODE *x = NEW_LIT(v, &NULL_LOC);
YYLTYPE _cur_loc;
rb_parser_set_location(p, &_cur_loc);
RB_OBJ_WRITTEN(p->ast, Qnil, x);

$$ = new_op_assign(p, $1, '+', x, $2, &@$);
/*%
VALUE v = rb_cstr_to_inum("1", 16, FALSE);
add_mark_object(p, (v));
VALUE v1, v2, v3, v4;
v1 = (yyvsp[-2].val);
v2 = (yyvsp[0].val);
v3 = v;
v4 = dispatch3(p, v1, v2, v3);
(yyval.val) = v4;
SET_LEX_STATE(EXPR_END);
%*/
}
| primary_value '[' opt_call_args rbracket tOP_ASGN lex_ctxt arg_rhs
{
/*%%%*/
Expand Down Expand Up @@ -10178,6 +10204,10 @@ parser_yylex(struct parser_params *p)
}
return tUPLUS;
}
if (c == '+') {
SET_LEX_STATE(EXPR_BEG);
return tINCOP;
}
SET_LEX_STATE(EXPR_BEG);
pushback(p, c);
return warn_balanced('+', "+", "unary operator");
Expand Down