* 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
Родитель d6c60dbf6d
Коммит b12904e85f
4 изменённых файлов: 33 добавлений и 12 удалений

Просмотреть файл

@ -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> Tue Jun 5 16:15:58 2001 Yukihiro Matsumoto <matz@ruby-lang.org>
* variable.c (rb_mod_const_at): use hash table as internal * variable.c (rb_mod_const_at): use hash table as internal

Просмотреть файл

@ -259,13 +259,13 @@ VALUE rb_eTypeError;
VALUE rb_eArgError; VALUE rb_eArgError;
VALUE rb_eIndexError; VALUE rb_eIndexError;
VALUE rb_eRangeError; VALUE rb_eRangeError;
VALUE rb_eNameError;
VALUE rb_eNoMethodError;
VALUE rb_eSecurityError; VALUE rb_eSecurityError;
VALUE rb_eNotImpError; VALUE rb_eNotImpError;
VALUE rb_eNoMemError; VALUE rb_eNoMemError;
VALUE rb_eNoMethodError;
VALUE rb_eScriptError; VALUE rb_eScriptError;
VALUE rb_eNameError;
VALUE rb_eSyntaxError; VALUE rb_eSyntaxError;
VALUE rb_eLoadError; VALUE rb_eLoadError;
@ -593,11 +593,11 @@ Init_Exception()
rb_eArgError = rb_define_class("ArgumentError", rb_eStandardError); rb_eArgError = rb_define_class("ArgumentError", rb_eStandardError);
rb_eIndexError = rb_define_class("IndexError", rb_eStandardError); rb_eIndexError = rb_define_class("IndexError", rb_eStandardError);
rb_eRangeError = rb_define_class("RangeError", 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_eScriptError = rb_define_class("ScriptError", rb_eException);
rb_eSyntaxError = rb_define_class("SyntaxError", rb_eScriptError); 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_eLoadError = rb_define_class("LoadError", rb_eScriptError);
rb_eNotImpError = rb_define_class("NotImplementedError", rb_eScriptError); rb_eNotImpError = rb_define_class("NotImplementedError", rb_eScriptError);

Просмотреть файл

@ -769,7 +769,7 @@ rb_mod_const_get(mod, name)
ID id = rb_to_id(name); ID id = rb_to_id(name);
if (!rb_is_const_id(id)) { 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); return rb_const_get(mod, id);
} }
@ -781,7 +781,7 @@ rb_mod_const_set(mod, name, value)
ID id = rb_to_id(name); ID id = rb_to_id(name);
if (!rb_is_const_id(id)) { 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); rb_const_set(mod, id, value);
return value; return value;
@ -794,7 +794,7 @@ rb_mod_const_defined(mod, name)
ID id = rb_to_id(name); ID id = rb_to_id(name);
if (!rb_is_const_id(id)) { 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); return rb_const_defined_at(mod, id);
} }

21
parse.y
Просмотреть файл

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