Mercurial > projects > dil
diff trunk/src/Parser.d @ 100:538e8b546669
- Added code for parsing IsExpressions.
- Added class SpecializationType for IsExpressions.
- Added missing default statement in parseDeclaratorSuffix().
- Added parameter identOptional to parseDeclarator().
author | aziz |
---|---|
date | Sat, 07 Jul 2007 13:55:01 +0000 |
parents | 6b8c248f5911 |
children | 6f3c5473c5e5 |
line wrap: on
line diff
--- a/trunk/src/Parser.d Sat Jul 07 12:30:01 2007 +0000 +++ b/trunk/src/Parser.d Sat Jul 07 13:55:01 2007 +0000 @@ -559,7 +559,40 @@ e = new TypeidExpression(type); break; case T.Is: -// e = new IsExpression(); + requireNext(T.LParen); + + Type type; + SpecializationType specType; + string ident; // optional Identifier + + type = parseDeclarator(ident, true); + + switch (token.type) + { + case T.Colon, T.Equal: + TOK specTok = token.type; + nT(); + switch (token.type) + { + case T.Typedef, + T.Struct, + T.Union, + T.Class, + T.Interface, + T.Enum, + T.Function, + T.Delegate, + T.Super, + T.Return: + specType = new SpecializationType(specTok, token.type); + break; + default: + specType = new SpecializationType(specTok, parseType()); + } + default: + } + + e = new IsExpression(type, ident, specType); break; case T.LParen: nT(); @@ -736,13 +769,15 @@ auto params = parseParameters(); // new FunctionType(params); break; + default: + break; } break; } return t; } - Type parseDeclarator(ref string ident) + Type parseDeclarator(ref string ident, bool identOptional = false) { auto t = parseBasicType2(parseBasicType()); @@ -751,7 +786,7 @@ ident = token.srcText; nT(); } - else + else if (!identOptional) errorIfNot(T.Identifier); t = parseDeclaratorSuffix(t);