static Func<dynamic> CompileString(LuaContext context, string source) { ContractUtils.RequiresNotNull(context, "context"); var sourceUnit = context.CreateSnippet(source, SourceCodeKind.Statements); //var options = (LuaCompilerOptions)context.GetCompilerOptions(); //var errorSink = context.GetCompilerErrorSink(); //var lexer = context.GetService<TokenizerService>(); var lexer = new Tokenizer(ErrorSink.Default, LuaCompilerOptions.Default); lexer.Initialize(null, sourceUnit.GetReader(), sourceUnit, SourceLocation.MinValue); var parser = new Parser(lexer, lexer.ErrorSink); var ast = parser.Parse(); var gen = new Generator(context); var expr = gen.CompileInline(ast, context.Trace.CurrentEvaluationScope.GetRoot(), context.Trace.CurrentScopeStorage, sourceUnit); return expr.Compile(); }