summaryrefslogtreecommitdiff
path: root/parse.y
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-06-05 07:50:59 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2001-06-05 07:50:59 +0000
commitb12904e85f5a9cc6c82f0fd06783ba219f334932 (patch)
treed34738fecfaf64eb47bf162e3ff6977262cc02de /parse.y
parentd6c60dbf6d42f411a31a1c2e768a5a986a270a8c (diff)
* 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
Diffstat (limited to 'parse.y')
-rw-r--r--parse.y21
1 files changed, 16 insertions, 5 deletions
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);