Mercurial > projects > ddmd
comparison dmd/Parser.d @ 179:cd48cb899aee
Updated to dmd2.040
author | korDen |
---|---|
date | Sun, 17 Oct 2010 20:56:07 +0400 |
parents | e3afd1303184 |
children | 52188e7e3fb5 |
comparison
equal
deleted
inserted
replaced
178:e3afd1303184 | 179:cd48cb899aee |
---|---|
3 import dmd.common; | 3 import dmd.common; |
4 import dmd.Lexer; | 4 import dmd.Lexer; |
5 import dmd.PostBlitDeclaration; | 5 import dmd.PostBlitDeclaration; |
6 import dmd.FileInitExp; | 6 import dmd.FileInitExp; |
7 import dmd.LineInitExp; | 7 import dmd.LineInitExp; |
8 import dmd.SharedStaticCtorDeclaration; | |
9 import dmd.SharedStaticDtorDeclaration; | |
8 import dmd.EnumMember; | 10 import dmd.EnumMember; |
9 import dmd.CtorDeclaration; | 11 import dmd.CtorDeclaration; |
10 import dmd.ShlAssignExp; | 12 import dmd.ShlAssignExp; |
11 import dmd.ShrAssignExp; | 13 import dmd.ShrAssignExp; |
12 import dmd.UshrAssignExp; | 14 import dmd.UshrAssignExp; |
479 goto Lstc2; | 481 goto Lstc2; |
480 } | 482 } |
481 break; | 483 break; |
482 | 484 |
483 case TOK.TOKconst: | 485 case TOK.TOKconst: |
484 if (peek(&token).value == TOK.TOKlparen) | 486 if (peekNext() == TOKlparen) |
485 goto Ldeclaration; | 487 goto Ldeclaration; |
486 stc = STC.STCconst; | 488 stc = STC.STCconst; |
487 goto Lstc; | 489 goto Lstc; |
488 | 490 |
489 case TOK.TOKimmutable: | 491 case TOK.TOKimmutable: |
490 if (peek(&token).value == TOK.TOKlparen) | 492 if (peekNext() == TOKlparen) |
491 goto Ldeclaration; | 493 goto Ldeclaration; |
492 stc = STC.STCimmutable; | 494 stc = STC.STCimmutable; |
493 goto Lstc; | 495 goto Lstc; |
494 | 496 |
495 case TOK.TOKshared: | 497 case TOK.TOKshared: |
496 if (peek(&token).value == TOK.TOKlparen) | 498 { |
497 goto Ldeclaration; | 499 TOK next = peekNext(); |
498 stc = STC.STCshared; | 500 if (next == TOKlparen) |
499 goto Lstc; | 501 goto Ldeclaration; |
500 | 502 if (next == TOKstatic) |
501 case TOKwild: | 503 { |
502 if (peek(&token).value == TOK.TOKlparen) | 504 TOK next2 = peekNext2(); |
505 if (next2 == TOKthis) | |
506 { | |
507 s = parseSharedStaticCtor(); | |
508 break; | |
509 } | |
510 if (next2 == TOKtilde) | |
511 { | |
512 s = parseSharedStaticDtor(); | |
513 break; | |
514 } | |
515 } | |
516 stc = STCshared; | |
517 goto Lstc; | |
518 } | |
519 | |
520 case TOKwild: | |
521 if (peekNext() == TOKlparen) | |
503 goto Ldeclaration; | 522 goto Ldeclaration; |
504 stc = STCwild; | 523 stc = STCwild; |
505 goto Lstc; | 524 goto Lstc; |
506 | 525 |
507 case TOK.TOKfinal: stc = STC.STCfinal; goto Lstc; | 526 case TOK.TOKfinal: stc = STC.STCfinal; goto Lstc; |
890 stc = STCsafe; | 909 stc = STCsafe; |
891 else if (token.ident == Id.trusted) | 910 else if (token.ident == Id.trusted) |
892 stc = STCtrusted; | 911 stc = STCtrusted; |
893 else if (token.ident == Id.system) | 912 else if (token.ident == Id.system) |
894 stc = STCsystem; | 913 stc = STCsystem; |
895 else | 914 else if (token.ident == Id.disable) |
896 error("valid attribute identifiers are @property, @safe, @trusted, @system, not @%s", token.toChars()); | 915 stc = STCdisable; |
916 else | |
917 error("valid attribute identifiers are @property, @safe, @trusted, @system, @disable not @%s", token.toChars()); | |
918 | |
897 return stc; | 919 return stc; |
898 } | 920 } |
899 } | 921 } |
900 /************************************** | 922 /************************************** |
901 * Parse constraint. | 923 * Parse constraint. |
1692 * static this() { body } | 1714 * static this() { body } |
1693 * Current token is 'this'. | 1715 * Current token is 'this'. |
1694 */ | 1716 */ |
1695 StaticCtorDeclaration parseStaticCtor() | 1717 StaticCtorDeclaration parseStaticCtor() |
1696 { | 1718 { |
1697 StaticCtorDeclaration f; | |
1698 Loc loc = this.loc; | 1719 Loc loc = this.loc; |
1699 | 1720 |
1700 nextToken(); | 1721 nextToken(); |
1701 check(TOKlparen); | 1722 check(TOKlparen); |
1702 check(TOKrparen); | 1723 check(TOKrparen); |
1703 | 1724 |
1704 f = new StaticCtorDeclaration(loc, Loc(0)); | 1725 StaticCtorDeclaration f = new StaticCtorDeclaration(loc, Loc(0)); |
1705 parseContracts(f); | 1726 parseContracts(f); |
1706 return f; | 1727 return f; |
1707 } | 1728 } |
1708 | 1729 |
1709 /***************************************** | 1730 /***************************************** |
1711 * static ~this() { body } | 1732 * static ~this() { body } |
1712 * Current token is '~'. | 1733 * Current token is '~'. |
1713 */ | 1734 */ |
1714 StaticDtorDeclaration parseStaticDtor() | 1735 StaticDtorDeclaration parseStaticDtor() |
1715 { | 1736 { |
1716 StaticDtorDeclaration f; | |
1717 Loc loc = this.loc; | 1737 Loc loc = this.loc; |
1718 | 1738 |
1719 nextToken(); | 1739 nextToken(); |
1720 check(TOKthis); | 1740 check(TOKthis); |
1721 check(TOKlparen); | 1741 check(TOKlparen); |
1722 check(TOKrparen); | 1742 check(TOKrparen); |
1723 | 1743 |
1724 f = new StaticDtorDeclaration(loc, Loc(0)); | 1744 StaticDtorDeclaration f = new StaticDtorDeclaration(loc, Loc(0)); |
1745 parseContracts(f); | |
1746 return f; | |
1747 | |
1748 } | |
1749 | |
1750 /***************************************** | |
1751 * Parse a shared static constructor definition: | |
1752 * shared static this() { body } | |
1753 * Current token is 'shared'. | |
1754 */ | |
1755 SharedStaticCtorDeclaration parseSharedStaticCtor() | |
1756 { | |
1757 Loc loc = this.loc; | |
1758 | |
1759 nextToken(); | |
1760 nextToken(); | |
1761 nextToken(); | |
1762 check(TOKlparen); | |
1763 check(TOKrparen); | |
1764 | |
1765 SharedStaticCtorDeclaration f = new SharedStaticCtorDeclaration(loc, Loc(0)); | |
1766 parseContracts(f); | |
1767 return f; | |
1768 } | |
1769 | |
1770 /***************************************** | |
1771 * Parse a shared static destructor definition: | |
1772 * shared static ~this() { body } | |
1773 * Current token is 'shared'. | |
1774 */ | |
1775 SharedStaticDtorDeclaration parseSharedStaticDtor() | |
1776 { | |
1777 Loc loc = this.loc; | |
1778 | |
1779 nextToken(); | |
1780 nextToken(); | |
1781 nextToken(); | |
1782 check(TOKthis); | |
1783 check(TOKlparen); | |
1784 check(TOKrparen); | |
1785 | |
1786 SharedStaticDtorDeclaration f = new SharedStaticDtorDeclaration(loc, Loc(0)); | |
1725 parseContracts(f); | 1787 parseContracts(f); |
1726 return f; | 1788 return f; |
1727 } | 1789 } |
1728 | 1790 |
1729 /***************************************** | 1791 /***************************************** |