public IEnumerable <List <ExoAtom> > Execute(Branch <ExoAtom> atom, ExoExpressionCommand caller) { TraceUtility.Check(atom.Content != null, "called function child has content!"); foreach (var item in Variables) { Content.Variables.Remove(item); } var splitChildren = atom.Leaves.SplitDivide(x => x.Content?.GetRawValue() == ","); TraceUtility.Check(splitChildren.Count != Variables.Count, "function call has unequal children definition"); for (int i = 0; i < splitChildren.Count; i++) { var vari = splitChildren[i]; var name = Variables[i]; var flattened = ExoExpressionCommand.FlattenBranch(vari); Content.Variables.Add(name, new ExoAtom(flattened)); } foreach (var item in Content.Commands) { yield return(item.ResolveExpression()); } }
public void Execute(ExpressionBuilder builder) { var result = new List <ExoExpressionCommand>(); // treat a whole entry for (int j = 0; j < builder.expressions.Count; j++) { TreatSinglePage(builder.expressions[j]); } // treat a single line void TreatSinglePage(List <StructureExpr> page) { List <string> rawtokens = new List <string>(); for (int i = 0; i < page.Count; i++) { var current = page[i]; if (current.Mode == FilterExoConfig.StructurizerMode.comm) { continue; } if (i == 0) { if (current?.Value == null) { LoggingFacade.LogDebug("No VALUE on: " + current.ToString()); continue; } } rawtokens.Add(current.Value); } //var command = rawtokens.First(); //rawtokens.RemoveAt(0); var filterCommand = new ExoExpressionCommand(rawtokens); result.Add(filterCommand); } // Resolve rule into a "Show" filter entry. var newEntry = new ExoBlock(); newEntry.Parent = builder.Owner.WriteCursor; builder.Owner.WriteCursor.Scopes.Add(newEntry); foreach (var item in result) { newEntry.AddCommand(item); } }
public IEnumerable <List <string> > ResolveAndSerialize() { for (int i = 0; i < Commands.Count; i++) { ExoExpressionCommand comm = this.Commands[i]; var result = comm.Serialize(); if (result.Count == 0) { continue; } yield return(result); } }
public void StoreVariable(string name, List <string> variableContent) { Check(FilterCore.FilterGenerationConfig.TierTagSort.ContainsKey(name), "variable uses reserved name!"); Check(FilterCore.FilterGenerationConfig.LineTypesSort.ContainsKey(name), "variable uses reserved name!"); Check(FilterCore.FilterGenerationConfig.ValidRarities.Contains(name), "variable uses reserved name!"); Check(name.ContainsSpecialCharacters(), "variable uses invalid characters!"); // we treat the variable as a command/expression to allow internal simplifications var command = new ExoExpressionCommand(variableContent); command.SetParent(this); var content = command.ResolveExpression(); // since we don't know if there's 1 or many variables after the simplifications, we store result as a "pack" this.Variables.Add(name, new ExoAtom(content)); }
public void Execute(ExpressionBuilder builder) { var properties = builder.Owner.ReadCursor.PropertyExpression; var functionName = properties[1]; var split = properties.SelectInnerContents( x => x.Value == "(", x => x.Value == ")"); List <string> varNames = new List <string>(); if (split != null) { var vars = split.SplitDivide(x => x.Value == ","); if (vars != null && vars.Count >= 1) { varNames = vars.Select(x => x.FirstOrDefault().Value).ToList(); } } var result = new List <ExoExpressionCommand>(); // treat a whole entry for (int j = 0; j < builder.expressions.Count; j++) { TreatSinglePage(builder.expressions[j]); } // treat a single line void TreatSinglePage(List <StructureExpr> page) { List <string> rawtokens = new List <string>(); for (int i = 0; i < page.Count; i++) { var current = page[i]; if (current.Mode == FilterExoConfig.StructurizerMode.comm) { continue; } if (i == 0) { if (current?.Value == null) { LoggingFacade.LogDebug("No VALUE on: " + current.ToString()); continue; } } rawtokens.Add(current.Value); } var filterCommand = new ExoExpressionCommand(rawtokens); result.Add(filterCommand); } var newEntry = new ExoBlock(); newEntry.Parent = builder.Owner.WriteCursor; // newEntry.Parent = builder.Owner.WriteCursor; //builder.Owner.WriteCursor.Scopes.Add(newEntry); foreach (var item in result) { newEntry.AddCommand(item); } // Resolve rule into a "Show" filter entry. var function = new ExoFunction { Name = functionName.Value, Content = newEntry, Variables = varNames }; builder.Owner.WriteCursor.Functions.Add(functionName.Value, new ExoAtom(function)); }
public void AddCommand(ExoExpressionCommand command) { this.Commands.Add(command); command.SetParent(this); }