Mercurial > projects > dil
diff trunk/src/Parser.d @ 81:aa1ea2548dd9
- Fixed parseExpression() method.
- Fixed error msg for octal numbers.
- Added classes DotIdExpression and CallExpression.
- Implemented "case T.Dot:".
- Added stub for parseNewExpression().
- Implemented parseArgumentList().
author | aziz |
---|---|
date | Tue, 03 Jul 2007 11:03:02 +0000 |
parents | 143caff09cd9 |
children | 9e6d66f647c9 |
line wrap: on
line diff
--- a/trunk/src/Parser.d Tue Jul 03 09:03:03 2007 +0000 +++ b/trunk/src/Parser.d Tue Jul 03 11:03:02 2007 +0000 @@ -43,7 +43,7 @@ { auto e = parseAssignExpression(); while (lx.token.type == TOK.Comma) - e = new CommaExpression(e, parseExpression()); + e = new CommaExpression(e, parseAssignExpression()); return e; } @@ -282,12 +282,10 @@ { case T.Dot: nT(); - Token t; - lx.peek(t); -// if (t.type == T.Identifier) -// -// else if (t.type == T.New) -// e = parseNewExpression(e); + if (lx.token.type == T.Identifier) + e = new DotIdExpression(e); + else if (lx.token.type == T.New) + e = parseNewExpression(e); break; case T.PlusPlus: nT(); @@ -299,7 +297,7 @@ break; case T.LParen: nT(); -// e = parseCallExpression(e); + e = new CallExpression(e, parseArgumentList(T.LParen)); break; case T.LBracket: // parse Slice- and IndexExpression @@ -355,6 +353,7 @@ e = parsePrimaryExpression(); break; } + assert(e !is null); return e; } @@ -363,6 +362,36 @@ return null; } + Expression parseNewExpression(Expression e) + { + return null; + } + + Expression[] parseArgumentList(TOK terminator) + { + Expression[] es; + + nT(); + if (lx.token.type == terminator) + { + nT(); + return null; + } + + while (1) + { + es ~= parseAssignExpression(); + if (lx.token.type == terminator) + break; +// if (lx.token.type != T.Comma) +// error(); + } +// if (lx.token.type != terminator) +// error(); + nT(); + return es; + } + void error(MID id, ...) { errors ~= new Information(Information.Type.Parser, id, lx.loc, arguments(_arguments, _argptr));