vcall.breaking.diff

Implementation which changes error messages for `nil = foo` - Michael Edgar, 07/10/2011 04:55 AM

Download (3.51 KB)

View differences:

parse.y (working copy)
426 426
#define get_value(val) ripper_get_value(val)
427 427
static VALUE assignable_gen(struct parser_params*,VALUE);
428 428
#define assignable(lhs,node) assignable_gen(parser, (lhs))
429
static int id_is_var_gen(struct parser_params *parser, ID id);
430
#define id_is_var(id) id_is_var_gen(parser, (id))
429 431
#endif /* !RIPPER */
430 432

  
431 433
static ID formal_argument_gen(struct parser_params*, ID);
......
699 701
%type <node> lambda f_larglist lambda_body
700 702
%type <node> brace_block cmd_brace_block do_block lhs none fitem
701 703
%type <node> mlhs mlhs_head mlhs_basic mlhs_item mlhs_node mlhs_post mlhs_inner
702
%type <id>   fsym variable sym symbol operation operation2 operation3
704
%type <id>   fsym keyword_variable user_variable sym symbol operation operation2 operation3
703 705
%type <id>   cname fname op f_rest_arg f_block_arg opt_f_block_arg f_norm_arg f_bad_arg
704 706
/*%%%*/
705 707
/*%
......
1601 1603
		    }
1602 1604
		;
1603 1605

  
1604
mlhs_node	: variable
1606
mlhs_node	: user_variable
1605 1607
		    {
1606 1608
			$$ = assignable($1, 0);
1607 1609
		    }
......
1671 1673
		    }
1672 1674
		;
1673 1675

  
1674
lhs		: variable
1676
lhs		: user_variable
1675 1677
		    {
1676 1678
			$$ = assignable($1, 0);
1677 1679
		    /*%%%*/
......
4257 4259
		    }
4258 4260
		;
4259 4261

  
4260
variable	: tIDENTIFIER
4261
		| tIVAR
4262
		| tGVAR
4263
		| tCONSTANT
4264
		| tCVAR
4265
		| keyword_nil {ifndef_ripper($$ = keyword_nil);}
4266
		| keyword_self {ifndef_ripper($$ = keyword_self);}
4267
		| keyword_true {ifndef_ripper($$ = keyword_true);}
4268
		| keyword_false {ifndef_ripper($$ = keyword_false);}
4269
		| keyword__FILE__ {ifndef_ripper($$ = keyword__FILE__);}
4270
		| keyword__LINE__ {ifndef_ripper($$ = keyword__LINE__);}
4271
		| keyword__ENCODING__ {ifndef_ripper($$ = keyword__ENCODING__);}
4272
		;
4262
keyword_variable : keyword_nil {ifndef_ripper($$ = keyword_nil);}
4263
		 | keyword_self {ifndef_ripper($$ = keyword_self);}
4264
		 | keyword_true {ifndef_ripper($$ = keyword_true);}
4265
		 | keyword_false {ifndef_ripper($$ = keyword_false);}
4266
		 | keyword__FILE__ {ifndef_ripper($$ = keyword__FILE__);}
4267
		 | keyword__LINE__ {ifndef_ripper($$ = keyword__LINE__);}
4268
		 | keyword__ENCODING__ {ifndef_ripper($$ = keyword__ENCODING__);}
4269
		 ;
4273 4270

  
4274
var_ref		: variable
4271
user_variable :	tIDENTIFIER
4272
	      | tIVAR
4273
	      | tGVAR
4274
	      | tCONSTANT
4275
	      | tCVAR
4276
	      ;
4277

  
4278
var_ref		: user_variable
4275 4279
		    {
4276 4280
		    /*%%%*/
4277 4281
			if (!($$ = gettable($1))) $$ = NEW_BEGIN(0);
4278 4282
		    /*%
4279
			$$ = dispatch1(var_ref, $1);
4283
		        if (id_is_var(get_id($1))) {
4284
		          $$ = dispatch1(var_ref, $1);
4285
		        } else {
4286
		          $$ = dispatch1(vcall, $1);
4287
		        }
4280 4288
		    %*/
4281 4289
		    }
4290
		| keyword_variable
4291
		    {
4292
		    /*%%%*/
4293
			if (!($$ = gettable($1))) $$ = NEW_BEGIN(0);
4294
		    /*%
4295
		        $$ = dispatch1(var_ref, $1);
4296
		    %*/
4297
		    }
4282 4298
		;
4283 4299

  
4284
var_lhs		: variable
4300
var_lhs		: user_variable
4285 4301
		    {
4286 4302
			$$ = assignable($1, 0);
4287 4303
		    /*%%%*/
......
7894 7910
    return t;
7895 7911
}
7896 7912

  
7897
#ifndef RIPPER
7913
#ifdef RIPPER
7914

  
7915
static int
7916
id_is_var_gen(struct parser_params *parser, ID id)
7917
{
7918
    if (is_global_id(id) || is_instance_id(id) || is_const_id(id) || is_class_id(id)) {
7919
	return 1;
7920
    }
7921
    else if (is_local_id(id)) {
7922
	if (dyna_in_block() && dvar_defined(id)) return 1;
7923
	if (local_id(id)) return 1;
7924
	/* method call without arguments */
7925
	return 0;
7926
    }
7927
    compile_error(PARSER_ARG "identifier %s is not valid to get", rb_id2name(id));
7928
    return 0;
7929
}
7930

  
7931
#else  /* !RIPPER */
7898 7932
static NODE*
7899 7933
node_newnode(struct parser_params *parser, enum node_type type, VALUE a0, VALUE a1, VALUE a2)
7900 7934
{