Cs2n
From Nemerle Homepage
Contents |
INTRODUCTION
What is cs2n?
cs2n is a tool for converting C# sources into Nemerle sources. It is available in standard Nemerle distribution and is included in our binary packages.
Requirements
To compile cs2n by hand you need to have antlr installed - ANother Tool for Language Recognition, which is used to create lexer and parser. Nemerle main configure script will detect it automatically and include cs2n in standard compilation process.
Compiling
Enter into nemerle/tools/cs2n/ directory. To compile type:
- make
Running
To convert your sources type:
- cs2n input_file.cs
Nemerlish options to cs2n
-nemerlish-function-parameters
Alias: -nfp
Drops "mutable" modifier from function parameters.
cs2n behavior:
Code
public void MyMethod (string s) { ... }
is translated to:
public MyMethod (s : string) { ... }
instead of:
public MyMethod (mutable s : string) { ... }
-nemerlish-default-value
Alias: -ndv
Uses "null", instead of DefaultValue macro for variable initializer.
cs2n behavior:
Code
SomeClass c;
is translated to:
mutable c = null;
instead of:
mutable c = Nemerle.Extension.DefaultValue (SomeClass);
Declarations of types: float, double, int, uint, long, ulong, byte, sbyte, short, ushort,decimal are initialized with 0. Char is initialized with '\0'.
-nemerlish-foreach
Alias: -nf
Drops ':> type' from foreach statement.
cs2n behavior:
Code
foreach (string s in collection) ...
is translated to:
foreach (s in collection) ...
instead of:
foreach (s :> string in collection) ...
-nemerlish
Alias: -n
Enables all -nemerlish-* flags.