public IExpression SentenceToExpression(string input, Dictionary <String, Double> preDefinedVariables) { var TextTokens = TextTokenizer.TextTokenize(input); Parser parsers = new Parser(TextTokens); var AbstractSyntaxTree = parsers.ParseExpression(); return(AbstractSyntaxTree); }
public object EvaluateSentence(string input, Dictionary <String, Double> preDefinedVariables) { var TextTokens = TextTokenizer.TextTokenize(input); Parser parsers = new Parser(TextTokens); var AbstractSyntaxTree = parsers.ParseExpression(); ExecutionContext context = variableMapToContext(preDefinedVariables); ExecutionEngine executionEngine = new ExecutionEngine(context); executionEngine.ExecuteExpression(AbstractSyntaxTree); return(AbstractSyntaxTree.EvaluatedValue.Value); }