Exemplo n.º 1
0
 /// <summary>
 /// Compute the given graph using the x and y identifier
 /// </summary>
 /// <param name="n">The root node of the graph</param>
 /// <param name="x">The x</param>
 /// <param name="y">The y</param>
 /// <returns>The computation result</returns>
 public double Compute(Node n, double x, double y)
 {
     computeVisitor = new ComputeVisitor(id => id == "x" ? x : id == "y" ? y : throw new ArgumentException("The identifier doesn't exist"));
     computeVisitor.VisitNode(n);
     return(computeVisitor.Result);
 }
Exemplo n.º 2
0
        // class algorithm

        public AstWrapper()
        {
            simpleAnalyzer = new SimpleAnalyzer();
            computeVisitor = new ComputeVisitor();
        }