protected override bool Load(Dsl.FunctionData funcData) { Dsl.ISyntaxComponent cond = funcData.Call.GetParam(0); IfExp.Clause item = new IfExp.Clause(); item.Condition = Calculator.Load(cond); for (int ix = 0; ix < funcData.GetStatementNum(); ++ix) { IExpression subExp = Calculator.Load(funcData.GetStatement(ix)); item.Expressions.Add(subExp); } m_Clauses.Add(item); return(true); }
protected override bool Load(Dsl.StatementData statementData) { foreach (var fData in statementData.Functions) { if (fData.GetId() == "if" || fData.GetId() == "elseif") { IfExp.Clause item = new IfExp.Clause(); if (fData.Call.GetParamNum() > 0) { Dsl.ISyntaxComponent cond = fData.Call.GetParam(0); item.Condition = Calculator.Load(cond); } else { //error Console.WriteLine("DslCalculator error, {0} line {1}", fData.ToScriptString(false), fData.GetLine()); } for (int ix = 0; ix < fData.GetStatementNum(); ++ix) { IExpression subExp = Calculator.Load(fData.GetStatement(ix)); item.Expressions.Add(subExp); } m_Clauses.Add(item); } else if (fData.GetId() == "else") { if (fData != statementData.Last) { //error Console.WriteLine("DslCalculator error, {0} line {1}", fData.ToScriptString(false), fData.GetLine()); } else { IfExp.Clause item = new IfExp.Clause(); for (int ix = 0; ix < fData.GetStatementNum(); ++ix) { IExpression subExp = Calculator.Load(fData.GetStatement(ix)); item.Expressions.Add(subExp); } m_Clauses.Add(item); } } else { //error Console.WriteLine("DslCalculator error, {0} line {1}", fData.ToScriptString(false), fData.GetLine()); } } return(true); }