Skip to content

liuhaopen/LuaUtility

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 

Repository files navigation

LuaUtility

parse lua code to a c# object, or generate lua code by a c# object

lua code => c# object

string test_code = "return {a=1.2, b=false, c=\"haha\"}";
TestClass obj = LuaUtility.FromLua<TestClass>(test_code);
//result : obj.a == 1.2 && obj.b == false && obj.c == "haha"

c# object => lua code

TestClass obj = new TestClass(){a=1, b=true, c="aaa"};
string code = LuaUtility.ToLua(obj);
//result : code == "{a=1, b=true, c="aaa"}"

Support Lua BNF:

 Stat ::= local Name ‘=’ Exp return Name | return Exp
 Exp ::= nil | false | true | Nunber | String | TableconStructor
 TableconStructor ::= ‘{’ [FieldList] ‘}’
 FieldList ::= Field {FieldSep Field} [FieldSep]
 Field ::= ‘[’ Exp ‘]’ ‘=’ Exp | Name ‘=’ Exp | Exp
 FieldSep ::= ‘,’ | ‘;’

About

parse lua code to a c# object, or generate lua code by a c# object

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages