public void Test4() { var operators = Operators.Keys; var factory = new AggregateTokenFactory( new ConstantNumberParser(), new OperatorParser(operators), new OpenerParser(), new CloserParser(), new FunctionParser("min"), new SeparatorParser(), new LambdaExpressionParser(LambdaDefaults.QuotationMarks), new VariableParser()); var nodeConverter = new AggregateNodeConverter( new ConstantNumberNodeConverter(), new BinaryOperatorNodeConverter(Operators), new OpenerNodeConverter(), new LambdaExpressionNodeConverter(), new VariableNodeConverter()); var result = "(2 + 2) * 2 + 't => t.Cenas == \"Sérgio\"' + 5" .SplitTokens(operators .Concat(LambdaDefaults.QuotationMarks) .Concat(Defaults.Separators)) .AggregateByQuotationMarks(LambdaDefaults.QuotationMarks) .ToLevelTokens() .Tokenify(factory) .Treeify(nodeConverter); }
public void TreeifyTransformsTheExpressionToATree() { var operators = Operators.Keys; var factory = new AggregateTokenFactory( new ConstantNumberParser(), new OperatorParser(operators), new OpenerParser(), new CloserParser(), new VariableParser()); var nodeConverter = new AggregateNodeConverter( new ConstantNumberNodeConverter(), new BinaryOperatorNodeConverter(Operators), new OpenerNodeConverter(), new VariableNodeConverter()); var tokens = "(2 + 2) * 2 + rui" .SplitTokens(operators.Concat(Defaults.Separators)) .ToLevelTokens() .Tokenify(factory) .ToList(); var result = tokens .Treeify(nodeConverter); Assert.Equal("(((2 + 2) * 2) + rui)", result.ToString()); }