-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
38 lines (35 loc) · 1.16 KB
/
Program.cs
File metadata and controls
38 lines (35 loc) · 1.16 KB
1
2
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
29
30
31
32
33
34
35
36
37
38
using System;
using System.Collections.Generic;
namespace expr
{
class Program
{
static void Main(string[] args)
{
Generator compiler = new Generator();
// compiler.Feed("123 + 345");
// var ans = compiler.Evaluate();
string input = RequestInput();
while(!input.Equals("exit")) {
try {
compiler.Feed(input);
Console.ForegroundColor = ConsoleColor.Magenta;
Console.WriteLine(" {0}", compiler.Evaluate());
Console.ResetColor();
} catch (Exception e) {
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine(e.Message);
Console.ResetColor();
}
input = RequestInput();
Console.ResetColor();
}
}
static string RequestInput()
{
Console.ForegroundColor = ConsoleColor.DarkCyan;
Console.Write("⍺ → ");
return Console.ReadLine();
}
}
}