1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

* error.c (Init_Exception): NameError went under StandardError,

and NoMethodError went under NameError.

* parse.y (rb_intern): non identifier symbols should be
  categorized as ID_JUNK. [new]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1505 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
matz 2001-06-05 07:50:59 +00:00
parent d6c60dbf6d
commit b12904e85f
4 changed files with 33 additions and 12 deletions

View file

@ -1,3 +1,13 @@
Tue Jun 5 16:45:48 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
* error.c (Init_Exception): NameError went under StandardError,
and NoMethodError went under NameError.
Tue Jun 5 16:40:06 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
* parse.y (rb_intern): non identifier symbols should be
categorized as ID_JUNK. [new]
Tue Jun 5 16:15:58 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
* variable.c (rb_mod_const_at): use hash table as internal

View file

@ -259,13 +259,13 @@ VALUE rb_eTypeError;
VALUE rb_eArgError;
VALUE rb_eIndexError;
VALUE rb_eRangeError;
VALUE rb_eNameError;
VALUE rb_eNoMethodError;
VALUE rb_eSecurityError;
VALUE rb_eNotImpError;
VALUE rb_eNoMemError;
VALUE rb_eNoMethodError;
VALUE rb_eScriptError;
VALUE rb_eNameError;
VALUE rb_eSyntaxError;
VALUE rb_eLoadError;
@ -593,11 +593,11 @@ Init_Exception()
rb_eArgError = rb_define_class("ArgumentError", rb_eStandardError);
rb_eIndexError = rb_define_class("IndexError", rb_eStandardError);
rb_eRangeError = rb_define_class("RangeError", rb_eStandardError);
rb_eNoMethodError = rb_define_class("NoMethodError", rb_eStandardError);
rb_eNameError = rb_define_class("NameError", rb_eStandardError);
rb_eNoMethodError = rb_define_class("NoMethodError", rb_eNameError);
rb_eScriptError = rb_define_class("ScriptError", rb_eException);
rb_eSyntaxError = rb_define_class("SyntaxError", rb_eScriptError);
rb_eNameError = rb_define_class("NameError", rb_eScriptError);
rb_eLoadError = rb_define_class("LoadError", rb_eScriptError);
rb_eNotImpError = rb_define_class("NotImplementedError", rb_eScriptError);

View file

@ -769,7 +769,7 @@ rb_mod_const_get(mod, name)
ID id = rb_to_id(name);
if (!rb_is_const_id(id)) {
rb_raise(rb_eNameError, "wrong constant name %s", name);
rb_raise(rb_eNameError, "wrong constant name %s", rb_id2name(id));
}
return rb_const_get(mod, id);
}
@ -781,7 +781,7 @@ rb_mod_const_set(mod, name, value)
ID id = rb_to_id(name);
if (!rb_is_const_id(id)) {
rb_raise(rb_eNameError, "wrong constant name %s", name);
rb_raise(rb_eNameError, "wrong constant name %s", rb_id2name(id));
}
rb_const_set(mod, id, value);
return value;
@ -794,7 +794,7 @@ rb_mod_const_defined(mod, name)
ID id = rb_to_id(name);
if (!rb_is_const_id(id)) {
rb_raise(rb_eNameError, "wrong constant name %s", name);
rb_raise(rb_eNameError, "wrong constant name %s", rb_id2name(id));
}
return rb_const_defined_at(mod, id);
}

21
parse.y
View file

@ -29,6 +29,7 @@
#define ID_ATTRSET 0x04
#define ID_CONST 0x05
#define ID_CLASS 0x06
#define ID_JUNK 0x07
#define is_notop_id(id) ((id)>LAST_TOKEN)
#define is_local_id(id) (is_notop_id(id)&&((id)&ID_SCOPE_MASK)==ID_LOCAL)
@ -4988,7 +4989,6 @@ static struct {
tLSHFT, "<<",
tRSHFT, ">>",
tCOLON2, "::",
tCOLON3, "::",
'`', "`",
0, 0,
};
@ -5009,6 +5009,7 @@ rb_intern(name)
const char *name;
{
static ID last_id = LAST_TOKEN;
const char *m = name;
ID id;
int last;
@ -5016,19 +5017,25 @@ rb_intern(name)
return id;
id = 0;
switch (name[0]) {
switch (*name) {
case '$':
id |= ID_GLOBAL;
m++;
if (!is_identchar(*m)) m++;
break;
case '@':
if (name[1] == '@')
if (name[1] == '@') {
m++;
id |= ID_CLASS;
else
}
else {
id |= ID_INSTANCE;
}
m++;
break;
default:
if (name[0] != '_' && !ISALPHA(name[0]) && !ismbchar(name[0])) {
/* operator */
/* operators */
int i;
for (i=0; op_tbl[i].token; i++) {
@ -5062,6 +5069,10 @@ rb_intern(name)
}
break;
}
while (*m && is_identchar(*m)) {
m++;
}
if (*m) id = ID_JUNK;
id |= ++last_id << ID_SCOPE_SHIFT;
id_regist:
name = strdup(name);