[nem-en] += Macro and delegates

Andrey Khropov andrey.khropov at gmail.com
Thu Dec 7 23:16:11 CET 2006


Hello,

I have a question about how "+=" macro is transformed to event handler
attachment :

We have TExpr.MacroEnvelope(original,the_macro,expanded)

original:
----------------------------------------------------------------
this.button1.Click += System.EventHandler (this.button1_Click)
----------------------------------------------------------------

expanded:
----------------------------------------------------------------
mutable _N_cached_obj4611 = this.button1;
_N_cached_obj4611.add_Click(System.EventHandler(this.button1_Click));
----------------------------------------------------------------

So I have a question how can I detect such a case (among all "+="s)
because I need to generate System.CodeDom.CodeAttachEventStatement in my
CodeDomParser in this case.

Should I just try to parse *original* like that:

----------------------------------------------------------------
match(original)
{
	| <[ $( e1 : ?* ) += $delegate ]> =>  ...
	...
}
----------------------------------------------------------------?

How should I detect that lhs of this expression is an event?

*(?) means 'what to insert here?'


-- 
AKhropov




More information about the devel-en mailing list