From b12904e85f5a9cc6c82f0fd06783ba219f334932 Mon Sep 17 00:00:00 2001 From: matz Date: Tue, 5 Jun 2001 07:50:59 +0000 Subject: [PATCH] * 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 --- ChangeLog | 10 ++++++++++ error.c | 8 ++++---- object.c | 6 +++--- parse.y | 21 ++++++++++++++++----- 4 files changed, 33 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0cefc72ce1..31d7d93010 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +Tue Jun 5 16:45:48 2001 Yukihiro Matsumoto + + * error.c (Init_Exception): NameError went under StandardError, + and NoMethodError went under NameError. + +Tue Jun 5 16:40:06 2001 Yukihiro Matsumoto + + * parse.y (rb_intern): non identifier symbols should be + categorized as ID_JUNK. [new] + Tue Jun 5 16:15:58 2001 Yukihiro Matsumoto * variable.c (rb_mod_const_at): use hash table as internal diff --git a/error.c b/error.c index eaaa54647b..a2c3715fd6 100644 --- a/error.c +++ b/error.c @@ -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); diff --git a/object.c b/object.c index dc0379050b..89b126538e 100644 --- a/object.c +++ b/object.c @@ -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); } diff --git a/parse.y b/parse.y index ed97518650..dd2fa96266 100644 --- a/parse.y +++ b/parse.y @@ -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);