protected override bool Load(Dsl.StatementData statementData) { //简化语法while(exp) func(args);语法的处理 if (statementData.GetFunctionNum() == 2) { var first = statementData.First; var second = statementData.Second; var firstId = first.GetId(); var secondId = second.GetId(); if (firstId == "while" && !first.HaveStatement() && !first.HaveExternScript() && !string.IsNullOrEmpty(secondId) && !second.HaveStatement() && !second.HaveExternScript()) { if (first.GetParamNum() > 0) { Dsl.ISyntaxComponent cond = first.GetParam(0); m_Condition = Interpreter.Load(cond); } else { //error Interpreter.Log("Interpreter error, {0} line {1}", first.ToScriptString(false), first.GetLine()); } IExpression subExp = Interpreter.Load(second); m_Expressions.Add(subExp); return(true); } } return(false); }
protected override bool Load(Dsl.StatementData statementData) { //简化语法if(exp) func(args);语法的处理 int funcNum = statementData.GetFunctionNum(); if (funcNum == 2) { var first = statementData.First; var second = statementData.Second; var firstId = first.GetId(); var secondId = second.GetId(); if (firstId == "if" && !first.HaveStatement() && !first.HaveExternScript() && !string.IsNullOrEmpty(secondId) && !second.HaveStatement() && !second.HaveExternScript()) { IfExp.Clause item = new IfExp.Clause(); if (first.GetParamNum() > 0) { Dsl.ISyntaxComponent cond = first.GetParam(0); item.Condition = Interpreter.Load(cond); } else { //error Interpreter.Log("Interpreter error, {0} line {1}", first.ToScriptString(false), first.GetLine()); } IExpression subExp = Interpreter.Load(second); item.Expressions.Add(subExp); m_Clauses.Add(item); return(true); } } //标准if语句的处理 foreach (var fData in statementData.Functions) { if (fData.GetId() == "if" || fData.GetId() == "elseif") { IfExp.Clause item = new IfExp.Clause(); if (fData.IsHighOrder && fData.LowerOrderFunction.GetParamNum() > 0) { Dsl.ISyntaxComponent cond = fData.LowerOrderFunction.GetParam(0); item.Condition = Interpreter.Load(cond); } else { //error Interpreter.Log("Interpreter error, {0} line {1}", fData.ToScriptString(false), fData.GetLine()); } for (int ix = 0; ix < fData.GetParamNum(); ++ix) { IExpression subExp = Interpreter.Load(fData.GetParam(ix)); item.Expressions.Add(subExp); } m_Clauses.Add(item); } else if (fData.GetId() == "else") { if (fData != statementData.Last) { //error Interpreter.Log("Interpreter error, {0} line {1}", fData.ToScriptString(false), fData.GetLine()); } else { IfExp.Clause item = new IfExp.Clause(); for (int ix = 0; ix < fData.GetParamNum(); ++ix) { IExpression subExp = Interpreter.Load(fData.GetParam(ix)); item.Expressions.Add(subExp); } m_Clauses.Add(item); } } else { //error Interpreter.Log("Interpreter error, {0} line {1}", fData.ToScriptString(false), fData.GetLine()); } } return(true); }