changeset 158:759f437313f9

- Moved enum Protection and class BaseClass to module Types. - Fixed parseBaseClasses(). T.Dot token can lead off (global scope operator) and template instances are handled by parseBasicType().
author aziz
date Fri, 13 Jul 2007 11:42:04 +0000
parents fdbd47d72614
children 5aa877506db0
files trunk/src/Declarations.d trunk/src/Parser.d trunk/src/Types.d
diffstat 3 files changed, 29 insertions(+), 34 deletions(-) [+]
line wrap: on
line diff
--- a/trunk/src/Declarations.d	Fri Jul 13 11:05:01 2007 +0000
+++ b/trunk/src/Declarations.d	Fri Jul 13 11:42:04 2007 +0000
@@ -69,26 +69,6 @@
   }
 }
 
-enum Protection
-{
-  None,
-  Private   = 1,
-  Protected = 1<<1,
-  Package   = 1<<2,
-  Public    = 1<<3
-}
-
-class BaseClass
-{
-  Protection prot;
-  string name;
-  this(Protection prot, string name)
-  {
-    this.prot = prot;
-    this.name = name;
-  }
-}
-
 class ClassDeclaration : Declaration
 {
   string name;
--- a/trunk/src/Parser.d	Fri Jul 13 11:05:01 2007 +0000
+++ b/trunk/src/Parser.d	Fri Jul 13 11:42:04 2007 +0000
@@ -512,30 +512,24 @@
     while (1)
     {
       Protection prot = Protection.Public;
-      string name;
       switch (token.type)
       {
-      case T.Identifier: goto LisIdentifier;
+      // TODO: What about class Foo : typeof(new Bar)?
+      case T.Identifier, T.Dot/+, Typeof+/: goto LparseBasicType;
       case T.Private:   prot = Protection.Private;   break;
       case T.Protected: prot = Protection.Protected; break;
       case T.Package:   prot = Protection.Package;   break;
       case T.Public:  /*prot = Protection.Public;*/  break;
-      //case T.Dot: // TODO: What about "class Foo : .Bar"?
       default:
         // TODO: issue error msg
         return bases;
       }
-      nT();
-      if (token.type == T.Identifier)
-      {
-      LisIdentifier:
-        name = token.identifier;
-        nT();
-        // TODO: handle template instantiations: class Foo : Bar!(int)
-      }
-      else
-        expected(T.Identifier);
-      bases ~= new BaseClass(prot, name);
+      nT(); // Skip protection attribute.
+    LparseBasicType:
+      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 ~= new BaseClass(prot, type);
       if (token.type != T.Comma)
         break;
     }
--- a/trunk/src/Types.d	Fri Jul 13 11:05:01 2007 +0000
+++ b/trunk/src/Types.d	Fri Jul 13 11:42:04 2007 +0000
@@ -71,6 +71,27 @@
   { return items.length; }
 }
 
+
+enum Protection
+{
+  None,
+  Private   = 1,
+  Protected = 1<<1,
+  Package   = 1<<2,
+  Public    = 1<<3
+}
+
+class BaseClass
+{
+  Protection prot;
+  Type type;
+  this(Protection prot, Type type)
+  {
+    this.prot = prot;
+    this.type = type;
+  }
+}
+
 enum TP
 {
   Type,