kill the commas! (phobos code cleanup)
ketmar via Digitalmars-d
digitalmars-d at puremagic.com
Wed Sep 3 08:59:20 PDT 2014
On Wed, 03 Sep 2014 15:20:55 +0000
via Digitalmars-d <digitalmars-d at puremagic.com> wrote:
> Unfortunately I don't understand DMD's internals enough to finish
> it
i'm pretty sure that this can be done with a little hack in
parseExpression(): just append 'cast(void)0' to the list of expressions
there.
something like this:
Expression *Parser::parseExpression(bool allowCommas)
{
Expression *e;
Expression *e2;
Loc loc = token.loc;
bool addVoid = false;
//printf("Parser::parseExpression() loc = %d\n", loc.linnum);
e = parseAssignExp();
while (token.value == TOKcomma)
{
if (!allowCommas)
{
warning(token.loc, "commas in expression are deprecated");
addVoid = true;
}
nextToken();
e2 = parseAssignExp();
e = new CommaExp(loc, e, e2);
loc = token.loc;
}
if (addVoid) e = new CommaExp(loc, e, new CastExp(loc, new IntegerExp(loc, 0, Type::tint32), Type::tvoid));
return e;
}
no need to introduce new types and hack semantic analyzer. ;-)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20140903/8a7a1de0/attachment.sig>
More information about the Digitalmars-d
mailing list