* parse.y: fixes for ripper.

* parse.y (primary): reduced duplcated code.

* parse.y (f_arg_item): should not override by meaningless value.

* parse.y (f_arg, assocs): should not use $$ before assigned.

* parse.y (assoc_list): dispatch assoclist_from_args for assocs as
  well as args.

* parse.y (assoc): return assoc if dispatched result is $1.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12222 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2007-04-26 08:18:00 +00:00
parent da4ad54e47
commit f70f8173cd
2 changed files with 27 additions and 12 deletions

View File

@ -1,3 +1,18 @@
Thu Apr 26 17:18:51 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* parse.y: fixes for ripper.
* parse.y (primary): reduced duplcated code.
* parse.y (f_arg_item): should not override by meaningless value.
* parse.y (f_arg, assocs): should not use $$ before assigned.
* parse.y (assoc_list): dispatch assoclist_from_args for assocs as
well as args.
* parse.y (assoc): return assoc if dispatched result is $1.
Thu Apr 26 13:54:51 2007 Nobuyoshi Nakada <nobu@ruby-lang.org>
* misc/ruby-style.el: new file. C/C++ style for ruby source code.

24
parse.y
View File

@ -2778,15 +2778,12 @@ primary : literal
}
| keyword_def fname
{
/*%%%*/
$<id>$ = cur_mid;
cur_mid = $2;
in_def++;
/*%%%*/
local_push(0);
/*%
$<id>$ = cur_mid;
cur_mid = $2;
in_def++;
%*/
}
f_arglist
@ -2809,13 +2806,11 @@ primary : literal
}
| keyword_def singleton dot_or_colon {lex_state = EXPR_FNAME;} fname
{
/*%%%*/
in_single++;
local_push(0);
lex_state = EXPR_END; /* force for args */
/*%%%*/
local_push(0);
/*%
in_single++;
lex_state = EXPR_END;
%*/
}
f_arglist
@ -4102,7 +4097,6 @@ f_arg_item : f_norm_arg
arg_var($1);
$$ = NEW_ARGS_AUX($1, 1);
/*%
$$ = rb_ary_new();
%*/
}
| tLPAREN f_margs rparen
@ -4133,7 +4127,7 @@ f_arg : f_arg_item
$$->nd_next = block_append($$->nd_next, $3->nd_next);
rb_gc_force_recycle((VALUE)$3);
/*%
rb_ary_push($$, $3);
$$ = rb_ary_push($1, $3);
%*/
}
;
@ -4278,7 +4272,11 @@ singleton : var_ref
assoc_list : none
| assocs trailer
{
/*%%%*/
$$ = $1;
/*%
$$ = dispatch1(assoclist_from_args, $1);
%*/
}
| args trailer
{
@ -4305,7 +4303,7 @@ assocs : assoc
/*%%%*/
$$ = list_concat($1, $3);
/*%
rb_ary_push($$, $3);
$$ = rb_ary_push($1, $3);
%*/
}
;
@ -4316,6 +4314,7 @@ assoc : arg_value tASSOC arg_value
$$ = list_append(NEW_LIST($1), $3);
/*%
$$ = dispatch2(assoc_new, $1, $3);
if ($$ == $1) $$ = rb_assoc_new($1, $3);
%*/
}
| tLABEL arg_value
@ -4323,7 +4322,8 @@ assoc : arg_value tASSOC arg_value
/*%%%*/
$$ = list_append(NEW_LIST(NEW_LIT(ID2SYM($1))), $2);
/*%
$$ = dispatch2(assoc_new, $1, $2);
$$ = dispatch2(assoc_new, $1, $2);
if ($$ == $1) $$ = rb_assoc_new($1, $2);
%*/
}
;