http://d.puremagic.com/issues/show_bug.cgi?id=3827
Don <clugd...@yahoo.com.au> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |clugd...@yahoo.com.au --- Comment #15 from Don <clugd...@yahoo.com.au> 2010-11-13 23:51:58 PST --- (In reply to comment #14) > you don't need to mess with associativity rules, you just need to be able to > handle two or three ast cases: > > 1. (~ str str) ie str ~ str > 2. (~ (~ x str) str) ie x ~ str ~ str > 3. (~ str (~ str x)) ie str ~ (str ~ x) Like this (optimize.c, line 1023): Expression *CatExp::optimize(int result) { Expression *e; //printf("CatExp::optimize(%d) %s\n", result, toChars()); e1 = e1->optimize(result); e2 = e2->optimize(result); + if (e1->op == TOKcat && (e2->op == TOKstring || e2->op == TOKnull) + && (((CatExp *)e1)->e2->op == TOKstring || ((CatExp *)e1)->e2->op == TOKnull)) + { + // Convert (e ~ str) ~ str into e ~ (str ~ str) + CatExp *ce = ((CatExp *)e1); + e1 = ce->e1; + ce->e1 = ce->e2; + ce->e2 = e2; + e2 = ce; + } e = Cat(type, e1, e2); if (e == EXP_CANT_INTERPRET) e = this; return e; } -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------