summaryrefslogtreecommitdiff
path: root/libjava/testsuite/libjava.lang/PR141.java
blob: c3314f2af763d296a8044f279fdbb7001692f4e2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import java.io.IOException;
import java.io.StreamTokenizer;
import java.io.StringReader;

public class PR141 {
  public static void test(String str) throws IOException {
    StringReader reader = new StringReader(str);
    StreamTokenizer st = new StreamTokenizer(reader);
    int t = 0;
    
    do {
      t = st.nextToken();
      
      switch (t) {
      case StreamTokenizer.TT_WORD:
	System.out.println("[TT_WORD]: " + st.sval);
	break;
      case StreamTokenizer.TT_NUMBER:
	System.out.println("[TT_NUMBER]: " + st.nval);
	break;
      case StreamTokenizer.TT_EOL:
	System.out.println("[TT_EOL]");
	break;
      case StreamTokenizer.TT_EOF:
	System.out.println("[TT_EOF]");
	break;
      default:
	System.out.println((char)t);
	break;
      }
    } while (t != StreamTokenizer.TT_EOF);
  }
  
  public static void main(String[] args) {
    try {
      test("(a).(b)");
    } catch (Throwable t) {
      t.printStackTrace();
    }
  }
}