Mercurial > projects > dil
changeset 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 | fc645fb2fe72 |
files | trunk/src/Expressions.d trunk/src/Messages.d trunk/src/Parser.d |
diffstat | 3 files changed, 50 insertions(+), 11 deletions(-) [+] |
line wrap: on
line diff
--- a/trunk/src/Expressions.d Tue Jul 03 09:03:03 2007 +0000 +++ b/trunk/src/Expressions.d Tue Jul 03 11:03:02 2007 +0000 @@ -283,18 +283,28 @@ { super(e); } } -class PostfixExpression : UnaryExpression +class DotExpression : UnaryExpression { this(Expression e) { super(e); } } -class DotExpression : UnaryExpression +class DotIdExpression : UnaryExpression { this(Expression e) { super(e); } } +class CallExpression : UnaryExpression +{ + Expression[] args; + this(Expression e, Expression[] args) + { + super(e); + this.args = args; + } +} + class NewExpression : UnaryExpression { this(Expression e)
--- a/trunk/src/Messages.d Tue Jul 03 09:03:03 2007 +0000 +++ b/trunk/src/Messages.d Tue Jul 03 11:03:02 2007 +0000 @@ -88,7 +88,7 @@ "overflow in binary number.", "overflow in octal number.", "overflow in float number.", - "decimal digits are not allowed in octal numbers.", + "digits 8 and 9 are not allowed in octal numbers.", "invalid hex number; at least one hex digit expected.", "invalid binary number; at least one binary digit expected.", "the exponent of a hexadecimal float number is required.",
--- 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));