/// <summary> /// /// </summary> /// <returns></returns> public bool Foreach() { this.SetUpPoint(); string varName = string.Empty; this.GetTag(); if (this._Tag == "var") { this.GetTagNotNull(); varName = this._Tag; } else { varName = this._Tag; } this.GetTag(); if (this._Tag != "in") { this.ResetUpPoint(); return(false); } pFEleme = new JForeachEleme(); pFEleme.Father = this.NEleme; pForeachEleme = pFEleme as JForeachEleme; pForeachEleme.Name = varName + "_" + this.PBParser.VarIndexCount++ + "_"; var def = new JDefinitionEleme(); def.SetPoint(this.PBParser.Point); def.Name = varName; var exists = this.ValidateNameExists(varName); if (exists != null) { def.Name = exists.GetAliasName(); def.PVariableType = Entity.EVariableType.SetValue; } this.AddFather(def, new JConstEleme(pForeachEleme.Name, Entity.EValueType.Const)); this.AddFather(pForeachEleme, def); var vE = new ValueEleme(); vE.Father = this.NEleme; var vS = new ValueSpan(this.PBParser, vE); vS.Init(); pForeachEleme.Where = vE; return(true); }
/// <summary> /// 设置参数 /// </summary> private void SetArgs() { if (this.pFunEleme.Arguments.IsNull()) { return; } int index = 0; foreach (var a in this.pFunEleme.Arguments) { var jdef = new JDefinitionEleme(); jdef.SetPoint(this.PBParser.Point); jdef.Name = a; jdef.IsFunArg = true; jdef.Childs = new List <BEleme>(); jdef.Childs.Add(new JConstEleme(string.Format("__paramers{0}__.__Get__({1})", this.pFunEleme.Sign, index), EValueType.Const)); this.AddFather(this.pFunEleme, jdef); index++; } }
public override void Init() { if (string.IsNullOrEmpty(VarName)) { this.GetTag(); if (string.IsNullOrEmpty(this._Tag)) { this.Error("无法找到定义的变量名称"); } } else { this._Tag = this.VarName; } this.ValidVar(); var definition = new JDefinitionEleme(); definition.SetPoint(this.PBParser.Point); definition.Name = this._Tag; definition.OperationChar = this.OperationChar; this.AnalysisAnnotation(definition); BEleme vdef = null; if (string.IsNullOrEmpty(this.VarName)) { vdef = this.ValidateNameExists(this._Tag, false); } else if (this.IsDef) { definition.PVariableType = Entity.EVariableType.SetValue; } if (vdef != null) { definition.PVariableType = Entity.EVariableType.SetValue; definition.Name = definition.GetAliasName(); } this.SetUpPoint(); this.GetChar(); if (this._Char == '=') { this.ResetUpPoint(); this.ValidChar('='); this.AddFather(definition); var valueSpan = new ValueSpan(this.PBParser, definition); valueSpan.Init(); } else if (this._Char == ',') { this.AddFather(definition, new JConstEleme("", Entity.EValueType.Undefined)); this.AddFather(definition); this.ResetUpPoint(); } else { if (this._Char != ';') { this.ResetUpPoint(); this.GetChar(false); if (this._Char != Tools.LineEndChar) { this.Error(); } } if (!(string.IsNullOrEmpty(VarName) || this.IsFollowUp)) { this.Error(); } this.AddFather(definition, new JConstEleme("", Entity.EValueType.Undefined)); this.AddFather(definition); } this.SetUpPoint(); this.GetChar(); if (this._Char == ',') { FollowUp(); } else { this.ResetUpPoint(); } }