`TermTokenizer.java`

    import java.io.*;
    import java.util.Date;
    import ilog.language.syntax.*;
    import ilog.language.io.StreamTokenizer;

    public class TermTokenizer implements Tokenizer
    {
      BufferedReader reader;
      StreamTokenizer input;
      String file = "stdin";

      TermTokenizer () throws IOException
        {
          setupReader(new InputStreamReader(System.in));
          interactive = true;
          banner();
          prompt();
        }

      TermTokenizer (File file) throws IOException
        {
          setupReader(new FileReader(file));
          this.file = file.toString();
          interactive = false;
          banner();
          System.out.println("*** Parsing file: "+file);
        }

      private void setupReader (Reader rd)
        {
          setReader(rd);
          input = new StreamTokenizer(reader);
          input.ordinaryChars("+-/");
          input.quoteChar('\'',0); // no escape allowed
        }

      public final int lineNumber()
        {
          return input.getLineNumber();
        }

      public final void setReader (Reader rd)
        {
          reader = new BufferedReader(rd);
        }

      public final Reader getReader ()
        {
          return reader;
        }

      public static boolean interactive;
      static String prompt = "> ";

      public static final void prompt ()
        {
          if (interactive)
            {
              System.out.print(prompt);
            }
        }

      static public final void setPrompt(String p)
        {
          prompt = p;
        }

      static String banner = "*** Welcome to the dynamic operator Term Parser!\n"+
                             "*** Version of "+ (new Date());

      public static final void banner ()
        {
          System.out.println(banner);
        }

      final boolean isOtherChar (int c)
        {
          return input.isOrdinaryChar(c)
            && !(input.isWhitespaceChar(c) || c == '(' || c == ')' || c == ',');
        }

      final ParseNode locate (ParseNode node)
        {
          return ((ParseNode)node.setStart(input.tokenStart).setEnd(input.tokenEnd))
    	.setFile(file);
        }

      public ParseNode nextToken() throws IOException
        {
          ParseNode t = null;

          switch (input.nextToken())
            {
            case StreamTokenizer.TT_EOF:
              reader.close();
              t = GenericParser.E_O_I;
              break;
            case '\'': case '"':
            case StreamTokenizer.TT_WORD:
    	  if (input.sval == "exit")
    	    t = GenericParser.literalToken("exit");
    	  else
    	    t = GenericParser.symbolToken("FUNCTOR",input.sval);
              break;
            case StreamTokenizer.TT_NUMBER:
              if (input.isInteger)
                t = GenericParser.numberToken("NUMBER",(int)input.nval);
              else
                t = GenericParser.numberToken("NUMBER",input.nval);
              break;
            case '(': case ')': case ',': case '.':
              t = GenericParser.literalToken(String.valueOf((char)input.ttype));
              break;
            default: // read the longest possible token and return it as a symbol
              StringBuffer functor = new StringBuffer();
              input.spaceIsSignificant(true);
              do functor.append(String.valueOf((char)input.ttype));
              while (isOtherChar(input.nextToken()));
              input.pushBack();
              input.spaceIsSignificant(false);
              t = GenericParser.symbolToken("FUNCTOR",functor.toString());
              break;
            }
          return locate(t);
        }
    }

This file was generated on Mon Dec 20 19:03:12 PST 2004 from file `TermTokenizer.java`
by the `ilog.language.tools.Hilite` Java tool written by Hassan Aït-Kaci