mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
parse.y: call_op2
* parse.y (call_op2): separate from call_op and also allow "::", while dot_or_colon should not allow ".?". [Feature #11537] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@52282 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
42a0bf55c7
commit
603b000dd0
3 changed files with 36 additions and 7 deletions
10
ChangeLog
10
ChangeLog
|
@ -1,3 +1,13 @@
|
|||
Mon Oct 26 12:55:06 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* parse.y (call_op2): separate from call_op and also allow "::",
|
||||
while dot_or_colon should not allow ".?". [Feature #11537]
|
||||
|
||||
Mon Oct 26 12:54:26 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* parse.y (call_op2): separate from call_op and also allow "::",
|
||||
while dot_or_colon should not allow ".?". [Feature #11537]
|
||||
|
||||
Mon Oct 26 01:03:23 2015 Rei Odaira <Rei.Odaira@gmail.com>
|
||||
|
||||
* thread_pthread.c: fix compile erros when
|
||||
|
|
16
parse.y
16
parse.y
|
@ -847,7 +847,7 @@ static void token_info_pop(struct parser_params*, const char *token, size_t len)
|
|||
%type <node> mlhs mlhs_head mlhs_basic mlhs_item mlhs_node mlhs_post mlhs_inner
|
||||
%type <id> fsym keyword_variable user_variable sym symbol operation operation2 operation3
|
||||
%type <id> cname fname op f_rest_arg f_block_arg opt_f_block_arg f_norm_arg f_bad_arg
|
||||
%type <id> f_kwrest f_label f_arg_asgn call_op
|
||||
%type <id> f_kwrest f_label f_arg_asgn call_op call_op2
|
||||
/*%%%*/
|
||||
/*%
|
||||
%type <val> program reswords then do dot_or_colon
|
||||
|
@ -1395,7 +1395,7 @@ command_call : command
|
|||
;
|
||||
|
||||
block_command : block_call
|
||||
| block_call dot_or_colon operation2 command_args
|
||||
| block_call call_op2 operation2 command_args
|
||||
{
|
||||
/*%%%*/
|
||||
$$ = NEW_CALL($1, $3, $4);
|
||||
|
@ -3608,7 +3608,7 @@ block_call : command do_block
|
|||
$$ = method_add_block($1, $2);
|
||||
%*/
|
||||
}
|
||||
| block_call dot_or_colon operation2 opt_paren_args
|
||||
| block_call call_op2 operation2 opt_paren_args
|
||||
{
|
||||
/*%%%*/
|
||||
$$ = NEW_CALL($1, $3, $4);
|
||||
|
@ -3617,7 +3617,7 @@ block_call : command do_block
|
|||
$$ = method_optarg($$, $4);
|
||||
%*/
|
||||
}
|
||||
| block_call dot_or_colon operation2 opt_paren_args brace_block
|
||||
| block_call call_op2 operation2 opt_paren_args brace_block
|
||||
{
|
||||
/*%%%*/
|
||||
block_dup_check($4, $5);
|
||||
|
@ -3629,7 +3629,7 @@ block_call : command do_block
|
|||
$$ = method_add_block($$, $5);
|
||||
%*/
|
||||
}
|
||||
| block_call dot_or_colon operation2 command_args do_block
|
||||
| block_call call_op2 operation2 command_args do_block
|
||||
{
|
||||
/*%%%*/
|
||||
block_dup_check($4, $5);
|
||||
|
@ -5107,7 +5107,7 @@ operation3 : tIDENTIFIER
|
|||
| op
|
||||
;
|
||||
|
||||
dot_or_colon : call_op
|
||||
dot_or_colon : '.'
|
||||
/*%c%*/
|
||||
/*%c
|
||||
{ $$ = $<val>1; }
|
||||
|
@ -5123,6 +5123,10 @@ call_op : '.' {$$ = '.';}
|
|||
| tDOTQ {$$ = tDOTQ;}
|
||||
;
|
||||
|
||||
call_op2 : call_op
|
||||
| tCOLON2 {$$ = tCOLON2;}
|
||||
;
|
||||
|
||||
opt_terms : /* none */
|
||||
| terms
|
||||
;
|
||||
|
|
|
@ -389,6 +389,16 @@ class TestRipper::ParserEvents < Test::Unit::TestCase
|
|||
}
|
||||
assert_equal true, thru_call
|
||||
assert_equal "[call(vcall(foo),::,call,[])]", tree
|
||||
|
||||
thru_call = false
|
||||
tree = parse("self.?foo", :on_call) {thru_call = true}
|
||||
assert_equal true, thru_call
|
||||
assert_equal "[call(ref(self),.?,foo)]", tree
|
||||
|
||||
thru_call = false
|
||||
tree = parse("self.?foo()", :on_call) {thru_call = true}
|
||||
assert_equal true, thru_call
|
||||
assert_equal "[call(ref(self),.?,foo,[])]", tree
|
||||
end
|
||||
|
||||
def test_excessed_comma
|
||||
|
@ -554,8 +564,13 @@ class TestRipper::ParserEvents < Test::Unit::TestCase
|
|||
|
||||
def test_defs
|
||||
thru_defs = false
|
||||
parse('def foo.bar; end', :on_defs) {thru_defs = true}
|
||||
tree = parse('def foo.bar; end', :on_defs) {thru_defs = true}
|
||||
assert_equal true, thru_defs
|
||||
assert_equal("[defs(vcall(foo),.,bar,[],bodystmt([void()]))]", tree)
|
||||
|
||||
thru_parse_error = false
|
||||
tree = parse('def foo.?bar; end', :on_parse_error) {thru_parse_error = true}
|
||||
assert_equal(true, thru_parse_error)
|
||||
end
|
||||
|
||||
def test_do_block
|
||||
|
|
Loading…
Add table
Reference in a new issue