Re: .NET Grammar modification
- From: "Bruce Wood" <brucewood@xxxxxxxxxx>
- Date: 29 Nov 2006 22:37:24 -0800
Jon Slaughter wrote:
I'm curious as to if .NET provides any direct means to modifying its own
grammar? e.g., if say I want to had some "features" to C# which can easily
be reinterpreted back into the original C# but I do not want to have to
write a full blow parser just to change some simple thing.
Lets suppose want to add a "macro" that on the surface adds the keyword
"property" which in reality is just a shorthand for the standard properties
in C#. I know VS has abilities to do macro's but they are more like "code
inserts" than preprocessing. I want something that is transparent in that it
acts like an extended version of C# but translates directly into it(through
preprocessing).
I know many will say that one shouldn't do this but thats not the point. I
don't want to hack together a quick brute force parser to do some small
conversions but I also don't want to have to implement a full blown parser
to handle a few modifications I want to do.
To be more clear, what I want is some way to preprocess C# files in a
grammatically compatible way to add some small isomorphic features to C#.
The method will simply generate a cs file that will be treated in the normal
way. (Although there is the problem of error handling but its not that big a
deal at this point)
The short answer is that no, there is no way in C#.
The preprocessor was an often-abused feature of C and is also a feature
of C++. So far as I know it was intentionally omitted from C# because
of the potential for abuse.
.
- References:
- .NET Grammar modification
- From: Jon Slaughter
- .NET Grammar modification
- Prev by Date: Re: advantage of boxing and unboxing
- Next by Date: Re: How force VS2005 to use older version of .NET Framework?
- Previous by thread: Re: .NET Grammar modification
- Next by thread: programmatically export the event log
- Index(es):
Relevant Pages
|