From 58085899e43e8356d84744eb5da971efc823d20b Mon Sep 17 00:00:00 2001 From: matz Date: Tue, 5 Jun 2001 07:50:59 +0000 Subject: * 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: http://svn.ruby-lang.org/repos/ruby/trunk@1505 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- parse.y | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) (limited to 'parse.y') diff --git a/parse.y b/parse.y index ed9751865..dd2fa9626 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); -- cgit