parse.y: backref_assign_error
* parse.y (backref_assign_error): unify parser and ripper code. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55860 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
76e8f883d8
commit
a2b06fe444
55
parse.y
55
parse.y
@ -492,6 +492,9 @@ static NODE *new_const_op_assign_gen(struct parser_params *parser, NODE *lhs, ID
|
|||||||
((in_def || in_single) ? yyerror("dynamic constant assignment") : (void)0), \
|
((in_def || in_single) ? yyerror("dynamic constant assignment") : (void)0), \
|
||||||
NEW_CDECL(0, 0, (path)))
|
NEW_CDECL(0, 0, (path)))
|
||||||
|
|
||||||
|
#define var_field(n) (n)
|
||||||
|
#define backref_assign_error(n, a) (rb_backref_error(n), NEW_BEGIN(0))
|
||||||
|
|
||||||
static NODE *kwd_append(NODE*, NODE*);
|
static NODE *kwd_append(NODE*, NODE*);
|
||||||
|
|
||||||
static NODE *new_hash_gen(struct parser_params *parser, NODE *hash);
|
static NODE *new_hash_gen(struct parser_params *parser, NODE *hash);
|
||||||
@ -560,6 +563,10 @@ static VALUE new_attr_op_assign_gen(struct parser_params *parser, VALUE lhs, VAL
|
|||||||
static VALUE const_decl_gen(struct parser_params *parser, VALUE path);
|
static VALUE const_decl_gen(struct parser_params *parser, VALUE path);
|
||||||
#define const_decl(path) const_decl_gen(parser, path)
|
#define const_decl(path) const_decl_gen(parser, path)
|
||||||
|
|
||||||
|
#define var_field(n) dispatch1(var_field, (n))
|
||||||
|
static VALUE backref_assign_error_gen(struct parser_params *parser, VALUE a);
|
||||||
|
#define backref_assign_error(n, a) backref_assign_error_gen(parser, (a))
|
||||||
|
|
||||||
static VALUE parser_reg_compile(struct parser_params*, VALUE, int, VALUE *);
|
static VALUE parser_reg_compile(struct parser_params*, VALUE, int, VALUE *);
|
||||||
|
|
||||||
#endif /* !RIPPER */
|
#endif /* !RIPPER */
|
||||||
@ -1325,14 +1332,8 @@ stmt : keyword_alias fitem {SET_LEX_STATE(EXPR_FNAME|EXPR_FITEM);} fitem
|
|||||||
}
|
}
|
||||||
| backref tOP_ASGN command_call
|
| backref tOP_ASGN command_call
|
||||||
{
|
{
|
||||||
/*%%%*/
|
$1 = var_field($1);
|
||||||
rb_backref_error($1);
|
$$ = backref_assign_error($1, node_assign($1, $3));
|
||||||
$$ = NEW_BEGIN(0);
|
|
||||||
/*%
|
|
||||||
$$ = dispatch2(assign, dispatch1(var_field, $1), $3);
|
|
||||||
$$ = dispatch1(assign_error, $$);
|
|
||||||
ripper_error();
|
|
||||||
%*/
|
|
||||||
}
|
}
|
||||||
| lhs '=' mrhs
|
| lhs '=' mrhs
|
||||||
{
|
{
|
||||||
@ -1795,14 +1796,8 @@ mlhs_node : user_variable
|
|||||||
}
|
}
|
||||||
| backref
|
| backref
|
||||||
{
|
{
|
||||||
/*%%%*/
|
$1 = var_field($1);
|
||||||
rb_backref_error($1);
|
$$ = backref_assign_error($1, $1);
|
||||||
$$ = NEW_BEGIN(0);
|
|
||||||
/*%
|
|
||||||
$$ = dispatch1(var_field, $1);
|
|
||||||
$$ = dispatch1(assign_error, $$);
|
|
||||||
ripper_error();
|
|
||||||
%*/
|
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -1866,13 +1861,8 @@ lhs : user_variable
|
|||||||
}
|
}
|
||||||
| backref
|
| backref
|
||||||
{
|
{
|
||||||
/*%%%*/
|
$1 = var_field($1);
|
||||||
rb_backref_error($1);
|
$$ = backref_assign_error($1, $1);
|
||||||
$$ = NEW_BEGIN(0);
|
|
||||||
/*%
|
|
||||||
$$ = dispatch1(assign_error, $1);
|
|
||||||
ripper_error();
|
|
||||||
%*/
|
|
||||||
}
|
}
|
||||||
;
|
;
|
||||||
|
|
||||||
@ -2073,15 +2063,8 @@ arg : lhs '=' arg_rhs
|
|||||||
}
|
}
|
||||||
| backref tOP_ASGN arg
|
| backref tOP_ASGN arg
|
||||||
{
|
{
|
||||||
/*%%%*/
|
$1 = var_field($1);
|
||||||
rb_backref_error($1);
|
$$ = backref_assign_error($1, new_op_assign($1, $2, $3));
|
||||||
$$ = NEW_BEGIN(0);
|
|
||||||
/*%
|
|
||||||
$$ = dispatch1(var_field, $1);
|
|
||||||
$$ = dispatch3(opassign, $$, $2, $3);
|
|
||||||
$$ = dispatch1(assign_error, $$);
|
|
||||||
ripper_error();
|
|
||||||
%*/
|
|
||||||
}
|
}
|
||||||
| arg tDOT2 arg
|
| arg tDOT2 arg
|
||||||
{
|
{
|
||||||
@ -10279,6 +10262,14 @@ const_decl_gen(struct parser_params *parser, VALUE path)
|
|||||||
}
|
}
|
||||||
return path;
|
return path;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static VALUE
|
||||||
|
backref_assign_error_gen(struct parser_params *parser, VALUE a)
|
||||||
|
{
|
||||||
|
a = dispatch1(assign_error, a);
|
||||||
|
ripper_error();
|
||||||
|
return a;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
x
Reference in New Issue
Block a user