[Mono-list] Implementing attribute-based code generation
Rodrigo B. de Oliveira
rbo@acm.org
Thu, 13 Jan 2005 13:36:14 -0200
Following up on my previous message on boo syntactic attributes:
* how does one get syntactic attributes working for c# (or a c# like
language)?
1) get a c# parser to generate a boo AST (there's a antlr
based c# grammar if I'm not mistaken)
2) plug the parser in a new boo compiler pipeline (very
simple step)
3) sit back and watch
Actually if you want the language to be strictly equivalent to c# you might
need to customize some other parts of the compiler (such as the overloaded
method resolution algorithm, stricter type checking for rvalues and some
other minor things) but I'm sure the boo community would be willing to help
since that would help to fullfil the boo goal of being a very flexible
language system.
Cheers,
Rodrigo
> -----Original Message-----
> From: mono-list-admin@lists.ximian.com
> [mailto:mono-list-admin@lists.ximian.com] On Behalf Of Stephen Touset
> Sent: Thursday, January 13, 2005 1:36 AM
> To: Rodrigo B. de Oliveira
> Cc: mono-list@lists.ximian.com
> Subject: Re: [Mono-list] Implementing attribute-based code generation
>
> Rodrigo B. de Oliveira wrote:
>
> >It sounds like you are talking about what we call syntactic
> attributes.
> >
> >
>
> I couldn't tell from the website. Essentially, I am trying to
> add design by contract support to the mono C# compiler (as an
> extension, rather than a core patch to mcs). The best way to
> do this would seem to be to have attributes that can modify
> methods. In other words:
>
> [Precondition("o != null")]
> [Postcondition("size > 0")]
> void AddObject(Object o) {
> // ... do stuff ...
> return;
> }
>
> Which would then at compile time insert
>
> void AddObject(Object o) {
> Check.Require(o != null);
> // ... do stuf ...
> Check.Ensure(size > 0);
> return;
> }
>
> While also obeying design by contract inheritance rules.
> _______________________________________________
> Mono-list maillist - Mono-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
>
>