The C# to Lua compiler.
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".
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)https://yanghuan.github.io/external/bridgelua-editor/index.html
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 exportedhttps://github.com/yanghuan/CSharp.lua/releases
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
- fibonacci, a console program code, print Fibonacci number.