On Mon, Oct 27, 2008 at 11:43 AM, Andrei Alexandrescu <[EMAIL PROTECTED]> wrote: > Bill Baxter wrote: >> >> On Mon, Oct 27, 2008 at 9:04 AM, Andrei Alexandrescu >> <[EMAIL PROTECTED]> wrote: >> >>>>> What's the precedence of your user-defined in-fix operator? >>>>> >>>>> --bb >>>> >>>> Yup, I realized this myself as well. Seemed like such a great idea when >>>> I >>>> only thought of it for three seconds. :p >>> >>> An operator could always be defined to have the same precedent as an >>> existing operator, which it has to specify. >> >> Walter said in a previous post a few days ago when I suggested it that >> that would kill D's easy parsability. >> You say no? I'm no parser expert, so hard for me to say. > > It can be done, but it's kinda involved. You define a grammar in which all > operators have the same precedence. Consequently you compile any expression > into a list of operands and operators. That makes the language parsable > without semanting info. Then the semantic stage transforms the list into a > tree. Cecil does that.
I see. So the price you pay is that you defer more decisions till semantic stage. I.e. "a b c d e" is allowed to parse into an amorphous list, then in the semantic pass you decide if 'b' and 'd' are actually legal operators or not. --bb