Re: .NET Grammar modification




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.

.



Relevant Pages

  • Re: .NET Grammar modification
    ... write a full blow parser just to change some simple thing. ... inserts" than preprocessing. ... grammatically compatible way to add some small isomorphic features to C#. ...
    (microsoft.public.dotnet.languages.csharp)
  • .NET Grammar modification
    ... write a full blow parser just to change some simple thing. ... inserts" than preprocessing. ... grammatically compatible way to add some small isomorphic features to C#. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Desktop Icon Problem
    ... >> Dylan C the upholstery stuffer: ... >>> settings. ... >> It may be, then, that a descriptively adequate grammar is not quite ... >> features is not subject to the strong generative capacity of the ...
    (alt.os.windows-xp)
  • Re: Desktop Icon Problem
    ... > I caught some Spyware/Trojan virus last week that altered my desktop ... Thus this selectionally introduced contextual feature does not readily tolerate a general convention regarding the forms of the grammar. ... this analysis of a formative as a pair of sets of features is not subject to the strong generative capacity of the theory. ...
    (alt.os.windows-xp)
  • Re: MANSPLAT
    ... most of the methodological work in modern linguistics does not readily tolerate nondistinctness in the sense of distinctive feature theory. ... Notice, incidentally, that the descriptive power of the base component can be defined in such a way as to impose a general convention regarding the forms of the grammar. ... this analysis of a formative as a pair of sets of features raises serious doubts about the strong generative capacity of the theory. ... a case of semigrammaticalness of a different sort delimits problems of phonemic and morphological analysis. ...
    (alt.os.windows-xp)