using System;
using Calculator;
int main()
{
try
{
Console.WriteLine("desk calculator");
string eof = "CTRL-D";
if (GetPlatform() == Platform.windows)
{
eof = "CTRL-Z";
}
Console.WriteLine("enter command, or " + eof + " to end:");
SymbolTable symbolTable = new SymbolTable();
Console.Write("> ");
string line = Console.ReadLine();
while (line != null)
{
try
{
Parse(line, symbolTable);
}
catch (ParsingException ex)
{
Console.Error.WriteLine("error: " + ex.Message);
}
catch (DivisionByZeroException ex)
{
Console.Error.WriteLine("error: " + ex.Message);
}
catch (VariableNotFoundException ex)
{
Console.Error.WriteLine("error: " + ex.Message);
}
catch (ConversionException ex)
{
Console.Error.WriteLine("error: " + ex.Message);
}
Console.Write("> ");
line = Console.ReadLine();
}
Console.WriteLine("bye!");
}
catch (Exception ex)
{
Console.Error.WriteLine(ex.ToString());
return 1;
}
return 0;
}