00001 package commandline.TxTPackage;
00002
00003
00004
00005
00006
00007 import java.io.BufferedReader;
00008 import java.io.EOFException;
00009 import java.io.IOException;
00010 import java.io.Reader;
00011 import java.io.StreamTokenizer;
00012
00013 import commandline.debuggingCode.Debug;
00014
00015
00016
00017
00018 public class input{
00019
00020 protected StreamTokenizer st;
00021
00022
00023 public input(Reader r)
00024 {
00025
00026 st = new StreamTokenizer(new BufferedReader(r));
00027 st.resetSyntax();
00028 st.wordChars('0', '9');
00029 st.wordChars('-', '-');
00030 st.wordChars('.', '.');
00031 st.wordChars('a', 'z');
00032 st.wordChars('A', 'Z');
00033 st.whitespaceChars(' ', ' ');
00034 st.whitespaceChars('\t', '\t');
00035 st.whitespaceChars('\r', '\r');
00036 st.whitespaceChars('\n', '\n');
00037 st.eolIsSignificant(false);
00038 }
00039
00040
00041
00042
00043 public String readNext() throws IOException
00044 {
00045 st.nextToken();
00046 if(st.ttype == StreamTokenizer.TT_WORD)
00047 return(st.sval);
00048 else
00049 {
00050 switch(st.ttype)
00051 {
00052 case StreamTokenizer.TT_WORD:
00053 System.out.print("Word token");
00054 break;
00055 case StreamTokenizer.TT_NUMBER:
00056 System.out.print("Number token");
00057 break;
00058 case StreamTokenizer.TT_EOL:
00059
00060
00061 return(readNext());
00062
00063 case StreamTokenizer.TT_EOF:
00064 if(!Debug.DISTIBUTION) Debug.print("EOF token");
00065 throw new EOFException("End of file");
00066 }
00067
00068 throw new IOException("Syntax error");
00069 }
00070 }
00071
00072 public int readInt() throws IOException
00073 {
00074 String str = readNext();
00075
00076 return((Integer.valueOf(str)).intValue());
00077 }
00078
00079 public double readDouble() throws IOException
00080 {
00081 String str = readNext();
00082
00083 return((Double.valueOf(str)).doubleValue());
00084 }
00085
00086 public float readFloat() throws IOException
00087 {
00088 String str = readNext();
00089
00090 return((Float.valueOf(str)).floatValue());
00091 }
00092
00093
00094
00095 }