Skip to content
This repository was archived by the owner on Feb 22, 2020. It is now read-only.

Repository files navigation

CSharp.lua

The C# to Lua compiler.

Introduction

CSharp.lua is a C# to Lua compiler. Write C# then run on lua VM.

  • Build on Microsoft Roslyn. Support for C# 7.0.

  • Highly readable code generation. C# AST ---> Lua AST ---> Lua Code.

  • Allowing almost all of the C# language features.

  • Provides CoreSystem.lua library, can run away of CLR.

  • Self-Compiling, run "./test/self-compiling/self.bat".

Sample

C# code

usingSystem;namespaceHelloLua{publicstaticclassProgram{publicstaticvoidMain(){Console.WriteLine("hello lua!");}}}

To Lua

-- Generated by CSharp.lua Compiler 1.0.0.0localSystem=SystemSystem.namespace("HelloLua", function (namespace) namespace.class("Program", function (namespace) localMainMain=function () System.Console.WriteLine("hello lua!")
endreturn {
Main=Main
}
end)
end)

Try Live

https://yanghuan.github.io/external/bridgelua-editor/index.html

How to Use

Command Line Parameters

D:\>dotnet CSharp.Lua.Launcher.dll -h
Usage: CSharp.lua [-s srcfolder] [-d dstfolder]
Arguments -s : source directory, all *.cs files whill be compiled
-d : destination directory, will put the out lua files
Options
-h : show the help message -l : libraries referenced, use ';' to separate -m : meta files, like System.xml, use ';' to separate -csc : csc.exe command argumnets, use ';' to separate
-c : support classic lua version(5.1), default support 5.3 -i : indent number, default is 2
-a : attributes need to export, use ';' to separate, if""-a"" only, all attributes whill be exported

Download

https://github.com/yanghuan/CSharp.lua/releases

CoreSystem.lua

CoreSystem.lua library that implements most of the .NET Framework core classes, including support for basic type, delegate, generic collection classes & linq. The Converted lua code, need to reference it

Example

  • fibonacci, a console program code, print Fibonacci number.

Documentation

https://github.com/yanghuan/CSharp.lua/wiki

License

Apache 2.0 license.

Acknowledgements

About

The C# to Lua compiler

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages