Project

General

Profile

Feature #15741 ยป ordinal-parameters.patch

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

View differences:

parse.y
#define NUM_SUFFIX_R (1<<0)
#define NUM_SUFFIX_I (1<<1)
#define NUM_SUFFIX_ALL 3
#define NUM_SUFFIX_TH (1<<2)
#define NUM_SUFFIX_ALL 7
static int
number_literal_suffix(struct parser_params *p, int mask)
......
mask &= ~NUM_SUFFIX_R;
continue;
}
if ((mask & NUM_SUFFIX_TH) && (c == 's' || c == 't' || c == 'n' || c == 'd' || c == 't' || c == 'h')) {
result |= (mask & NUM_SUFFIX_TH);
continue;
}
if (!ISASCII(c) || ISALPHA(c) || c == '_') {
p->lex.pcur = lastp;
literal_flush(p, p->lex.pcur);
......
return type;
}
static bool parser_numbered_param(struct parser_params *p, unsigned long n);
static enum yytokentype
set_integer_literal(struct parser_params *p, VALUE v, int suffix)
{
......
v = rb_rational_raw1(v);
type = tRATIONAL;
}
if (suffix & NUM_SUFFIX_TH) {
int n = NUM2LONG(v);
if (n < 0 || n > NUMPARAM_MAX) {
YYLTYPE loc;
RUBY_SET_YYLLOC(loc);
compile_error(p, "too large numbered parameter");
parser_show_error_line(p, &loc);
set_yylval_noname();
return tNUMPARAM;
}
else if (parser_numbered_param(p, n+1)) {
return tNUMPARAM;
}
}
return set_number_literal(p, v, type, suffix);
}
    (1-1/1)