KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ppg > atoms > Terminal


1 package ppg.atoms;
2
3 import ppg.parse.*;
4 import ppg.util.*;
5 public class Terminal extends GrammarSymbol
6 {
7     public Terminal(String JavaDoc name, String JavaDoc label) {
8         this.name = name;
9         this.label = label;
10     }
11
12     public Terminal(String JavaDoc name) {
13         this.name = name;
14         label = null;
15     }
16
17     public Object JavaDoc clone () {
18         return new Terminal(name, label);
19     }
20     
21     public boolean equals(Object JavaDoc o) {
22         if (o instanceof Terminal) {
23             return name.equals( ((Terminal)o).getName() );
24         } else if (o instanceof String JavaDoc) {
25             // do we even need the nonterminal/terminal distinction?
26
return name.equals(o);
27         }
28         return false;
29     }
30 }
31
Popular Tags