Custom Syntax Development

  • Thread starter Thread starter Lucky
  • Start date Start date
L

Lucky

Hi Guys!
I'm working on a project that involves some other developing language
then c#. It as some syntax, those reduces code development complexty
and gives more readability to code.

I would like to extend such syntaxes into C# but i dont know where to
start and how to do.

Many of you might have worked on such developments or might have used
custom syntaxes in different ways. I welcome your suggestions,
guidelines to put my thought in place.

Please provide some kick start info.

Thanks,
 
I thought there would be some replies by now.
Seems the content was not enough to attract attention.

here some more,

I'm thinking to develop some syntaxes like this:

if(item not in itemes)
{

}


if(item in items)
{

}

It would be nice to have some syntaxes those provides more readability
and less coding efforts.

if some one can give me a startup, it would be great.

Regards,
 
If items is a List it probably has the Contains function.
If it does, you can use
if(!items.Contains(item))
and
if (item.Contains(item))

HTH
 
lucky said:
I thought there would be some replies by now.
Seems the content was not enough to attract attention.

The world is big... It was dark here when you posted both posts...

here some more,

I'm thinking to develop some syntaxes like this:

if(item not in itemes)
{

}


if(item in items)
{

}

It would be nice to have some syntaxes those provides more readability
and less coding efforts.

if some one can give me a startup, it would be great.

Regards,

Do you want to create your own compiler which has some similarities to C#,
but is tweeked with your own syntax specifications?

Do you want to build a preprocessor that converts the code you posted to
something like Ciaran posted, then just compile the temporary info as C#?

Mike
 
Hi Guys!
I'm working on a project that involves some other developing language
then c#. It as some syntax, those reduces code development complexty
and gives more readability to code.

I would like to extend such syntaxes into C# but i dont know where to
start and how to do.

Many of you might have worked on such developments or might have used
custom syntaxes in different ways. I welcome your suggestions,
guidelines to put my thought in place.

Please provide some kick start info.

There are no compile-time metaprogramming capabilities available in C#
as of today. It is not clear when (or even if) they might appear.

If you want to extend C# for your own purposes, the best you can do is
take Mono C# compiler (which is, I believe, LGPL'ed), and hack its
source code to add the constructs that you want.

Alternatively, think whether your language extensions aren't actually
better off as library extensions.
 
I thought there would be some replies by now.
Seems the content was not enough to attract attention.

here some more,

I'm thinking to develop some syntaxes like this:

if(item not in itemes)
{

}

if(item in items)
{

}

See, that's precisely what I mean by "consider library solutions".

What's wrong with:

if (items.Contains(item))

?

Note that you can add this sort of functionality for any existing type
that "items" might have using extension methods in C# 3.0.

Also have a look at lambdas. They allow to define control structures,
though not quite with the same look as built-in ones. For example,
here's the parallelized foreach from Parallel LINQ:

Parallel.ForEach(items, item => {
Console.WriteLine(item);
});
 
Back
Top