Giter Club home page Giter Club logo

csharp.lua's Introduction

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# 6.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

using System;

namespace HelloLua {
    public static class Program {
        public static void Main() {
            Console.WriteLine("hello lua!");
        }
    }
}

To Lua

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

Try Live

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

How to Use

Command Line Parameters

D:\>CSharp.Lua.exe -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
-sem            : append semicolon when statement over
-a              : attributes need to export, use ';' to separate, if ""-a"" only, all attributes whill be exported

Download

CSharp.lua.1.0.0.0.zip

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.

csharp.lua's People

Contributors

lostplesed avatar yanghuan avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.