internal ScriptObject LoadString(String strBreviary, String strBuffer, ScriptContext context) { try { m_StackInfoStack.Clear(); ScriptLexer scriptLexer = new ScriptLexer(strBuffer); strBreviary = Util.IsNullOrEmpty(strBreviary) ? scriptLexer.GetBreviary() : strBreviary; ScriptParser scriptParser = new ScriptParser(this, scriptLexer.GetTokens(), strBreviary); ScriptExecutable scriptExecutable = scriptParser.Parse(); return(new ScriptContext(this, scriptExecutable, context, Executable_Block.Context).Execute()); } catch (System.Exception e) { throw new ScriptException("load buffer [" + strBreviary + "] is error : " + e.ToString()); } }
public static SerializeData Serialize(string breviary, string buffer) { var lexer = new ScriptLexer(buffer, breviary); breviary = lexer.Breviary; var parser = new ScriptParser(lexer.GetTokens(), breviary); var context = parser.Parse(); return(new SerializeData(parser.ConstDouble.ToArray(), parser.ConstLong.ToArray(), parser.ConstString.ToArray(), context, parser.Functions.ToArray(), parser.Classes.ToArray())); }
internal ScriptObject LoadString(String strBreviary, String strBuffer, ScriptContext context, bool clearStack) { try { if (Util.IsNullOrEmpty(strBuffer)) { return(m_Null); } if (clearStack) { m_StackInfoStack.Clear(); } ScriptLexer scriptLexer = new ScriptLexer(strBuffer, strBreviary); return(Load(scriptLexer.GetBreviary(), scriptLexer.GetTokens(), context)); } catch (System.Exception e) { throw new ScriptException("load buffer [" + strBreviary + "] is error : " + e.ToString()); } }
static void Main(string[] args) { string source = ""; string target = ""; try { for (int i = 0; i < args.Length; ++i) { if (args[i] == "-s") { source = args[i + 1]; } else if (args[i] == "-o") { target = args[i + 1]; } } } catch (System.Exception ex) { Console.WriteLine("参数出错 -s [源文件] -o [输出文件] error : " + ex.ToString()); goto exit; } if (string.IsNullOrEmpty(source) || string.IsNullOrEmpty(target)) { Console.WriteLine("参数出错 -s [源文件] -o [输出文件] "); goto exit; } source = Path.Combine(Environment.CurrentDirectory, source); target = Path.Combine(Environment.CurrentDirectory, target); try { ScriptLexer lexer = new ScriptLexer(File.ReadAllText(source)); File.WriteAllBytes(target, Serialize(lexer.GetTokens())); } catch (System.Exception ex) { Console.WriteLine("解析出错 error : " + ex.ToString()); } exit: Console.WriteLine("生成完成,请按任意键继续"); Console.ReadKey(); }
internal ScriptObject LoadString(string strBreviary, string strBuffer, ScriptContext context, bool clearStack) { ScriptObject obj2; try { if (Util.IsNullOrEmpty(strBuffer)) { return(this.m_Null); } if (clearStack) { this.m_StackInfoStack.Clear(); } ScriptLexer lexer = new ScriptLexer(strBuffer, strBreviary); obj2 = this.Load(lexer.GetBreviary(), lexer.GetTokens(), context); } catch (System.Exception exception) { throw new ScriptException("load buffer [" + strBreviary + "] is error : " + exception.ToString()); } return(obj2); }