comparison trunk/src/Parser.d @ 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
comparison
equal deleted inserted replaced
157:fdbd47d72614 158:759f437313f9
510 BaseClass[] bases; 510 BaseClass[] bases;
511 511
512 while (1) 512 while (1)
513 { 513 {
514 Protection prot = Protection.Public; 514 Protection prot = Protection.Public;
515 string name;
516 switch (token.type) 515 switch (token.type)
517 { 516 {
518 case T.Identifier: goto LisIdentifier; 517 // TODO: What about class Foo : typeof(new Bar)?
518 case T.Identifier, T.Dot/+, Typeof+/: goto LparseBasicType;
519 case T.Private: prot = Protection.Private; break; 519 case T.Private: prot = Protection.Private; break;
520 case T.Protected: prot = Protection.Protected; break; 520 case T.Protected: prot = Protection.Protected; break;
521 case T.Package: prot = Protection.Package; break; 521 case T.Package: prot = Protection.Package; break;
522 case T.Public: /*prot = Protection.Public;*/ break; 522 case T.Public: /*prot = Protection.Public;*/ break;
523 //case T.Dot: // TODO: What about "class Foo : .Bar"?
524 default: 523 default:
525 // TODO: issue error msg 524 // TODO: issue error msg
526 return bases; 525 return bases;
527 } 526 }
528 nT(); 527 nT(); // Skip protection attribute.
529 if (token.type == T.Identifier) 528 LparseBasicType:
530 { 529 auto type = parseBasicType();
531 LisIdentifier: 530 //if (type.tid != TID.DotList)
532 name = token.identifier; 531 // TODO: issue error msg. base classes can only be one or more identifiers or template instances separated by dots.
533 nT(); 532 bases ~= new BaseClass(prot, type);
534 // TODO: handle template instantiations: class Foo : Bar!(int)
535 }
536 else
537 expected(T.Identifier);
538 bases ~= new BaseClass(prot, name);
539 if (token.type != T.Comma) 533 if (token.type != T.Comma)
540 break; 534 break;
541 } 535 }
542 return bases; 536 return bases;
543 } 537 }