Example #1
0
 static void RunScanner(string fileName)
 {
     StreamReader r = new StreamReader(fileName, Encoding.GetEncoding(Settings.getEncoding(false)));
      SQLPlusScanner scanner = new SQLPlusScanner(r, fileName);
      while (true)
      {
          try
          {
              scanner.get();
              Console.WriteLine("Line [" + (scanner.tokenStartLineIndex + 1) + "," + (scanner.currLineIndex + 1) + "] Col [" + (scanner.tokenStartColIndex + 1) + "," + scanner.currColIndex + "] " + scanner.tokenType + ":" + scanner.token);
          }
          catch (EOBException)
          {
              if (scanner.tokenType != TokenTypes.NotAvailable)
              {
                  Console.WriteLine("Line [" + (scanner.tokenStartLineIndex + 1) + "," + (scanner.currLineIndex + 1) + "] Col [" + (scanner.tokenStartColIndex + 1) + "," + scanner.currColIndex + "] " + scanner.tokenType + ":" + scanner.token);
              }
              Console.WriteLine("* {0} * {1} * {2} * {3} * {4} * {5} *", scanner.getModeDesc(), scanner.currCommand.action, scanner.currCommand.cmdName, scanner.currCommand.objectName, scanner.currCommand.secondaryCmdName, scanner.currCommand.secondaryObjectName);
              Console.WriteLine(scanner.currBlockText.ToString().Trim());
              Console.WriteLine("*** EOB ***\n");
              scanner.resetBlockType();
          }
          catch (EOFException)
          {
              if (scanner.tokenType != TokenTypes.NotAvailable)
              {
                  Console.WriteLine("Line [" + (scanner.tokenStartLineIndex + 1) + "," + (scanner.currLineIndex + 1) + "] Col [" + (scanner.tokenStartColIndex + 1) + "," + scanner.currColIndex + "] " + scanner.tokenType + ":" + scanner.token);
              }
              if (scanner.tokenType != TokenTypes.NotAvailable)
              {
                  Console.WriteLine("* {0} * {1} * {2} * {3} * {4} * {5} *", scanner.getModeDesc(), scanner.currCommand.action, scanner.currCommand.cmdName, scanner.currCommand.objectName, scanner.currCommand.secondaryCmdName, scanner.currCommand.secondaryObjectName);
              }
              else
              {
                  Console.WriteLine("*** EOF ***");
              }
              break;
          }
      }
 }