KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ppg > cmds > DropCmd


1 package ppg.cmds;
2
3 import java.util.*;
4 import ppg.atoms.*;
5 import ppg.util.*;
6 public class DropCmd implements Command
7 {
8     private Production prod; // productions to be dropped for some nonterminal
9
private Vector sym; // or, the single nonterminal to be dropped
10

11     /*
12     public DropCmd(String symbol)
13     {
14         // here it does not matter whether it's a nonterminal or terminal
15         sym = symbol;
16         prod = null;
17     }
18     */

19     
20     public DropCmd(Vector symbols)
21     {
22         sym = symbols;
23         prod = null;
24     }
25     
26     public DropCmd(Production productions)
27     {
28         prod = productions;
29         sym = null;
30     }
31
32     public boolean isProdDrop() { return prod != null; }
33     public boolean isSymbolDrop() { return sym != null; }
34     
35     public Production getProduction() { return prod; }
36     public Vector getSymbols() { return sym; }
37     
38     public void unparse(CodeWriter cw) {
39         //cw.begin(0);
40
cw.write("DropCmd");
41         cw.allowBreak(0);
42         if (prod != null)
43             prod.unparse(cw);
44         else
45             for (int i=0; i < sym.size(); i++) {
46                 cw.write((String JavaDoc)sym.elementAt(i));
47             }
48         //cw.end();
49
}
50     
51 }
52
Popular Tags