KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ppg > test > multi > Tester


1 package ppg.test.multi;
2
3 import java.io.*;
4 import java_cup.runtime.*;
5
6 public class Tester {
7
8     public Tester() {}
9
10     public static void main (String JavaDoc args[]) {
11         FileInputStream fileInput;
12         String JavaDoc filename="";
13         try {
14             filename = args[0];
15             fileInput = new FileInputStream(filename);
16         } catch (FileNotFoundException e) {
17             System.out.println("Error: "+filename+" is not found.");
18             return;
19         } catch (ArrayIndexOutOfBoundsException JavaDoc e) {
20             System.out.println("Error: No file name given.");
21             return;
22         }
23
24         File file = new File(filename);
25         String JavaDoc simpleName = file.getName();
26         Lexer lex = new Lexer(fileInput, simpleName);
27         
28         Parser parser = new Parser(filename, lex);
29         Expr e1 = null, e2 = null;
30         Object JavaDoc o=null;
31         Symbol s;
32         
33         try {
34             /*
35             o = parser.parse_expr();
36             if (o instanceof Expr) {
37                 System.out.println("e1: "+e1.toString());
38             } else if (o instanceof Symbol) {
39                 System.out.println("blah");
40             } else {
41                 Class c = o.getClass();
42                 System.out.println(c.toString());
43             }
44             */

45             e1 = (Expr) parser.parse_expr().value;
46             //e2 = (Expr) parser.parse_expr().value;
47
} catch (Exception JavaDoc e) {
48             System.out.println("Exception: "+e.getMessage());
49             return;
50         }
51
52         System.out.println("e1: "+e1.toString());
53         //System.out.println("e2: "+e2.toString());
54
}
55
56 }
57
Popular Tags