comparison dmd/Parser.d @ 131:206db751bd4c

dmdfe 2.037 compiles now
author Eldar Insafutdinov <e.insafutdinov@gmail.com>
date Fri, 10 Sep 2010 00:27:37 +0100
parents 60bb0fe4563e
children c494af1dba80
comparison
equal deleted inserted replaced
130:60bb0fe4563e 131:206db751bd4c
201 import dmd.PragmaDeclaration; 201 import dmd.PragmaDeclaration;
202 import dmd.DebugSymbol; 202 import dmd.DebugSymbol;
203 import dmd.VersionSymbol; 203 import dmd.VersionSymbol;
204 import dmd.AliasThis; 204 import dmd.AliasThis;
205 import dmd.Global; 205 import dmd.Global;
206 import dmd.TRUST;
207 import dmd.PowExp;
206 208
207 import core.stdc.string : memcpy; 209 import core.stdc.string : memcpy;
208 210
209 import std.exception; 211 import std.exception;
210 import core.memory; 212 import core.memory;
311 Dsymbol s; 313 Dsymbol s;
312 Dsymbols decldefs; 314 Dsymbols decldefs;
313 Dsymbols a; 315 Dsymbols a;
314 Dsymbols aelse; 316 Dsymbols aelse;
315 PROT prot; 317 PROT prot;
316 STC stc; 318 StorageClass stc;
317 STC storageClass; 319 StorageClass storageClass;
318 Condition condition; 320 Condition condition;
319 string comment; 321 string comment;
320 322
321 //printf("Parser.parseDeclDefs()\n"); 323 //printf("Parser.parseDeclDefs()\n");
322 decldefs = new Dsymbols(); 324 decldefs = new Dsymbols();
753 * Starts with token on the first ident. 755 * Starts with token on the first ident.
754 * Ends with scanner past closing ';' 756 * Ends with scanner past closing ';'
755 */ 757 */
756 version (DMDV2) 758 version (DMDV2)
757 { 759 {
758 Dsymbols parseAutoDeclarations(STC storageClass, const(char)[] comment) 760 Dsymbols parseAutoDeclarations(StorageClass storageClass, const(char)[] comment)
759 { 761 {
760 auto a = new Dsymbols; 762 auto a = new Dsymbols;
761 763
762 while (true) 764 while (true)
763 { 765 {
838 break; 840 break;
839 } 841 }
840 return a; 842 return a;
841 } 843 }
842 version(DMDV2) { 844 version(DMDV2) {
843 void composeStorageClass(STC stc) 845 void composeStorageClass(StorageClass stc)
844 { 846 {
845 STC u = stc; 847 StorageClass u = stc;
846 u &= STC.STCconst | STC.STCimmutable | STC.STCmanifest; 848 u &= STC.STCconst | STC.STCimmutable | STC.STCmanifest;
847 if (u & (u - 1)) 849 if (u & (u - 1))
848 error("conflicting storage class %s", Token.toChars(token.value)); 850 error("conflicting storage class %s", Token.toChars(token.value));
849 851
850 u = stc; 852 u = stc;
861 /*********************************************** 863 /***********************************************
862 * Parse storage class, lexer is on '@' 864 * Parse storage class, lexer is on '@'
863 */ 865 */
864 866
865 version(DMDV2) { 867 version(DMDV2) {
866 STC parseAttribute() 868 StorageClass parseAttribute()
867 { 869 {
868 nextToken(); 870 nextToken();
869 STC stc = STCundefined; 871 StorageClass stc = STCundefined;
870 if (token.value != TOKidentifier) 872 if (token.value != TOKidentifier)
871 { 873 {
872 error("identifier expected after @, not %s", token.toChars()); 874 error("identifier expected after @, not %s", token.toChars());
873 } 875 }
874 else if (token.ident == Id.property) 876 else if (token.ident == Id.property)
1802 while (1) 1804 while (1)
1803 { Type *tb; 1805 { Type *tb;
1804 Identifier ai = null; 1806 Identifier ai = null;
1805 Type at; 1807 Type at;
1806 Parameter a; 1808 Parameter a;
1807 STC storageClass = STC.STCundefined; 1809 StorageClass storageClass = STC.STCundefined;
1808 STC stc; 1810 StorageClass stc;
1809 Expression ae; 1811 Expression ae;
1810 1812
1811 for ( ;1; nextToken()) 1813 for ( ;1; nextToken())
1812 { 1814 {
1813 switch (token.value) 1815 switch (token.value)
2555 if (token.value == TOK.TOKpure) 2557 if (token.value == TOK.TOKpure)
2556 ispure = true; 2558 ispure = true;
2557 else if (token.value == TOK.TOKnothrow) 2559 else if (token.value == TOK.TOKnothrow)
2558 isnothrow = true; 2560 isnothrow = true;
2559 else if (token.value == TOKat) 2561 else if (token.value == TOKat)
2560 { STC stc = parseAttribute(); 2562 { StorageClass stc = parseAttribute();
2561 switch (cast(uint)(stc >> 32)) 2563 switch (cast(uint)(stc >> 32))
2562 { case STCproperty >> 32: 2564 { case STCproperty >> 32:
2563 isproperty = true; 2565 isproperty = true;
2564 break; 2566 break;
2565 case STCsafe >> 32: 2567 case STCsafe >> 32:
2750 nextToken(); 2752 nextToken();
2751 continue; 2753 continue;
2752 2754
2753 case TOK.TOKat: 2755 case TOK.TOKat:
2754 { 2756 {
2755 STC stc = parseAttribute(); 2757 StorageClass stc = parseAttribute();
2756 auto tfunc = cast(TypeFunction)tf; 2758 auto tfunc = cast(TypeFunction)tf;
2757 switch (cast(uint)(stc >> 32)) 2759 switch (cast(uint)(stc >> 32))
2758 { 2760 {
2759 case STCproperty >> 32: 2761 case STCproperty >> 32:
2760 tfunc.isproperty = 1; 2762 tfunc.isproperty = 1;
2802 } 2804 }
2803 2805
2804 return ts; 2806 return ts;
2805 } 2807 }
2806 2808
2807 Dsymbols parseDeclarations(STC storage_class) 2809 Dsymbols parseDeclarations(StorageClass storage_class)
2808 { 2810 {
2809 STC stc; 2811 StorageClass stc;
2810 Type ts; 2812 Type ts;
2811 Type t; 2813 Type t;
2812 Type tfirst; 2814 Type tfirst;
2813 Identifier ident; 2815 Identifier ident;
2814 Dsymbols a; 2816 Dsymbols a;
3295 { 3297 {
3296 nextToken(); 3298 nextToken();
3297 auto a = parseBlock(); 3299 auto a = parseBlock();
3298 Dsymbol d = new StorageClassDeclaration(STCstatic, a); 3300 Dsymbol d = new StorageClassDeclaration(STCstatic, a);
3299 s = new DeclarationStatement(loc, d); 3301 s = new DeclarationStatement(loc, d);
3300 if (flags & PSscope) 3302 if (flags & ParseStatementFlags.PSscope)
3301 s = new ScopeStatement(loc, s); 3303 s = new ScopeStatement(loc, s);
3302 break; 3304 break;
3303 } 3305 }
3304 goto Ldeclaration; 3306 goto Ldeclaration;
3305 } 3307 }
3520 3522
3521 while (1) 3523 while (1)
3522 { 3524 {
3523 Identifier ai = null; 3525 Identifier ai = null;
3524 Type at; 3526 Type at;
3525 STC storageClass = STC.STCundefined; 3527 StorageClass storageClass = STC.STCundefined;
3526 3528
3527 if (token.value == TOK.TOKinout || token.value == TOK.TOKref) 3529 if (token.value == TOK.TOKinout || token.value == TOK.TOKref)
3528 { storageClass = STC.STCref; 3530 { storageClass = STC.STCref;
3529 nextToken(); 3531 nextToken();
3530 } 3532 }
5214 case TOK.TOKtypeid: 5216 case TOK.TOKtypeid:
5215 { 5217 {
5216 nextToken(); 5218 nextToken();
5217 check(TOK.TOKlparen, "typeid"); 5219 check(TOK.TOKlparen, "typeid");
5218 Object o; 5220 Object o;
5219 if (isDeclaration(&token, 0, TOKreserved, NULL)) 5221 if (isDeclaration(&token, 0, TOKreserved, null))
5220 { // argument is a type 5222 { // argument is a type
5221 o = parseType(); 5223 o = parseType();
5222 } 5224 }
5223 else 5225 else
5224 { // argument is an expression 5226 { // argument is an expression
5458 ispure = true; 5460 ispure = true;
5459 else if (token.value == TOK.TOKnothrow) 5461 else if (token.value == TOK.TOKnothrow)
5460 isnothrow = true; 5462 isnothrow = true;
5461 else if (token.value == TOKat) 5463 else if (token.value == TOKat)
5462 { 5464 {
5463 STC stc = parseAttribute(); 5465 StorageClass stc = parseAttribute();
5464 switch (cast(uint)(stc >> 32)) 5466 switch (cast(uint)(stc >> 32))
5465 { 5467 {
5466 case STCproperty >> 32: 5468 case STCproperty >> 32:
5467 isproperty = true; 5469 isproperty = true;
5468 break; 5470 break;
5759 // ident!(template_arguments) 5761 // ident!(template_arguments)
5760 tiargs = parseTemplateArgumentList(); 5762 tiargs = parseTemplateArgumentList();
5761 else 5763 else
5762 // ident!template_argument 5764 // ident!template_argument
5763 tiargs = parseTemplateArgument(); 5765 tiargs = parseTemplateArgument();
5764 e = new DotTemplateInstanceExp(loc, e, tiargs); 5766 e = new DotTemplateInstanceExp(loc, e, id, tiargs);
5765 } 5767 }
5766 else 5768 else
5767 e = new DotIdExp(loc, e, id); 5769 e = new DotIdExp(loc, e, id);
5768 continue; 5770 continue;
5769 } 5771 }