Пример #1
0
        public static void Main(string[] args)
        {
            String filename   = "";
            int    tokenCount = 0;

            if (args.Length == 1 && File.Exists(Path.Combine(Directory.GetCurrentDirectory(), ($@"{Environment.CurrentDirectory}\\..\\..\\..\\" + args[0]))))
            {
                filename = args[0];
            }
            else
            {
                Console.WriteLine("Invalid Arguments - Only Ada file should be the argument");
                Console.WriteLine("Enter the Ada File Name: ");
                filename = Console.ReadLine();
            }

            if (File.Exists(Path.Combine(Directory.GetCurrentDirectory(), ($@"{Environment.CurrentDirectory}\\..\\..\\..\\" + filename))))
            {
                Lexical  myLex  = new Lexical(filename);
                RDParser parser = new RDParser(myLex);

                while (myLex.token != Symbol.eoft)
                {
                    myLex.GetNextToken();
                    //Console.WriteLine("Token: " + myLex.token);
                    parser.Procedures();
                }

                Console.WriteLine("Compiled with no errors");

                /*while (myLex.token != Symbol.eoft)
                 * {
                 *  if (tokenCount <= 24)
                 *  {
                 *      myLex.GetNextToken();
                 *      myLex.PrintToken();
                 *      tokenCount++;
                 *  }
                 *  else
                 *  {
                 *      Console.WriteLine("Press any key to Continue");
                 *      Console.ReadLine();
                 *      tokenCount = 0;
                 *  }
                 * }*/
            }
            else
            {
                Console.WriteLine("Incorrect Ada File Path. Please try again ");
                Environment.Exit(0);
            }
        }
Пример #2
0
 /*************************************************************
 ** Function    : Match                                      **
 ** Inputs      : Symbol                                     **
 ** Return      : Void                                       **
 **************************************************************
 ** Description : Checks if the wantedSymbol is equal to the **
 **               currentObject Symbol, else Error Message.  **
 *************************************************************/
 public void Match(Symbol desired)
 {
     //Console.WriteLine("Token: " + myLex.token + "   match");
     if (myLex.token == desired)
     {
         myLex.GetNextToken();
     }
     else
     {
         Console.WriteLine("Error Expected: " + myLex.token + " and instead got: " + desired);
         Environment.Exit(1);
         return;
     }
 }