PROPOSAL: opSeq()

Russell Lewis webmaster at villagersonline.com
Wed Apr 9 05:56:55 PDT 2008


Bill Baxter wrote:
> It's an interesting idea.  Are you sure it doesn't kill 
> the-ease-of-parsing requirement for the grammar?

That is something that I have worried about, as well, and I haven't done 
a rock-solid analysis of it.  However, my hand-waving argument is that 
we parse the code without any knowledge of the types (we don't know 
which are opSeq handlers and which are not).  If our parsing shows us 
that we have a sequence of expressions without any sort of operator 
between them, then we interpret that using the opSeq parse rule:

	expression:
		expression expression ...

Then, in semantic analysis, we would decide whether that syntax is valid 
or not.  Since opSeq is right-associative, we start at the far-right of 
any chain of expressions, and see if the next-to-last expression is an 
opSeq handler; if so, it must take 1 argument, and the type must match 
the rightmost expression.  If not, then we work left, and so on.

Mechanically, I think I can argue that this doesn't make the parser any 
more complex.  What I don't know for sure, yet, is whether it introduces 
ambiguities into the grammar.  Those often require a tool to find. :(

Russ



More information about the Digitalmars-d mailing list