KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > javacc > jjdoc > Generator


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 package org.javacc.jjdoc;
26
27 import java.io.PrintWriter JavaDoc;
28
29 import org.javacc.parser.*;
30
31 public class Generator {
32   protected PrintWriter JavaDoc ostr;
33
34   public Generator(PrintWriter JavaDoc o) {
35     ostr = o;
36   }
37
38   public void text(String JavaDoc s) {
39     print(s);
40   }
41
42   public void print(String JavaDoc s) {
43     ostr.print(s);
44   }
45
46   public void specialTokens(String JavaDoc s) {
47     ostr.print(s);
48   }
49
50   public void documentStart() {
51     ostr.print("\nDOCUMENT START\n");
52   }
53   public void documentEnd() {
54     ostr.print("\nDOCUMENT END\n");
55   }
56
57   public void nonterminalsStart() {
58     text("NON-TERMINALS\n");
59   }
60   public void nonterminalsEnd() {
61   }
62
63   public void tokensStart() {
64     text("TOKENS\n");
65   }
66   public void tokensEnd() {
67   }
68
69   public void javacode(JavaCodeProduction jp) {
70     productionStart(jp);
71     text("java code");
72     productionEnd(jp);
73   }
74
75   public void productionStart(NormalProduction np) {
76     ostr.print("\t" + np.lhs + "\t:=\t");
77   }
78   public void productionEnd(NormalProduction np) {
79     ostr.print("\n");
80   }
81
82   public void expansionStart(Expansion e, boolean first) {
83     if (!first) {
84       ostr.print("\n\t\t|\t");
85     }
86   }
87   public void expansionEnd(Expansion e, boolean first) {
88   }
89
90   public void nonTerminalStart(NonTerminal nt) {
91   }
92   public void nonTerminalEnd(NonTerminal nt) {
93   }
94
95   public void reStart(RegularExpression r) {
96   }
97   public void reEnd(RegularExpression r) {
98   }
99 }
100
Popular Tags