comparison dmd/lexer.c @ 1614:dbf7b54f542f

Merge DMD r292: bugzilla 3455 Some Unicode characters not allowed... bugzilla 3455 Some Unicode characters not allowed in identifiers. --- dmd/lexer.c | 34 ++++++++++++++++++++++------------ 1 files changed, 22 insertions(+), 12 deletions(-)
author Leandro Lucarella <llucax@gmail.com>
date Wed, 06 Jan 2010 15:18:21 -0300
parents eae495e6ae8d
children
comparison
equal deleted inserted replaced
1613:8f50a13d09a0 1614:dbf7b54f542f
632 case 'U': case 'V': case 'W': case 'X': case 'Y': 632 case 'U': case 'V': case 'W': case 'X': case 'Y':
633 case 'Z': 633 case 'Z':
634 case '_': 634 case '_':
635 case_ident: 635 case_ident:
636 { unsigned char c; 636 { unsigned char c;
637 StringValue *sv; 637
638 Identifier *id; 638 while (1)
639
640 do
641 { 639 {
642 c = *++p; 640 c = *++p;
643 } while (isidchar(c) || (c & 0x80 && isUniAlpha(decodeUTF()))); 641 if (isidchar(c))
644 sv = stringtable.update((char *)t->ptr, p - t->ptr); 642 continue;
645 id = (Identifier *) sv->ptrvalue; 643 else if (c & 0x80)
644 { unsigned char *s = p;
645 unsigned u = decodeUTF();
646 if (isUniAlpha(u))
647 continue;
648 error("char 0x%04x not allowed in identifier", u);
649 p = s;
650 }
651 break;
652 }
653
654 StringValue *sv = stringtable.update((char *)t->ptr, p - t->ptr);
655 Identifier *id = (Identifier *) sv->ptrvalue;
646 if (!id) 656 if (!id)
647 { id = new Identifier(sv->lstring.string,TOKidentifier); 657 { id = new Identifier(sv->lstring.string,TOKidentifier);
648 sv->ptrvalue = id; 658 sv->ptrvalue = id;
649 } 659 }
650 t->ident = id; 660 t->ident = id;
1175 p++; 1185 p++;
1176 pragma(); 1186 pragma();
1177 continue; 1187 continue;
1178 1188
1179 default: 1189 default:
1180 { unsigned char c = *p; 1190 { unsigned c = *p;
1181 1191
1182 if (c & 0x80) 1192 if (c & 0x80)
1183 { unsigned u = decodeUTF(); 1193 { c = decodeUTF();
1184 1194
1185 // Check for start of unicode identifier 1195 // Check for start of unicode identifier
1186 if (isUniAlpha(u)) 1196 if (isUniAlpha(c))
1187 goto case_ident; 1197 goto case_ident;
1188 1198
1189 if (u == PS || u == LS) 1199 if (c == PS || c == LS)
1190 { 1200 {
1191 loc.linnum++; 1201 loc.linnum++;
1192 p++; 1202 p++;
1193 continue; 1203 continue;
1194 } 1204 }
1195 } 1205 }
1196 if (isprint(c)) 1206 if (c < 0x80 && isprint(c))
1197 error("unsupported char '%c'", c); 1207 error("unsupported char '%c'", c);
1198 else 1208 else
1199 error("unsupported char 0x%02x", c); 1209 error("unsupported char 0x%02x", c);
1200 p++; 1210 p++;
1201 continue; 1211 continue;
1453 unsigned u = decodeUTF(); 1463 unsigned u = decodeUTF();
1454 p++; 1464 p++;
1455 if (u == PS || u == LS) 1465 if (u == PS || u == LS)
1456 loc.linnum++; 1466 loc.linnum++;
1457 else 1467 else
1458 error("non-hex character \\u%x", u); 1468 error("non-hex character \\u%04x", u);
1459 } 1469 }
1460 else 1470 else
1461 error("non-hex character '%c'", c); 1471 error("non-hex character '%c'", c);
1462 if (n & 1) 1472 if (n & 1)
1463 { v = (v << 4) | c; 1473 { v = (v << 4) | c;