Re: Properties

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Jon Slaughter wrote:
If, suppose, you can explain why the follow will not work then I might understand some of you.

I will "extend" the C# grammar by creating a parser. The parser inputs a super set of the grammar of C# and returns compatible C# code.

Heres how the simplified parser works(would actually do more if implemented):

1. Looks for any properties.
2. Get the name of the property.
3. Creates a private field in the same class as the property and appends a random string to the the name of property and use that for the field.
4. looks for any references to properties and the use the .this quantifier. If found replaces these tokens with the name of the field generated in 3.
5. repeat until done.


Example.

Extended C#:
public string Name
{
get { return Name.this }
set { Name.this = value; }
}

after parse, changed text in brackets:

private string Name398492893;
public string Name
{
get { return Name398492893 }
set { Name398492893 = value; }
}


Is there any reason why this would not work and not simplify the redudancy in creating properties?

Nothin is preventing you from creating the new language
jon# with all the features you want.

But I would not switch to that language, because
I can not see any advantage of it.

And the preprocessor model has some disadvantages in
the build and debug process when it is not supported
by the compiler.

Arne
.



Relevant Pages

  • Re: Properties
    ... I will "extend" the C# grammar by creating a parser. ... super set of the grammar of C# and returns compatible C# code. ... private string name public property Name; ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Is pyparsing really a recursive descent parser?
    ... There are an enormous variety of parsing tools, ... For instance, the Earley parser ... Okay, in some contexts, an ambiguous grammar may be considered ... over the other through the context of the parse results? ...
    (comp.lang.python)
  • Re: ANTLR Target for Ruby
    ... is to figure out where backtracking might be needed and do it efficiently ... a large overhead over using a hand-crafted parser. ... If you also provided a sweet metagrammar (I find your earlier Grammar ... The real work is in the "engine" that does parser ...
    (comp.lang.ruby)
  • Re: Has anyone implemented BASIC in Python?
    ... >>one whose grammar needs to evolve over time, ... but I see the grammar definition ... > friends harder to understand than a recursive descending parser. ... Does that mean you shouldn't use recursive descent? ...
    (comp.lang.python)
  • Re: Why LL(1) Parsers do not support left recursion?
    ... I read Quinn's grammar and assumed it was Andru's. ... applied by LR parser generators and camoflague the fact that Quinn's ... Left recursion is not an inherently ambiguous situation. ... even for unambiguous left-recursive grammars the LL algorithm ...
    (comp.compilers)