using System;
using System.Collections.Generic;
using Axiom.Interpreter;

namespace AxiomConsole
{
  class Program
  {
    static void Main(string[] args)
    {

      //String expression=@"
      //  A=1;
      //  B=1;
      //  WHILE(A<10)
      //  {
      //    WHILE(B<10)
      //    {
      //      IF(B==1)THEN BREAK;
      //      B=B+1;
      //    }
      //    IF(A==1)THEN BREAK;
      //    A=A+1;
      //  }"; 
      String expression=@"
        A=1;
        B=1;
        C=1;
        D=1;
        WHILE(A<10)
        {
          WHILE(B<10)
          {
            WHILE(C<10)
            {
              WHILE(D<10)
              {
                A=A+1;
                B=B+1;
                C=C+1;
                D=D+1;
                IF(D==10)THEN BREAK;
                BREAK;
              }
              BREAK;
            }
            BREAK;
          }
          BREAK;
        }";
      CodeRunner codeRunner = new CodeRunner();
      //if (!codeRunner.Execute(expression))
      //{
      //  Console.WriteLine("CodeRunner Failed with {0}", codeRunner.LastMessage);
      //  Console.Read();
      //}

      List<String> disassembly=codeRunner.Disassemble(expression);
			if(codeRunner.IsInError)
			{
			  Console.WriteLine("CodeRunner Failed with {0}",codeRunner.LastMessage);
			}
			else
			{
				Console.WriteLine(expression);
				foreach(String line in disassembly)
				{
					Console.WriteLine(line);
				}
			}
      Console.Read();
    }
  }
}

