Project

General

Profile

Feature #15741 ยป ordinal-parameters.patch

mame (Yusuke Endoh), 03/31/2019 11:52 PM

View differences:

parse.y
6392 6392

  
6393 6393
#define NUM_SUFFIX_R   (1<<0)
6394 6394
#define NUM_SUFFIX_I   (1<<1)
6395
#define NUM_SUFFIX_ALL 3
6395
#define NUM_SUFFIX_TH  (1<<2)
6396
#define NUM_SUFFIX_ALL 7
6396 6397

  
6397 6398
static int
6398 6399
number_literal_suffix(struct parser_params *p, int mask)
......
6413 6414
	    mask &= ~NUM_SUFFIX_R;
6414 6415
	    continue;
6415 6416
	}
6417
	if ((mask & NUM_SUFFIX_TH) && (c == 's' || c == 't' || c == 'n' || c == 'd' || c == 't' || c == 'h')) {
6418
	    result |= (mask & NUM_SUFFIX_TH);
6419
	    continue;
6420
	}
6416 6421
	if (!ISASCII(c) || ISALPHA(c) || c == '_') {
6417 6422
	    p->lex.pcur = lastp;
6418 6423
	    literal_flush(p, p->lex.pcur);
......
6445 6450
    return type;
6446 6451
}
6447 6452

  
6453
static bool parser_numbered_param(struct parser_params *p, unsigned long n);
6454

  
6448 6455
static enum yytokentype
6449 6456
set_integer_literal(struct parser_params *p, VALUE v, int suffix)
6450 6457
{
......
6453 6460
	v = rb_rational_raw1(v);
6454 6461
	type = tRATIONAL;
6455 6462
    }
6463
    if (suffix & NUM_SUFFIX_TH) {
6464
	int n = NUM2LONG(v);
6465
	if (n < 0 || n > NUMPARAM_MAX) {
6466
	    YYLTYPE loc;
6467
	    RUBY_SET_YYLLOC(loc);
6468
	    compile_error(p, "too large numbered parameter");
6469
	    parser_show_error_line(p, &loc);
6470
	    set_yylval_noname();
6471
	    return tNUMPARAM;
6472
	}
6473
	else if (parser_numbered_param(p, n+1)) {
6474
	    return tNUMPARAM;
6475
	}
6476
    }
6456 6477
    return set_number_literal(p, v, type, suffix);
6457 6478
}
6458 6479