new(p1, p2 = v2, p3 = v3)
public
Show source
static VALUE
ripper_initialize(int argc, VALUE *argv, VALUE self)
{
struct parser_params *parser;
VALUE src, fname, lineno;
TypedData_Get_Struct(self, struct parser_params, &parser_data_type, parser);
rb_scan_args(argc, argv, "12", &src, &fname, &lineno);
if (RB_TYPE_P(src, T_FILE)) {
lex_gets = ripper_lex_io_get;
}
else if (rb_respond_to(src, id_gets)) {
lex_gets = ripper_lex_get_generic;
}
else {
StringValue(src);
lex_gets = lex_get_str;
}
lex_input = src;
parser->eofp = 0;
if (NIL_P(fname)) {
fname = STR_NEW2("(ripper)");
OBJ_FREEZE(fname);
}
else {
StringValueCStr(fname);
fname = rb_str_new_frozen(fname);
}
parser_initialize(parser);
ruby_sourcefile_string = fname;
ruby_sourcefile = RSTRING_PTR(fname);
ruby_sourceline = NIL_P(lineno) ? 0 : NUM2INT(lineno) - 1;
return Qnil;
}