changeset 646:68953760d569

Added class ParenExpression.
author Aziz K?ksal <aziz.koeksal@gmail.com>
date Mon, 14 Jan 2008 17:21:45 +0100
parents 89ee7802c978
children 6a1cb6768bd2
files trunk/src/dil/ast/Expressions.d trunk/src/dil/ast/NodesEnum.d trunk/src/dil/parser/Parser.d trunk/src/dil/semantic/Pass1.d
diffstat 4 files changed, 26 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/trunk/src/dil/ast/Expressions.d	Mon Jan 14 16:01:21 2008 +0100
+++ b/trunk/src/dil/ast/Expressions.d	Mon Jan 14 17:21:45 2008 +0100
@@ -926,6 +926,17 @@
   }
 }
 
+/// ParenthesisExpression := "(" Expression ")"
+class ParenExpression : Expression
+{
+  Expression next;
+  this(Expression next)
+  {
+    mixin(set_kind);
+    this.next = next;
+  }
+}
+
 // version(D2)
 // {
 class TraitsExpression : Expression
--- a/trunk/src/dil/ast/NodesEnum.d	Mon Jan 14 16:01:21 2008 +0100
+++ b/trunk/src/dil/ast/NodesEnum.d	Mon Jan 14 17:21:45 2008 +0100
@@ -169,6 +169,7 @@
   "TypeDotIdExpression",
   "TypeidExpression",
   "IsExpression",
+  "ParenExpression",
   "FunctionLiteralExpression",
   "TraitsExpression", // D2.0
   "VoidInitializer",
--- a/trunk/src/dil/parser/Parser.d	Mon Jan 14 16:01:21 2008 +0100
+++ b/trunk/src/dil/parser/Parser.d	Mon Jan 14 17:21:45 2008 +0100
@@ -741,7 +741,6 @@
     if (prev_lt == LinkageType.None)
       prev_lt = lt;
     else
-      // TODO: create new msg RedundantLinkageType.
       error(begin, MSG.RedundantLinkageType, Token.textSpan(begin, this.prevToken));
   }
 
@@ -1074,7 +1073,7 @@
 
     BaseClass[] bases;
 
-    while (1)
+    do
     {
       Protection prot = Protection.Public;
       switch (token.type)
@@ -1092,13 +1091,8 @@
     LparseBasicType:
       auto begin = token;
       auto type = parseBasicType();
-      //if (type.tid != TID.DotList)
-        // TODO: issue error msg. base classes can only be one or more identifiers or template instances separated by dots.
       bases ~= set(new BaseClass(prot, type), begin);
-      if (token.type != T.Comma)
-        break;
-      nT();
-    }
+    } while (skipped(T.Comma))
     return bases;
   }
 
@@ -1357,7 +1351,6 @@
     assert(token.type == T.Delete);
     nT(); // Skip delete keyword.
     auto parameters = parseParameterList();
-    // TODO: only one parameter of type void* allowed. Check in parsing or semantic phase?
     auto funcBody = parseFunctionBody();
     return new DeleteDeclaration(parameters, funcBody);
   }
@@ -1402,7 +1395,6 @@
   {
     if (skipped(T.LParen))
     {
-      // TODO: What about mixin(...).ident;?
       auto e = parseAssignExpression();
       require(T.RParen);
       require(T.Semicolon);
@@ -2152,7 +2144,6 @@
       case ID.exit, ID.success, ID.failure:
         break;
       default:
-        // TODO: create MID.InvalidScopeIdentifier
         error(this.prevToken, MSG.InvalidScopeIdentifier, this.prevToken.srcText);
       }
     require(T.RParen);
@@ -3364,7 +3355,7 @@
       e = new IsExpression(type, ident, opTok, specTok, specType, tparams);
       break;
     case T.LParen:
-      if (tokenAfterParenIs(T.LBrace))
+      if (tokenAfterParenIs(T.LBrace)) // Check for "(...) {"
       {
         auto parameters = parseParameterList();
         // ( ParameterList ) FunctionBody
@@ -3377,7 +3368,7 @@
         nT();
         e = parseExpression();
         require(T.RParen);
-        // TODO: create ParenExpression?
+        e = new ParenExpression(e);
       }
       break;
     version(D2)
--- a/trunk/src/dil/semantic/Pass1.d	Mon Jan 14 16:01:21 2008 +0100
+++ b/trunk/src/dil/semantic/Pass1.d	Mon Jan 14 17:21:45 2008 +0100
@@ -176,6 +176,16 @@
   Declaration visit(MixinDeclaration)
   { return null; }
 
+  Expression visit(ParenExpression e)
+  {
+    if (!e.type)
+    {
+      e.next = visitE(e.next);
+      e.type = e.next.type;
+    }
+    return e;
+  }
+
   Expression visit(CommaExpression e)
   {
     if (!e.type)