public static void Main(string [] args) { LuaParser parser; var context = new LuaContext (); context.AddBasicLibrary (); context.AddIoLibrary (); if (args.Any ()) { // take first arg as file name parser = new LuaParser (context, args [0]); parser.Parse (); return; } // otherwise, run repl Console.WriteLine ("AluminumLua 0.1 (c) 2011 Alex Corrado"); parser = new LuaParser (context); try { parser.Parse (true); } catch (LuaException e) { Console.WriteLine (e.Message); } }
public static void Main(string [] args) { LuaParser parser; var context = new LuaContext(); context.AddBasicLibrary(); context.AddIoLibrary(); if (args.Any()) // take first arg as file name { parser = new LuaParser(context, args [0]); parser.Parse(); return; } // otherwise, run repl Console.WriteLine("AluminumLua 0.1 (c) 2011 Alex Corrado"); parser = new LuaParser(context); while (true) { try { Console.Write("> "); parser.Parse(true); } catch (LuaException e) { Console.WriteLine(e.Message); } } }
private LuaObject dofile(LuaObject [] args) { LuaParser parser; var exec = LuaSettings.Executor(this); var file = args.FirstOrDefault(); /*if (file.IsNil) * parser = new LuaParser (exec); // read from stdin * else*/ parser = new LuaParser(exec, file.AsString()); parser.Parse(); return(exec.Result()); }
static void Lua() { //Error: Exception: System.Exception: Native code encountered, plug required. Please see https://github.com/CosmosOS/Cosmos/wiki/Plugs). System.IRuntimeMethodInfo System.Delegate.FindMethodHandle(). //1 > Called from: //1 > System.Delegate::System.Reflection.MethodInfo GetMethodImpl() //1 > System.Delegate::System.Reflection.MethodInfo get_Method() //1 > AluminumLua.LuaObject::System.String ToString() context.AddBasicLibrary(); context.AddIoLibrary(); context.SetGlobal("OSv", Kernel.OSv); context.SetGlobal("command", "hello"); var parser = new LuaParser(context); // < or leave file_name out to read stdin parser.Parse(); }
/// <summary> /// The load. /// </summary> /// <param name="builder"> /// The builder. /// </param> protected override void Load(ContainerBuilder builder) { if (string.IsNullOrEmpty(this.fileName)) this.fileName = "autofac.lua"; LuaParser parser; var context = new LuaContext(); context.AddBasicLibrary(); parser = new LuaParser(context, this.fileName); SetBuilderTable(builder, context); SetRefletionTable(builder, context); parser.Parse(); //lua = new Lua(); //{ // lua["builder"] = new AutofacLuaBuilder(builder); // lua.DoString(File.ReadAllText(fileName)); //} }
public static string ValidateArtemisScript(string script) { try { script = "if false then " + Environment.NewLine + Regex.Replace(script, @"^\s*([A-Z]\w+):\s(.+)$", new MatchEvaluator(artemisScriptValidator), RegexOptions.Multiline) + Environment.NewLine + " end"; } catch { return "Failed to parse script. Dunno why. This shouldn't happen."; } LuaContext lua = new LuaContext(); lua.AddBasicLibrary(); LuaParser p = new LuaParser(lua, new StringReader(script)); try { p.Parse(); } catch (LuaException ex) { return ex.Message; } return null; }