diff dmd/Parser.d @ 179:cd48cb899aee

Updated to dmd2.040
author korDen
date Sun, 17 Oct 2010 20:56:07 +0400
parents e3afd1303184
children 52188e7e3fb5
line wrap: on
line diff
--- a/dmd/Parser.d	Sun Oct 17 07:42:00 2010 +0400
+++ b/dmd/Parser.d	Sun Oct 17 20:56:07 2010 +0400
@@ -5,6 +5,8 @@
 import dmd.PostBlitDeclaration;
 import dmd.FileInitExp;
 import dmd.LineInitExp;
+import dmd.SharedStaticCtorDeclaration;
+import dmd.SharedStaticDtorDeclaration;
 import dmd.EnumMember;
 import dmd.CtorDeclaration;
 import dmd.ShlAssignExp;
@@ -481,25 +483,42 @@
 			break;
 
 			case TOK.TOKconst:
-			if (peek(&token).value == TOK.TOKlparen)
+			if (peekNext() == TOKlparen)
 				goto Ldeclaration;
 			stc = STC.STCconst;
 			goto Lstc;
 
 			case TOK.TOKimmutable:
-			if (peek(&token).value == TOK.TOKlparen)
+			if (peekNext() == TOKlparen)
 				goto Ldeclaration;
 			stc = STC.STCimmutable;
 			goto Lstc;
 
 			case TOK.TOKshared:
-			if (peek(&token).value == TOK.TOKlparen)
-				goto Ldeclaration;
-			stc = STC.STCshared;
-			goto Lstc;
-
-	        case TOKwild:
-		    if (peek(&token).value == TOK.TOKlparen)
+			{
+				TOK next = peekNext();
+				if (next == TOKlparen)
+					goto Ldeclaration;
+				if (next == TOKstatic)
+				{   
+					TOK next2 = peekNext2();
+					if (next2 == TOKthis)
+					{	
+						s = parseSharedStaticCtor();
+						break;
+					}
+					if (next2 == TOKtilde)
+					{	
+						s = parseSharedStaticDtor();
+						break;
+					}
+				}
+				stc = STCshared;
+				goto Lstc;
+			}
+
+			case TOKwild:
+			if (peekNext() == TOKlparen)
 		        goto Ldeclaration;
 		    stc = STCwild;
 		    goto Lstc;
@@ -892,8 +911,11 @@
 	        stc = STCtrusted;
         else if (token.ident == Id.system)
 	        stc = STCsystem;
-        else
-	        error("valid attribute identifiers are @property, @safe, @trusted, @system, not @%s", token.toChars());
+        else if (token.ident == Id.disable)
+			stc = STCdisable;
+		else
+			error("valid attribute identifiers are @property, @safe, @trusted, @system, @disable not @%s", token.toChars());
+
         return stc;
     }
 }
@@ -1694,14 +1716,13 @@
 	 */
     StaticCtorDeclaration parseStaticCtor()
 	{
-		StaticCtorDeclaration f;
 		Loc loc = this.loc;
 
 		nextToken();
 		check(TOKlparen);
 		check(TOKrparen);
 
-		f = new StaticCtorDeclaration(loc, Loc(0));
+		StaticCtorDeclaration f = new StaticCtorDeclaration(loc, Loc(0));
 		parseContracts(f);
 		return f;
 	}
@@ -1713,7 +1734,6 @@
 	 */
     StaticDtorDeclaration parseStaticDtor()
 	{
-		StaticDtorDeclaration f;
 		Loc loc = this.loc;
 
 		nextToken();
@@ -1721,7 +1741,49 @@
 		check(TOKlparen);
 		check(TOKrparen);
 
-		f = new StaticDtorDeclaration(loc, Loc(0));
+		StaticDtorDeclaration f = new StaticDtorDeclaration(loc, Loc(0));
+		parseContracts(f);
+		return f;
+
+	}
+	
+	/*****************************************
+	 * Parse a shared static constructor definition:
+	 *	shared static this() { body }
+	 * Current token is 'shared'.
+	 */
+    SharedStaticCtorDeclaration parseSharedStaticCtor()
+	{
+		Loc loc = this.loc;
+
+		nextToken();
+		nextToken();
+		nextToken();
+		check(TOKlparen);
+		check(TOKrparen);
+
+		SharedStaticCtorDeclaration f = new SharedStaticCtorDeclaration(loc, Loc(0));
+		parseContracts(f);
+		return f;
+	}
+	
+	/*****************************************
+	 * Parse a shared static destructor definition:
+	 *	shared static ~this() { body }
+	 * Current token is 'shared'.
+	 */
+    SharedStaticDtorDeclaration parseSharedStaticDtor()
+	{
+	    Loc loc = this.loc;
+
+		nextToken();
+		nextToken();
+		nextToken();
+		check(TOKthis);
+		check(TOKlparen);
+		check(TOKrparen);
+
+		SharedStaticDtorDeclaration f = new SharedStaticDtorDeclaration(loc, Loc(0));
 		parseContracts(f);
 		return f;
 	}