private static EvaluatorState Evaluate(string statement, string prompt) { Console.WriteLine(); if (string.IsNullOrWhiteSpace(statement)) { return(null); } VariableResolver resolver = new VariableResolver(); var tokens = tokenizer.Tokenize(statement); var ast = parser.Parse(tokens); var variables = resolver.Resolve(ast); foreach (var resolved in variables) { var nestedPrompt = $"{resolved.Key} = "; var stmt = ProcessKeyEvents(nestedPrompt); var value = Evaluate(stmt, nestedPrompt); printer.Print(new Run() { Text = " --------", Color = RunColor.White }); var existing = variables[resolved.Key]; existing.IsSigned = value.IsSigned; existing.Type = value.Type; existing.Value = value.Value; } var result = evaluator.Evaluate(ast, variables, printer, context); return(result); }
public static string ResolveValue(this TestCaseContext testCaseContext, string value) { return(VariableResolver.Resolve(value, item => testCaseContext.GetRequiredItem(item))); }
public void ResolveFuncThrows(string value) { Assert.That(() => VariableResolver.Resolve(value, (key) => throw new KeyNotFoundException()), Throws.InstanceOf <KeyNotFoundException>()); }
public void ResolveThrows(string value) { Assert.That(() => VariableResolver.Resolve(value, (key) => _variables[key]), Throws.InstanceOf <ArgumentException>()); }
public string ResolveFormatSucceeds(string value) { return(VariableResolver.Resolve(value, key => _variables2[key])); }
public static string Resolve(this IItemsHolder pipelineContext, string value) { return(VariableResolver.Resolve(value, (key) => pipelineContext.GetRequiredItem(key))); }