1 using System;
2 using Calculator;
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28 int main()
29 {
30 try
31 {
32 Console.WriteLine("desk calculator");
33 #if (WINDOWS)
34 Console.WriteLine("enter command, or CTRL-Z to end:");
35 #else
36 Console.WriteLine("enter command, or CTRL-D to end:");
37 #endif
38 Console.Write("> ");
39 string line = Console.ReadLine();
40 while (!Console.In().EndOfStream())
41 {
42 try
43 {
44 Parse(ToUtf32(line));
45 }
46 catch (const ParsingException& ex)
47 {
48 Console.Out() << "error: " << ex.Message() << endl();
49 }
50 catch (const DivisionByZeroException& ex)
51 {
52 Console.Out() << "error: " + ex.Message() << endl();
53 }
54 catch (const VariableNotFoundException& ex)
55 {
56 Console.Out() << "error: " + ex.Message() << endl();
57 }
58 catch (const ConversionException& ex)
59 {
60 Console.Out() << "error: " + ex.Message() << endl();
61 }
62 Console.Write("> ");
63 line = Console.ReadLine();
64 }
65 Console.WriteLine("bye!");
66 }
67 catch (Exception ex)
68 {
69 Console.Error() << ex.ToString() << endl();
70 return 1;
71 }
72 return 0;
73 }