KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ppg > atoms > Nonterminal


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