Re: [Mono-dev] [PATCH] Generate Consts.vb from Consts.cs (new patch)

2006-08-24 Thread Carlos Alberto Cortez

> I might be wrong but I am wondering if it is consistent to use Perl for 
> this kind of things, inside the mono project. It would be more logical 
> to use Mono itself, and then not having another external dependency 
> (Mono depending on Perl??), right?

Just for the record: we already have perl scripts in the build system,
as well in gtk-sharp, for example.

Carlos.

___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] [PATCH] Generate Consts.vb from Consts.cs (new patch)

2006-08-24 Thread Ympostor
Kornél Pál wrote:
> I attached a cs2vb.cs that is functionally equivalent to cs2vb.pl. (I 
> created this just for fun to show how much easier it is in Perl.:)

I keep preferring C# :D


> I anybody has ideas how to compile a C# program before compiling 
> anything else help is welcome otherwise I think the previously attached 
> cs2vb.pl is the best solution.

Hey, if the conversion tool is made with C#, you need to compile the 
runtime first but, when is this tool needed? I suppose it is only for 
the VB part. Why not compiling all the C# stuff, compile this tool, and 
then all the VB part?

Regards

-- 

___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] [PATCH] Generate Consts.vb from Consts.cs (new patch)

2006-08-24 Thread Kornél Pál

Hi,

I attached a cs2vb.cs that is functionally equivalent to cs2vb.pl. (I 
created this just for fun to show how much easier it is in Perl.:)


I anybody has ideas how to compile a C# program before compiling anything 
else help is welcome otherwise I think the previously attached cs2vb.pl is 
the best solution.



But perhaps tomorrow you need constans and X; and in one month you see
that you need Y too, and then Z... And you could have finished it
earlier reusing code..? :)


Consts.cs is for constants. If we need code it probably will be (and should 
be) put to separate code files. Converting code from one language to another 
as the part of the build process is a bad idea anyway. Even if you convert 
it programatically you have to look at the result that everyting is fine. So 
if we need the same code both in C# and VB there should be two source files 
in SVN.


Consts.cs is a special case because it only contains constants. It's more 
like a configuration file than a code file.


Kornél

- Original Message - 
From: "Ympostor" <[EMAIL PROTECTED]>

To: 
Sent: Thursday, August 24, 2006 1:45 PM
Subject: Re: [Mono-dev] [PATCH] Generate Consts.vb from Consts.cs (new 
patch)



Kornél Pál escribió:

This conversion is restricted to constants. And it should be simple rather
than a complex language converter.


But perhaps tomorrow you need constans and X; and in one month you see
that you need Y too, and then Z... And you could have finished it
earlier reusing code..? :)



BTW who do you mean on the SD guys?


Sorry for not clarifying, SD: SharpDevelop.

Regards.

--

___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list 

//
// cs2vb.cs
//
// Author:
//   Kornél Pál <http://www.kornelpal.hu/>
//
// Copyright (C) 2006 Kornél Pál
//

//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//

// This converter is suitable only for Consts.cs.

// There will be no hidden bugs because unsupported constructs are not
// converted that will cause compilation errors in Visual Basic compiler.

using System;
using System.Globalization;
using System.IO;
using System.Text.RegularExpressions;

internal class cs2vb
{
private static string line;
private static Match match;

private static string GetSubstring (int index)
{
return GetSubstring (match, index);
}

private static string GetSubstring (Match match, int index)
{
return match.Groups [index].Value;
}

private static bool IsMatch (string pattern)
{
return IsMatch (line, pattern);
}

private static bool IsMatch (string input, string pattern)
{
match = Regex.Match (input, pattern, 
RegexOptions.CultureInvariant);
return match.Success;
}

private static bool Replace (string pattern, string replacement)
{
return Replace (ref line, pattern, replacement);
}

private static bool Replace (string pattern, MatchEvaluator evaluator)
{
return Replace (ref line, pattern, evaluator);
}

private static bool Replace (ref string input, string pattern, string 
replacement)
{
if (!IsMatch (input, pattern))
return false;

input = Regex.Replace (input, pattern, replacement, 
RegexOptions.CultureInvariant);
return true;
}

private static bool Replace (ref string input, string pattern, 
MatchEvaluator evaluator)
{
if (!IsMatch (input, pattern))
return false;

input = Regex.Replace (input, pattern, evaluator, 
RegexOptions.CultureInvariant);
return true;
}

  

Re: [Mono-dev] [PATCH] Generate Consts.vb from Consts.cs (new patch)

2006-08-24 Thread Ympostor
Kornél Pál escribió:
> This conversion is restricted to constants. And it should be simple rather 
> than a complex language converter.

But perhaps tomorrow you need constans and X; and in one month you see 
that you need Y too, and then Z... And you could have finished it 
earlier reusing code..? :)


> BTW who do you mean on the SD guys?

Sorry for not clarifying, SD: SharpDevelop.

Regards.

-- 

___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] [PATCH] Generate Consts.vb from Consts.cs (new patch)

