diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-08-11 01:24:24 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-08-11 01:24:24 +0000 |
commit | 0859c42b77095e57e845844018a0c810f6df8654 (patch) | |
tree | 981841f1a0c669e7d52fb57d99df6179ec6853f4 /parse.y | |
parent | 2bd6264cd8726676e3eb12845e7d19cd71337dc7 (diff) | |
download | ruby-0859c42b77095e57e845844018a0c810f6df8654.tar.gz |
parse.y: const field macros
* parse.y (const_path_field, top_const_field): unify parser and
ripper code.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@55858 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'parse.y')
-rw-r--r-- | parse.y | 29 |
1 files changed, 10 insertions, 19 deletions
@@ -486,6 +486,9 @@ static NODE *new_attr_op_assign_gen(struct parser_params *parser, NODE *lhs, ID static NODE *new_const_op_assign_gen(struct parser_params *parser, NODE *lhs, ID op, NODE *rhs); #define new_const_op_assign(lhs, op, rhs) new_const_op_assign_gen(parser, (lhs), (op), (rhs)) +#define const_path_field(w, n) NEW_COLON2(w, n) +#define top_const_field(n) NEW_COLON3(n) + static NODE *kwd_append(NODE*, NODE*); static NODE *new_hash_gen(struct parser_params *parser, NODE *hash); @@ -515,7 +518,7 @@ static void parser_heredoc_dedent(struct parser_params*,NODE*); #define get_id(id) (id) #define get_value(val) (val) -#else +#else /* RIPPER */ #define NODE_RIPPER NODE_CDECL static inline VALUE @@ -548,6 +551,9 @@ static int id_is_var_gen(struct parser_params *parser, ID id); static VALUE new_op_assign_gen(struct parser_params *parser, VALUE lhs, VALUE op, VALUE rhs); static VALUE new_attr_op_assign_gen(struct parser_params *parser, VALUE lhs, VALUE type, VALUE attr, VALUE op, VALUE rhs); #define new_attr_op_assign(lhs, type, attr, op, rhs) new_attr_op_assign_gen(parser, (lhs), (type), (attr), (op), (rhs)) +#define new_const_op_assign(lhs, op, rhs) new_op_assign(lhs, op, rhs) +#define const_path_field(w, n) dispatch2(const_path_field, (w), (n)) +#define top_const_field(n) dispatch1(top_const_field, (n)) static VALUE parser_reg_compile(struct parser_params*, VALUE, int, VALUE *); @@ -1304,13 +1310,8 @@ stmt : keyword_alias fitem {SET_LEX_STATE(EXPR_FNAME|EXPR_FITEM);} fitem } | primary_value tCOLON2 tCONSTANT tOP_ASGN command_call { - /*%%%*/ - $$ = NEW_COLON2($1, $3); + $$ = const_path_field($1, $3); $$ = new_const_op_assign($$, $4, $5); - /*% - $$ = dispatch2(const_path_field, $1, $3); - $$ = dispatch3(opassign, $$, $4, $5); - %*/ } | primary_value tCOLON2 tIDENTIFIER tOP_ASGN command_call { @@ -2097,23 +2098,13 @@ arg : lhs '=' arg_rhs } | primary_value tCOLON2 tCONSTANT tOP_ASGN arg { - /*%%%*/ - $$ = NEW_COLON2($1, $3); + $$ = const_path_field($1, $3); $$ = new_const_op_assign($$, $4, $5); - /*% - $$ = dispatch2(const_path_field, $1, $3); - $$ = dispatch3(opassign, $$, $4, $5); - %*/ } | tCOLON3 tCONSTANT tOP_ASGN arg { - /*%%%*/ - $$ = NEW_COLON3($2); + $$ = top_const_field($2); $$ = new_const_op_assign($$, $3, $4); - /*% - $$ = dispatch1(top_const_field, $2); - $$ = dispatch3(opassign, $$, $3, $4); - %*/ } | backref tOP_ASGN arg { |