comparison dmd/Lexer.d @ 135:af1bebfd96a4 dmd2037

dmd 2.038
author Eldar Insafutdinov <e.insafutdinov@gmail.com>
date Mon, 13 Sep 2010 22:19:42 +0100
parents 60bb0fe4563e
children b7b61140701d
comparison
equal deleted inserted replaced
134:4251f96733f4 135:af1bebfd96a4
496 496
497 Token.tochars[TOK.TOKorass] = "|="; 497 Token.tochars[TOK.TOKorass] = "|=";
498 Token.tochars[TOK.TOKidentifier] = "identifier"; 498 Token.tochars[TOK.TOKidentifier] = "identifier";
499 Token.tochars[TOK.TOKat] = "@"; 499 Token.tochars[TOK.TOKat] = "@";
500 Token.tochars[TOK.TOKpow] = "^^"; 500 Token.tochars[TOK.TOKpow] = "^^";
501 //Token.tochars[TOK.TOKpowass] = "^^="; 501 Token.tochars[TOK.TOKpowass] = "^^=";
502 502
503 // For debugging 503 // For debugging
504 Token.tochars[TOKerror] = "error"; 504 Token.tochars[TOKerror] = "error";
505 Token.tochars[TOK.TOKdotexp] = "dotexp"; 505 Token.tochars[TOK.TOKdotexp] = "dotexp";
506 Token.tochars[TOK.TOKdotti] = "dotti"; 506 Token.tochars[TOK.TOKdotti] = "dotti";
748 case 'P': case 'Q': case 'R': case 'S': case 'T': 748 case 'P': case 'Q': case 'R': case 'S': case 'T':
749 case 'U': case 'V': case 'W': case 'X': case 'Y': 749 case 'U': case 'V': case 'W': case 'X': case 'Y':
750 case 'Z': 750 case 'Z':
751 case '_': 751 case '_':
752 case_ident: 752 case_ident:
753 { ubyte c;
754 StringValue *sv;
755 Identifier id;
756
757 do
758 { 753 {
759 c = *++p; 754 ubyte c;
760 } while (isidchar(c) || (c & 0x80 && isUniAlpha(decodeUTF()))); 755
761 sv = stringtable.update((cast(immutable(char)*)t.ptr)[0.. p - t.ptr]); /// 756 while (1)
762 id = cast(Identifier) sv.ptrvalue; 757 {
758 c = *++p;
759 if (isidchar(c))
760 continue;
761 else if (c & 0x80)
762 {
763 ubyte *s = p;
764 uint u = decodeUTF();
765 if (isUniAlpha(u))
766 continue;
767 error("char 0x%04x not allowed in identifier", u);
768 p = s;
769 }
770 break;
771 }
772
773 StringValue *sv = stringtable.update((cast(immutable(char)*)t.ptr)[0.. p - t.ptr]);
774 Identifier id = cast(Identifier) sv.ptrvalue;
775
763 if (id is null) 776 if (id is null)
764 { id = new Identifier(sv.lstring.string_, TOK.TOKidentifier); 777 { id = new Identifier(sv.lstring.string_, TOK.TOKidentifier);
765 sv.ptrvalue = cast(void*)id; 778 sv.ptrvalue = cast(void*)id;
766 } 779 }
767 t.ident = id; 780 t.ident = id;
1264 version(DMDV2) { 1277 version(DMDV2) {
1265 case '^': 1278 case '^':
1266 p++; 1279 p++;
1267 if (*p == '^') 1280 if (*p == '^')
1268 { p++; 1281 { p++;
1269 //static if (false) { 1282 if (*p == '=')
1270 // if (*p == '=') 1283 { p++;
1271 // { p++; 1284 t.value = TOKpowass; // ^^=
1272 // t.value = TOKpowass; // ^^= 1285 }
1273 // } 1286 else
1274 // else
1275 //}
1276 t.value = TOKpow; // ^^ 1287 t.value = TOKpow; // ^^
1277 } 1288 }
1278 else if (*p == '=') 1289 else if (*p == '=')
1279 { p++; 1290 { p++;
1280 t.value = TOKxorass; // ^= 1291 t.value = TOKxorass; // ^=
1368 p++; 1379 p++;
1369 pragma_(); 1380 pragma_();
1370 continue; 1381 continue;
1371 1382
1372 default: 1383 default:
1373 { ubyte c = *p; 1384 { uint c = *p;
1374 1385
1375 if (c & 0x80) 1386 if (c & 0x80)
1376 { uint u = decodeUTF(); 1387 { c = decodeUTF();
1377 1388
1378 // Check for start of unicode identifier 1389 // Check for start of unicode identifier
1379 if (isUniAlpha(u)) 1390 if (isUniAlpha(c))
1380 goto case_ident; 1391 goto case_ident;
1381 1392
1382 if (u == PS || u == LS) 1393 if (c == PS || c == LS)
1383 { 1394 {
1384 loc.linnum++; 1395 loc.linnum++;
1385 p++; 1396 p++;
1386 continue; 1397 continue;
1387 } 1398 }
1388 } 1399 }
1389 if (isprint(c)) 1400 if (c < 0x80 && isprint(c))
1390 error("unsupported char '%c'", c); 1401 error("unsupported char '%c'", c);
1391 else 1402 else
1392 error("unsupported char 0x%02x", c); 1403 error("unsupported char 0x%02x", c);
1393 p++; 1404 p++;
1394 continue; 1405 continue;
1717 uint u = decodeUTF(); 1728 uint u = decodeUTF();
1718 p++; 1729 p++;
1719 if (u == PS || u == LS) 1730 if (u == PS || u == LS)
1720 loc.linnum++; 1731 loc.linnum++;
1721 else 1732 else
1722 error("non-hex character \\u%x", u); 1733 error("non-hex character \\u%04x", u);
1723 } 1734 }
1724 else 1735 else
1725 error("non-hex character '%c'", c); 1736 error("non-hex character '%c'", c);
1726 if (n & 1) 1737 if (n & 1)
1727 { v = (v << 4) | c; 1738 { v = (v << 4) | c;