Exemplo n.º 1
0
 /// <summary>
 /// The entry point of the program, where the program control starts and ends.
 /// </summary>
 /// <param name="args">The command-line arguments.</param>
 public static void Main(string[] args)
 {
     try
     {
         ParseTree myTree = new ParseTree("(- (/ 100 20) (* 5 3))");
         Console.WriteLine(myTree.PrintTree());
         Console.WriteLine(myTree.CountTree());
     }
     catch(UnexpectedSymbolException e)
     {
         Console.WriteLine("Incorrect input");
         Console.WriteLine("Exception: " + e.Message);
     }
     catch(DivideByZeroException e)
     {
         Console.WriteLine(e.Message);
     }
 }
Exemplo n.º 2
0
 public void SimplePrintTreeTest()
 {
     ParseTree myTree = new ParseTree("(* 10 5)");
     Assert.AreEqual("(* 10 5) ", myTree.PrintTree());
 }
Exemplo n.º 3
0
 public void ThreeCalculationsPrintTreeTest()
 {
     ParseTree myTree = new ParseTree("(/ (* 10 5) (+ 2 3))");
     Assert.AreEqual("(/ (* 10 5)  (+ 2 3) ) ", myTree.PrintTree());
 }
Exemplo n.º 4
0
 public void SevenCalculationsPrintTreeTest()
 {
     ParseTree myTree = new ParseTree("(- (* (- 12 2) (* 5 2)) (/ (* 10 5) (+ 2 3)))");
     Assert.AreEqual("(- (* (- 12 2)  (* 5 2) )  (/ (* 10 5)  (+ 2 3) ) ) ", myTree.PrintTree());
 }