All Projects → yanghuan → Csharp.lua

yanghuan / Csharp.lua

Licence: other
The C# to Lua compiler

Programming Languages

lua
6591 projects
csharp
926 projects

Labels

Projects that are alternatives of or similar to Csharp.lua

Janino
Janino is a super-small, super-fast Java™ compiler.
Stars: ✭ 627 (-11.94%)
Mutual labels:  compiler
Amacc
Small C Compiler generating ELF executable Arm architecture, supporting JIT execution
Stars: ✭ 661 (-7.16%)
Mutual labels:  compiler
Tiramisu
A polyhedral compiler for expressing fast and portable data parallel algorithms
Stars: ✭ 685 (-3.79%)
Mutual labels:  compiler
Fastexpressioncompiler
Fast ExpressionTree compiler to delegate
Stars: ✭ 631 (-11.38%)
Mutual labels:  compiler
Cakeml
CakeML: A Verified Implementation of ML
Stars: ✭ 651 (-8.57%)
Mutual labels:  compiler
Wirefilter
An execution engine for Wireshark-like filters
Stars: ✭ 677 (-4.92%)
Mutual labels:  compiler
Sultan
Sultan: Command and Rule over your Shell
Stars: ✭ 625 (-12.22%)
Mutual labels:  compiler
Marked
A markdown parser and compiler. Built for speed.
Stars: ✭ 26,556 (+3629.78%)
Mutual labels:  compiler
Gocaml
🐫 Practical statically typed functional programming language implementation with Go and LLVM
Stars: ✭ 653 (-8.29%)
Mutual labels:  compiler
Mlton
The MLton repository
Stars: ✭ 683 (-4.07%)
Mutual labels:  compiler
Cyclone
🌀 A brand-new compiler that allows practical application development using R7RS Scheme. We provide modern features and a stable system capable of generating fast native binaries.
Stars: ✭ 634 (-10.96%)
Mutual labels:  compiler
Js of ocaml
Compiler from OCaml to Javascript.
Stars: ✭ 643 (-9.69%)
Mutual labels:  compiler
Tiny Compiler
A tiny evaluator and compiler of arithmetic expressions.
Stars: ✭ 680 (-4.49%)
Mutual labels:  compiler
Lebab
Turn your ES5 code into readable ES6. Lebab does the opposite of what Babel does.
Stars: ✭ 5,479 (+669.52%)
Mutual labels:  compiler
Constexpr 8cc
Compile-time C Compiler implemented as C++14 constant expressions
Stars: ✭ 687 (-3.51%)
Mutual labels:  compiler
Minic Hosting
A simple stack-based virtual machine that runs C in the browser.
Stars: ✭ 628 (-11.8%)
Mutual labels:  compiler
Rustc codegen cranelift
Cranelift based backend for rustc
Stars: ✭ 675 (-5.2%)
Mutual labels:  compiler
Inc
an incremental approach to compiler construction
Stars: ✭ 702 (-1.4%)
Mutual labels:  compiler
Jscl
A Lisp-to-Javascript compiler bootstrapped from Common Lisp
Stars: ✭ 688 (-3.37%)
Mutual labels:  compiler
Esper
Esper Complex Event Processing, Streaming SQL and Event Series Analysis
Stars: ✭ 680 (-4.49%)
Mutual labels:  compiler

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# 8.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".

  • Self-Compiling (linux), run "./make" (if no errors, will prompt for fibbonacci 'N' value and generate fib sequence in lua)

  • Used by .NET Core, Ability to across platforms.

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
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:\>dotnet CSharp.Lua.Launcher.dll -h
Usage: CSharp.lua [-s srcfolder] [-d dstfolder]
Arguments
-s              : can be a directory where all cs files will be compiled, or a list of files, using ';' or ',' to separate
-d              : destination directory, will put the out lua files

Options
-h              : show the help message and exit
-l              : libraries referenced, use ';' to separate
                  if the librarie is a module, whitch is compield by CSharp.lua with -module arguemnt, the last character needs to be '!' in order to mark  

-m              : meta files, like System.xml, use ';' to separate
-csc            : csc.exe command argumnets, use ' ' or '\t' to separate

-c              : support classic lua version(5.1), default support 5.3
-a              : attributes need to export, use ';' to separate, if ""-a"" only, all attributes whill be exported
-e              : enums need to export, use ';' to separate, if ""-e"" only, all enums will be exported
-ei             : enums is represented by a variable reference rather than a constant value, need to be used with -e
-p              : do not use debug.setmetatable, in some Addon/Plugin environment debug object cannot be used
-metadata       : export all metadata, use @CSharpLua.Metadata annotations for precise control
-module         : the currently compiled assembly needs to be referenced, it's useful for multiple module compiled
-inline-property: inline some single-line properties
-include        : the root directory of the CoreSystem library, adds all the dependencies to a single file named out.lua

Make sure that .NET 5.0 is installed. https://dotnet.microsoft.com/download/dotnet/5.0

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

Communication

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].