Mercurial > projects > ddmd
diff dmd/Parser.d @ 137:09c858522d55
merge
author | Trass3r |
---|---|
date | Mon, 13 Sep 2010 23:29:00 +0200 |
parents | af1bebfd96a4 |
children | e3afd1303184 |
line wrap: on
line diff
--- a/dmd/Parser.d Mon Sep 13 23:27:38 2010 +0200 +++ b/dmd/Parser.d Mon Sep 13 23:29:00 2010 +0200 @@ -79,6 +79,7 @@ import dmd.DivAssignExp; import dmd.AndAssignExp; import dmd.AddAssignExp; +import dmd.PowAssignExp; import dmd.ModuleDeclaration; import dmd.CaseRangeStatement; import dmd.CommaExp; @@ -496,6 +497,12 @@ stc = STC.STCshared; goto Lstc; + case TOKwild: + if (peek(&token).value == TOK.TOKlparen) + goto Ldeclaration; + stc = STCwild; + goto Lstc; + case TOK.TOKfinal: stc = STC.STCfinal; goto Lstc; case TOK.TOKauto: stc = STC.STCauto; goto Lstc; case TOK.TOKscope: stc = STC.STCscope; goto Lstc; @@ -527,6 +534,7 @@ case TOK.TOKinvariant: case TOK.TOKimmutable: case TOK.TOKshared: + case TOKwild: // If followed by a (, it is not a storage class if (peek(&token).value == TOK.TOKlparen) break; @@ -534,6 +542,8 @@ stc = STC.STCconst; else if (token.value == TOK.TOKshared) stc = STC.STCshared; + else if (token.value == TOKwild) + stc = STC.STCwild; else stc = STC.STCimmutable; goto Lstc; @@ -1840,14 +1850,23 @@ goto Ldefault; stc = STC.STCshared; goto L2; + + case TOKwild: + if (peek(&token).value == TOK.TOKlparen) + goto Ldefault; + stc = STCwild; + goto L2; case TOK.TOKin: stc = STC.STCin; goto L2; case TOK.TOKout: stc = STC.STCout; goto L2; +version(D1INOUT) { case TOK.TOKinout: +} case TOK.TOKref: stc = STC.STCref; goto L2; case TOK.TOKlazy: stc = STC.STClazy; goto L2; case TOK.TOKscope: stc = STC.STCscope; goto L2; case TOK.TOKfinal: stc = STC.STCfinal; goto L2; + case TOK.TOKauto: stc = STCauto; goto L2; L2: if (storageClass & stc || (storageClass & STC.STCin && stc & (STC.STCconst | STC.STCscope)) || @@ -2316,6 +2335,17 @@ t = t.makeSharedConst(); return t; } + else if (token.value == TOKwild && peekNext() == TOKshared && peekNext2() != TOKlparen || + token.value == TOKshared && peekNext() == TOKwild && peekNext2() != TOKlparen) + { + nextToken(); + nextToken(); + /* shared wild type + */ + t = parseType(pident, tpl); + t = t.makeSharedWild(); + return t; + } else if (token.value == TOK.TOKconst && peekNext() != TOK.TOKlparen) { nextToken(); @@ -2344,6 +2374,15 @@ t = t.makeShared(); return t; } + else if (token.value == TOKwild && peekNext() != TOKlparen) + { + nextToken(); + /* wild type + */ + t = parseType(pident, tpl); + t = t.makeWild(); + return t; + } else t = parseBasicType(); t = parseDeclarator(t, pident, tpl); @@ -2471,10 +2510,24 @@ check(TOK.TOKrparen); if (t.isConst()) t = t.makeSharedConst(); + else if (t.isWild()) + t = t.makeSharedWild(); else t = t.makeShared(); break; + case TOKwild: + // wild(type) + nextToken(); + check(TOK.TOKlparen); + t = parseType(); + check(TOK.TOKrparen); + if (t.isShared()) + t = t.makeSharedWild(); + else + t = t.makeWild(); + break; + default: error("basic type expected, not %s", token.toChars()); t = Type.tint32; @@ -2742,6 +2795,14 @@ nextToken(); continue; + case TOKwild: + if (tf.isShared()) + tf = tf.makeSharedWild(); + else + tf = tf.makeWild(); + nextToken(); + continue; + case TOK.TOKnothrow: (cast(TypeFunction)tf).isnothrow = 1; nextToken(); @@ -2874,6 +2935,12 @@ if (peek(&token).value == TOK.TOKlparen) break; stc = STC.STCshared; + goto L1; + + case TOKwild: + if (peek(&token).value == TOK.TOKlparen) + break; + stc = STC.STCwild; goto L1; case TOK.TOKstatic: stc = STC.STCstatic; goto L1; @@ -3334,6 +3401,7 @@ version (DMDV2) { case TOK.TOKimmutable: case TOK.TOKshared: + case TOKwild: case TOK.TOKnothrow: case TOK.TOKpure: case TOK.TOKtls: @@ -3526,7 +3594,11 @@ Type at; StorageClass storageClass = STC.STCundefined; - if (token.value == TOK.TOKinout || token.value == TOK.TOKref) + if (token.value == TOKref +//#if D1INOUT +// || token.value == TOKinout +//#endif + ) { storageClass = STC.STCref; nextToken(); } @@ -4374,12 +4446,14 @@ if ((t.value == TOK.TOKconst || t.value == TOK.TOKinvariant || t.value == TOK.TOKimmutable || + t.value == TOKwild || t.value == TOK.TOKshared) && peek(t).value != TOK.TOKlparen) { /* const type * immutable type * shared type + * wild type */ t = peek(t); } @@ -4538,7 +4612,8 @@ case TOK.TOKinvariant: case TOK.TOKimmutable: case TOK.TOKshared: - // const(type) or immutable(type) or shared(type) + case TOKwild: + // const(type) or immutable(type) or shared(type) or wild(type) t = peek(t); if (t.value != TOK.TOKlparen) goto Lfalse; @@ -4703,6 +4778,7 @@ case TOK.TOKinvariant: case TOK.TOKimmutable: case TOK.TOKshared: + case TOKwild: case TOK.TOKpure: case TOK.TOKnothrow: t = peek(t); @@ -4763,18 +4839,22 @@ t = peek(t); break; +version(D1INOUT) { + case TOKinout: +} case TOKin: case TOKout: - case TOKinout: case TOKref: case TOKlazy: case TOKfinal: + case TOKauto: continue; case TOKconst: case TOKinvariant: case TOKimmutable: case TOKshared: + case TOKwild: t = peek(t); if (t.value == TOKlparen) { @@ -5287,6 +5367,7 @@ token.value == TOK.TOKinvariant && peek(&token).value == TOK.TOKrparen || token.value == TOK.TOKimmutable && peek(&token).value == TOK.TOKrparen || token.value == TOK.TOKshared && peek(&token).value == TOK.TOKrparen || + token.value == TOKwild && peek(&token).value == TOKrparen || ///} token.value == TOK.TOKfunction || token.value == TOK.TOKdelegate || @@ -5581,7 +5662,7 @@ nextToken(); check(TOK.TOKlparen); /* Look for cast(), cast(const), cast(immutable), - * cast(shared), cast(shared const) + * cast(shared), cast(shared const), cast(wild), cast(shared wild) */ MOD m; if (token.value == TOK.TOKrparen) @@ -5596,7 +5677,7 @@ } else if ((token.value == TOK.TOKimmutable || token.value == TOK.TOKinvariant) && peekNext() == TOK.TOKrparen) { - m = MOD.MODinvariant; + m = MOD.MODimmutable; goto Lmod2; } else if (token.value == TOK.TOKshared && peekNext() == TOK.TOKrparen) @@ -5604,10 +5685,22 @@ m = MOD.MODshared; goto Lmod2; } + else if (token.value == TOKwild && peekNext() == TOK.TOKrparen) + { + m = MODwild; + goto Lmod2; + } + else if (token.value == TOKwild && peekNext() == TOK.TOKshared && peekNext2() == TOK.TOKrparen || + token.value == TOK.TOKshared && peekNext() == TOKwild && peekNext2() == TOK.TOKrparen) + { + m = MOD.MODshared | MOD.MODwild; + goto Lmod3; + } else if (token.value == TOK.TOKconst && peekNext() == TOK.TOKshared && peekNext2() == TOK.TOKrparen || token.value == TOK.TOKshared && peekNext() == TOK.TOKconst && peekNext2() == TOK.TOKrparen) { m = MOD.MODshared | MOD.MODconst; + Lmod3: nextToken(); Lmod2: nextToken(); @@ -5734,6 +5827,15 @@ break; } assert(e); + + // ^^ is right associative and has higher precedence than the unary operators + while (token.value == TOK.TOKpow) + { + nextToken(); + Expression e2 = parseUnaryExp(); + e = new PowExp(loc, e, e2); + } + return e; } @@ -5862,7 +5964,6 @@ case TOK.TOKmul: nextToken(); e2 = parseUnaryExp(); e = new MulExp(loc,e,e2); continue; case TOK.TOKdiv: nextToken(); e2 = parseUnaryExp(); e = new DivExp(loc,e,e2); continue; case TOK.TOKmod: nextToken(); e2 = parseUnaryExp(); e = new ModExp(loc,e,e2); continue; - case TOK.TOKpow: nextToken(); e2 = parseUnaryExp(); e = new PowExp(loc,e,e2); continue; default: break; @@ -6129,7 +6230,7 @@ case TOK.TOKmulass: nextToken(); e2 = parseAssignExp(); e = new MulAssignExp(loc,e,e2); continue; case TOK.TOKdivass: nextToken(); e2 = parseAssignExp(); e = new DivAssignExp(loc,e,e2); continue; case TOK.TOKmodass: nextToken(); e2 = parseAssignExp(); e = new ModAssignExp(loc,e,e2); continue; -// case TOK.TOKpowass: nextToken(); e2 = parseAssignExp(); e = new PowAssignExp(loc,e,e2); continue; + case TOK.TOKpowass: nextToken(); e2 = parseAssignExp(); e = new PowAssignExp(loc,e,e2); continue; case TOK.TOKandass: nextToken(); e2 = parseAssignExp(); e = new AndAssignExp(loc,e,e2); continue; case TOK.TOKorass: nextToken(); e2 = parseAssignExp(); e = new OrAssignExp(loc,e,e2); continue; case TOK.TOKxorass: nextToken(); e2 = parseAssignExp(); e = new XorAssignExp(loc,e,e2); continue;