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