Mercurial > projects > dil
comparison trunk/src/Parser.d @ 231:6846138a0e24
- Fixed parseEnumDeclaration().
- Fix: skip T.Semicolon in parseStatement().
author | aziz |
---|---|
date | Fri, 27 Jul 2007 11:19:00 +0000 |
parents | 8f1790d16753 |
children | 2a4e2c8ca094 |
comparison
equal
deleted
inserted
replaced
230:8f1790d16753 | 231:6846138a0e24 |
---|---|
707 string[] members; | 707 string[] members; |
708 Expression[] values; | 708 Expression[] values; |
709 bool hasBody; | 709 bool hasBody; |
710 | 710 |
711 nT(); // Skip enum keyword. | 711 nT(); // Skip enum keyword. |
712 enumName = requireIdentifier(); | 712 |
713 if (token.type == T.Identifier) | |
714 { | |
715 enumName = token.identifier; | |
716 nT(); | |
717 } | |
713 | 718 |
714 if (token.type == T.Colon) | 719 if (token.type == T.Colon) |
715 { | 720 { |
716 nT(); | 721 nT(); |
717 baseType = parseBasicType(); | 722 baseType = parseBasicType(); |
718 } | 723 } |
719 | 724 |
720 if (token.type == T.Semicolon) | 725 if (token.type == T.Semicolon) |
721 { | 726 { |
722 //if (ident.length == 0) | 727 if (enumName.length == 0) |
723 // TODO: issue error msg | 728 expected(T.Identifier); |
724 nT(); | 729 nT(); |
725 } | 730 } |
726 else if (token.type == T.LBrace) | 731 else if (token.type == T.LBrace) |
727 { | 732 { |
728 hasBody = true; | 733 hasBody = true; |
747 break; | 752 break; |
748 } | 753 } |
749 } while (token.type != T.RBrace) | 754 } while (token.type != T.RBrace) |
750 nT(); | 755 nT(); |
751 } | 756 } |
757 else | |
758 error(MID.ExpectedButFound, "enum declaration", token.srcText); | |
752 | 759 |
753 return new EnumDeclaration(enumName, baseType, members, values, hasBody); | 760 return new EnumDeclaration(enumName, baseType, members, values, hasBody); |
754 } | 761 } |
755 | 762 |
756 Declaration parseClassDeclaration() | 763 Declaration parseClassDeclaration() |
1545 break; | 1552 break; |
1546 case T.LBrace: | 1553 case T.LBrace: |
1547 s = parseScopeStatement(); | 1554 s = parseScopeStatement(); |
1548 break; | 1555 break; |
1549 case T.Semicolon: | 1556 case T.Semicolon: |
1557 nT(); | |
1550 s = new EmptyStatement(); | 1558 s = new EmptyStatement(); |
1551 break; | 1559 break; |
1552 default: | 1560 default: |
1553 bool success; | 1561 bool success; |
1554 auto expression = try_(parseExpression(), success); | 1562 auto expression = try_(parseExpression(), success); |