[nem-en] syntax extension on member lvl
Kamil Dworakowski
kamil.dworakowski at googlemail.com
Fri Sep 8 22:36:50 CEST 2006
Hi all,
I wish it was possible write unit tests like this:
test an important behavior of the unit {
...
}
==>
[Test] public void test_an_important_behaviour_of_the_unit() {
...
}
That also would be nice:
public pointcut pc(o: object): execution(* *) && target(o);
==>
[pointcut(execution(* *) && target(o))] public abstract pointcut_pc(o:
object): void;
Idea 1 (general)
This could be achieved by modifying the token stream. There could be a
special pass for it. Upon spotting the test keyword parser hands the
control over the token stream to the macro. The macro changes the stream.
The problem is that Token remembers only next element. The context to
the left can't be read. Some macros could need that.
Macro could be given the token five positions left as well. Other option
is to look for sequences during the pass (like 'modifier keyword').
Idea 2 (quick fix)
MainParser.parse_top_extensions (modifiers : Modifiers, target :
MacroTargets) : void
This method is called by MainParser.ParseClassMember(): ClassMember just
after parsing attributes and modifiers.
If "parse_top_extensions" method allowed a macro to modify the token
stream it would do for both examples.
What do you think?
Kamil Dworakowski
More information about the devel-en
mailing list