diff dmd/parse.c @ 658:50383e476c7e

Upgraded frontend to DMD 1.035
author Tomas Lindquist Olsen <tomas.l.olsen@gmail.com>
date Mon, 06 Oct 2008 16:22:11 +0200
parents aaade6ded589
children 20a5180f2e80
line wrap: on
line diff
--- a/dmd/parse.c	Mon Oct 06 14:37:00 2008 +0200
+++ b/dmd/parse.c	Mon Oct 06 16:22:11 2008 +0200
@@ -2374,6 +2374,7 @@
     Loc loc = this->loc;
     Token *t;
     int braces;
+    int brackets;
 
     switch (token.value)
     {
@@ -2461,6 +2462,39 @@
 	    return is;
 
 	case TOKlbracket:
+	    /* Scan ahead to see if it is an array initializer or
+	     * an expression.
+	     * If it ends with a ';', it is an array initializer.
+	     */
+	    brackets = 1;
+	    for (t = peek(&token); 1; t = peek(t))
+	    {
+		switch (t->value)
+		{
+		    case TOKlbracket:
+			brackets++;
+			continue;
+
+		    case TOKrbracket:
+			if (--brackets == 0)
+			{   t = peek(t);
+			    if (t->value != TOKsemicolon &&
+				t->value != TOKcomma &&
+				t->value != TOKrcurly)
+				goto Lexpression;
+			    break;
+			}
+			continue;
+
+		    case TOKeof:
+			break;
+
+		    default:
+			continue;
+		}
+		break;
+	    }
+
 	    ia = new ArrayInitializer(loc);
 	    nextToken();
 	    comma = 0;
@@ -4247,7 +4281,7 @@
 	    nextToken();
 	    if (token.value != TOKrbracket)
 	    {
-		while (1)
+		while (token.value != TOKeof)
 		{
 		    Expression *e = parseAssignExp();
 		    if (token.value == TOKcolon && (keys || values->dim == 0))
@@ -4525,10 +4559,13 @@
 		tk = peek(tk);		// skip over right parenthesis
 		switch (tk->value)
 		{
+		    case TOKnot:
+			tk = peek(tk);
+			if (tk->value == TOKis)	// !is
+			    break;
 		    case TOKdot:
 		    case TOKplusplus:
 		    case TOKminusminus:
-		    case TOKnot:
 		    case TOKdelete:
 		    case TOKnew:
 		    case TOKlparen:
@@ -5149,6 +5186,7 @@
 void Parser::addComment(Dsymbol *s, unsigned char *blockComment)
 {
     s->addComment(combineComments(blockComment, token.lineComment));
+    token.lineComment = NULL;
 }