[Issue 3577] Wrong precedence for opPow
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Dec 5 11:31:17 PST 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3577
Don <clugdbug at yahoo.com.au> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |clugdbug at yahoo.com.au
--- Comment #1 from Don <clugdbug at yahoo.com.au> 2009-12-05 11:31:16 PST ---
PATCH: To give it higher precedence than *, but lower than unary operators, so
that both of the examples return 17, just create a parsePowExp() function in
parse.c.
----
Expression *Parser::parseMulExp()
{ Expression *e;
Expression *e2;
Loc loc = this->loc;
e = parsePowExp();
while (1)
{
switch (token.value)
{
case TOKmul: nextToken(); e2 = parsePowExp(); e = new MulExp(loc,e,e2);
continue;
case TOKdiv: nextToken(); e2 = parsePowExp(); e = new DivExp(loc,e,e2);
continue;
case TOKmod: nextToken(); e2 = parsePowExp(); e = new ModExp(loc,e,e2);
continue;
default:
break;
}
break;
}
return e;
}
Expression *Parser::parsePowExp()
{ Expression *e;
Expression *e2;
Loc loc = this->loc;
e = parseUnaryExp();
while (1)
{
switch (token.value)
{
case TOKpow: nextToken(); e2 = parseUnaryExp(); e = new
PowExp(loc,e,e2); continue;
default:
break;
}
break;
}
return e;
}
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list