Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
        }