2006-08-24 Thread Kornél Pál
This conversion is restricted to constants. And it should be simple rather 
than a complex language converter.

BTW who do you mean on the SD guys?

Kornél

- Original Message - 
From: "Ympostor" <[EMAIL PROTECTED]>
To: 
Sent: Thursday, August 24, 2006 12:24 PM
Subject: Re: [Mono-dev] [PATCH] Generate Consts.vb from Consts.cs (new 
patch)


Kornél Pál escribió:
> I think we already have perl dependency. I decided to use perl because 
> this
> conversion is done solely using regular expressions and perl is good at 
> it.
> On the other hand things in the common directory are built before any
> bootstrap compilation is done it may be better not to rely on mcs in this
> directory.
>
> Anyway if others prefer to have a cs2vb.cs instead I'll port it to C#
> because it's really small work.

Thanks for both answers Kornel and Robert.

BTW, there is already some implementation of language conversion
utilities, which could be reused here AFAIK, from the SD guys. But I
don't know if the use of mono-lite implies any restriction on the code
used that could not be fulfilled the mentioned utilities...

Regards.

-- 

___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list 

___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] [PATCH] Generate Consts.vb from Consts.cs (new patch)

2006-08-24 Thread Ympostor
Kornél Pál escribió:
> I think we already have perl dependency. I decided to use perl because this 
> conversion is done solely using regular expressions and perl is good at it. 
> On the other hand things in the common directory are built before any 
> bootstrap compilation is done it may be better not to rely on mcs in this 
> directory.
> 
> Anyway if others prefer to have a cs2vb.cs instead I'll port it to C# 
> because it's really small work.

Thanks for both answers Kornel and Robert.

BTW, there is already some implementation of language conversion 
utilities, which could be reused here AFAIK, from the SD guys. But I 
don't know if the use of mono-lite implies any restriction on the code 
used that could not be fulfilled the mentioned utilities...

Regards.

-- 

___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] [PATCH] Generate Consts.vb from Consts.cs (new patch)

2006-08-24 Thread Robert Jordan
Ympostor wrote:
> Kornél Pál wrote:
>> I've done some more work on cs2vb.pl; now I consider it being complete.
> 
> I might be wrong but I am wondering if it is consistent to use Perl for 
> this kind of things, inside the mono project. It would be more logical 
> to use Mono itself, and then not having another external dependency 
> (Mono depending on Perl??), right?

I'm pretty sure Kornél won't disagree if you'd rewrite
this in C#. And don't forget to take care about the
bootstrapping using mono-lite, because at this stage
the class libs don't exist ;-)

Robert

___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] [PATCH] Generate Consts.vb from Consts.cs (new patch)

2006-08-24 Thread Kornél Pál
Hi,

I think we already have perl dependency. I decided to use perl because this 
conversion is done solely using regular expressions and perl is good at it. 
On the other hand things in the common directory are built before any 
bootstrap compilation is done it may be better not to rely on mcs in this 
directory.

Anyway if others prefer to have a cs2vb.cs instead I'll port it to C# 
because it's really small work.

Kornél

- Original Message - 
From: "Ympostor" <[EMAIL PROTECTED]>
To: 
Sent: Thursday, August 24, 2006 11:41 AM
Subject: Re: [Mono-dev] [PATCH] Generate Consts.vb from Consts.cs (new 
patch)


Kornél Pál wrote:
> I've done some more work on cs2vb.pl; now I consider it being complete.

I might be wrong but I am wondering if it is consistent to use Perl for
this kind of things, inside the mono project. It would be more logical
to use Mono itself, and then not having another external dependency
(Mono depending on Perl??), right?

Regards.

-- 

___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list 

___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


Re: [Mono-dev] [PATCH] Generate Consts.vb from Consts.cs (new patch)

2006-08-24 Thread Ympostor
Kornél Pál wrote:
> I've done some more work on cs2vb.pl; now I consider it being complete.

I might be wrong but I am wondering if it is consistent to use Perl for 
this kind of things, inside the mono project. It would be more logical 
to use Mono itself, and then not having another external dependency 
(Mono depending on Perl??), right?

Regards.

-- 

___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list


[Mono-dev] [PATCH] Generate Consts.vb from Consts.cs (new patch)

2006-08-24 Thread Kornél Pál

Hi,

I've done some more work on cs2vb.pl; now I consider it being complete.

Kornél

- Original Message - 
From: "Kornél Pál" <[EMAIL PROTECTED]>

To: 
Sent: Wednesday, August 23, 2006 8:17 PM
Subject: [PATCH] Generate Consts.vb from Consts.cs



Hi,

Microsoft.VisualBasic and vbnc are written in VB. Consts.cs contains
contants that are usable in these assemblies as well so it is preferable 
to

have a Consts.vb as well.

I created cs2vb.pl that is intended to generate Consts.vb from Consts.cs 
so

that only Consts.cs.in has to be maintained by hand.

Please review and approve the patch.

Kornél



Consts.vb.diff
Description: Binary data
___
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list