KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > SPL


1
2 /*
3  * Copyright © 2002 Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
4  * California 95054, U.S.A. All rights reserved. Sun Microsystems, Inc. has
5  * intellectual property rights relating to technology embodied in the product
6  * that is described in this document. In particular, and without limitation,
7  * these intellectual property rights may include one or more of the U.S.
8  * patents listed at http://www.sun.com/patents and one or more additional
9  * patents or pending patent applications in the U.S. and in other countries.
10  * U.S. Government Rights - Commercial software. Government users are subject
11  * to the Sun Microsystems, Inc. standard license agreement and applicable
12  * provisions of the FAR and its supplements. Use is subject to license terms.
13  * Sun, Sun Microsystems, the Sun logo and Java are trademarks or registered
14  * trademarks of Sun Microsystems, Inc. in the U.S. and other countries. This
15  * product is covered and controlled by U.S. Export Control laws and may be
16  * subject to the export or import laws in other countries. Nuclear, missile,
17  * chemical biological weapons or nuclear maritime end uses or end users,
18  * whether direct or indirect, are strictly prohibited. Export or reexport
19  * to countries subject to U.S. embargo or to entities identified on U.S.
20  * export exclusion lists, including, but not limited to, the denied persons
21  * and specially designated nationals lists is strictly prohibited.
22  */

23
24
25
26 class SPL {
27
28   public static void main(String JavaDoc args[]) {
29     SPLParser parser;
30     if (args.length == 1) {
31       System.out.println("Stupid Programming Language Interpreter Version 0.1: Reading from file " + args[0] + " . . .");
32       try {
33         parser = new SPLParser(new java.io.FileInputStream JavaDoc(args[0]));
34       } catch (java.io.FileNotFoundException JavaDoc e) {
35         System.out.println("Stupid Programming Language Interpreter Version 0.1: File " + args[0] + " not found.");
36         return;
37       }
38     } else {
39       System.out.println("Stupid Programming Language Interpreter Version 0.1: Usage :");
40       System.out.println(" java SPL inputfile");
41       return;
42     }
43     try {
44       parser.CompilationUnit();
45       parser.jjtree.rootNode().interpret();
46     } catch (ParseException e) {
47       System.out.println("Stupid Programming Language Interpreter Version 0.1: Encountered errors during parse.");
48       e.printStackTrace();
49     } catch (Exception JavaDoc e1) {
50       System.out.println("Stupid Programming Language Interpreter Version 0.1: Encountered errors during interpretation/tree building.");
51       e1.printStackTrace();
52     }
53   }
54 }
55
Popular Tags