//
// Proj2: Lexer assignment
//
// Author: Mosur Ravishankar
// Date: 18 Mar 1998
//


//
// Note: This implementation does not include the SymbolTable class.
//


import java.io.*;

public class Proj2
{
  public static void main (String[] args)
    {
      Token t;

      // Wrap up the standard input (System.in) within a BufferedReader
      BufferedReader in = new BufferedReader (new InputStreamReader(System.in));

      // Create a new lexer that reads the BufferedReader just created
      Lexer lex = new Lexer(in);
      
      try {
	// Get each token and print out its details
	for (;;) {
	  t = lex.getToken();
	  System.out.println (t.getLexeme() + " " + t.getTypeName());
	}
      } catch (InputException e) {
	// Illegal character in input.
	System.out.println ("Error in input:");
	lex.printLine();
      } catch (LexerStateException e) {
	// This should never happen.  Implies a bug in the lexer.
	System.out.println ("Lexer internal error:");
	lex.printLine();
      } catch (EOFException e) {
	// EOF; done
      } catch (IOException e) {
	// Should never happen; nothing much can be done anyway.
	System.out.println ("I/O Exception");
      }
    }
}
