label_patch.diff

Implementation - Michael Edgar, 06/27/2011 11:28 AM

Download (4.07 KB)

View differences:

parse.y (working copy)
365 365
#define new_evstr(n) new_evstr_gen(parser,(n))
366 366
static NODE *evstr2dstr_gen(struct parser_params*,NODE*);
367 367
#define evstr2dstr(n) evstr2dstr_gen(parser,(n))
368
static NODE *dstr_to_dsym_gen(struct parser_params*, NODE*);
369
#define dstr_to_dsym(n) dstr_to_dsym_gen(parser,(n))
368 370
static NODE *splat_array(NODE*);
369 371

  
370 372
static NODE *call_bin_op_gen(struct parser_params*,NODE*,ID,NODE*);
......
733 735
%token tAMPER		/* & */
734 736
%token tLAMBDA		/* -> */
735 737
%token tSYMBEG tSTRING_BEG tXSTRING_BEG tREGEXP_BEG tWORDS_BEG tQWORDS_BEG
736
%token tSTRING_DBEG tSTRING_DVAR tSTRING_END tLAMBEG
738
%token tSTRING_DBEG tSTRING_DVAR tSTRING_END tLAMBEG tLABEL_END
737 739

  
738 740
/*
739 741
 *	precedence table
......
4203 4205
		    {
4204 4206
			lex_state = EXPR_END;
4205 4207
		    /*%%%*/
4206
			if (!($$ = $2)) {
4207
			    $$ = NEW_LIT(ID2SYM(rb_intern("")));
4208
			}
4209
			else {
4210
			    VALUE lit;
4211

  
4212
			    switch (nd_type($$)) {
4213
			      case NODE_DSTR:
4214
				nd_set_type($$, NODE_DSYM);
4215
				break;
4216
			      case NODE_STR:
4217
				lit = $$->nd_lit;
4218
				$$->nd_lit = ID2SYM(rb_intern_str(lit));
4219
				nd_set_type($$, NODE_LIT);
4220
				break;
4221
			      default:
4222
				$$ = NEW_NODE(NODE_DSYM, Qnil, 1, NEW_LIST($$));
4223
				break;
4224
			    }
4225
			}
4208
		        $$ = dstr_to_dsym($2);
4226 4209
		    /*%
4227 4210
			$$ = dispatch1(dyna_symbol, $2);
4228 4211
		    %*/
......
4765 4748
			$$ = dispatch2(assoc_new, $1, $2);
4766 4749
		    %*/
4767 4750
		    }
4768
		;
4751
		| tSTRING_BEG string_contents tLABEL_END arg_value
4752
		    {
4753
		    /*%%%*/
4754
			$$ = list_append(NEW_LIST(dstr_to_dsym($2)), $4);
4755
		    /*%
4756
			$$ = dispatch2(assoc_new, dispatch1(dyna_symbol, $2), $4);
4757
		    %*/
4758
		    };
4769 4759

  
4770 4760
operation	: tIDENTIFIER
4771 4761
		| tCONSTANT
......
6586 6576
	}
6587 6577
	else {
6588 6578
	    token = parse_string(lex_strterm);
6589
	    if (token == tSTRING_END || token == tREGEXP_END) {
6579
	    if (token == tSTRING_END && (peek_n('\'', -1) || peek_n('"', -1))) {
6580
	        if (peek(':') && (lex_state == EXPR_BEG || lex_state == EXPR_ENDARG || IS_ARG())) {
6581
                    nextc();
6582
                    token = tLABEL_END;
6583
                }
6584
            }
6585
            if (token == tSTRING_END || token == tREGEXP_END || token == tLABEL_END) {
6590 6586
		rb_gc_force_recycle((VALUE)lex_strterm);
6591 6587
		lex_strterm = 0;
6592 6588
		lex_state = EXPR_END;
......
8129 8125
}
8130 8126

  
8131 8127
static NODE *
8128
dstr_to_dsym_gen(struct parser_params *parser, NODE *node) {
8129
    NODE *key;
8130
    if (!(key = node)) {
8131
        key = NEW_LIT(ID2SYM(rb_intern("")));
8132
    }
8133
    else {
8134
        VALUE lit;
8135
    
8136
        switch (nd_type(key)) {
8137
          case NODE_DSTR:
8138
    	    nd_set_type(key, NODE_DSYM);
8139
    	    break;
8140
          case NODE_STR:
8141
    	    lit = key->nd_lit;
8142
    	    key->nd_lit = ID2SYM(rb_intern_str(lit));
8143
    	    nd_set_type(key, NODE_LIT);
8144
    	    break;
8145
          default:
8146
    	    key = NEW_NODE(NODE_DSYM, Qnil, 1, NEW_LIST(key));
8147
    	    break;
8148
        }
8149
    }
8150
    return key;
8151
}
8152

  
8153
static NODE *
8132 8154
call_bin_op_gen(struct parser_params *parser, NODE *recv, ID id, NODE *arg1)
8133 8155
{
8134 8156
    value_expr(recv);
ext/ripper/eventids2.c (working copy)
42 42
static ID ripper_id_regexp_beg;
43 43
static ID ripper_id_regexp_end;
44 44
static ID ripper_id_label;
45
static ID ripper_id_label_end;
45 46
static ID ripper_id_tlambda;
46 47
static ID ripper_id_tlambeg;
47 48

  
......
95 96
    ripper_id_regexp_beg = rb_intern_const("on_regexp_beg");
96 97
    ripper_id_regexp_end = rb_intern_const("on_regexp_end");
97 98
    ripper_id_label = rb_intern_const("on_label");
99
    ripper_id_label_end = rb_intern_const("on_label_end");
98 100
    ripper_id_tlambda = rb_intern_const("on_tlambda");
99 101
    ripper_id_tlambeg = rb_intern_const("on_tlambeg");
100 102

  
......
247 249
    {tWORDS_BEG,	&ripper_id_words_beg},
248 250
    {tXSTRING_BEG,	&ripper_id_backtick},
249 251
    {tLABEL,		&ripper_id_label},
252
    {tLABEL_END,	&ripper_id_label_end},
250 253
    {tLAMBDA,		&ripper_id_tlambda},
251 254
    {tLAMBEG,		&ripper_id_tlambeg},
252 255