diff 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
line wrap: on
line diff
--- a/dmd/Lexer.d	Sat Sep 11 13:03:39 2010 +0100
+++ b/dmd/Lexer.d	Mon Sep 13 22:19:42 2010 +0100
@@ -498,7 +498,7 @@
 		Token.tochars[TOK.TOKidentifier]	= "identifier";
 		Token.tochars[TOK.TOKat]		= "@";
         Token.tochars[TOK.TOKpow]		= "^^";
-        //Token.tochars[TOK.TOKpowass]		= "^^=";
+        Token.tochars[TOK.TOKpowass]		= "^^=";
         
 		 // For debugging
 		Token.tochars[TOKerror]		= "error";
@@ -750,16 +750,29 @@
 				case 'Z':
 				case '_':
 				case_ident:
-				{   ubyte c;
-				StringValue *sv;
-				Identifier id;
+				{
+                ubyte c;
 
-				do
-				{
-					c = *++p;
-				} while (isidchar(c) || (c & 0x80 && isUniAlpha(decodeUTF())));
-				sv = stringtable.update((cast(immutable(char)*)t.ptr)[0.. p - t.ptr]);	///
-				id = cast(Identifier) sv.ptrvalue;
+		        while (1)
+		        {
+		            c = *++p;
+		            if (isidchar(c))
+			            continue;
+		            else if (c & 0x80)
+		            {
+                        ubyte *s = p;
+			            uint u = decodeUTF();
+			            if (isUniAlpha(u))
+    			            continue;
+			            error("char 0x%04x not allowed in identifier", u);
+			            p = s;
+		            }
+		            break;
+		        }
+
+		        StringValue *sv = stringtable.update((cast(immutable(char)*)t.ptr)[0.. p - t.ptr]);
+		        Identifier id = cast(Identifier) sv.ptrvalue;
+                    
 				if (id is null)
 				{   id = new Identifier(sv.lstring.string_, TOK.TOKidentifier);
 					sv.ptrvalue = cast(void*)id;
@@ -1266,13 +1279,11 @@
 		p++;
 		if (*p == '^')
 		{   p++;
-//static if (false) {
-//		    if (*p == '=')
-//		    {   p++;
-//			t.value = TOKpowass;  // ^^=
-//		    }
-//		    else
-//}
+		    if (*p == '=')
+		    {   p++;
+			t.value = TOKpowass;  // ^^=
+		    }
+		    else
 			t.value = TOKpow;     // ^^
 		}
 		else if (*p == '=')
@@ -1370,23 +1381,23 @@
 				continue;
 
 				default:
-				{	ubyte c = *p;
+				{	uint c = *p;
 
 				if (c & 0x80)
-				{   uint u = decodeUTF();
+				{   c = decodeUTF();
 
 					// Check for start of unicode identifier
-					if (isUniAlpha(u))
+					if (isUniAlpha(c))
 					goto case_ident;
 
-					if (u == PS || u == LS)
+					if (c == PS || c == LS)
 					{
 					loc.linnum++;
 					p++;
 					continue;
 					}
 				}
-				if (isprint(c))
+				if (c < 0x80 && isprint(c))
 					error("unsupported char '%c'", c);
 				else
 					error("unsupported char 0x%02x", c);
@@ -1719,7 +1730,7 @@
 					if (u == PS || u == LS)
 					loc.linnum++;
 					else
-					error("non-hex character \\u%x", u);
+					error("non-hex character \\u%04x", u);
 				}
 				else
 					error("non-hex character '%c'", c);